// JavaScript Document

var tieniMemoriaString = ""

window.onresize = function(){
	
	if(document.getElementById("galleryBackCover") && document.getElementById("galleryBackCover").style.visibility == "visible" && window.location.href.indexOf('index.asp')<0 && window.location.href.indexOf('index.asp')<0){
		
		posizionaPopup('gallery')
		document.getElementById("galleryBackCover").style.height = screen.height+"px";
	
	}
	if(document.getElementById("descBackCover") && document.getElementById("descBackCover").style.visibility == "visible"){
		
		posizionaPopup('intDescPopup')
		document.getElementById("descBackCover").style.height = screen.height+"px";
		
	}
	
	if(document.getElementById("mailBackCover") && document.getElementById("mailBackCover").style.visibility == "visible"){
		
		posizionaPopup('invioMailPopup')
		document.getElementById("mailBackCover").style.height = screen.height+"px";
		
	}
	
	if(document.getElementById("mailBackCover2") && document.getElementById("mailBackCover2").style.visibility == "visible"){
		
		posizionaPopup('invioMailPopup2')
		document.getElementById("mailBackCover2").style.height = screen.height+"px";
		
	}
	
	if(document.getElementById("mailBackCover3") && document.getElementById("mailBackCover3").style.visibility == "visible"){
		
		posizionaPopup('invioMailPopup3')
		document.getElementById("mailBackCover3").style.height = screen.height+"px";
		
	}
	
	
	if(document.getElementById("valutaBackCover") && document.getElementById("valutaBackCover").style.visibility == "visible"){
		//alert(window.location.href.indexOf('index.asp')>0)
		posizionaPopup('valuta')
		document.getElementById("valutaBackCover").style.height = screen.height+"px";
	}
	
	
	
	if(document.getElementById("searchBar") && window.location.href.indexOf('index.asp')<0 && window.location.href.indexOf('index.asp')<0 && window.location.href != 'http://www.garda-casa.com/'){
		
		placeSearchBar()
	}
	
	if(document.getElementById("glossBar")){
		
		placeGlossBar()
	}
	
	
	
	
	if(document.getElementById("popupLogin") && document.getElementById("loginBackCover").style.visibility == "visible"){
		
		posizionaPopup('popupLogin')
		document.getElementById("loginBackCover").style.height=screen.height+"px";
		document.getElementById("loginBackCover").style.visibility = "visible"
	}
	
	if(document.getElementById("warnBackCover") && document.getElementById("warnBackCover").style.visibility == "visible" && document.getElementById("warningPopup").style.visibility == "visible"){
		
		posizionaPopup('warningPopup')
		document.getElementById("warnBackCover").style.height = screen.height+"px";
		
	}
	
	if(document.getElementById("warnBackCover") && document.getElementById("warnBackCover").style.visibility == "visible" && document.getElementById("calcPopup").style.visibility == "visible"){
		
		posizionaPopup('calcPopup')
		document.getElementById("warnBackCover").style.height = screen.height+"px";
		
	}
	if(document.getElementById("warnBackCover") && document.getElementById("warnBackCover").style.visibility == "visible" && document.getElementById("notesPopup").style.visibility == "visible"){
		
		posizionaPopup('notesPopup')
		document.getElementById("warnBackCover").style.height = screen.height+"px";
		
	}
	if(document.getElementById("warnBackCover") && document.getElementById("warnBackCover").style.visibility == "visible" && document.getElementById("mutuoPopup").style.visibility == "visible"){
		
		posizionaPopup('mutuoPopup')
		document.getElementById("warnBackCover").style.height = screen.height+"px";
		
	}
	
	
	if(document.getElementById("vendereBackCover") && document.getElementById("vendereBackCover").style.visibility == "visible"){
		
		posizionaPopup('vendere')
		document.getElementById("vendereBackCover").style.height = screen.height+"px";
		
	}
	if(document.getElementById("galleryBackCover") && document.getElementById("galleryBackCover").style.visibility == "visible"){
		
		posizionaPopup('tasse')
		document.getElementById("galleryBackCover").style.height = screen.height+"px";
		
	}
	

	
}


function mutuo(){
	
	var tot = document.getElementById('mut1').value	
	
	if(tot.indexOf(",")>=0 && tot.indexOf(".")>=0){
		tot = tot.replace(",","")
	}else{
	
		tot = tot.replace(",",".")	
		
	}

	var dur = document.getElementById('mut2').value	
	var cad = document.getElementById('mut3').value	
	var int = document.getElementById('mut4').value	
	int = int.replace(",",".")
		
	cad = 12
	//alert('rata.php'+'M='+tot+'&durata='+dur+'&cadenza='+cad+'&tasso='+int)
	if (tot != "" && int != "")
	{invioAjax('rata.php','M='+tot+'&durata='+dur+'&cadenza='+cad+'&tasso='+int)}

	
}

function mutuoPopup(){
	
	var tot = document.getElementById('mut1b').value
	
	if(tot.indexOf(",")>=0 && tot.indexOf(".")>=0){
		tot = tot.replace(",","")
	}else{
	
		tot = tot.replace(",",".")	
		
	}

	var dur = document.getElementById('mut2b').value	
	var int = document.getElementById('mut4b').value	
	int = int.replace(",",".")
		
	cad = 12	
		
	if (tot != "" && int != "")
	{invioAjax('rata.php?','M='+tot+'&durata='+dur+'&cadenza='+cad+'&tasso='+int)}

	
}



function closeMut(){

	document.getElementById('mutPopTab').style.visibility='hidden';	
	document.getElementById('mut1b').value = "";
	document.getElementById('mut4b').value = "";
}


function hideMutuo(){
	
	document.getElementById('mutCover').style.display = 'none';
	document.getElementById('mutCover').innerHTML = '';
	document.getElementById('refresh').style.display = 'none';
	document.getElementById("lentess").style.display = 'block';	
	
	document.getElementById('mut1').value = "";
	document.getElementById('mut4').value = "";
	
	
}


function rivista(){
	
	var nomecog,via,cap,citta,prov,tel
	
	nomecog = document.getElementById('rn').value
	via = document.getElementById('rv').value
	cap = document.getElementById('ra').value
	citta = document.getElementById('rc').value
	prov = document.getElementById('rp').value
	tel = document.getElementById('rt').value
	
	if(nomecog == "" || via == "" || cap == "" || citta == "" || prov == "" || tel == ""){
	
		document.getElementById('rivEr').innerHTML = "E' necessario inserire tutti i dati per inviare una richiesta!"	
		
	}else{
		
		dd = nomecog+"$"+via+"$"+cap+"$"+citta+"$"+prov+"$"+tel
		invioAjax('include/asp/spedisciRiv.asp',dd)
		
		
	}

	
}


