
$(window).load(function(e) {
	$(".bookmark").click(function(e) {		
		if ($.browser.opera == false || $.browser.opera==undefined) {		
			e.preventDefault();
			var url = this.href;  
			var title = this.title;
			if ($.browser.mozilla) {
				window.sidebar.addPanel(title, url, '');
				return false;
			} else if($.browser.msie) {  
				window.external.AddFavorite( url, title);
				return false;
			} else {
				alert('Please use CTRL + D to bookmark this website.');
			}
	    }
	});	
});

function send(url) {
	window.open('send.jsp?url='+url+'','send','toolbar=0,status=0,width=626,height=436');
}
function fbs_click() {
	u=location.href; 
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}


function resizeImages() {
		
		var navWidth = 0;
		var navHeight = 0;
		var newHeightContent = 0

		if($.browser.msie){
				navWidth = document.body.clientWidth;
				navHeight = document.body.clientHeight;
			} else {
				navWidth = window.innerWidth;
				navHeight = window.innerHeight;
		}
		
		newHeightContent = (navHeight - $("#modal").height() - $("#footer").height())/2;
		newHeightContent_modal = (navHeight - $(".modal").height())/2;
		newHeightContent_dettaglio = (navHeight - $("#superDettaglio").height())/2;
		newWidthContent_dettaglio = (navWidth - 960)/2;

		newWidthContent = (navWidth-638)/2;

		var motoHeight = navHeight - $("#moto").height() - $("#footer").height() + 32;
		var motoWidth = (navWidth-960)/2;
		var bolloHeight = (navHeight - $("#bollo").height() - $("#footer").height())/2
		
		$("#arrows").css("top",newHeightContent+"px");
		$("#modal").css({"top":newHeightContent+"px","left":newWidthContent+"px"});		

		$(".modal").css({"top":newHeightContent_modal+"px","left":newWidthContent+"px"});
		$("#superDettaglio").css({"top":newHeightContent_dettaglio+"px","left":newWidthContent_dettaglio+"px"});

		$("#bollo").css("top",bolloHeight+"px");
		
		$("#moto").css({"top":motoHeight+"px","left":motoWidth+"px"});
		$("#motoscritte").css({"top":motoHeight+"px","left":motoWidth+"px"});
		
		var navRatio = navWidth / navHeight;
		var picRatio = 1.5;

		var newHeight = navWidth * 800 / 1200;
		var newWidth = navWidth;
		var newHeight_img = navWidth * 800 / 1200;
		var newWidth_img = navWidth;
		
		if (navWidth<1200) {
			newHeight_img = 800;
			newWidth_img = 1200;
			newHeight = 800;
		}

		var holdwidth = newWidth*4;

		newTop = 0 - (newHeight - navHeight);
	
		$('#image_holder').css({height: navHeight, width: navWidth});
		$("#image_holder .hold").css("width",holdwidth+"px");
		$('#image_container > .img > img').css({height: newHeight_img, width: newWidth_img});		
		$('#image_holder > .hold > .img > img').css({height: newHeight_img, width: newWidth_img});		
		
		$('#image_container > .img').each(function() {
			if (!$(this).hasClass("zero")) {
				$(this).css({height: newHeight, width: newWidth});
			}
		});

		$('#image_holder > .hold > .img').each(function() {
			if (!$(this).hasClass("zero")) {
				$(this).css({height: newHeight, width: newWidth});
			}
		});
		
	}
	
	function putImages() {
		var firstImage = $("#image_container").find(".img:first");
		firstImage.clone().appendTo(".hold");
		$("#modal .frase span").html(firstImage.attr("rel"));
		$(".nextstep span").html(firstImage.attr("title"));
	}