/**
 * @author: D.M.Maresca
 * @mail: domenico.maresca@gmail.com
 * @version: 1
 */

//swfobject.embedSWF("/images/layout/volo.swf", "ear", "955", "189", "9.0.0", false, {}, {wmode: "transparent"}, {});
swfobject.embedSWF("/images/layout/volo.swf", "anim", "955", "189", "9.0.0", false, {}, {wmode: "transparent"}, {});
swfobject.embedSWF("/images/contents/slidehome.swf", "slide", "284", "271", "9.0.0", false, {}, {wmode: "transparent"}, {});

$(document).ready(function(){
	$(document).pngFix();
	$("a.fancy").fancybox({'zoomSpeedIn':500,'zoomSpeedOut':500,'overlayOpacity':0.2,'overlayShow':true});
	$("a.fancy").click(function(){if(jQuery.browser.msie&&jQuery.browser.version<7){alert("Sorry, Your browser is too old to support this function.\nPlease update your browser to use this functionality.");window.location.reload()}});

	if(document.getElementById('news')!=null){
		try{
			var news = $("#news");
			var imageObj = new Image(); 
		    imageObj.onload = function(){ $("#news").click(); }
			imageObj.src=news.attr("href");
			news.hide();
		}catch(ex){}
	}
	
	if(document.getElementById('gallery')!=null){
		try{
        	$("#gallery").myGallery({perPage:5,thumbMargin:1,thumbHeight:85});
			$("#gallery div.wrapper").find("img").reflect({height: 0.3, opacity: 0.3});
		}catch(ex){} 
    }
	
	$('a.new').click(function(){
		window.open($(this).attr('href'));
		return false;
	});
	
	offers();
	Banner();
	$('.date-pick').datePicker({clickInput:true});
});

function Banner(){
	if(document.getElementById('specialBoxOffers')!=null){
		var fx = setInterval(function(){
			$('#specialBoxOffers #maniglia').fadeOut(1150, function() { $(this).fadeIn(1150); });
		},3500);
		var box = $('#specialBoxOffers');
		//box.css({top:'340px'});
		$('#specialBoxOffers #maniglia').click(function(){
			if(!box.hasClass('active')){
				banner_open(box);				
			}else{
				banner_close(box);
			}
		});
		$('#specialBoxOffers').hover(
			function(){
				$(this).addClass('hover');
			},
			function(){
				$(this).removeClass('hover');
			})
	}
}	
function banner_open(box){
	box.animate({left:'0px'},2000);
	box.addClass('active');
}
function banner_close(box){
	box.animate({left:'-800px'},2000);
	box.removeClass('active');
}

function offers(){
	return;
	var offers = $("div.piscina-sidebar a:gt(0)");
	var index = 0;
	offers.hide();
	
	setInterval(function(){
		$("div.piscina-sidebar a:eq("+(index-1)+")").fadeOut("slow");
		if(index>offers.length) index=0;
		$("div.piscina-sidebar a:eq("+(index)+")").fadeIn("slow");
		index++;
	},5000);	
}