function hidDivs(){
	
	try
  {
  document.getElementById('separatore').style.display = 'none';
  document.getElementById('div1').style.display = 'none';	
	document.getElementById('div2').style.display = 'none';	
	document.getElementById('div3').style.display = 'none';	
  }
catch(err)
  {
  //Handle errors here
  }
	
	


	
}



function tryIt(){
	
	document.getElementById('is2').style.visibility = "visible"
}

function tryItBack(){
	
	document.getElementById('is2').style.visibility = "hidden"
}

function getAll2(){
	
	var totStringSearch = ""
	var tip1 = ""
	var tip2 = ""
	var tip3 = ""
	var tip4 = ""
	
	for(i=0;i<36;i++){
		var tempAll = document.getElementsByTagName("input")[i]
		if(tempAll.id.indexOf('tip')>-1 && (tempAll.checked == "true" || tempAll.checked == true )){
		
			if(tempAll.id.toLowerCase() == "tip1"){tip1+=tempAll.value+";";}
			
			if(tempAll.id.toLowerCase() == "tip3"){tip3+=tempAll.value+";";}
			
			
		}		
	}	
	
	tip2 = document.getElementById("tip2").value
	tip4 = document.getElementById("FStextArea").value
	
	
	
	var tip1LIO = tip1.lastIndexOf(";")
	//var tip2LIO = tip2.lastIndexOf(";")
	var tip3LIO = tip3.lastIndexOf(";")
	
	tip1 = tip1.substr(0,tip1LIO)
	//tip2 = tip2.substr(0,tip2LIO)
	tip3 = tip3.substr(0,tip3LIO)


	
	
	totStringSearch += tip1+"/"+tip2+"/"+tip3+"/"+tip4
	//alert(totStringSearch)
	//
	window.location.href="ricerca.asp?all="+totStringSearch	
	

}





function getAll2s(){
	
	var totStringSearch = ""
	var tip1 = ""
	var tip2 = ""
	var tip3 = ""
	var tip4 = ""
	
	for(i=0;i<36;i++){
		var tempAll = document.getElementsByTagName("input")[i]
		if(tempAll.id.indexOf('tip')>-1 && (tempAll.checked == "true" || tempAll.checked == true )){
		
			if(tempAll.id.toLowerCase() == "tip1"){tip1+=tempAll.value+";";}
			
			if(tempAll.id.toLowerCase() == "tip3"){tip3+=tempAll.value+";";}
			
			
		}		
	}	
	
	tip2 = document.getElementById("tip2").value
	tip4 = document.getElementById("FStextArea").value
	
	
	
	var tip1LIO = tip1.lastIndexOf(";")
	//var tip2LIO = tip2.lastIndexOf(";")
	var tip3LIO = tip3.lastIndexOf(";")
	
	tip1 = tip1.substr(0,tip1LIO)
	//tip2 = tip2.substr(0,tip2LIO)
	tip3 = tip3.substr(0,tip3LIO)


	
	
	totStringSearch += tip1+"/"+tip2+"/"+tip3+"/"+tip4
	//alert(totStringSearch)
	//
	window.location.href="ricerca.asp?all="+totStringSearch	
	

}


function getAllS(){
	
	var sim1 = ""
	var sim2 = ""
	var sim3 = ""
	var sim4 = ""
	var sim5 = ""
	var sim6 = ""
	var sim7 = ""
	var sim8 = ""
	var sim9 = ""
	var sim10 = ""
	var sim11 = ""
	
	var totStringSearch = ""
	
	if(document.getElementById('sim1').checked){
		sim1 = document.getElementById('sim1').value+";";
	}
	
	if(document.getElementById('sim2').checked){
		sim2 = document.getElementById('sim2').value+";";
	}
	
	if(document.getElementById('sim3').checked){
		sim3 = document.getElementById('sim3').value+";";
	}
	
	if(document.getElementById('sim4').checked){
		sim4 = document.getElementById('sim4').value;
	}
	
	if(document.getElementById('sim5').checked){
		sim5 = document.getElementById('sim5').value;
	}
	
	if(document.getElementById('sim6').checked){
		sim6 = document.getElementById('sim6').value+";";
	}
	
	if(document.getElementById('sim7').checked){
		sim7 = document.getElementById('sim7').value+";";
	}
	
	if(document.getElementById('sim8').checked){
		sim8 = document.getElementById('sim8').value+";";
	}
	
	if(document.getElementById('sim9').checked){
		sim9 = document.getElementById('sim9').value+";";
	}
	
	if(document.getElementById('sim10').checked){
		sim10 = document.getElementById('sim10').value+";";
	}
	
	if(document.getElementById('sim11').checked){
		sim11 = document.getElementById('sim11').value+";";
	}
	
	
	
	var tip1 = sim1+sim2+sim3+sim4+sim5
	var tip3 = sim6+sim7+sim8+sim9+sim10+sim11
	
	
	
	var tip1LIO = tip1.lastIndexOf(";")
	//var tip2LIO = tip2.lastIndexOf(";")
	var tip3LIO = tip3.lastIndexOf(";")
	
	tip1 = tip1.substr(0,tip1LIO)
	//tip2 = tip2.substr(0,tip2LIO)
	tip3 = tip3.substr(0,tip3LIO)


	
	
	totStringSearch += tip1+"/2.000/"+tip3+"/"
	//alert(totStringSearch)
	//
	window.location.href="ricerca.asp?all="+totStringSearch	
	

}


