/*****************************************************************************************
*	FUNZIONI PER FAR MUOVERE LO SPAN ATTENDEREP PREGO CON LA PAGINA (anche quando sgrullo)
******************************************************************************************/
function setVariables(){
	if (navigator.appName == "Netscape") {
		if (parseInt(navigator.appVersion) >= 5){
			v=".top=";
			h=".left=";
			dS="document.getElementById(\"";sD="\").style";
			y="window.pageYOffset";
			x="window.pageXOffset";
		}
		else {
			v=".top=";
			h=".left=";
			dS="document.";
			sD="";
			y="window.pageYOffset";
			x="window.pageXOffset";
		}
	}
	else {
	//ENTRO QUI
		h=".pixelLeft=";
		v=".pixelTop=";
		dS="";
		sD=".style";
		y="document.body.scrollTop";
		x="document.body.scrollLeft";
	}
	checkLocationA()
}

movex=0,movey=0,xdiff=0,ydiff=0,ystart=0,xstart=0
var elFake ;


function checkLocation(){
	object="obj";
	yy=eval(y);
	xx=eval(x);
	ydiff=ystart-yy;
	xdiff=xstart-xx;
	
	if ((ydiff<(-1))||(ydiff>(1))) {
		movey=Math.round(ydiff/10) ;
		ystart-=movey ;
	}
	if ((xdiff<(-1))||(xdiff>(1))) {
		movex=Math.round(xdiff/10) ; 
		xstart-=movex ;
	}
	
	if (ystart>=10){
		
		var alldiv = document.body.getElementsByTagName("DIV");
		nu = alldiv.length ;
		var altro_div = null ;
	
		
		for(r=0;r<nu;r++){
			if("loading" == alldiv[r].getAttribute('id')){
				altro_div = alldiv[r].getAttribute('id');		
			}
		}
		
		elFake = document.getElementById(altro_div).style ;
		var newY = ystart + ((screen.height) / 2) - 150 ;
		eval("elFake"+".top="+newY) ;
		
	} 
	else {
		var alldiv = document.body.getElementsByTagName("DIV");
		nu = alldiv.length ;
		var altro_div = null ;
	
		
		for(r=0;r<nu;r++){
			if("loading" == alldiv[r].getAttribute('id')){
				altro_div = alldiv[r].getAttribute('id');		
			}
		}
		
		elFake = document.getElementById(altro_div).style ;
		var newY = ((screen.height) / 2) - 150 ;
		eval("elFake"+".top="+newY) ;
	}


	var alldiv = document.body.getElementsByTagName("DIV");
	nu = alldiv.length ;
	var altro_div = null ;

	
	for(r=0;r<nu;r++){
		if("loading" == alldiv[r].getAttribute('id')){
			altro_div = alldiv[r].getAttribute('id');		
		}
	}
	
	elFake = document.getElementById(altro_div).style ;
	var newX = xstart ;
	//eval("elFake"+".left="+newX) ;
		
	setTimeout("checkLocation()",10);
}

function checkLocationA(){
	ystart=eval(y);
	xstart=eval(x);
}



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



    
 
/*******************************************************************
*					PARTE PRODUCER
*******************************************************************/


function toggleDisplay(fO){
	
	var ns4 = (document.layers);
	var ie4 = (document.all && !document.getElementById);
	var ie5 = (document.all && document.getElementById);
	var ns6 = (!document.all && document.getElementById);


	if(ie5 || ns6){
		if (document.getElementById(fO).style.display=="none") {
		document.getElementById(fO).style.display="inline";
		}else{
		document.getElementById(fO).style.display="none";
		}
	}

	if(ie4){
		if (document.all[fO].style.display=="none") {
		document.all[fO].style.display="inline";
		}else{
		document.all[fO].style.display="none";
		}
	}	
}
 

