var nn=document.layers?true:false;
var w3c=document.getElementById?true:false;
var beg=nn?"document.layers.":w3c?"document.getElementById('":"document.all['";
var mid=nn?"":w3c?"').style":"'].style";
var mid2=nn?"":w3c?"')":"";


/* News Ticker */

var AltezzaLinee=12;
var Velocita = 100;
var Intervallo = 2000;
var Step=1;

var nn = document.layers?true:false;
var N6 = navigator.userAgent.toLowerCase().indexOf("gecko")!=-1?true:false;
var LayText=null;
var AltezzaLivello=0;
var LarghezzaLivello=0;
var Limite =0;
var texTop=0;
var DeltaTop = 0;
var timsc=null;

function newsticker()
	{
	LayText=nn?document.layers.news:N6?document.getElementById("news").style:document.all.news.style;
	LayText.height="14px";
	LayText.clip="rect(0px,0px,0px,0px)";
	LayText.visibility="visible";
	DeltaTop=nn?LayText.top:N6?document.getElementById("news").offsetTop:document.all.news.offsetTop;
	AltezzaLivello=parseInt(nn?LayText.clip.height:N6?LayText.height:LayText.height);
	LarghezzaLivello=parseInt(nn?LayText.clip.width:N6?LayText.width:LayText.width);
	Limite=-AltezzaLivello+(nn?LayText.document.height:N6?document.getElementById("divN6").offsetHeight:document.all.news.clientHeight);
	setTimeout("newstickerMove()",Intervallo);
	}

function newstickerMove(where)
	{
	pos=texTop+1;
	LayText.top=-pos+DeltaTop;
	if (nn)
		{
		LayText.clip.top=pos;
		LayText.clip.bottom=eval(pos+AltezzaLivello);
		}
		else
		LayText.clip = "rect(" + pos + ", " + LarghezzaLivello + ", " +eval(pos+AltezzaLivello) + ", 0)";
	texTop>=Limite?texTop=0:texTop+=Step;

	if (texTop % AltezzaLinee != 0 )
		setTimeout("newstickerMove()",Velocita);
	else
		setTimeout("newstickerMove()",Intervallo);

	if (texTop>=Limite)
			texTop=0;

	}
	
if(N6 || nn){
	stile = document.styleSheets[0].cssRules;
}else{
	stile = document.styleSheets[0].rules;
}
msg = (!N6 && !nn) ? stile[19].style.cssText :  stile[16].cssText;
function newstickerMOZ(){
	//LayText = (!N6 && !nn) ? stile[19].style :  stile[16].style;
	LayText=nn?document.layers.news:N6?document.getElementById("news").style:document.all.news.style;
	LayText.visibility="visible";
	AltezzaLivello=parseInt(document.getElementById("divN6").style.height);
	Limite=(nn?LayText.document.height:N6?document.getElementById("divN6").offsetHeight:document.all.divN6.clientHeight);
	nowTimeout = setTimeout("newstickerMoveMOZ()",Intervallo);
}

function newstickerMoveMOZ(){
	LayText.top = ( (-parseInt(LayText.top)>=Limite) ? (0+"px") : (parseInt(LayText.top)-1+"px") );
	
	if(-parseInt(LayText.top) % AltezzaLinee != 0 ){
		clearTimeout(nowTimeout);
		nowTimeout = setTimeout("newstickerMoveMOZ()",Velocita);
	}else{
		clearTimeout(nowTimeout);
		nowTimeout = setTimeout("newstickerMoveMOZ()",Intervallo);
	}
}