function subscribePROVA(){
	
	var asd = document.getElementById('step1').getElementsByTagName("input")
	var error = ""
	var nome = document.getElementById('logName1').value
	var cognome = document.getElementById('logName2').value
	var email = document.getElementById('logName4').value
	var cond = document.getElementById('condiz').checked
	//var email2 = document.getElementById('logName5').value
	
	var cellulare = Number(document.getElementById('logName3').value)
	cellTemp = String(cellulare)
	
	if (nome == ""){error += "- Il nome inserito &eacute; vuoto <br>";}
	if (cognome == ""){error += "- Il cognome inserito &eacute; vuoto <br>"}
	if (String(email) == "" || email.indexOf("@")<0){error += "- I'Email inserita non &eacute; valida <br>";}
	//if (String(email2) == ""  || email2.indexOf("@")<0){error += "- La Conferma Email inserita non &eacute; valida <br>"}
	//if(String(email) != String(email2)){error += "- Le Email inserite non sono uguali <br>"}
	if (cellulare == "" || typeof(cellulare) != "number" || cellTemp.length < 10){error += "- Il Cellulare inserito non &eacute; valido <br>"}
	
	//alert(cellulare)
	
	if(error != ""){
	
		document.getElementById('innerPopup').innerHTML = ""
		document.getElementById('innerPopup').innerHTML = "<h2 style='font-size:12px;color:#333333;'>Qualcosa &eacute; andato storto durante la registrazione!<br/></h2>"
		document.getElementById('innerPopup').innerHTML += "<h2 style='font-size:11px;color:red'>"+error+"</h2>"		
		posizionaPopup("warningPopup")
	}else{
		
		if(cond){
		
			str = 'Congratulazioni <b>'+nome+'</b> per esserti iscritto al portale GardaCasa!<br><br>Clicca su ACCEDI all&acute;interno del sito Gardacasa e inserisci la Password che ti &eacute; stata inviata sul tuo cellulare.<br><br>In questa maniera potrai usufruire di tutte le funzionalit&aacute; del sito.<br><br>Ricordati anche di cambiare la password appena puoi.<br><br><p>Se pensi di aver ricevuto questa email per errore, ti preghiamo di cancellarla immediatamente ed ignorare il suo contenuto. Per informazioni scrivete a domini@esprimia.it</p>'
			
			var cellulareSpl = String(cellulare)
			
			var cellulareSpl2 = cellulareSpl.substr(0,3)
			
			var cellulareSpl3 = cellulareSpl.substr(3,cellulare.length)
			
			//alert("/"+cellulareSpl2+"/"+cellulareSpl3)
			
			//pwd = nome.substr(0,2)+cognome.substr(0,2)+cellTemp.substring(7,10)
			pwd = nome.substr(0,2)+cellTemp.substring(8,10)
			
			//GeneraCookie('Gentile Cliente, la password richiesta per attivare il suo account su www.garda-casa.com &eacute; : 7561',cellulareSpl3,cellulareSpl2,'Gardacasa','30','1');
			
			dd = "GardaCasa$"+str+"$"+nome+"/"+cognome+"/"+email+"/"+pwd+"/"+cellulare
			
			tieniMemoriaString = dd;
			
			invioAjax('include/asp/spedisci.asp',dd)
		
		}else{
		
			error += "- &Eacute; necessario confermare il trattamento dei i dati personali<br>"	
			document.getElementById('innerPopup').innerHTML = ""
			document.getElementById('innerPopup').innerHTML = "<h2 style='font-size:12px;color:#333333;'>Qualcosa &eacute; andato storto durante la registrazione!<br/></h2>"
			document.getElementById('innerPopup').innerHTML += "<h2 style='font-size:11px;color:red'>"+error+"</h2>"		
			posizionaPopup("warningPopup")
			
		}
	
	}
			
}


function subscribe(){
	
	var asd = document.getElementById('step1').getElementsByTagName("input")
	var error = ""
	var nome = document.getElementById('logName1').value
	var cognome = document.getElementById('logName2').value
	var email = document.getElementById('logName4').value
	var email2 = document.getElementById('logName5').value
	
	var cellulare = Number(document.getElementById('logName3').value)
	cellTemp = String(cellulare)
	
	if (nome == ""){error += "- Il nome inserito &eacute; vuoto <br>";}
	if (cognome == ""){error += "- Il cognome inserito &eacute; vuoto <br>"}
	if (String(email) == "" || email.indexOf("@")<0){error += "- I'Email inserita non &eacute; valida <br>";}
	if (String(email2) == ""  || email2.indexOf("@")<0){error += "- La Conferma Email inserita non &eacute; valida <br>"}
	if(String(email) != String(email2)){error += "- Le Email inserite non sono uguali <br>"}
	if (cellulare == "" || typeof(cellulare) != "number" || cellTemp.length < 10){error += "- Il Cellulare inserito non &eacute; valido <br>"}
	
	//alert(cellulare)
	
	if(error != ""){
	
		document.getElementById('innerPopup').innerHTML = ""
		document.getElementById('innerPopup').innerHTML = "<h2 style='font-size:12px;color:#333333;'>Qualcosa &eacute; andato storto durante la registrazione!<br/></h2>"
		document.getElementById('innerPopup').innerHTML += "<h2 style='font-size:11px;color:red'>"+error+"</h2>"		
		posizionaPopup("warningPopup")
	}else{
		
		str = 'Congratulazioni <b>'+nome+'</b> per esserti iscritto al portale GardaCasa!<br><br>Clicca su ACCEDI all&acute;interno del sito Gardacasa e inserisci User Name e Password : in questa maniera potrai usufruire di tutti le funzionalit&aacute;.<br><br>Ricordati anche di cambiare la password appena puoi.<br><br><p>Se pensi di aver ricevuto questa email per errore, ti preghiamo di cancellarla immediatamente ed ignorare il suo contenuto. Per informazioni scrivete a domini@esprimia.it</p>'
		
		var cellulareSpl = String(cellulare)
		
		var cellulareSpl2 = cellulareSpl.substr(0,3)
		
		var cellulareSpl3 = cellulareSpl.substr(3,cellulare.length)
		
		//alert("/"+cellulareSpl2+"/"+cellulareSpl3)
		
		pwd = nome.substr(0,2)+cognome.substr(0,2)+cellTemp.substring(7,10)
		
		//GeneraCookie('Gentile Cliente, la password richiesta per attivare il suo account su www.garda-casa.com &eacute; : 7561',cellulareSpl3,cellulareSpl2,'Gardacasa','30','1');
		
		dd = "GardaCasa$"+str+"$"+nome+"/"+cognome+"/"+email+"/"+pwd+"/"+cellulare
		
		tieniMemoriaString = dd;
		
		invioAjax('include/asp/spedisci.asp',dd)
	
	}
			
}

var vocedamigl

function miglioraVoce(voce){
	
	vocedamigl = voce
	
	document.getElementById('glt').innerHTML = vocedamigl;

	posizionaPopup('invioMailPopup2')
	
}

function sendGlosImprv(){
	
	migl = document.getElementById('migl').value
	
	dd = vocedamigl+"$"+migl
	
	if(migl != ""){invioAjax('include/asp/spedisciGloss.asp',dd)	}
	
	
	
	
}


function sendEspr(){
	
	miglEspr = document.getElementById('miglEspr').value
	nomeEspr = document.getElementById('nomeEspr').value
	
	if(miglEspr == "" && nomeEspr == ""){
		
		
	}else{
	
		dd =miglEspr+"$"+nomeEspr
		
		invioAjax('include/asp/spedisciEsprimi.asp',dd)	
		
	}
}





function retrieveR(){
	
	var mails = document.getElementById('mailsR').value
	

	
	//alert(cellulare)
	
	if(mails != ""){
		
		str = "Un'email con i tuoi dati &eacute; stata inviata all'indirizzo da te indicato."
		
		
		dd = mails+"$"+str
		invioAjax('include/asp/recupera.asp',dd)
	
	}
			
}




