/* [jQuery] */
$(document).ready(function() {

	/* [Wrap TinyMCE with a link taken from the image] */
	$(".colorbox-img").each(function() {
		var src = $(this).attr('src');
		var a = $('<a/>').attr('href', src).attr('rel', 'colorbox-image');
		$(this).wrap(a);
	});
	/* [/End Wrap TinyMCE with a link taken from the image] */
	
	/* [Colorbox] */
	$(".colorbox-popup").colorbox({
		width:"980", 
		height:"500", 
		iframe:true,
		open:true
	}); 	
	$("a[rel='colorbox-image']").colorbox({
		scalePhotos:true,
		current: "Immagine {current} di {total}"		
	});	
	$("a[rel='colorbox-modal-box']").colorbox({
		iframe:true,
		current: "Immagine {current} di {total}"
	});		
	/* [/End Colorbox] */	

	/* [Hide Label Class] */
	$("#form label").addClass("hide-label");
	/* [/End Hide Label Class] */
	
	/* [Fix Placeholder HTML5] */	
	$('input[placeholder], textarea[placeholder]').placeholder();
	/* [/End Fix Placeholder HTML5] */
	
	/* [Image Preloader] */
	$([
		'assets/templates/default/img/general/bg-modal.jpg',
		'assets/templates/default/img/general/bg-modal.png',
		'assets/templates/default/img/general/bg-close.png',
	]).preload();
	/* [/End Image Preloader] */
	
	/* [DropDown Menu] */
	function addMega(){
		$(this).addClass("hovering");
		}
		function removeMega(){
		$(this).removeClass("hovering");
		}
	var megaConfig = {
		interval: 60,
		sensitivity: 4,
		over: addMega,
		timeout: 160,
		out: removeMega
	}
	$("#menu ul li").hoverIntent(megaConfig)
	/* [/End DropDown Menu] */		
	
	/* [Modal] */
	$('.modal').jqm({
		modal: true,
		trigger: '#login-modal',
		overlay: 40, 
		overlayClass: 'modal-overlay'})
	$('input.modal-close');	
	/* [/End Modal] */
	
});	
/* [/End jQuery] */

$(window).load(function(){
	/* [Slideshow] */	
	$('#slider').nivoSlider({
        effect: 'fade', // Specify sets like: 'sliceDown,sliceDownLeft,sliceUp,sliceUpLeft,sliceUpDown,sliceUpDownLeft,fold,fade,random,slideInRight,slideInLeft,boxRandom,boxRain,boxRainReverse,boxRainGrow,boxRainGrowReverse'
        slices: 15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed: 500, // Slide transition speed
        pauseTime: 3000, // How long each slide will show
        startSlide: 0, // Set starting Slide (0 index)
        directionNav: false, // Next & Prev navigation
        directionNavHide: false, // Only show on hover
        controlNav: false, // 1,2,3... navigation
        controlNavThumbs: false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel: false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav: false, // Use left & right arrows
        pauseOnHover: false, // Stop animation while hovering
        manualAdvance: false, // Force manual transitions
        captionOpacity: 0.8, // Universal caption opacity
        prevText: 'Prev', // Prev directionNav text
        nextText: 'Next', // Next directionNav text
        beforeChange: function(){}, // Triggers before a slide transition
        afterChange: function(){}, // Triggers after a slide transition
        slideshowEnd: function(){}, // Triggers after all slides have been shown
        lastSlide: function(){}, // Triggers when last slide is shown
        afterLoad: function(){} // Triggers when slider has loaded
    });
	/* [/End Slideshow] */
});	
