/* parte per newsletter div*/

var tableWidth = 760;
var divWidth = 281;
var divWidthSonda = 760;
var divWidthSondaSmall = 628;
var divHeightSonda = 400;
var sideDivColor = "#FFFFFF";
var bannerImg = "img/tramHP.gif";

var rightAdj = 0;
var leftAdj = 60;
var topAdj = 0;

var divTop = 10;
var divTopSonda = 10;
var maxRight = 330;
var maxRightSonda = 150;
var maxTop = 190;
var fermataLeft = 250;
var fermataLeftSonda = 55;
var fermataTop = 0;

var ieMinVersion = 5;
var mozMinVersion = 5;
var bannerLink = "javaScript:apriPopUp('popup/novita02_11.php','pop','width=515, height=430, top=60, left=20','width=515, height=400, top=40, left=15')";

// non toccare
var timeOut;
var timeOutSmall;
var timeOutBig;
var scrWidth = 0;
var scrHeight = 0;
var browserChecked = false;
var effectFermLeft = 0;
var effectFermTop = 0;
var stopDone = false;
var fix = 0;
var fixHeight = 0;

if(navigator.appName.indexOf('Microsoft Internet Explorer') != -1){

	bv = navigator.userAgent;
	ieVind = bv.indexOf("MSIE") + 5;
	ieV = parseFloat(bv.substr(ieVind, bv.indexOf(";", bv.indexOf("MSIE")) - ieVind));

	if(ieV >= ieMinVersion){
		scrWidth = document.body.offsetWidth;
		scrHeight = document.body.offsetHeight;
		rightAdj -= 3;
		leftAdj -= 3;
		if (scrWidth > 1024)
 		 fix = 0;
		else
		 fix = 30;
		fixHeight = -150;
		browserChecked = true;
	}
    
}else if(navigator.appName.indexOf('Netscape') != -1){
	if(parseInt(navigator.appVersion) >= mozMinVersion){
		if(navigator.userAgent.indexOf("Netscape") != -1){
			if(parseFloat(navigator.userAgent.substr(navigator.userAgent.lastIndexOf("/") + 1)) >= 7){
				scrWidth = window.innerWidth;
				scrHeight = window.innerHeight;
				browserChecked = true;
			}
		}else if(navigator.userAgent.indexOf("rv:1.6") != -1 || navigator.userAgent.indexOf("rv:1.4") != -1 || navigator.userAgent.indexOf("rv:1.7") != -1 || navigator.userAgent.indexOf("rv:1.8") != -1){
			scrWidth = window.innerWidth;
			scrHeight = window.innerHeight;
			browserChecked = true;
		} else if (navigator.userAgent.indexOf("Safari") != -1){
			scrWidth = document.body.offsetWidth;
	        scrHeight = document.body.offsetHeight;
			browserChecked = true;
		}
	}
	if (scrWidth > 1024)
	  fix = 0;
	else  
	  fix = 8;
} else if(navigator.appName.indexOf('Safari') != -1){
	
	scrWidth = document.body.offsetWidth;
	scrHeight = document.body.offsetHeight;
	browserChecked = true;
    
	if (scrWidth > 1024)
	  fix = 0;
	else  
	  fix = 8;
}

var minLeft = 0;
var minTop = 0;

//var maxRight = 0;

/*sezione per div newsletter*/