function posizionaPopup(id){
	
	var w = getScreenRes()
	var h = getScreenRes2()
	
	document.getElementById(id).style.top = (((h - 529)/2))+"px"
	document.getElementById(id).style.left = ((w - 920)/2)+"px"
	document.getElementById(id).style.visibility="visible";
	
	if(id == "warningPopup"){
		document.getElementById(id).style.top = (((h - 334)/2))+"px"
		document.getElementById(id).style.left = ((w - 435)/2)+"px"
		document.getElementById("warnBackCover").style.height=h+"px"
		document.getElementById("warnBackCover").style.visibility = "visible"
			
	}
	
	
	if(id == "tasseresPopup"){
		document.getElementById(id).style.top = (((h - 334)/2))+"px"
		document.getElementById(id).style.left = ((w - 435)/2)+"px"
		document.getElementById("tasseresBackCover").style.height=h+"px"
		document.getElementById("tasseresBackCover").style.visibility = "visible"
			
	}
	
	if(id == "mutuoPopup"){
		document.getElementById(id).style.top = (((h - 334)/2))+"px"
		document.getElementById(id).style.left = ((w - 435)/2)+"px"
		document.getElementById("warnBackCover").style.height=h+"px"
		document.getElementById("warnBackCover").style.visibility = "visible"
			
	}
	
	
	if(id == "gallery"){
		document.getElementById(id).style.top = (((h - 531)/2))+"px"
		document.getElementById(id).style.left = ((w - 920)/2)+"px"
		document.getElementById("galleryBackCover").style.height=h+"px"
		document.getElementById("galleryBackCover").style.visibility = "visible"
			
	}
	
	
	if(id == "valuta"){
		
		document.getElementById('mqApp').value = document.getElementById('GApp').value
		document.getElementById('nAnni').value = document.getElementById('GAnn').value
		document.getElementById('mqGiard').value = document.getElementById('GGia').value
		document.getElementById('nGarage').value = document.getElementById('GGar').value
		document.getElementById('nCantine').value = ""
		document.getElementById('nAutoC').value = ""
		document.getElementById('nAutoS').value = ""
		document.getElementById('mqTer').value = ""
		document.getElementById("valutaBackCover").style.height=h+"px"
		document.getElementById("valutaBackCover").style.visibility = "visible"
		
		
			
	}
	
	if(id == "tasse"){
		document.getElementById("galleryBackCover").style.height=h+"px"
		document.getElementById("galleryBackCover").style.visibility = "visible"
			
	}
	
	
	if(id == "vendere"){
		document.getElementById("vendereBackCover").style.height=h+"px"
		document.getElementById("vendereBackCover").style.visibility = "visible"
			
	}
	
	if(id == "intDescPopup"){
		document.getElementById(id).style.top = (((h - 529)/2))+"px"
		document.getElementById(id).style.left = ((w - 920)/2)+"px"
		document.getElementById("descBackCover").style.height=h+"px"
		document.getElementById("descBackCover").style.visibility = "visible"
			
	}
	
	if(id == "invioMailPopup"){
		document.getElementById("mailBackCover").style.height=h+"px"
		document.getElementById("mailBackCover").style.visibility = "visible"
		document.getElementById(id).style.position = "fixed"
			
	}
	
	if(id == "invioMailPopup2"){
		document.getElementById("mailBackCover2").style.height=h+"px"
		document.getElementById("mailBackCover2").style.visibility = "visible"
		document.getElementById(id).style.position = "fixed"
			
	}
	
	
	if(id == "invioMailPopup3"){
		document.getElementById("mailBackCover3").style.height=h+"px"
		document.getElementById("mailBackCover3").style.visibility = "visible"
		document.getElementById(id).style.position = "fixed"
			
	}
	
	if(id == "popupLogin"){
		document.getElementById("loginBackCover").style.height=h+"px"
		document.getElementById("loginBackCover").style.visibility = "visible"
			
	}
	
	
	if(id == "calcPopup"){
		document.getElementById(id).style.top = (((h - 334)/2)+20)+"px"
		document.getElementById(id).style.left = ((w - 435)/2)+"px"
		document.getElementById("warnBackCover").style.height=h+"px"
		document.getElementById("warnBackCover").style.visibility = "visible"
			
	}
	
	if(id == "notesPopup"){
		document.getElementById(id).style.top = (((h - 690)/2)+20)+"px"
		document.getElementById(id).style.left = ((w - 920)/2)+"px"
		document.getElementById("warnBackCover").style.height=h+"px"
		document.getElementById("warnBackCover").style.visibility = "visible"
			
	}
	

	
}


function checkLog(){
	
	if(usrLgnName_ != ""){	
	
		posizionaPopup('valuta')
	
	}else{deviLog()}
}


function checkLoginTrue(){
	
	if(pwdCheck && loginCheck){
		
		document.getElementById("loginBtnGrey").className = "loginBtnDarkGrey";
		document.getElementById("loginBtnGrey").attachEvent("onclick",login)
		
	}else{
		
		document.getElementById("loginBtnGrey").className = "loginBtnGrey";
		document.getElementById("loginBtnGrey").detachEvent("onclick",login)
		
	}
	
}

function voidf(){}

var pwdCheck
var loginCheck

function loginAlert(id){

	if(document.getElementById(id).value!=""){loginCheck=true}else{loginCheck=false};
	checkLoginTrue();
}


function pwdAlert(id){

	if(document.getElementById(id).value!=""){pwdCheck=true}else{pwdCheck=false};
	checkLoginTrue();
	
}


function registrati(){
	
	alert("ti devi registrare per vedere il prezzo")	
	
}



function checkMailTrue(){
	
	if(emailToCheck && textCheck){
		
		document.getElementById("sendBtnGrey").className = "sendBtnDarkGrey";
		document.getElementById("sendBtnGrey").attachEvent("onclick",immoSendGo)
		
	}else{
		
		document.getElementById("sendBtnGrey").className = "sendBtnGrey";
		document.getElementById("sendBtnGrey").detachEvent("onclick",immoSendGo)
		
	}
	
}

var emailToCheck,textCheck

function emailToAlert(id){

	if(document.getElementById(id).value!=""){emailToCheck=true}else{emailToCheck=false};
	checkMailTrue();
}


function textAlert(id){

	if(document.getElementById(id).value!=""){textCheck=true}else{textCheck=false};
	checkMailTrue();
	
}

function send(){
	
	alert("messaggio inviato!")	
	
}



function getScreenRes(){
	
	if (window.innerWidth){
	return window.innerWidth;} 
	else if (document.documentElement && document.documentElement.clientWidth != 0){
	return document.documentElement.clientWidth; }
	else if (document.body){return document.body.clientWidth;} 
	return 0;

}


function beta(){
	
	document.getElementById('innerPopup').innerHTML = ""
	document.getElementById('innerPopup').innerHTML = '<h2 style="font-size:13px;color:red">ATTENZIONE</h2>'	
	document.getElementById('innerPopup').innerHTML += "<h2 style='font-size:12px;color:#333333;'>Siamo spiacenti, ma questa componente non &eacute; ancora stata implementata in questa versione del sito : <br><br>Una volta pubblicata troverai una presentazione nella home page di questo sito internet.<br/></h2>"

	posizionaPopup("warningPopup")		
	
}


