/* * FANCY BOX - jQuery Plugin * */
$(document).ready(function() {
	/* This is basic - uses default settings */
	
	$("a.zoom").fancybox({
	'transitionIn'	:	'elastic',
	'transitionOut'	:	'elastic',
	'speedIn'		:	400, 
	'speedOut'		:	400, 
	'overlayShow'	:	true,
	'titleShow'     :   false,
	'titlePosition' : 'over', // 'float', 'outside', 'inside' or 'over'
	'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
		return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + ' ' + title + '</span>';
	},
	'titleFromAlt' : false,
	'showNavArrows' : true,
	'easingIn'      : 'easeOutBack',
	'easingOut'     : 'easeInBack'
	});
	
	$("a.zoom_map").fancybox({
	'width'			: '40%',
	'height'		: '80%',
	'transitionIn'	:	'elastic',
	'transitionOut'	:	'elastic',
	'speedIn'		:	400, 
	'speedOut'		:	400, 
	'overlayShow'	:	true,
	'easingIn'      : 'easeOutBack',
	'easingOut'     : 'easeInBack',
	'type'			: 'iframe'
	});
	
	/* Using custom settings */
	
	$("a.edit-entry").fancybox({
		'width'				: '85%',
		'height'			: '85%',
	    'autoScale'   : false,
	    'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'type'				: 'iframe',
		'titlePosition'   : 'inside'
	});
});
/* * FANCY BOX END - jQuery Plugin * */

/* * SCROLLABLE  - jQuery Plugin * */
$(document).ready(function() {
// initialize scrollable together with the navigator plugin
$("#browsable").scrollable().navigator();	
});
/* * SCROLLABLE END - jQuery Plugin * */


/* * NIVO SLIDER - jQuery Plugin * */
 $(window).load(function() {
	$('.content_media_img').nivoSlider({
		effect:'fade', //Specify sets like: 'sliceDown,sliceDownLeft,sliceUp,sliceUpLeft,sliceUpDown, sliceUpDownLeft, fold,fade,random,slideInRight,slideInLeft'
		slices:15,
		animSpeed:300,
		pauseTime:3000,
		startSlide:0, //Set starting Slide (0 index)
		directionNav:false, //Next & Prev
		directionNavHide:false, //Only show on hover
		controlNav:false, //1,2,3...
		controlNavThumbs:false, //Use thumbnails for Control Nav
      	controlNavThumbsFromRel:false, //Use image rel for thumbs
		controlNavThumbsSearch: '.jpg', //Replace this with...
		controlNavThumbsReplace: '.jpg', //...this in thumb Image src
		keyboardNav:true, //Use left & right arrows
		pauseOnHover:true, //Stop animation while hovering
		manualAdvance:false, //Force manual transitions
		captionOpacity:0.8, //Universal caption opacity
		beforeChange: function(){},
		afterChange: function(){},
		slideshowEnd: function(){}, //Triggers after all slides have been shown
        lastSlide: function(){}, //Triggers when last slide is shown
        afterLoad: function(){} //Triggers when slider has loaded
	});
});

/* * NIVO SLIDER END - jQuery Plugin * */

/* * SUPERFISH END - jQuery Plugin * */
$(document).ready(function(){$("ul.sf-menu").superfish();});
/* * SUPERFISH END - jQuery Plugin * */


/*  top page */
$(document).ready(function() {
    
	    $('a[href=#top]').click(function(){
	        $('html, body').animate({scrollTop:0}, 'fast');
	        return false;
	    });
	 
	});


/*  cookie sort */
$('#sort').change(function() {
	$.cookie("sort", $(this).val(), { path: '/', expires: 365 });
	$.post(location, function() {
      //alert("success");
    }
	 );
	location.reload();
});	

$('#limit').change(function() {
	$.cookie("limit", $(this).val(), { path: '/', expires: 365 });
	$.post(location, function() {
      //alert("success");
    }
	 );
	location.reload();
});	

//$('#sort').hasClass("random").click(function() {
////	$.post(location, function() {
////        }
////	 );
//	location.reload();
//});	
					   
var cookieName = 'orderby';
var cookieValue = $.cookie(cookieName);
/*  chained mini */
	if ($.cookie(cookieName)){
		$("#sort").chained("#orderby");
		//$("#sort").removeAttr("disabled")
		//$("select#orderby option[value='title']").attr("selected", "selected");
		$("select#orderby").val(cookieValue).attr("selected", "selected");
		$("#orderby").trigger("change");

	} else {
		$("#sort").chained("#orderby");
	}


/**
 * jQuery Komodo Cookie  End
 **/
 function remember( selector ){
    $(selector).each(
    	function(){
    	
    		//if this item has been cookied, restore it
    		var name = $(this).attr('name');
    		if( $.cookie( name ) ){
				if( $(this).is(':checkbox') ){
    				$(this).attr('checked',$.cookie( name ));
					    			}else{
    				$(this).val( $.cookie(name) );
    			}
    										
    		}
    		
    		//assign a change function to the item to cookie it
    		$(this).change(
    			function(){
    				if( $(this).is(':checkbox') ){
    					$.cookie(name, $(this).attr('checked'), { path: '/', expires: 365 });
    				}else{
    					$.cookie(name, $(this).val(), { path: '/', expires: 365 });
    				}
    			}
    		);
    	}
    );
}

$(document).ready( function(){remember("[name=limit]");} );
$(document).ready( function(){remember("[name=orderby]");} );
$(document).ready( function(){remember("[name=sort]");} );