function sanoriposoMouseOver(num) {    
	
	var txt = "" ;
	switch(num) {
		case '1' :
		txt =   'il sonno' ;
		break ;
		case '2':
		txt =   'i disturbi del sonno' ;
		break ;
		case '3':
		txt =   'la cultura Previdorm' ;
		break ;
		case '4':
		txt =   'naturalmente lattice' ;
		break ;
		case '5':
		txt =   'naturalmente Previdorm' ;
		break ;
		case '6':
		txt =   'il sistema ideale' ;
		break ;
		case '7':
		txt =   'circolazione' ;
		break ;
		case '8':
		txt =   'igene' ;
		break ;
		case '9':
		txt =   'certificazioni' ;
		break ;
	}
	
	//alert(txt);
	document.getElementById('menuTesto').innerHTML=txt ;				
 	
 		
}

function nemicoMouseOver(num) {    
	
	var txt = "" ;
	switch(num) {
		case '1' :
		txt =   'troppo molle?' ;
		break ;
		case '2':
		txt =   'troppo rigido?' ;
		break ;
		case '3':
		txt =   'acari' ;
		break ;
		case '4':
		txt =   'batteri e micromuffe' ;
		break ;
		case '5':
		txt =   'elettrosmog' ;
		break ;
		case '6':
		txt =   'poliuretano?' ;
		break ;
		 
	}
	
	//alert(txt);
	document.getElementById('menuTesto').innerHTML=txt ;				
 	
 		
}

function sanoriposoMouseOut(num) {
	document.getElementById('menuTesto').innerHTML='';
}

function nemicoMouseOut(num) {

		document.getElementById('menuTesto').innerHTML='';

}

function sistemaidealeMouseOver(num) {    
	
	var txt = "" ;
	switch(num) {
		case '1' :
		txt =   '<a href="javascript:;" onclick="sistemaideale(\'1\')">Genius</a>' ;
		break ;
		case '2':
		txt =   'troppo rigido?' ;
		break ;
		case '3':
		txt =   'acari' ;
		break ;
		case '4':
		txt =   'batteri e micromuffe' ;
		break ;
		 
		 
	}
	
	//alert(txt);
	document.getElementById('menuTesto').innerHTML=txt ;				
 	
 		
}

function sistemaidealeMouseOut(num) {

		document.getElementById('menuTesto').innerHTML='';

}

function sistemaidealeMenu(num) { 
	document.getElementById(1).style.color='#71747D' ;
	document.getElementById(2).style.color='#71747D' ;
	document.getElementById(3).style.color='#71747D' ;
	document.getElementById(4).style.color='#71747D' ;
	eval("document.getElementById("+num+").style.color='#990000' ;") ;
	
	document.getElementById('menuTesto1').style.display='none';
	document.getElementById('menuTesto2').style.display='none';
	document.getElementById('menuTesto3').style.display='none';
	document.getElementById('menuTesto4').style.display='none';

	eval("document.getElementById('menuTesto"+num+"').style.display='';") ;
}

function sanoriposo(num) {

	document.form.menuCkecked.value=num ;
	
	var url = "" ;
	
	url  = "php/sanoriposoAJX.php?num="+num  ;
	
	document.getElementById(1).innerHTML="<img src='img/1verde.gif' border=0>" ;
	document.getElementById(2).innerHTML="<img src='img/2verde.gif' border=0>" ;
	document.getElementById(3).innerHTML="<img src='img/3verde.gif' border=0>" ;
	document.getElementById(4).innerHTML="<img src='img/4verde.gif' border=0>" ;
	document.getElementById(5).innerHTML="<img src='img/5verde.gif' border=0>" ;
	document.getElementById(6).innerHTML="<img src='img/6verde.gif' border=0>" ;
	document.getElementById(7).innerHTML="<img src='img/7verde.gif' border=0>" ;
	document.getElementById(8).innerHTML="<img src='img/8verde.gif' border=0>" ;
	document.getElementById(9).innerHTML="<img src='img/9verde.gif' border=0>" ;
 
	eval("document.getElementById("+num+").innerHTML=\"<img src='img/"+num+"verdeOver.gif' border=0>\" ;") ;
 
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {
		
			if (htmlOld == html) {

				window.clearInterval(myInterval);

				var elem = document.getElementById('container') ;
				 
				//alert(html);
				
				elem.innerHTML=html ;

			}

		} else {
			
		}
	}
	,1) ; 
}

