// initialise plugins
jQuery(function(){
	
	// jQuery autoAlign
	jQuery("#fsb").autoColumn(50, ".widget-container");
	jQuery("#fsb").autoHeight(".widget-container");
	
	jQuery(".columns").autoColumn(33, ".column");
	jQuery(".columns").autoHeight(".column");
	
	jQuery(".sh_rec_prj_wrap").autoColumn(24, ".sh_rec_prj_item");
	jQuery(".sh_rec_prj_wrap").autoHeight(".sh_rec_prj_item");
	
	jQuery(".sh_lat_posts_wrap").autoColumn(24, ".sh_lat_posts_item");
	jQuery(".sh_lat_posts_wrap").autoHeight(".sh_lat_posts_item");
	
	jQuery(".columns2").autoColumn(33, ".column");
	jQuery(".columns2").autoHeight(".column");
	
	jQuery(".columns3").autoColumn(33, ".column");
	jQuery(".columns3").autoHeight(".column");
	
	jQuery(".columns4").autoColumn(33, ".column");
	jQuery(".columns4").autoHeight(".column");
	
	jQuery(".columns5").autoColumn(33, ".column");
	jQuery(".columns5").autoHeight(".column");
	
	jQuery(".columns6").autoColumn(33, ".column");
	jQuery(".columns6").autoHeight(".column");
	
	jQuery(".columns7").autoColumn(33, ".column");
	jQuery(".columns7").autoHeight(".column");
	
	jQuery(".columns8").autoColumn(33, ".column");
	jQuery(".columns8").autoHeight(".column");
	
	jQuery(".columns9").autoColumn(33, ".column");
	jQuery(".columns9").autoHeight(".column");
	
	jQuery(".columns10").autoColumn(33, ".column");
	jQuery(".columns10").autoHeight(".column");
	
	jQuery(".columns11").autoColumn(33, ".column");
	jQuery(".columns11").autoHeight(".column");
	
	jQuery(".columns12").autoColumn(33, ".column");
	jQuery(".columns12").autoHeight(".column");
	
	jQuery(".columns13").autoColumn(33, ".column");
	jQuery(".columns13").autoHeight(".column");
	
	jQuery(".columns14").autoColumn(33, ".column");
	jQuery(".columns14").autoHeight(".column");
	
	jQuery(".columns15").autoColumn(33, ".column");
	jQuery(".columns15").autoHeight(".column");
	
	// jQuery Watermark Plugin
	jQuery('input[name="s"]').each(function() {
		jQuery(this).Watermark("Enter keywords");
	});

	if (jQuery("#nivo-slider").length) {
		jQuery("#nivo-slider").nivoSlider({
			effect:'boxRainGrow', // Specify sets like: 'fold,fade,sliceDown'
			slices: 25, // For slice animations
			boxCols: 8, // For box animations
			boxRows: 4, // For box animations
			animSpeed: 700, // Slide transition speed
			pauseTime: 5000, // How long each slide will show
			startSlide: 0, // Set starting Slide (0 index)
			directionNav: true, // Next & Prev navigation
			directionNavHide: true, // Only show on hover
			controlNav: true, // 1,2,3... navigation
			keyboardNav: true, // Use left & right arrows
			pauseOnHover: true, // Stop animation while hovering
			manualAdvance: false, // Force manual transitions
			captionOpacity: 0.8, // Universal caption opacity
			prevText: 'Prev',
			nextText: 'Next'
		});
	}
	
	if (jQuery(".gototop").length) {
		jQuery.localScroll();
	}
	
	if (jQuery("#slideshow").length) {
		jQuery("#slideshow").jMask({
			width:980,
			height:420,
			time:4000,
			bg:'#ffffff',
			border:'1px solid #ffffff',
			callback:function(){}
		});
	}
	
});

function animateCaption(){
	jQuery('#slideshow h2').stop().animate({'marginLeft':'-320px'},500);
}

/* --- DropDown Menu Plugin --- */
ddsmoothmenu.init({
	mainmenuid: "menu", //menu DIV id
	orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
	classname: 'ddsmoothmenu', //class added to menu's outer DIV
	//customtheme: ["#1c5a80", "#18374a"],
	contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})

// jquery quicksand
	function reloadPrettyPhoto() {
		jQuery(".pp_pic_holder").remove();
		jQuery(".pp_overlay").remove();
		jQuery(".ppt").remove();
		// edit it with your initialization
		jQuery('a[rel^="prettyPhoto"]').prettyPhoto({
			animationSpeed: 'normal', /* fast/slow/normal */
			opacity: 0.70, /* Value between 0 and 1 */
			showTitle: false, /* true/false */
			allowresize: true, /* true/false */
			counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
			theme: 'dark_square' /* light_rounded / dark_rounded / light_square / dark_square / facebook */
		});
	}
// Custom sorting plugin
jQuery(document).ready(function($) {

	// bind radiobuttons in the form
	var $filterType = $('#filter a');

	// get the first collection
	var $list = $('#gallery');

	// clone applications to get a second collection
	var $data = $list.clone();

	$filterType.click(function(event) {

		if ($(this).attr('rel') == 'all') {
		  var $sortedData = $data.find('li');
		} else {
			var $sortedData = $data.find('.'+ $(this).attr('rel'));
		}

		$('#filter a').removeClass('current_link');
		$(this).addClass('current_link');
			
		$list.quicksand($sortedData, {
		  attribute: 'id',
		  duration: 800,
		  easing: 'easeInOutQuad',
		  adjustHeight: 'auto',
		  useScaling: 'false'
		}, function() {
			reloadPrettyPhoto();
			imagelink();
			videolink();

		});

		return false;
	});

});