/*
if(N6 || nn){
	stile = document.styleSheets[0].cssRules;
}else{
	stile = document.styleSheets[0].rules;
}
msg = (!N6 && !nn) ? stile[19].style.cssText :  stile[16].cssText;
function newsticker(){
	LayText = (!N6 && !nn) ? stile[19].style :  stile[16].style;
	LayText.visibility="visible";
	AltezzaLivello=parseInt(LayText.fontSize);
	Limite=-AltezzaLivello+(nn?LayText.document.height:N6?document.getElementById("newsengine").offsetHeight:document.all.newsengine.clientHeight);
	nowTimeout = setTimeout("newstickerMove()",Intervallo);
}

function newstickerMove(){
	LayText.top = ( (-parseInt(LayText.top)==Limite) ? (0+"px") : (parseInt(LayText.top)-1+"px") );
	
	if(-parseInt(LayText.top) % AltezzaLinee != 0 ){
		clearTimeout(nowTimeout);
		nowTimeout = setTimeout("newstickerMove()",Velocita);
	}else{
		clearTimeout(nowTimeout);
		nowTimeout = setTimeout("newstickerMove()",Intervallo);
	}
}
*/
/* Fine News Ticker */


/* Gestione AutoScrollUP */
var soglia=1500;
var control=0;
var posupper=30;
var temp=1;
//var larghezza = "";
var altezza = "";
 function Inizializza() {
  if (document.all) {
   //larghezza = TextScroll.offsetWidth;
   altezza = upper.offsetHeight;
   setInterval("TextScroll_IE()", temp);   
  }
  else if (document.layers) {
   //larghezza = document.TextScroll.document.width;
   altezza = document.upper.document.height;
   setInterval("TextScroll_NN()", temp);
   document.upper.visibility = "Show";
  }
 }
 function TextScroll_IE() {
  //TextScroll.style.pixelLeft = document.body.scrollLeft + document.body.clientWidth - larghezza - 10;
 	if((document.body.scrollTop + document.body.clientHeight)>soglia && control!=1){
		upper.style.visibility = "Visible";
		control=1;
	}else if((document.body.scrollTop + document.body.clientHeight)<soglia && control!=0){
		upper.style.visibility = "hidden";
		control=0;
	}
  upper.style.pixelTop = document.body.scrollTop + document.body.clientHeight - altezza - posupper;
 }
 function TextScroll_NN() {
  //document.TextScroll.left = pageXOffset + window.innerWidth - larghezza - 10;
	if((pageYOffset + window.innerHeight)>soglia && control!=1){
		document.upper.visibility = "Show";
		control=1;
	}else if((pageYOffset + window.innerHeight)<soglia && control!=0){
		document.upper.visibility = "hide";
		control=0;
	}
  document.upper.top = pageYOffset + window.innerHeight - altezza - posupper;
 }

//window.onload = Inizializza;
/* Fine gestione AutoScrollUP */

/* Inizio Motore Stampa */
function stampa_popup(nowbox,nowsez,nowbreads) {
var testo = "<html><head><title>"+document.title+"</title>";
testo += "<link href=\"tpl/style/general.css\" rel=\"stylesheet\" type=\"text/css\" /><link href=\"tpl/style/"+nowsez+".css\" rel=\"stylesheet\" type=\"text/css\" /></head>";
testo += "<body><div align=\"center\"><img src=\"/img/graphic/img_default.jpg\" border=\"0\" style=\"float:left;\" /><div class=\"bigtitle\">Comune di Secinaro</div><div class=\"titolo\">[ "+nowbreads+" ]</div></div>";
testo += "<br style=\"clear:both;\"/><br /><br><br><div align=\"center\"><div id=\""+nowbox+"\" align=\"left\">"+document.getElementById(nowbox).innerHTML+"</div></div>";
testo += "<br style=\"clear:both\"><br><div align=\"center\">Copyright&copy; - Comune di Secinaro - All Rights Reserved</div><br><br>";
testo += "<div align=\"center\" style=\"clear:both\"><a href=\"javascript:print();\">Stampa</a></div></body></html>";
var ident_finestra = window.open("","finestra_stampa","height='100%',width='593pt',scrollbars");
ident_finestra.document.open();
ident_finestra.document.write(testo);
ident_finestra.document.close();

ident_finestra.print();
ident_finestra.close();

}
/* Fine Motore Stampa */



