$(document).ready(function() {
	// ROLLOVER MENU
	$("#mainNav li.parent a").hover(
		function() { //rollover	
			$(this).parent().siblings().children("ul.visible").hide(); 	
			$(this).parent().children("ul").not(".visible").show(); 	
		},
		function() { //rollout
			$(this).parent().siblings().children("ul.visible").show();
			$(this).parent().children("ul").not(".visible").hide();
		}
	);
	$("#mainNav li ul").hover(
		function() { //rollover
			$(this).show();
			$(this).parent().siblings().children("ul.visible").hide();
			$(this).parent().children("a").addClass("rollover");
		},
		function() { //rollout
			$(this).not(".visible").hide();
			$(this).parent().siblings().children("ul.visible").show();
			$(this).parent().children("a").removeClass("rollover");
		}
	);
});

function select_anno_mese(){
		location.href = location.pathname + '?anno=' + $('#anno').val() + '&mese=' + $('#mese').val();
}


function openPopUp(pageID){
  switch (pageID){
    case 'privacy': 
        popup('/Privacy.aspx', 470,440,'menubar=no, resizable=no, scrollbars=yes, status=no, toolbar=no');
        break;
    case 'legal': 
         popup('/Legal.aspx', 470,440,'menubar=no, resizable=no, scrollbars=yes, status=no, toolbar=no');
        break;
        
  }  
}

function popup(popUrl, popWidth, popHeight, popParam){
    var popLeft   = (screen.width  - popWidth)/2;
    var popTop    = (screen.height - popHeight)/2;
    window.open(popUrl,'', 'width=' + popWidth + ', height=' + popHeight + ', top=' + popTop + ', left=' + popLeft + ', ' + popParam);
}


function QueryString( param )	
{
	var begin,end;

	if(self.location.search.length>1)	  
	{
	    begin=self.location.search.indexOf(param) +param.length+1;
	    end=self.location.search.indexOf("&",begin);
	    if(end==(-1)) end=self.location.search.length;
	    return(self.location.search.substring(begin,end));
	 }
	 else if(self.location.hash.length>1)	  
	 {
	    begin=self.location.hash.indexOf(param) +param.length+1;
	    end=self.location.hash.indexOf("&",begin);
	    if(end==(-1)) end=self.location.hash.length;
	    return(self.location.hash.substring(begin,end));
	 }
	 else return("");
}

function AddFrameParam(nameParam)
{
	var param = QueryString(nameParam);
	
	var ServiceFrame = document.getElementById("ServiceFrame");
	
	if (ServiceFrame != null)
	{ 
		if (ServiceFrame.src.indexOf("?",0) == -1)
		{
			ServiceFrame.src = ServiceFrame.src + "?" + nameParam + "=" + param;
		}
	}
}

