

window.addEvent('domready',function(){

	/*$('languageSlide').position({x: 0, y: -60});


	$('linguetta').addEvent('click', function(e){

		e = new Event(e);

		currPos=$('languageSlide').getPosition();
		
		if(currPos.y<-10){
				$('languageSlide').tween('top', '-10px');
				e.stop();
		}else{
				$('languageSlide').tween('top', '-60px');
				e.stop();
		}
		


	});*/
	/******************************************************************************/
	$('searchText').addEvent('click', function(e){

		e = new Event(e);
		
		$('searchText').set("value","");
	
	
	});
	

	/******************************************************************************/

		$('drop_down_menu').getElements('li.menu').each( function( elem ){
			var list = elem.getElement('ul.links');
			myFx = new Fx.Slide(list).hide();			
			elem.addEvents({
				'mouseenter' : function(){ 	
					myFx.cancel();
					myFx.slideIn();			
				},
				'mouseleave' : function(){ 
					myFx.cancel();
					myFx.slideOut();					
				}
				
			});	

		})

	

}
)










function switchFilter(id,page,filter, mixed){

	if(filter=="type" && String(id)=="none"){
		window.location=page+"?"+filter+"=none";
		return;
	}

	if(mixed==0){
		window.location=page+"?"+filter+"="+id;
	}else{
	//var querystring = location.search;	
	var urlString=self.location.href.split("?");
		if(urlString[1]==undefined || urlString[1]=="" || urlString[1]=="type=none"){
			window.location=page+"?"+filter+"="+id;
		}else{
			//prima di procedere elimino il parametro pNum
			
			if(urlString[1].indexOf("Rs1pNum=")==-1){
				var paramString=urlString[1];
			}else{
				var strippingParamArray=urlString[1].split("Rs1pNum")
				// Se pNum è l'ultimo parametro...
				if(strippingParamArray[1].indexOf("&")==-1){
					var paramString=strippingParamArray[0];
				}else{
					var otherParams=strippingParamArray[1].split("&")
					otherParams=otherParams.slice (1,otherParams.length );
					
					var paramString=otherParams.join("&");

				}
				
				
			}
			
	
			var params=paramString.split("&")
			var totParams=params.length;
			var paramFound=false;

			for(i=0;i<params.length;i++){
				if(params[i].split("=")[0]==filter){
					var paramFound=true;
					if(id!=0){
						params[i]=filter+"="+id;
					}else{
						params.splice(i,1);
					}					
				}
			}
			if(paramFound==false){
				params.push(filter+"="+id)
			}
			
			var querystring=params.join("&");

			window.location=urlString[0]+"?"+querystring
		}
	}	

}




function checkMail (form,lang){
		switch (lang){
		case 1:
		 if (document.forms[form].nome.value == "") {
		   alert("Prego compilare il campo NOME")
		   document.forms[form].nome.focus();
		   return false;}   
		 if (document.forms[form].cognome.value == "") {
		   alert("Prego compilare il campo COGNOME")
		   document.forms[form].cognome.focus();
		   return false;}
		 if (document.forms[form].email.value == "") {
		   alert("Prego compilare il campo MAIL")
		   document.forms[form].email.focus();
		   return false;}
		if (document.forms[form].privacyCheck.checked == false) {
		   alert("Prego accettare le condizioni relative alla Privacy")
		   document.forms[form].privacyCheck.focus();
		   return false;} 
		break;
		case 2:
		 if (document.forms[form].nome.value == "") {
		   alert("Please fill the \"First name\" field")
		   document.forms[form].nome.focus();
		   return false;}   
		 if (document.forms[form].cognome.value == "") {
		   alert("Please fill the \"Last name\" field")
		   document.forms[form].cognome.focus();
		   return false;}
		 if (document.forms[form].email.value == "") {
		   alert("Please fill the \"E-mail\" field")
		   document.forms[form].email.focus();
		   return false;}
		if (document.forms[form].privacyCheck.checked == false) {
		   alert("Please accept the Privacy policy agreement")
		   document.forms[form].privacyCheck.focus();
		   return false;} 
		break;
		case 3:
		 if (document.forms[form].nome.value == "") {
		   alert("Prière de compléter le champ \"Nom\"")
		   document.forms[form].nome.focus();
		   return false;}   
		 if (document.forms[form].cognome.value == "") {
		   alert("Prière de compléter le champ \"Prénom\"")
		   document.forms[form].cognome.focus();
		   return false;}
		 if (document.forms[form].mail.value == "") {
		   alert("Prière de compléter le champ \"E-mail\"")
		   document.forms[form].mail.focus();
		   return false;}
		if (document.forms[form].privacyCheck.checked == false) {
		   alert("Prière d’accepter les conditions sur la protection de la vie privée")
		   document.forms[form].privacyCheck.focus();
		   return false;}
		break;	
		
	}

}


function select_provincia(idprov){
	
    xmlHttptab	=	GetXmlHttpObject() //See if it works with users browser.
	
	var url="../www/ajaxindex.php?pag=../www/pages/web/cercapunti.php";

	var params=Array();

	params.push('idprov='+idprov);
	var mypars=params.join("&");
	
	xmlHttptab.open("POST", url, true);
	
	//Send the proper header information along with the request
	xmlHttptab.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttptab.setRequestHeader("Content-length", mypars.length);
	xmlHttptab.setRequestHeader("Connection", "close");

	xmlHttptab.onreadystatechange=function () 
								{
								if (xmlHttptab.readyState==4 || xmlHttptab.readyState=="complete")
								 { 
									document.getElementById('cardlist').innerHTML = xmlHttptab.responseText;
									
								 } 
								};
	xmlHttptab.send(mypars);
}