function seeyes(obj){
 i=0;
 eval(beg+obj+"_a"+mid2).href = "javascript:seeno('"+obj+"')";
 eval(beg+obj+"_a"+mid2).title = "Nascondi questo blocco di risultati!";
 eval(beg+obj+"_img"+mid2).src = "img/graphic/meno.jpg";
 while( eval(beg+obj+"_"+i+mid2) ){
  eval(beg+obj+"_"+i+mid).display = "block";
  i++;
 }
}
function seeno(obj){
 i=0;
 eval(beg+obj+"_a"+mid2).href = "javascript:seeyes('"+obj+"')";
 eval(beg+obj+"_a"+mid2).title = "Visualizza questo blocco di risultati!";
 eval(beg+obj+"_img"+mid2).src = "img/graphic/piu.jpg";
 while( eval(beg+obj+"_"+i+mid2) ){
  eval(beg+obj+"_"+i+mid).display = "none";
  i++;
 } 
}


function seeall(yesno){
 i=1;
 obj="testo";
 while( eval(beg+obj+"_"+i+"_0"+mid2) ){
  obj = obj+"_"+i;
  if(yesno=="yes"){
   eval(beg+obj+"_a"+mid2).href = "javascript:seeno('"+obj+"')";
   eval(beg+obj+"_a"+mid2).title = "Nascondi questo blocco di risultati!";
   eval(beg+obj+"_img"+mid2).src = "img/graphic/meno.jpg";
   eval(beg+obj+"_0"+mid).display = "block";
  }else{
   eval(beg+obj+"_a"+mid2).href = "javascript:seeyes('"+obj+"')";
   eval(beg+obj+"_a"+mid2).title = "Visualizza questo blocco di risultati!";
   eval(beg+obj+"_img"+mid2).src = "img/graphic/piu.jpg";
   eval(beg+obj+"_0"+mid).display = "none";
  }
  i++;
  obj="testo";
 }
}

if(N6==true){
	newstickerMOZ();
}else{
	newsticker();
}


/* Inizio Gestione Motore Foto */
var nn=document.layers?true:false;
var w3c=document.getElementById?true:false;
var beg=nn?"document.layers":w3c?"document.getElementById('":"document.all";
var mid=nn?"":w3c?"').style":".style";
var mid2=nn?"":w3c?"')":"";
var iedom=document.all||document.getElementById;


function changer(objchange){
 myImage2 = new Image;
 myImage2.src = objchange.src;
 finalwidth = myImage2.width;
 finalheight = myImage2.height;
 dest=eval(beg+"bigphoto"+mid2);
 dest.src=objchange.src;
 //alert(finalwidth+" - "+finalheight);
 dest.width=((parseInt(finalwidth)<194)?parseInt(finalwidth):194);
 dest.height=((parseInt(finalheight)<244)?parseInt(finalheight):244);
 dest2=eval(beg+"bigphoto_a"+mid2);
 dest2.href=(objchange.src).replace("ICON_","");
}

function opener(objopen){
 myImage = new Image;
 myImage.src = (objopen.src).replace("ICON_","");
 var finalwidth = myImage.width;
 var finalheight = myImage.height;
 alert(finalwidth+" - "+finalheight);
 var LeftPosition = (screen.width) ? (screen.width-700)/2 : 0;
 var TopPosition = (screen.height) ? (screen.height-550)/2 : 0;
 	var finestra=window.open('','','width='+(finalwidth+6)+',height='+(finalheight+6)+',top='+TopPosition+',left='+LeftPosition+',status=no,menubar=no,resizable=yes,scrollbars=no');//open('popup.php?src='+myImage.src+'&h='+finalheight+'&w='+finalwidth+'','','width=700,height=550,status=no,menubar=no,resizable=no,scrollbars=no');
	with(finestra.document)
		{
		open();
		writeln("<html>");
		writeln("<head>");
		writeln("<title>Zoom Immagine - Comune di Secinaro </title>");
		writeln("</head>");
		writeln("<body style='margin:0px; background-color:#ffffff;'>");
		writeln("<div style='position:absolute; top:3px; left:3px;'>");
		writeln("<img id='imageplus' src='"+((objopen.src).replace("ICON_",""))+"' border='0'>");// width='"+finalwidth+"' height='"+finalheight+"' align='center' valign='middle'
		writeln("</div>");
		writeln("</body>");
		writeln("</html>");
		close();
		}
}


