




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){
	
	/*checkLength=document.forms[form].elements['doc[]'].length;
	somethingscheched=false;
	for(i=0;i<checkLength;i++){
		if(document.forms[form].elements['doc[]'][i].checked==true){
			somethingscheched=true;
		}
	}
	
	if (somethingscheched == false) {
	   alert("E' necessario indicare almeno un documento da scaricare")
	   return false;} */
	   
	 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].indirizzo.value == "") {
	   alert("Prego compilare il campo INDIRIZZO")
	   document.forms[form].indirizzo.focus();
	   return false;}
	if (document.forms[form].cap.value == "") {
	   alert("Prego compilare il campo CAP")
	   document.forms[form].cap.focus();
	   return false;}
	 if (document.forms[form].citta.value == "") {
	   alert("Prego compilare il campo CITTA'")
	   document.forms[form].citta.focus();
	   return false;}*/
	
	if (document.forms[form].txt.value  == "") {
	   alert("Prego compilare il campo TESTO DEL MESSAGGIO")
	   document.forms[form].txt.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;} 

}


function getRoadMap(mapLink, title){	
	document.getElementById('mapIframe').src=mapLink+'&output=embed';
	//document.getElementById('mapLink').href=mapLink;
	document.getElementById('mapLink').href="javascript:openPage('"+mapLink+"')";	
	document.getElementById('mapTitle').innerHTML=title;
}


function checkNewUser(form){
	
	alert("asd");
	
	if (document.forms["newUser"].pwdtmp_ckpwdtmp_obl_pas.value != "" && document.forms["newUser"].pwdtmp_ckpwdtmp_obl_pas.value != document.forms["newUser"].pwdverify_ckpwdverify_obl_pas.value) {
		makeError(114,"Password","pwdtmp_ckpwdtmp_obl_pas","newUser");	 
		return false;
	}
	
	
	if(document.forms["newUser"].acconsento.checked==false){
		/*error = Array(102,"Acconsento","acconsento");
		makeError(102,"Password","pwdtmp_ckpwd_tmp_obl_pas","newUser");	 */
		return false;
	}
	
	confirmSubmit('newUser','newConchigliaUser','');	


}


function sendConchNewsletter(frmName){
	
	
	var alertMsg = confirm ("Attenzione: stai per inviare la newsletter selezionata. Vuoi continuare?")
	if (!alertMsg){
		$('waitClip').setStyle('display', 'none');
		return;
	}else{
		
		$('waitClip').setStyle('display', 'block');
		
		xmlHttp=GetXmlHttpObject() //See if it works with users browser.
		
		var url = RootPath + "www/ajaxindex.php?pag=../www/ajaxphp/newsletterSend.php";
		
		var params = Array();

		params.push('id='+ document.forms[frmName].id.value);
		params.push('idgruppo=' + document.forms[frmName].idgruppo_int.value);
		var mypars=params.join("&");
		
		xmlHttp.open("POST", url, true);
		
		//Send the proper header information along with the request
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", mypars.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.onreadystatechange=function(){
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
				//alert(xmlHttp.responseText);
				if(xmlHttp.responseText=='0'){
					alert("Attenzione: problemi di invio");
					$('waitClip').setStyle('display', 'none');
				}else{
					window.location = self.location;
				}
			
			 } 
		 };
		xmlHttp.send(mypars);
		
		
		
	}		
}

function openPage(fileName) {
	props='scrollbars=yes,toolbar=no, status=0,resizable=yes,width=870, height=570, left =10, top =10'
	window.open(fileName,'Conchiglia Map',props);
};


function catDownload(){
	window.location.href="#dldPanel";
	$('hiddenDownloadPanel').fade('in');
}

/*var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("safari") == -1) {
	window.addEvent('domready',function() {
		new SmoothScroll({ duration:1000 }); 
	});
}*/