function initNewsletter(){
/*sezione per la nl*/
/*
    var ck = document.cookie;
	
	if(browserChecked && ck.indexOf("oraNLDiv") == -1){
        
		maxRight= ((parseInt(scrWidth) - parseInt(divWidthSonda))/2);
		minTop = ((parseInt(scrHeight) - parseInt(divHeightSonda))/2) - parseInt(divHeightSonda);
		maxRight -= 20;
		
		effectFermTop = 115;
		
		buildDivBigNL();
		timeOut = setTimeout('goBigNL(' + minTop + ')', 2000);

		var adesso = new Date().getTime();
		
		  if( parseInt(scrWidth) <= parseInt(tableWidth) ){
			maxRightSonda = 45 + tableWidth;
			minLeft = -45 + (parseInt(divWidthSondaSmall) * -1);
			effectFermLeft = fermataLeftSonda;
		  }else{
			minLeft = -45 +((parseInt(scrWidth) - parseInt(tableWidth))/2) - parseInt(divWidthSondaSmall);
			effectFermLeft = fermataLeftSonda + ((parseInt(scrWidth) - parseInt(tableWidth))/2)- leftAdj;
			maxRightSonda = 45+ tableWidth + ((parseInt(scrWidth) - parseInt(tableWidth))/2);

		  }

			effectFermLeft += 15;
			minLeft -= leftAdj;
			buildDivSmallNL();
			timeOut = setTimeout('goBigNL(' + minTop+ ')', 2000);

	} else if (browserChecked && ck.indexOf("bastaNLDiv") == -1){
        
		var adesso = new Date().getTime();
		var prima = ck.substring(ck.indexOf("oraNLDiv=")+9,ck.indexOf("XXX"));
		
		if ((parseInt(adesso)-parseInt(prima)) > 1)   
		{
		  if( parseInt(scrWidth) <= parseInt(tableWidth) ){
			maxRightSonda = 45 + tableWidth;
			minLeft = parseInt(divWidthSondaSmall) * -1;
			effectFermLeft = fermataLeftSonda;
		  }else{
			minLeft = ((parseInt(scrWidth) - parseInt(tableWidth))/2) - parseInt(divWidthSondaSmall);
			effectFermLeft = fermataLeftSonda + ((parseInt(scrWidth) - parseInt(tableWidth))/2)- leftAdj;
			maxRightSonda = 45 + tableWidth + ((parseInt(scrWidth) - parseInt(tableWidth))/2);

		  }

			effectFermLeft += 60;
			minLeft -= leftAdj;
			buildDivSmallNL();
			timeOut = setTimeout('goSmallNL(' + minLeft + ')', 2000);
	 	 }

	}*/
	
}

function moveDownNL(newTop){
    /* per far scendere il div grande del sondaggio*/
	document.getElementById("NLBigLayer").style.top = newTop + "px";
	goBigNL(parseInt(newTop));
}

function moveRightNL(newLft){
	document.getElementById("NLSmallLayer").style.left = newLft + "px";
	goSmallNL(parseInt(newLft));
}

function stopNLSmall(){
	clearTimeout(timeOutSmall);
	document.getElementById("NLSmallLayer").style.visibility = 'hidden';
	document.getElementById("NLSmallLayer").style.left = maxRight;
	document.cookie = "bastaNL=2";
}

function stopNLBig(){
	clearTimeout(timeOutBig);
	document.getElementById("NLBigLayer").style.visibility = 'hidden';
	document.getElementById("NLBigLayer").style.left = maxRight;
	document.cookie = "bastaNL=1";
}

