﻿function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//Print

function PrintPage(){
	if (window.print){
		window.print();
	}
	else {
		alert("Il tuo browser non supporta la funzionalita' di stampa! Per stampare scegli la voce STAMPA dal menu' FILE!");
	}
}

//
// Menu punti prelievo
//
function viewMenu(a){
	var d=document.getElementById(a);
	
	var Browser = {
		Version:function(){
			var version = 999; 
			if (navigator.appVersion.indexOf("MSIE") != -1)
			
			version = parseFloat(navigator.appVersion.split("MSIE")[1]);
			return version;
		}
	}
	
	//alert(Browser.Version());
	
	if (d.style.display=="block"){
		d.style.display="none";
		
		if (Browser.Version() >= 8){
			document.getElementById('ppsr').src='/static/img/punti-preliefvo-sr-on.png';
			document.getElementById('ppsrImg').attributes.onMouseOver.value="MM_swapImage('ppsr','','/static/img/punti-preliefvo-sr-on.png',1)";
			document.getElementById('ppsrImg').attributes.onMouseOut.value='MM_swapImgRestore();';
		}
	}
	else{
		d.style.display="block";

		if (Browser.Version() >= 8){
			document.getElementById('ppsr').src='/static/img/punti-preliefvo-sr-on.png';
			document.getElementById('ppsrImg').attributes.onMouseOver.value='';
			document.getElementById('ppsrImg').attributes.onMouseOut.value='';
		}
	}
	return true;
}

//
// Menu come fare per
//

var first=true;
var h;

function viewMenuCome(a){
	var d=document.getElementById(a);
	var o=false;
	if (d.style.display=="block"){
		d.style.display="none";
		o=false;
	}
	else{
		d.style.display="block";
		o=true;
	}
	moveMenu(a,o);
	return true;
}

function moveMenu(a,o){
	var d=document.getElementById("linkLogo");

	if(first==true){
		if(document.getElementById(a).innerHeight!= undefined){
			h=document.getElementById(a).innerHeight;
		}
		if(document.getElementById(a).clientHeight!= undefined){
			h=document.getElementById(a).clientHeight;
		}

		document.getElementById(a).style.display="none";
		first=false;
	}

	if(o==false){
		d.style.marginTop=h+"px";
	}
	else{
		d.style.marginTop="0px";
		document.getElementById(a).style.display="block";
	}
	return true;
}

/**/

function viewCntRelated(a){
	var d=document.getElementById(a);
	
	var Browser = {
		Version:function(){
			var version = 999; 
			if (navigator.appVersion.indexOf("MSIE") != -1)
			
			version = parseFloat(navigator.appVersion.split("MSIE")[1]);
			return version;
		}
	}
	
	//alert(Browser.Version());
	
	if (d.style.display=="block"){
		d.style.display="none";
		
		if (Browser.Version() >= 8){
			if(a=='elencoMedici'){
				document.getElementById('bullet').src='/static/img/bulletON.png';
				document.getElementById('linkMedici').attributes.onMouseOver.value="MM_swapImage('bullet','','/static/img/bulletON.png',1)";
				document.getElementById('linkMedici').attributes.onMouseOut.value='MM_swapImgRestore();';
			}
			if(a=='elencoPrest'){
				document.getElementById('bulletPrest').src='/static/img/bulletON.png';
				document.getElementById('linkPrest').attributes.onMouseOver.value="MM_swapImage('bulletPrest','','/static/img/bulletON.png',1)";
				document.getElementById('linkPrest').attributes.onMouseOut.value='MM_swapImgRestore();';
			}
		}
	}
	else{
		d.style.display="block";

		if (Browser.Version() >= 8){
			if(a=='elencoMedici'){
				document.getElementById('bullet').src='/static/img/bulletON.png';
				document.getElementById('linkMedici').attributes.onMouseOver.value='';
				document.getElementById('linkMedici').attributes.onMouseOut.value='';
			}
			if(a=='elencoPrest'){
				document.getElementById('bulletPrest').src='/static/img/bulletON.png';
				document.getElementById('linkPrest').attributes.onMouseOver.value='';
				document.getElementById('linkPrest').attributes.onMouseOut.value='';
			}
		}
	}
	return true;
}