function deleteProf(){
	
	document.getElementById('innerPopup').innerHTML = ""
	document.getElementById('innerPopup').innerHTML = '<h2 style="font-size:13px;color:red">ATTENZIONE</h2>'	
	document.getElementById('innerPopup').innerHTML += "<h2 style='font-size:12px;color:#333333;'>Stai per cancellare il tuo profilo garda-casa.com : <br><br>Non sar&aacute; pi&uacute; possibile recuperare i tuoi dati.<br/><br/>Sei Sicuro di voler procedere ?<br/><br/><a href='#' onclick='invioAjax(\"include/asp/cancellati.asp\",mailToDel);closeWindow(\"warningPopup\");'/>SI, CANCELLAMI&nbsp;</a> / <a href='#' onclick='closeWindow(\"warningPopup\")'/>&nbsp;NO, ANNULLA</a><br><br>Riceverai una mail di avvenuta cancellazione.</h2>"

	posizionaPopup("warningPopup")		
	
}


function deviLog(){
	
	document.getElementById('innerPopup').innerHTML = ""
	/*document.getElementById('innerPopup').innerHTML = '<h2 style="font-size:13px;color:red">ATTENZIONE</h2>'*/	
	document.getElementById('innerPopup').innerHTML += "<h2 style='font-size:12px;color:#333333;'>Siamo spiacenti, ma devi essere loggato per accedere a questa funzionalit&aacute;:<br/></h2>"
	document.getElementById('innerPopup').innerHTML +="<h2 style='font-size:13px;text-transform:uppercase;color:#b2df14;'>Iscriviti subito, non costa nulla.<br/></h2>"
	document.getElementById('innerPopup').innerHTML +="<h2 style='font-size:12px;color:#333333;'> e ti permetter&aacute; di sfruttare al 100% il potenziale di questo sito internet, per trovare la tua casa in maniera semplice e veloce.</h2><br>"
	document.getElementById('innerPopup').innerHTML +="<h2 style='font-size:12px;color:#333333;'> <a href='#' onclick='iscrQui()'>ISCRIVITI QUI</a></h2>"

	//document.getElementById('innerPopup').innerHTML += '<h2 style="font-size:11px;color:red">- profilo personale<br>- gestione immobili "preferiti"<br></h2>'	
	posizionaPopup("warningPopup")		
	
}


function iscrQui(){
	closeWindow('warningPopup');
	posizionaPopup('popupLogin');
	document.getElementById('step1').style.visibility='visible';

}


function getScreenRes2(){
	
	if (window.innerHeight){
	return window.innerHeight;} 
	else if (document.documentElement && document.documentElement.clientHeight != 0){
	return document.documentElement.clientHeight; }
	else if (document.body){return document.body.clientHeight;} 
	return 0;

}


function closeWindow(id){
	//alert(id)
	document.getElementById(id).style.visibility="hidden";
	document.getElementById(id).style.top = 0+"px"
	document.getElementById(id).style.left = 0+"px"	
	
	
	if(id == "gallery"){
		//document.getElementById("galleryBackCover").style.height=h+"px"
		document.getElementById("galleryBackCover").style.visibility = "hidden"
		document.getElementById("nasc2").style.visiblity ="visible"
			
	}
	
	if(id == "valuta"){
		//document.getElementById("galleryBackCover").style.height=h+"px"
		document.getElementById("valutaBackCover").style.visibility = "hidden"
		//document.getElementById("nasc2").style.visiblity ="visible"
			
	}
	
	if(id == "tasse"){
		//document.getElementById("galleryBackCover").style.height=h+"px"
		document.getElementById("galleryBackCover").style.visibility = "hidden"
		document.getElementById("nasc2").style.visiblity ="visible"
			
	}
	
	
	if(id == "vendere"){
		//document.getElementById("galleryBackCover").style.height=h+"px"
		document.getElementById("vendereBackCover").style.visibility = "hidden"
		//document.getElementById("nasc2").style.visiblity ="visible"
			
	}
	
	if(id == "intDescPopup"){
		//document.getElementById("galleryBackCover").style.height=h+"px"
		document.getElementById("descBackCover").style.visibility = "hidden";
		document.getElementById('openGallins').style.visibility= "hidden";
		document.getElementById('immoLess').style.visibility= "hidden";
		document.getElementById('fb2').style.visibility= "hidden";
		document.getElementById('mail2').style.visibility= "hidden";
		document.getElementById('print2').style.visibility= "hidden";
			
	}
	
	if(id == "invioMailPopup"){
		//document.getElementById("mailBackCover").style.height=h+"px"
		document.getElementById("mailBackCover").style.visibility = "hidden"
		document.getElementById("mailName").value = ""	
		document.getElementById("mailText").value = ""
		document.getElementById("rifincMail").value = ""
		document.getElementById("sendGoRes").innerHTML = "" 
			
	}
	
	if(id == "invioMailPopup2"){
		//document.getElementById("mailBackCover").style.height=h+"px"
		document.getElementById('resultGl').innerHTML = "";
		document.getElementById("mailBackCover2").style.visibility = "hidden"
		document.getElementById('migl').value = ""
			
	}
	
	
	if(id == "invioMailPopup3"){
		//document.getElementById("mailBackCover").style.height=h+"px"
		document.getElementById("mailBackCover3").style.visibility = "hidden"
		document.getElementById('migl').value
			
	}
	
	if(id == "popupLogin"){
		//document.getElementById("mailBackCover").style.height=h+"px"
		document.getElementById("loginBackCover").style.visibility = "hidden"
		document.getElementById('step1').style.visibility='hidden'
		document.getElementById('step2').style.visibility='hidden'
	}
	
	if(id == "warningPopup"){
		//document.getElementById("mailBackCover").style.height=h+"px"
		document.getElementById("warnBackCover").style.visibility = "hidden"
		//document.getElementById('step1').style.visibility='hidden'
	}
	
	if(id == "calcPopup"){
		//document.getElementById("mailBackCover").style.height=h+"px"
		document.getElementById("warnBackCover").style.visibility = "hidden"
		//document.getElementById('step1').style.visibility='hidden'
	}
	
	if(id == "mutuoPopup"){
		//document.getElementById("mailBackCover").style.height=h+"px"
		document.getElementById("warnBackCover").style.visibility = "hidden"
		//document.getElementById('step1').style.visibility='hidden'
	}
	
	if(id == "notesPopup"){
		//document.getElementById("mailBackCover").style.height=h+"px"
		document.getElementById("warnBackCover").style.visibility = "hidden"
		//document.getElementById('step1').style.visibility='hidden'
	}
	
	if(id == "tasseresPopup"){
		//document.getElementById("mailBackCover").style.height=h+"px"
		document.getElementById("tasseresBackCover").style.visibility = "hidden"
		//document.getElementById('step1').style.visibility='hidden'
	}
	
	
	
	
	
}