function sistemaideale(num) {

	document.form.menuCkecked.value=num ;
	
	var url = "" ;
	
	document.getElementById('genius').style.color='#71747D' ;
	document.getElementById('morfeo').style.color='#71747D' ;
	document.getElementById('eracle').style.color='#71747D' ;
	document.getElementById('ermes').style.color='#71747D' ;
	document.getElementById('formassage').style.color='#71747D' ;
	document.getElementById('formedouble').style.color='#71747D' ;
	document.getElementById('medea').style.color='#71747D' ;
	document.getElementById('venere').style.color='#71747D' ;
	document.getElementById('accessori').style.color='#71747D' ;
	document.getElementById('guanciali').style.color='#71747D' ;
	document.getElementById('softwood').style.color='#71747D' ;
	document.getElementById('cachemireSeta').style.color='#71747D' ;
	
	eval("document.getElementById('"+num+"').style.color='#990000' ;") ;
	
	url  = "php/sistemaidealeAJX.php?num="+num  ;
 
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {
		
			if (htmlOld == html) {

				window.clearInterval(myInterval);

				var elem = document.getElementById('container') ;
				 
				//alert(html);
				
				elem.innerHTML=html ;

			}

		} else {
			
		}
	}
	,1) ; 
}

function nemico(num) {

	document.form.menuCkecked.value=num ;
	
	var url = "" ;
	
	url  = "php/nemicoAJX.php?num="+num  ;
	
	document.getElementById(1).innerHTML="<img src='img/1nero.gif' border=0>" ;
	document.getElementById(2).innerHTML="<img src='img/2nero.gif' border=0>" ;
	document.getElementById(3).innerHTML="<img src='img/3nero.gif' border=0>" ;
	document.getElementById(4).innerHTML="<img src='img/4nero.gif' border=0>" ;
	document.getElementById(5).innerHTML="<img src='img/5nero.gif' border=0>" ;
	document.getElementById(6).innerHTML="<img src='img/6nero.gif' border=0>" ;
	 
 
	eval("document.getElementById("+num+").innerHTML=\"<img src='img/"+num+"neroOver.gif' border=0>\" ;") ;
 
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {
		
			if (htmlOld == html) {

				window.clearInterval(myInterval);

				var elem = document.getElementById('container') ;
				 
				//alert(html);
				
				elem.innerHTML=html ;

			}

		} else {
			
		}
	}
	,1) ; 
}



function popup(url_pagina,w,h,sw_scroll) {


          /*w = 500;
          h = 400;*/
          l = (screen.width - w) / 2;
          t = (screen.height - h) / 2;

          wnd = window.open(url_pagina,"","fullscreen=0,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars="+sw_scroll+", resizable=no, width="+w+", height="+h+", left="+l+", top="+t);
          wnd.focus();

}
 
function previdorm(link) {
	 
	document.getElementById('linkPrevidorm').style.display='inline' ;
	document.getElementById('link1').style.fontWeight = 'bold';

	if(link == 'riposo') {
		document.getElementById('linkRiposo').style.color = '#990000';
		document.getElementById('linkMission').style.color = '#666';
	}
	if(link == 'mission') {
		document.getElementById('linkMission').style.color = '#990000';
		document.getElementById('linkRiposo').style.color = '#666';
	}
	
	var url = "" ;
	
	url  = "php/previdorm.php?link="+link  ;	
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {
		
			if (htmlOld == html) {

				window.clearInterval(myInterval);

				var elem = document.getElementById('container') ;
				 
				//alert(html);
				
				elem.innerHTML=html ;

			}

		} else {
			
		}
	}
	,1) ;
}

function cambiaFoto(num,url,container) {
	var url = "" ;
	
	url  = webpath  ;
	
	var ajaxObj = new ClassAJAX();
	ajaxObj.setExecute(false) ;
	ajaxObj.setReturn(true) ;
	ajaxObj.runAJAX(url) ;

	var html = "" ;
	var htmlOld = "" ;

	myInterval = window.setInterval(
	function() {
		htmlOld = html ;
		html = ajaxObj.getHtml() ;
		if (html != false) {
		
			if (htmlOld == html) {

				window.clearInterval(myInterval);

				var elem = eval("document.getElementById('"+container+"') ;") ;
				 
				elem.innerHTML=html ;

			}

		} else {
			
		}
	}
	,1) ;
}