function buildDivBigNL(){

	document.write("<DIV id=\"NLBigLayer\" style=\" z-index:1000;position:absolute; top: " + minTop + "px; left: " + maxRight + "px; visibility: hidden\">");
    document.write('<html>');
	document.write('<head>');
	document.write('<title>Documento senza titolo</title>');
	document.write('<style type="text/css">');
	document.write('<!-- body{ background : url(null) fixed no-repeat; } ');
	document.write('.Stile1 {');
	document.write('	font-family:Verdana, Arial, Helvetica, sans-serif;');
	document.write('	font-size: 13px;');
	document.write('	color:#000000;');
	document.write('	font-weight:bold;');
	document.write('	text-align:left;');
	document.write('}');
	document.write('');
	document.write('A.Stile1 {');
	document.write('	color:#000000;');
	document.write('	text-decoration:none;');
	document.write('}');
	document.write('');
	document.write('A:hover.Stile1 {');
	document.write('	color:#000000;');
	document.write('	text-decoration:underline;');
	document.write('}');
	document.write('-->');
	document.write('</style>');
	document.write("<script language=\"Javascript\"> ");
	document.write("function vai(){ document.cookie = \"oraNLDiv=\" + new Date().getTime() +\"XXX; path=/\"; ");  
	document.write("document.getElementById('NLBigLayer').style.visibility='hidden';}");
	document.write("function persempre(){var expire= new Date(); expire.setTime(expire.getTime() + 3600000*24*2*365); document.cookie = \"oraNLDiv=\" + new Date().getTime() +\"XXX; expires=\"+expire.toGMTString()+\"; path=/\"; document.cookie = \"bastaNLDiv=1; expires=\"+expire.toGMTString()+\"; path=/\";  document.getElementById('NLBigLayer').style.visibility='hidden';}");
	document.write("</script></head>");
	
	document.write('');
	
	document.write('<body>');
	document.write('<table width="700" border="0" cellpadding="0" cellspacing="0" >');
	document.write('	  <tr>');
	document.write('			<td align="center"><img src="/imbol/pages/images/divSondaggio.jpg" width="770" height="360" border="0" usemap="#MapD" /></td>');
	document.write('			</tr>');
	document.write('		  </table>');
	document.write('	');
	document.write('');
	document.write('    <map name="MapD" id="MapD">');
	document.write('    <area shape="rect" coords="286,159,339,203" href="http://www.ilmiobaby.com/imbol/pages/sondaggi/sondaggio_01.jsp" alt="" target=_blank />');
        document.write(' <area shape="rect" coords="33,332,97,354" href="#" onclick="vai();" alt="" />');
        document.write('</map></body>');
	document.write('	</html>');
	document.write("</DIV>");

}

function buildDivSmallNL(){

	document.write("<DIV id=\"NLSmallLayer\" style=\"position:absolute; top: " + divTopSonda + "px; left: " + minLeft + "px; visibility: hidden\">");
    document.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><style type=\"text/css\">');
	document.write('<!-- ');
	document.write('	.Stile1 {');
	document.write('	font-family:Verdana, Arial, Helvetica, sans-serif;');
	document.write('	font-size: 13px;');
	document.write('	color:#000000;');
	document.write('	font-weight:bold;');
	document.write('	text-align:left;');
	document.write('}');
	document.write('');
	document.write('A.Stile1 {');
	document.write('	color:#000000;');
	document.write('	text-decoration:none;');
	document.write('}');
	document.write('');
	document.write('A:hover.Stile1 {');
	document.write('	color:#000000;');
	document.write('	text-decoration:underline;');
	document.write('}');
	document.write('');	
	document.write('	--> </style>');
	document.write("<script language=\"Javascript\"> function nonOra(){");
	document.write("document.cookie = \"bastaNL=1; path=/\"; document.getElementById('NLSmallLayer').style.visibility='hidden';}"); 
	document.write("function ora(){");
	document.write("document.cookie=\"oraNLDiv=\"+new Date().getTime()+\"XXX; path=/\"; ");
	document.write("document.location.href=\"http://www.sceglitu.it/newsletter/inoltraIscrivi.php\"};");
	document.write("</script></head>");
	document.write('<body>');
	document.write('<table width="700" border="0" cellpadding="0" cellspacing="0">');
	document.write('  <tr>');
	document.write('    <td><img src="/img/webzine/divPiccSondaggio.jpg" width="628" height="83" border="0" usemap="#MapD" /></td>');
	document.write('  </tr>');
	document.write('</table>');
	document.write('');
	document.write('');
	document.write('');
	document.write('<map name="MapD" id="MapD">');
        document.write('<area shape="rect" coords="9,53,70,68" href="#" onclick="nonOra();" />');
        document.write('<area shape="rect" coords="16,10,284,44" href="http://www.sceglitu.it/sondaggiHP/index.php" target="_blank" />');
        document.write('    <area shape="rect" coords="207,44,286,73" href="Javascript: apriPopUpQS(\'/popup/inoltraPagina.php\',\'pag=/sondaggiHP/index.php\',\'nn\',\'resizable=1,scrollbars=1,width=400,height=300\');" alt="" />');
	document.write('</map></body></html>');
	document.write("</DIV>");
	
	document.write("<DIV id=\"NLLeftLayer\" style=\"background-color: " + sideDivColor + " ;position:absolute; width: " + divWidth + "px;top: " + divTopSonda + "px; left: " + maxRightSonda + "px; visibility: visible\">");
    document.write("<html><head><style type=\"text/css\"><!-- body{ background : url(null) fixed no-repeat; } --></style>");	
	document.write("</head><body>");	
	document.write("<table width=\"100%\" cellspacing=\"0\" border=\"0\">");
	document.write("<TR><TD ><IMG src=\"/img/spacer.gif\" width=\"1\" height=\"221\"/></TD></TR>");
    document.write("</table></body></html>");
	document.write("</DIV>");
    
	document.write("<DIV id=\"NLLeftLayer\" style=\"background-color: " + sideDivColor + " ;position:absolute; width: " + divWidthSondaSmall + "px;top: " + divTopSonda + "px; left: " + minLeft + "px; visibility: visible\">");
    document.write("<html><head><style type=\"text/css\"></style>");
	document.write("<table width=\"100%\" cellspacing=\"0\" border=\"0\">");
	document.write("<TR><TD ><IMG src=\"/img/spacer.gif\" width=\"2\" height=\"221\"/></TD></TR>");
    document.write("</table></body></html>");	
	document.write("</DIV>");
	
}

