//Define Global Variables
//This bumper page determines if the user's browser fits into one of four categories:
//Level 1: has most recent version of flash
//Level 2: has older version of flash
//Level 3: doesn't have flash
//Level 4: we're unsure what their deal is
//We call these 4 states "browser_capability_level" 1-4. 
//This script displays an informative graphic according to browser_capability_level
//These detection schemes should work on any browser
//We should be able to detect flash on N2.0+, IE3+ (Win) and N3.0+ (Mac). 
//Please note that this script could be more efficient
//but it has been designed to be as easy to understand as possible

//Define Function
function vaia(n){
	location.href=(menu[n]);
}

function addbookmark(){
	if (browser == "Microsoft"){
		if (document.all)
			window.external.AddFavorite(bookmarkurl,bookmarktitle)
	}else{
	alert('digita CTRL + D')
	}
}	

function invia(which){
	var pass=true;
	var tmp=which.nominativo;
	if (tmp.value==""){
		pass=false;
		alert(CHECK_1);
	}else{
		trimIn(tmp.value," ");
		if (t==""){
			pass=false;
			alert(CHECK_10);
		}
	}
	if (pass){
		tmp=which.email;
		if (tmp.value==""){
			alert(CHECK_2);
			pass=false;
		}else{
			if ((tmp.value.indexOf("@")==-1 || tmp.value.indexOf(".")==-1 || tmp.value.indexOf("'")!=-1 || tmp.value.indexOf('"')!=-1) || tmp.value.length<8){
				alert(CHECK_20);
				pass=false;
			}	
		}
	}
	if (pass){
		tmp=which.messaggio;
		if (tmp.value==""){
			pass=false;
			alert(CHECK_3);
		}else{
			trimIn(tmp.value," ");
			if (t==""||t.length<10){
				pass=false;
				alert(CHECK_30);
			}
		}
	}
	if (!pass){
		tmp.select();
	}else{	
		which.method="post";
		which.action="email.asp";
		which.submit();
	}
}

function cancella(which){
	which.reset();
}
function msg(mi){
	if (mi=="OK"){
		alert(conferma);
	}
}

function SpedisciForm(){
if ((document.formcasatait.ragione.value == "")||(document.formcasatait.indirizzo.value == "")){
	alert(CHECK);
	}
	else{
	document.accesso.submit();
	}
}

function autoResize(){
// self.moveTo(0,0);self.resizeTo(screen.availWidth,screen.availHeight);
	x,y=0;
	if (screen.availWidth>800){
		x=(screen.availWidth-800)/2;
		y=(screen.availHeight-590)/2;
	}else{
		alert('la risoluzione video minima e ottimale per la corretta visualizzazione del sito è \n800x600. \nPurtroppo la tua risoluzione video corrente è di \n'+screen.availWidth+'x'+screen.availHeight);
	}
	self.moveTo(x,y);
	self.resizeTo(790,590);
}

function chiudi(){
	if (confirm('Vuoi chiudere questa finestra?')){
		window.top.close();
	}
}

function cambia(){
	window.top.close();
	window.opener.location.href="http://www.casatait.com";
	//parent.top.close();
}

function avanti(){
	parent.corpo.history.go(+1);
}

function indietro(){
	parent.corpo.history.go(-1);
}

function aggiorna(){
	parent.corpo.location.reload();
}

function MakeDis(){
	document.metatag.canc.disabled=true;
}

function MakeAb(){
	if (document.metatag.add.value == "Genera"){
		var txt='<meta name="Description" content="'+document.metatag.description.value+'">\r\n';
		txt+='<meta name="Keywords" content="';
		if (document.metatag.keywords.value){
			txt+=document.metatag.keywords.value+'">\r\n';
			document.metatag.source.value=txt;
			document.metatag.add.value="Conferma";
			document.metatag.canc.disabled=false;
		}else{
			txt="devi inserire almeno una parola chiave";
			document.metatag.source.value=txt;
		}
	}else{
	document.metatag.submit()
}
}

function MakeNew(){
	document.metatag.add.value="Genera";
	document.metatag.canc.disabled=true;
	document.metatag.reset();
}

function AddText(form, Action){
	var AddTxt="";
	var txt="";
	form.keywords.value+=AddTxt;
	
}

function ResetPage(form){
	if(confirm("Do you want to clear all and start a new META-tag Creation?")){	
		form.description.value="";	
		form.source.value="";	
		form.keywords.value="";	
  	}
}

function stampa(){
var NS = (navigator.appName == "Netscape");
var VERSION = parseInt(navigator.appVersion);	
	if (VERSION > 3) {
		parent.principale.focus();
		parent.principale.print();
	}else{
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
		WebBrowser1.ExecWB(6, 2);
		WebBrowser1.outerHTML = "";  
	}
}

function autoChange(){
	if ((browser_capability_level == 1)||(browser_capability_level == 4)){
		if (browser=="Microsoft"){
			site=window.open(CASATAIT,'site','scrollbars=0,resizable=0,status=0,location=0,toolbar=0,fullscreen=1');
		}else{
			site=window.open(CASATAIT,'site','scrollbars=0,resizable=0,status=0,location=0,toolbar=0,width='+width+',height='+height+',top=0,left=0,screenx=0,screeny=0');
		}	
		site.focus();
	}else{
		alert(y);
		site=window.open(PLUGINSPAGE,'site','scrollbars=1,resizable=1,status=1,location=1,toolbar=0,width=650,height=500,top=50,left=50,screenx=50,screeny=50')
		site.focus();
	}
}

function fineSession(){
	alert(MEMO);
	window.close();
	window.opener.focus();
	window.opener.site=null;
}
	
function manChange(){
	if(site!=null){
		site.focus();
	}else{
		autoChange();		
	}
}

function trimIn(test,c){
	p = test.indexOf(c);
	while(p!= -1){
		t1 = test.substring(0,p);
		t2 = test.substring(p+1);
		test = t1+t2;
		p = test.indexOf(c);
	} 
//	return t;
	t=test;
}
function credits(){
	winC=window.open('http://www.1191.it/credits.asp','credits','scrollbars=0,resizable=0,status=1,location=0,toolbar=0,width=100,height=100,top=0,left=0');
	winC.focus();
}