$(window).load(function() {
		
	if($.browser.msie) {
		DD_roundies.addRule("#menu ul li a", "10px");
	}				
				
	// MENU POSITION		
	menuW = 0;
	dw = 0;
	$("#menu ul li").each(function() {
		mr = parseInt(($(this).css("margin-right")).replace("px",""));
		if(dw==0) dw = mr;		
		menuW += $(this).width()+mr;		
	});
	menuW = menuW - dw;
	var distanzaMenuUL = ((940 - menuW)/2);
	$("#menu ul").css("left",distanzaMenuUL+"px");
	$("#menu ul li:last").addClass("last");
	$("#menu ul").css("visibility","visible");	
	


	$("div.blockOverlay, .blockUiX").live("click",function(e) {
		
		if($.browser.safari) {
			$(".flashObject").show();			
		}			
		
		var loc = ""+window.location+"";
		if($.browser.msie && !isIE6() && loc.indexOf("blog")>0) {
			location.href = loc;
		} else {		
			$.unblockUI();
		}

       	return false;
	});
	
	
	$("#search_pop_contents .search_pop_q").focus(function() {
		f = $(this).val();
		if($(this).val()==f) $(this).attr("value","");
	});
	
	
	if($("#rotating_banners").length>0) {
		$("#rotating_banners").cycle({
		    fx:     "cover", 
		    speed:  "slow", 
		    timeout: 4000, 
			cleartype: 1		
		});
	}
	
	$(".zebraLinks ul li:odd").css("background-color","#141414");
	
});

function showMondoIcon(id) {
	$(".mondo_prev").hide();
	$(id).show();		
}

function isIE6() {
	if($.browser.msie && $.browser.version=="6.0") {
		return true;
	} else {
		return false;
	}
}

function emailIsValid(emailObj) {
	rt = true;
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(!reg.test(emailObj)) rt = false;
	
	return rt;	
}

function popMessage(msgType, title,msg) {	
	
	var msgTypeClass = " info";
	if(msgType!=null && msgType!="") msgTypeClass = " "+msgType;
	
    $.blockUI({ 
        message: "<div class=\"popMsg"+msgTypeClass+"\"><a href=\"javascript:closePopMsg();\" class=\"popCross\"><img src=\"/images/popcross.png\" /></a><div><h6>"+title+"</h6><p>"+msg+"</p></div></div>",
        fadeIn: 700, 
        fadeOut: 700, 
        timeout: 5000, 
        showOverlay: true,
		css : {
			border : "none",
            "-webkit-border-radius": "10px", 
            "-moz-border-radius": "10px"			
		}
    });	
}

function closePopMsg() {
	$.unblockUI();
}

function coinStyle() {
	$("#logo").after("<div id=\"logo_world\"><img src=\"/images/style.gif\" style=\"position:relative; top:-2px;\" /></div>");
}

function webcam() {
	newWindow("/jsp/it/webcam/index.jsp","webcam",800,660,"no");
}

function newWindow(mypage,myname,w,h,scroll) {
	var win=null;
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	var settings ='height='+h+',';
	settings +='width='+w+',';
	settings +='top='+wint+',';
	settings +='left='+winl+',';
	settings +='scrollbars='+scroll+',';
	settings +='resizable=yes';
	win=window.open(mypage,myname,settings);
	if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