function goSmallNL(lft){

  if (document.cookie.indexOf("bastaNLDiv") == -1)
      {
     	if(document.getElementById("NLSmallLayer").style.visibility == 'hidden')
	   	document.getElementById("NLSmallLayer").style.visibility = 'visible';
      } 
    //alert(lft+"..."+effectFermLeft+"..."+maxRight);
	//lft += 30;
	lft += 2;
	if((parseInt(lft) < parseInt(effectFermLeft)) || (parseInt(lft) < maxRightSonda && stopDone)){
	   if (document.cookie.indexOf("bastaNLDiv") == -1)
		timeOut = setTimeout('moveRightNL(\'' + lft + '\')', 10);
	 	
	}else if(parseInt(lft) < maxRightSonda && !stopDone){
 	   if (document.cookie.indexOf("bastaNLDiv") == -1)
        {
		 stopDone = true;
		 timeOut = setTimeout('moveRightNL(\'' + lft + '\')', 10000);
		} 
	 	
	}else{
	   if (document.cookie.indexOf("bastaNLDiv") == -1)
        {
			document.getElementById("NLSmallLayer").style.visibility = 'hidden';
			document.getElementById("NLSmallLayer").style.left = minLeft + "px";
			stopDone = false;
			/*azzero timer */
			document.cookie="ora="+new Date().getTime()+"XXX; path=/";
			/*
			ck = document.cookie;
			ck.replace(ck.substring(ck.indexOf("ora=")+4,ck.indexOf("XXX")),new Date().getTime());
			alert(ck.substring(ck.indexOf("ora=")+4,ck.indexOf("XXX")));
			*/
			setTimeout('goSmallNL(' + minLeft + ')', 1000*15); /*o al max come il tram 3000*/
		}
	}
}