function valImm(){
	
	
		
	var mq = document.getElementById('mqApp').value
	if(mq == ""){mq = "0";}
	if(mq.indexOf(".")>=0){mq = mq.replace(".",",")}
	//if(mq.indexOf(",")>=0){var mq2 = mq.split(",");mq = mq2[0];}
	
	var pogTer = document.getElementById('mqTer').value
	if(pogTer == ""){pogTer = "0"}
	if(pogTer.indexOf(".")>=0){pogTer = pogTer.replace(".",",")}
	//if(pogTer.indexOf(",")>=0){var pogTer2 = pogTer.split(",");pogTer = pogTer2[0];}
	
	var gar = document.getElementById('nGarage').value
	if(gar == ""){gar = "0"}
	if(gar.indexOf(".")>=0){gar = gar.replace(".",",")}
	//if(gar.indexOf(",")>=0){var gar2 = gar.split(",");gar = gar2[0];}
	
	var autoS = document.getElementById('nAutoS').value
	if(autoS == ""){autoS = "0"}
	if(autoS.indexOf(".")>=0){autoS = autoS.replace(".",",")}
	//if(autoS.indexOf(",")>=0){var autoS2 = autoS.split(",");autoS = autoS2[0];}
	
	var autoC = document.getElementById('nAutoC').value
	if(autoC == ""){autoC = "0"}
	if(autoC.indexOf(".")>=0){autoC = autoC.replace(".",",")}
	//if(autoC.indexOf(",")>=0){var autoC2 = autoC.split(",");autoC = autoC2[0];}
	
	var cant = document.getElementById('nCantine').value
	if(cant == ""){cant = "0"}
	if(cant.indexOf(".")>=0){cant = cant.replace(".",",")}
	//if(cant.indexOf(",")>=0){var cant2 = cant.split(",");cant = cant2[0];}
	
	var giard = document.getElementById('mqGiard').value
	if(giard == ""){giard = "0"}
	if(giard.indexOf(".")>=0){giard = giard.replace(".",",")}
	//if(giard.indexOf(",")>=0){var giard2 = giard.split(",");giard = giard2[0];}
	
	var ann = document.getElementById('nAnni').value
	if(ann == ""){ann = "0"}
	if(ann.indexOf(".")>=0){ann = ann.replace(".",",")}
	//if(ann.indexOf(",")>=0){var ann2 = ann.split(",");ann = ann2[0];}
	
	var zona = document.getElementById('valZona').value
	
	//manca errori
	
	invioAjax('include/asp/valutaImm.asp',mq+"$"+pogTer+"$"+gar+"$"+autoS+"$"+autoC+"$"+cant+"$"+giard+"$"+ann+"$"+zona)
	
	
	
	
}



function menuSearch(){

	document.getElementById('simplePan').style.display='none';
	document.getElementById('contenitRic').style.display='block';
		try
		{
		document.getElementById('src1').style.display='block';
		document.getElementById('src2').style.display='none';	
		}
		catch(err)
		{
		//Handle errors here
		}
	
	
}



function showImg(){
	
	
	
	document.getElementById("searchCont").innerHTML = '<div style="position:absolute;left:-15px;top:-70px;background:#ffffff;width:700px;height:auto"><img style="margin-top:0px;"  src="INCLUDE/img/STRUTTURA/frecceamanop.jpg"/></div>'	
	
}

function showImgSimp(){
	try
	{
		document.getElementById('src2').style.display='block';
		document.getElementById('src1').style.display='none';	
	}
	catch(err)
		{
		//document.getElementById("searchCont").innerHTML = '<div style="position:absolute;left:-15px;top:-70px;background:#ffffff;width:700px;height:auto"><img style="margin-top:0px;"  src="include/img/logobiggg.jpg"/></div>'

		}

		document.getElementById('simplePan').style.display='block';
		document.getElementById('contenitRic').style.display='none';
	
	
}


function showImgAdv(){
	try
	{
		document.getElementById('src2').style.display='none';
		document.getElementById('src1').style.display='block';
	}
	catch(err)
		{
		//document.getElementById("searchCont").innerHTML = '<div style="position:absolute;left:-15px;top:-70px;background:#ffffff;width:700px;height:auto"><img style="margin-top:0px;"  src="INCLUDE/img/STRUTTURA/frecceamanop.jpg"/></div>'

		}
		document.getElementById('simplePan').style.display='none';
		document.getElementById('contenitRic').style.display='block';
	
	
}



function checkSwitch(val){

	if(val == "impr"){
		switchTd()
	}else{
		switchTdBack()
	}	
	
}



function switchTd(){
	
	document.getElementById('td1').innerHTML = 'Valore dichiarato : <input type="text" value="" id="rendita2"/>'
	//document.getElementById('tdIva').style.display = "none";
	document.getElementById('tsss').style.display = "none";
	
	
}

function switchTdBack(){
	
	document.getElementById('td1').innerHTML = 'Rendita catastale : <input type="text" value="" id="rendita2"/>'
	//document.getElementById('tdIva').style.display = "none";
	document.getElementById('tsss').style.display = "none";
	
	
}

function favsQuery(str){
	
	if(usrLgnName_ != ""){
		window.location.href="ricerca.asp?favSh="+str
	}else{
		deviLog()
	}
		
	
}


function filterQuery(str){
	
	if(usrLgnName_ != ""){
		window.location.href="ricerca.asp?filtSh="+str
	}else{
		deviLog()
	}
		
	
}



function tasse(){


	var c1,c2
	
	c1 = document.getElementById('privono').value
	c2 = document.getElementById('casar').value
		
	var i1 = document.getElementById("rendita2").value	
	
	i1 = i1.replace(".",",")
	
	//alert(c1+"%"+c2+"%"+i1)
	
	invioAjax('include/asp/tasse.asp',c1+"%"+c2+"%"+i1)

}

function setTasse(str){

	str = str.split("%")
	
	var c1 = str[0]
	
	var ir = str[3]
	var ic = str[2]
	var ii = str[4]
	var tot = str[1]
	
	if(c1=="priv"){
	
		document.getElementById('tdIva2').style.display="none"
		document.getElementById('iva2').innerHTML = "";
		
		document.getElementById('ir2').innerHTML = ir+" &euro;"
		document.getElementById('ii2').innerHTML = ii+" &euro;"
		document.getElementById('ic2').innerHTML = ic+" &euro;"
		
		document.getElementById('ttt2').innerHTML = tot+" &euro;"
		
	}else{
		
		var iva = str[5]
		
		document.getElementById('tdIva2').style.display="block"
		document.getElementById('iva2').innerHTML = iva+" &euro;"
		
		document.getElementById('ir2').innerHTML = ir+" &euro;"
		document.getElementById('ii2').innerHTML = ii+" &euro;"
		document.getElementById('ic2').innerHTML = ic+" &euro;"
		
		document.getElementById('ttt2').innerHTML = tot+" &euro;"
		
	}
	
	posizionaPopup("tasseresPopup")	
	
}


function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}


function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}



var popsiono = true