toptime=0;
bottomtime=0;
lefttime=0;
righttime=0;
timespeed=20;

scrollspeed=(document.all)?4:6;

//var charfin=( (location.search).indexOf('&')!=-1 ? (location.search).indexOf('&') : (location.search).length );
//sezpage=(location.search).substring(3,charfin);

var sezpage = (location.search).split("&");
if(!sezpage[1]){
 sezpage[1]="";
}
if(sezpage[0].substring(3)=="10" || ( sezpage[0].substring(3)=="2" && sezpage[1].substring(3)=="storia" ) || sezpage[0].substring(3)=="11" || sezpage[0].substring(3)=="12"){
 cross_scroll=document.getElementById ? document.getElementById("scrolllink") : document.all.scrolllink;
 menuheight=parseInt(eval(beg+"scrolllinkp"+mid).height);
 menuwidth=parseInt(eval(beg+"scrolllinkp"+mid).width);
 actualheight=parseInt(eval(beg+"scrolllink"+mid).height);
 actualwidth=parseInt(eval(beg+"scrolllink"+mid).width);
 
 cross_scroll2=document.getElementById ? document.getElementById("scrolllink") : document.all.scrolllink;
 menuheight2=parseInt(eval(beg+"scrolllinkp"+mid).height);
 menuwidth2=parseInt(eval(beg+"scrolllinkp"+mid).width);
 actualheight2=parseInt(eval(beg+"scrolllink"+mid).height);
 actualwidth2=parseInt(eval(beg+"scrolllink"+mid).width);
}


function movetop(objs){
 if (iedom&&parseInt(cross_scroll2.style.top)>(menuheight2-actualheight2)){
  cross_scroll2.style.top=(parseInt(cross_scroll2.style.top)-scrollspeed)+"px";
 }else if (document.layers&&ns_scroll2.top>(menuheight2-actualheight2)){
  ns_scroll2.top-=scrollspeed;
 }
 toptime=setTimeout("movetop()",timespeed);
}

function movebottom(objd){
 if (iedom&&parseInt(cross_scroll2.style.top)<0){
  cross_scroll2.style.top=(parseInt(cross_scroll2.style.top)+scrollspeed)+"px";
 }else if (document.layers&&ns_scroll2.top<0){
  ns_scroll2.top+=scrollspeed;
 }
 bottomtime=setTimeout("movebottom()",timespeed);
}

function moveleft(objs){
 if (iedom&&parseInt(cross_scroll.style.left)>(menuwidth-actualwidth)){
  cross_scroll.style.left=parseInt(cross_scroll.style.left)-scrollspeed+"px";
 }else if (document.layers&&ns_scroll.left>(menuwidth-actualwidth)){
  ns_scroll.left-=scrollspeed;
 }
 lefttime=setTimeout("moveleft()",timespeed);
}

function moveright(objd){
 if (iedom&&parseInt(cross_scroll.style.left)<0){
  cross_scroll.style.left=parseInt(cross_scroll.style.left)+scrollspeed+"px";
 }else if (document.layers&&ns_scroll.left<0){
  ns_scroll.left+=scrollspeed;
 }
 righttime=setTimeout("moveright()",timespeed);
}
/* Fine Gestione Motore Foto */