function goBigNL(tp){

	if(document.getElementById("NLBigLayer").style.visibility == 'hidden')
		document.getElementById("NLBigLayer").style.visibility = 'visible';

	tp += 3;
	
	maxTop += fixHeight;
	if((parseInt(tp) < parseInt(effectFermTop)) || (parseInt(tp) < maxTop && stopDone)){
		timeOut = setTimeout('moveDownNL(\'' + tp + '\')', 10);
	}/*else if(parseInt(tp) < maxTop && !stopDone){
		stopDone = true;
		timeOut = setTimeout('moveDown(\'' + tp + '\')', 10);
	}*/else{
	
	    /* stop
		document.getElementById("sondBigLayer").style.visibility = 'hidden';
		document.getElementById("sondBigLayer").style.left = minTop + "px";
		stopDone = false;
		setTimeout('goBig(' + minTop + ')', 3000);
		*/
	}
	
}

//if (ReadCookie("STLOGSOND") == "")
  initNewsletter();

/* fine parte newsletter div*/



/*
 tenuti da parte per newsletter

function buildDivBigNL(){

	document.write("<DIV id=\"NLBigLayer\" style=\" z-index:1000;position:absolute; top: " + minTop + "px; left: " + maxRight + "px; visibility: hidden\">");
    document.write('<html>');
	document.write('<head>');
	document.write('<title>Documento senza titolo</title>');
	document.write('<style type="text/css">');
	document.write('<!-- body{ background : url(null) fixed no-repeat; } ');
	document.write('.Stile1 {');
	document.write('	font-family:Verdana, Arial, Helvetica, sans-serif;');
	document.write('	font-size: 13px;');
	document.write('	color:#000000;');
	document.write('	font-weight:bold;');
	document.write('	text-align:left;');
	document.write('}');
	document.write('');
	document.write('A.Stile1 {');
	document.write('	color:#000000;');
	document.write('	text-decoration:none;');
	document.write('}');
	document.write('');
	document.write('A:hover.Stile1 {');
	document.write('	color:#000000;');
	document.write('	text-decoration:underline;');
	document.write('}');
	document.write('-->');
	document.write('</style>');
	document.write("<script language=\"Javascript\"> ");
	document.write("function vai(){ document.cookie = \"oraNL=\" + new Date().getTime() +\"XXX; path=/\"; ");  
	document.write("document.getElementById('NLBigLayer').style.visibility='hidden';}");
	document.write("</script></head>");
	
	document.write('');
	
	document.write('<body>');
	document.write('<table width="700" border="0" cellpadding="0" cellspacing="0" >');
	document.write('	  <tr>');
	document.write('			<td align="center"><img src="/newsletter/img/div.gif" width="758" height="350" border="0" usemap="#Map" /></td>');
	document.write('			</tr>');
	document.write('		  </table>');
	document.write('	');
	document.write('');
	document.write('    <map name="Map" id="Map">');
	document.write('    <area shape="rect" coords="64,181,171,206" href="http://www.sceglitu.it/newsletter/n5_dicembre06Bb.html" alt="" />');
	document.write('    <area shape="rect" coords="67,119,382,172" href="http://www.sceglitu.it/newsletter/n5_dicembre06Bb.html" alt="" />');
	document.write('    <area shape="rect" coords="541,182,681,222" href="Javascript: apriPopUpQS(\'/popup/openNL.php\',\'\',\'nl\',\'width=775,height=550,resizable=1,scrollbars=1\');" alt="" />');
        document.write('     <area shape="rect" coords="285,246,542,300" href="Javascript: apriPopUpQS(\'/popup/openNL.php\',\'\',\'nl\',\'width=775,height=550,resizable=1,scrollbars=1\');" alt="" /> ');
        document.write('<area shape="poly" coords="296,201,384,193,474,158,589,44,608,62,504,188,348,236,300,232" href="http://www.sceglitu.it/newsletter/n5_dicembre06Bb.html" alt=""/> ');
        document.write(' <area shape="rect" coords="650,324,755,350" href="#" onclick="vai();" alt="" />');
        document.write('</map></body>');
	document.write('	</html>');
	document.write("</DIV>");

}

function buildDivSmallNL(){

	document.write("<DIV id=\"NLSmallLayer\" style=\"position:absolute; top: " + divTopSonda + "px; left: " + minLeft + "px; visibility: hidden\">");
    document.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><style type=\"text/css\">');
	document.write('<!-- ');
	document.write('	.Stile1 {');
	document.write('	font-family:Verdana, Arial, Helvetica, sans-serif;');
	document.write('	font-size: 13px;');
	document.write('	color:#000000;');
	document.write('	font-weight:bold;');
	document.write('	text-align:left;');
	document.write('}');
	document.write('');
	document.write('A.Stile1 {');
	document.write('	color:#000000;');
	document.write('	text-decoration:none;');
	document.write('}');
	document.write('');
	document.write('A:hover.Stile1 {');
	document.write('	color:#000000;');
	document.write('	text-decoration:underline;');
	document.write('}');
	document.write('');	
	document.write('	--> </style>');
	document.write("<script language=\"Javascript\"> function nonOra(){");
	document.write("document.cookie = \"bastaNL=1; path=/\"; document.getElementById('NLSmallLayer').style.visibility='hidden';}"); 
	document.write("function ora(){");
	document.write("document.cookie=\"oraNL=\"+new Date().getTime()+\"XXX; path=/\"; ");
	document.write("document.location.href=\"http://www.sceglitu.it/newsletter/inoltraIscrivi.php\"};");
	document.write("</script></head>");
	document.write('<body>');
	document.write('<table border="0" cellpadding="0" cellspacing="0">');
	document.write('  <tr>');
	document.write('    <td><img src="/newsletter/img/divPicOttobre06.jpg" width="628" height="83" border="0" usemap="#Map" /></td>');
	document.write('  </tr>');
	document.write('</table>');
	document.write('');
	document.write('');
	document.write('');
	document.write('<map name="Map" id="Map">');
        document.write('<area shape="rect" coords="10,54,84,75" href="#" onclick="nonOra();" />');
        document.write('<area shape="rect" coords="446,11,616,28" href="Javascript: apriPopUpQS(\'/popup/openNL.php\',\'\',\'nl\',\'width=775,height=550,resizable=1,scrollbars=1\');" />');
        document.write('<area shape="rect" coords="489,41,610,73" href="Javascript: apriPopUpQS(\'/popup/openNL.php\',\'\',\'nl\',\'width=775,height=550,resizable=1,scrollbars=1\');" />');
        document.write('<area shape="poly" coords="17,13,361,17,359,58,220,58,220,33,16,31" href="/newsletter/n5_dicembre06Bb.html" />');
	document.write('</map></body></html>');
	document.write("</DIV>");
	
	document.write("<DIV id=\"NLLeftLayer\" style=\"background-color: " + sideDivColor + " ;position:absolute; width: " + divWidth + "px;top: " + divTopSonda + "px; left: " + maxRightSonda + "px; visibility: visible\">");
    document.write("<html><head><style type=\"text/css\"><!-- body{ background : url(null) fixed no-repeat; } --></style>");	
	document.write("</head><body>");	
	document.write("<table width=\"100%\" cellspacing=\"0\" border=\"0\">");
	document.write("<TR><TD ><IMG src=\"/img/spacer.gif\" width=\"1\" height=\"221\"/></TD></TR>");
    document.write("</table></body></html>");
	document.write("</DIV>");
    
	document.write("<DIV id=\"NLLeftLayer\" style=\"background-color: " + sideDivColor + " ;position:absolute; width: " + divWidthSondaSmall + "px;top: " + divTopSonda + "px; left: " + minLeft + "px; visibility: visible\">");
    document.write("<html><head><style type=\"text/css\"></style>");
	document.write("<table width=\"100%\" cellspacing=\"0\" border=\"0\">");
	document.write("<TR><TD ><IMG src=\"/img/spacer.gif\" width=\"2\" height=\"221\"/></TD></TR>");
    document.write("</table></body></html>");	
	document.write("</DIV>");
	
}


*/