function checkFormContatto() {
	
	var msg = "" ;
	var sw = 0 ;
	
	var the_box1 = document.form.autorizzo[1].checked;
	if (the_box1 == true) {
		msg += "Devi accettare la clausola.\n" ;	
		sw = 1 ;
		}
	
		var x = document.form.email.value;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) {
		//alert('YES! Correct email address');
		} else {
		
		msg += "Indirizzo email inesatto.\n" ;
		sw = 1 ;	
		} 

		if (!document.form.email.value) {
		msg += "devi inserire l\' email.\n" ;
		sw = 1 ;
		}
		if (!document.form.nome.value) {
		msg += "devi inserire il nome.\n" ;
		sw = 1 ;
		}
		if (!document.form.cognome.value) {
		msg += "devi inserireil cognome.\n" ;
		sw = 1 ;
		}

		
		if(sw == 1 ) {		
			alert(msg);
			return false ;
		} else{
			return true ;
		}


}


function checkFormNewsletter() {
	
	var msg = "" ;
	var sw = 0 ;
	
	var the_box1 = document.form.autorizzo[1].checked;
	if (the_box1 == true) {
		msg += "Devi accettare la clausola.\n" ;	
		sw = 1 ;
		}
	
		var x = document.form.email.value;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) {
		//alert('YES! Correct email address');
		} else {
		
		msg += "Indirizzo email inesatto.\n" ;
		sw = 1 ;	
		} 

		if (!document.form.email.value) {
		msg += "devi inserire l\' email.\n" ;
		sw = 1 ;
		}
		if (!document.form.nome.value) {
		msg += "devi inserire il nome.\n" ;
		sw = 1 ;
		}
		if (!document.form.cognome.value) {
		msg += "devi inserireil cognome.\n" ;
		sw = 1 ;
		}

		
		if(sw == 1 ) {		
			alert(msg);
			return false ;
		} else{
			return true ;
		}


}


function checkFormTeam() {
	
	var msg = "" ;
	var sw = 0 ;
	
	var the_box1 = document.form.autorizzo[1].checked;
	if (the_box1 == true) {
		msg += "Devi accettare la clausola.\n" ;	
		sw = 1 ;
		}
	
		var x = document.form.email.value;
		var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		if (filter.test(x)) {
		//alert('YES! Correct email address');
		} else {
		
		msg += "Indirizzo email inesatto.\n" ;
		sw = 1 ;	
		} 

		if (!document.form.email.value) {
		msg += "devi inserire l\' email.\n" ;
		sw = 1 ;
		}
		if (!document.form.nome.value) {
		msg += "devi inserire il nome.\n" ;
		sw = 1 ;
		}
		if (!document.form.cognome.value) {
		msg += "devi inserireil cognome.\n" ;
		sw = 1 ;
		}

		
		if(sw == 1 ) {		
			alert(msg);
			return false ;
		} else{
			return true ;
		}


}

function showGrafico(id) {
	eval("document.getElementById('div_"+id+"').setAttribute('style', 'cursor:pointer');") ; 
	eval("document.getElementById('div_"+id+"').setAttribute('class', 'testonero');") ;

	document.getElementById('grafici').innerHTML = '<img src="http://'+window.location.host+'/ogi/img/grafici/'+id+'.gif">' ;
	document.getElementById('grafici').style.display='inline';
}

function legenda(lang) {
var html = "" ;

if(lang == "it") {	
	html = '<map name="legenda"><area shape="rect" coords="440,0,460,15" href="javascript:;" onclick="document.getElementById(\'div_legenda\').innerHTML=\'\'" alt="chiudi" title="chiudi"></map><img src="img/legenda.gif"  usemap="#legenda" border=0>';
} else {
	html = '<map name="legenda"><area shape="rect" coords="440,0,460,25" href="javascript:;" onclick="document.getElementById(\'div_legenda\').innerHTML=\'\'" alt="close" title="close"></map><img src="img/legenda_en.gif"  usemap="#legenda" border=0>';
}

	
 
		document.getElementById('div_legenda').innerHTML=html ;
	 
	
}