function changeImg(){
	
	document.getElementById('ti1').style.display='none';
	document.getElementById('ti1b').style.display='block';
	document.getElementById('simplePan').style.display='block';
	document.getElementById('searchBar').style.display='none';
}


function changeImg2(){
	
	document.getElementById('ti1').style.display='block';
	document.getElementById('ti1b').style.display='none';
	document.getElementById('simplePan').style.display='none';
	document.getElementById('searchBar').style.display='block';
}


function nascScherm(){
	
	document.getElementById('offerta').style.display="none";
	
	document.getElementById('frecceHelp').style.display="block";
}


function ricercaPop(){
	
	
	hidDivs();
	
	
	//if(popsiono){
		
		try
		{
			document.getElementById('ti1').style.display='block';
			document.getElementById('ti1b').style.display='none';
		}
		catch(err)
		{
		//Handle errors here
		}
	
		
		document.getElementById('offerta').style.left = "190px"	
		
		//document.getElementById("sliderFull").style.width = "4128px"
		document.getElementById('offerta').style.display="none";
		
		document.getElementById('frecceHelp').style.display="block";
		
		/*for(i=1;i<7;i++){
			
			document.getElementById("sliderSingBig"+i).style.width = "688px"	
			var t = document.getElementById("sliderSingImg"+i).src 
			t = t.replace('thumsnavi_libro_slider','thumsnavi_libro_slider_small')
			document.getElementById("sliderSingImg"+i).src = t;
			document.getElementById("sliderSingImg"+i).style.top="100px"
			document.getElementById("slBt"+i).style.fontSize = "22px"
			document.getElementById("slBt"+i).style.top = "20px"
			document.getElementById("slBtxt"+i).style.top = "120px"
			document.getElementById("slBtxt"+i).style.fontSize = "13px"   
			document.getElementById("slBtxt"+i).style.right="10px"   
			document.getElementById("slBtxt"+i).style.lineHeight = "14px"
			document.getElementById("slBtxt"+i).style.width="200px"
			document.getElementById("testdiv").style.marginLeft="-95px"
	
		}*/
		
		//move(fotoPos,true)
		
		popsiono = false
	
	//}
}





function featureDemo(subject){
	
	alert("iscriviti per avere accesso alle funzionalità complete del sito!")
	
}


function gestContact(string){
	
	if(string == "arco"){
		
		document.getElementById('whichContact').className = 'whichContact';
		document.getElementById('arco').style.color = '#97d704';
		document.getElementById('riva').style.color = '#999999';
	
		document.getElementById("rivaTel").style.visibility="hidden"
		document.getElementById("rivaFax").style.visibility="hidden"
		document.getElementById("rivaMail").style.visibility="hidden"
		document.getElementById("rivaSkype").style.visibility="hidden"
		document.getElementById("arcoTel").style.visibility="visible"
		document.getElementById("arcoFax").style.visibility="visible"
		document.getElementById("arcoMail").style.visibility="visible"
		document.getElementById("arcoSkype").style.visibility="visible"
				
		
	}
	
	if(string == "riva"){
		
		document.getElementById('whichContact').className = 'whichContact2'
		document.getElementById('arco').style.color = '#999999';
		document.getElementById('riva').style.color = '#97d704';
		
		document.getElementById("arcoTel").style.visibility="hidden"
		document.getElementById("arcoFax").style.visibility="hidden"
		document.getElementById("arcoMail").style.visibility="hidden"
		document.getElementById("arcoSkype").style.visibility="hidden"	
		document.getElementById("rivaTel").style.visibility="visible"
		document.getElementById("rivaFax").style.visibility="visible"
		document.getElementById("rivaMail").style.visibility="visible"
		document.getElementById("rivaSkype").style.visibility="visible"	
		
	}
	
	
	
	
}


function is_numeric(num)

	{

		var exp = new RegExp("^[0-9-.]*$","g");

		return exp.test(num);

	}



function checkRich(){
	
	var erro=""
	
	var com = document.getElementById('com').value
	var ind = document.getElementById('ind').value
	var tip = document.getElementById('tip').value
	var select = document.getElementById('tip');
	var tip = select.options[select.selectedIndex].value;
	//alert(tip)
	var sups = document.getElementById('sup').value
	var des = document.getElementById('des').value
	var nom = document.getElementById('nom').value
	var tel = document.getElementById('tel').value
	var mai = document.getElementById('mai').value
	
	if(nom == ""){erro+="Il campo nome e cognome &eacute; obbligatorio.<br>"}
	if(tel == "" || !is_numeric(tel)){erro+="Il campo telefono &eacute; obbligatorio e solo numerico.<br>"}
	if(mai == "" || mai.indexOf('@')<0){erro+="Il campo mail &eacute; obbligatorio e dev'essere valido.<br>"}
	if(tip == ""){erro+="Il campo tipologia &eacute; vuoto.<br>"}
	
	if(erro!=""){document.getElementById('erroTar').innerHTML ="<h2 style='color:red;'>"+erro+"</h2>"}else{invioAjax('include/asp/valutazemail.asp',com+"$"+ind+"$"+tip+"$"+sups+"$"+des+"$"+nom+"$"+tel+"$"+mai)}
	
}



function checkRichiesta(){
	
	var erro=""
	
	var cM1 = ""
	var cM2 = ""
	var cM3 = ""
	
	
	var nom = document.getElementById('nom').value
	var com = document.getElementById('com').value
	var ind = document.getElementById('ind').value
	var select = document.getElementById('tip');
	var tip = select.options[select.selectedIndex].value;
	var select = document.getElementById('loc');
	var loc = select.options[select.selectedIndex].value;
	var tel = document.getElementById('tel').value
	var mai = document.getElementById('mai').value
	
	var c1 = document.getElementById('c1').checked
	var c2 = document.getElementById('c2').checked
	var c3 = document.getElementById('c3').checked
	
	if(c1){cM1 = "Richiesta invio rivista gardacasa.<br/>"}
	if(c2){cM2 = "Richiesta contatto in base alle esigenze del cliente.<br/>"}
	if(c3){cM3 = "Richiesta invio newsletter gardacasa.<br/>"}
	
	if(nom == ""){erro+="Il campo nome e cognome &eacute; obbligatorio.<br>"}
	if(tel == "" || !is_numeric(tel)){erro+="Il campo telefono &eacute; obbligatorio e solo numerico.<br>"}
	if(mai == "" || mai.indexOf('@')<0){erro+="Il campo mail &eacute; obbligatorio e dev'essere valido.<br>"}
	if(com == ""){erro+="Il campo citt&aacute; &eacute; obbligatorio.<br>"}
	
	//alert(tip&"_"&loc)
	
	if(erro!=""){document.getElementById('erroTar').innerHTML ="<h2 style='color:red;'>"+erro+"</h2>"}else{invioAjax('include/asp/richemail.asp',com+"$"+ind+"$"+tip+"$"+loc+"$"+nom+"$"+tel+"$"+mai+"$"+cM1+"$"+cM2+"$"+cM3)}
	
}