/**/
function validateRegNewsletter(objFrm){
	var err = "";
	var exp = /^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/;
	
	strData=objFrm.txtddn.value;
	
	if (!exp.test(strData)){
		err +='La data inserita non \u00E8 corretta\r\n \r\n';
	}
	
	if (isEmpty(objFrm.txtname.value)){
		err += 'Nome mancante!\r\n \r\n';
	}
	if (isEmpty(objFrm.txtsurname.value)){
		err += 'Cognome mancante!\r\n \r\n';
	}
	if (isEmpty(objFrm.txtMail.value)){
		err += 'Indirizzo mail mancante!\r\n \r\n';
	}
	if (isEmpty(objFrm.txtProfessione.value)){
		err += 'Professione mancante!\r\n \r\n';
	}
	if (isEmpty(objFrm.txtCity.value)){
		err += 'Citt\u00E0 mancante!\r\n \r\n';
	}
	else if (!isEmail(objFrm.txtMail.value)){
		err += 'Indirizzo mail non valido!\r\n \r\n';
	}
	if(document.getElementById("no").checked){
		err += 'Non \u00E8 possibile proseguire se non si acconsente al trattamento dei dati personali.\r\n \r\n';
	}

	if (err!= ""){
		alert(err);
		return false;
	}
	else {
		return true;
	}
}

//-----------------------------------------------------------------//
// cambio dello sfondo della sezione in base alla sede selezionata //
//-----------------------------------------------------------------//
window.onload = function(){
	var url = String(window.location);
	
	if (url.indexOf('/it/respighi/')>-1){
		// medicina preventiva
		if(document.getElementById('labRightMedPrev')){
			document.getElementById('labRightMedPrev').style.background = "url(/static/img/med-preventiva-right-respig.png)"; 
			document.getElementById('labRightMedPrev').style.backgroundRepeat="no-repeat";
		}
		// laboratorio di analisi
		if(document.getElementById('labLeft')){
			document.getElementById('labLeft').style.background = "url(/static/img/hp_laboratori_respighi.png)"; 
			document.getElementById('labLeft').style.backgroundRepeat="no-repeat";
		}
		if(document.getElementById('labRight')){
			document.getElementById('labRight').style.background = "url(/static/img/med-preventiva-right-respig.png)"; 
			document.getElementById('labRight').style.backgroundRepeat="no-repeat";
		}
	}
	
	if (url.indexOf('/it/san-donato/')>-1){
		// medicina preventiva
		if(document.getElementById('labRightMedPrev')){
			document.getElementById('labRightMedPrev').style.background = "url(/static/img/med-preventiva-right-sanDon.png)"; 
			document.getElementById('labRightMedPrev').style.backgroundRepeat="no-repeat";
		}
	}	
	
	if (url.indexOf('/it/santa-croce/')>-1){
		// medicina preventiva
		if(document.getElementById('labRightMedPrev')){
			document.getElementById('labRightMedPrev').style.background = "url(/static/img/med-preventiva-right-scroce.png)"; 
			document.getElementById('labRightMedPrev').style.backgroundRepeat="no-repeat";
		}
		// laboratorio di analisi
		if(document.getElementById('labLeft')){
			document.getElementById('labLeft').style.background = "url(/static/img/lab-analisi-sCroce.png)"; 
			document.getElementById('labLeft').style.backgroundRepeat="no-repeat";
		}
		if(document.getElementById('labRight')){
			document.getElementById('labRight').style.background = "url(/static/img/med-preventiva-right-scroce.png)"; 
			document.getElementById('labRight').style.backgroundRepeat="no-repeat";
		}
	}
}


function serchFormMed(objform){
	var bRtn=true;
	var ERR='';
		
	if(objform.nm.value=='' && objform.cm.value=='' && objform.spec.value=='0'){
		ERR += 'Specificare un campo di ricerca!!';
		bRtn=false;
	}
	/*
	else{
		if(objform.nm.value==''){
			objform.nm.value='null'
			//alert(objform.nm.value='null')
		}
		if(objform.cm.value==''){
			objform.cm.value='null'
			//alert(objform.cm.value)
		}
	}
	*/
	if(ERR!='') alert(ERR);
	return bRtn;
}