function printContent(obj){
	//alert()
	
	obj = document.getElementById(obj).innerHTML
	
	newwin=window.open('','printwin','left=-10,top=100,width=950,height=700')
	newwin.document.write('<HTML>\n<HEAD>\n')
	newwin.document.write('<TITLE>STAMPA PAGINA</TITLE>\n')
	newwin.document.write('<link href="include/css/main.css" rel="stylesheet" type="text/css" />')
	newwin.document.write('<style type="text/css">#descPicsCent{display:none;} #fotoContStmp{max-width:300px;max-height:250px;overflow:hidden;}</style>\n')
	newwin.document.write('<scri'+'pt>\n')
	newwin.document.write('function chkstate(){\n')
	newwin.document.write('	if(document.readyState=="complete"){\n')
	newwin.document.write('		window.close()\n')
	newwin.document.write('	}\n')
	newwin.document.write('	else{\n')
	newwin.document.write('		setTimeout("chkstate()",2000)\n')
	newwin.document.write('	}\n')
	newwin.document.write('}\n')
	newwin.document.write('function print_win(){\n')
	newwin.document.write('	window.print();\n')
	//newwin.document.write('	chkstate();\n')
	newwin.document.write('}\n')
	newwin.document.write('<\/scri'+'pt>\n')
	newwin.document.write('</HEAD>\n')
	newwin.document.write('<BODY onload="print_win()" style="font-family:Arial;position:relative;">\n')
	newwin.document.write('<div style="position:relative;border:1px solid #ffffff;width:850px;height:25px;>')
	newwin.document.write(obj)
	newwin.document.write('</div>\n')
	newwin.document.write('</BODY>\n')
	newwin.document.write('</HTML>\n')
	newwin.document.close()
	
}

function printContent2(obj){
	
	
	obj = document.getElementById(obj).innerHTML
	
	newwin=window.open('','printwin','left=-10,top=100,width=685,height=295')
	newwin.document.write('<HTML>\n<HEAD>\n')
	newwin.document.write('<TITLE>STAMPA PAGINA</TITLE>\n')
	newwin.document.write('<link href="include/css/main.css" rel="stylesheet" type="text/css" />')
	newwin.document.write('<scri'+'pt>\n')
	newwin.document.write('function chkstate2(){\n')
	newwin.document.write('	if(document.readyState=="complete"){\n')
	newwin.document.write('		window.close()\n')
	newwin.document.write('	}\n')
	newwin.document.write('	else{\n')
	newwin.document.write('		setTimeout("chkstate2()",2000)\n')
	newwin.document.write('	}\n')
	newwin.document.write('}\n')
	newwin.document.write('function print_win2(){\n')
	newwin.document.write('	window.print();\n')
	//newwin.document.write('	chkstate2();\n')
	newwin.document.write('}\n')
	newwin.document.write('<\/scri'+'pt>\n')
	newwin.document.write('</HEAD>\n')
	newwin.document.write('<BODY onload="print_win2()" style="font-family:Arial;">\n')
	newwin.document.write('<div style="position:relative;border:1px solid #ebebeb;width:667px;height:295px;>')
	newwin.document.write(obj)
	newwin.document.write('</div>\n')
	newwin.document.write('</BODY>\n')
	newwin.document.write('</HTML>\n')
	newwin.document.close()
	
}



function printContent3(){
	
	
	src = document.getElementById('galleryTarget').src
	
	//alert(src)
	
	newwin=window.open('','printwin','left=-10,top=100,width=685,height=295')
	newwin.document.write('<HTML>\n<HEAD>\n')
	newwin.document.write('<TITLE>STAMPA PAGINA</TITLE>\n')
	newwin.document.write('<link href="include/css/main.css" rel="stylesheet" type="text/css" />')
	newwin.document.write('<scri'+'pt>\n')
	newwin.document.write('function chkstate2(){\n')
	newwin.document.write('	if(document.readyState=="complete"){\n')
	newwin.document.write('		window.close()\n')
	newwin.document.write('	}\n')
	newwin.document.write('	else{\n')
	newwin.document.write('		setTimeout("chkstate2()",2000)\n')
	newwin.document.write('	}\n')
	newwin.document.write('}\n')
	newwin.document.write('function print_win2(){\n')
	newwin.document.write('	window.print();\n')
	//newwin.document.write('	chkstate2();\n')
	newwin.document.write('}\n')
	newwin.document.write('<\/scri'+'pt>\n')
	newwin.document.write('</HEAD>\n')
	newwin.document.write('<BODY onload="print_win2()" style="font-family:Arial;">\n')
	newwin.document.write('<img src='+src+' />')
	newwin.document.write('</BODY>\n')
	newwin.document.write('</HTML>\n')
	newwin.document.close()
	
}




// INVIO SMS

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



function messcontacar()  {
	conta=160-document.smsArubaForm.smstesto.value.length ;
	document.smsArubaForm.smscar.value=conta;
	if (conta < 0)  {
	    	smsArubaForm.smstesto.value = smsArubaForm.smstesto.value.substr(0, 160);
	    	document.smsArubaForm.smscar.value=0;
      }
  }



/////////////////////////////////
function Redirect()
{
	CookieRandom = Math.random().toString()
	CookieRandom = CookieRandom.replace(".","")
	CookieRandom = CookieRandom.replace(",","")
	setCookie(CookieRandom,"1")
	
	var y_ = ((screen.height-300)/2)
	var x_ = ((screen.width-400)/2)
	
	window.open("ProxyPage.asp?TipoOperazione=UNO&RandID=" + CookieRandom,"finestra","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,width="+screen.width+",height=300,top="+y_+",left=0,resizable=no")
}



function getCookie(name) 
{
	var dc = document.cookie;
	var prefix = name + "=";
	 //alert(dc)
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1) 
	{
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} 
	else
	{
		begin += 2;
	}
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
	{
		end = dc.length;
	}
	return unescape(dc.substring(begin + prefix.length, end));
}





function setCookie(name,value,expires,path)//,domain)//,secure) 
{
	var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : ""); /*+
      ((domain) ? "; domain=" + domain : ""); +
      ((secure) ? "; secure" : "")*/
    // alert(curCookie)
	document.cookie = curCookie;
}




function GeneraCookie(StrVar1,StrVar2,StrVar3,StrVar4,StrVar6,StrVar7)
{
	var UrlCliente = ""
	setCookie("TestoMessaggio",StrVar1)
	setCookie("NumeroMessaggio",StrVar2)
	setCookie("PrefissoMessaggio",StrVar3)
	setCookie("MittenteMessaggio",StrVar4)
	setCookie("smstipodest",StrVar6)
	setCookie("tptarget",StrVar7)
	UrlCliente = document.location.host + document.location.pathname
	setCookie("UrlCliente",UrlCliente)
	
	Redirect();
}
///////////////////////////////////////




