numero=1;
imghead=1;

function newsletter() {
    var nnome=document.getElementById("nnome");
	nnome.value="Nome";
    nnome.onclick=function(){if(nnome.value=="Nome") nnome.value=""}
	nnome.onblur=function(){if(nnome.value=="") nnome.value="Nome"}

    var ncognome=document.getElementById("ncognome");
	ncognome.value="Cognome";
    ncognome.onclick=function(){if(ncognome.value=="Cognome") ncognome.value=""}
	ncognome.onblur=function(){if(ncognome.value=="") ncognome.value="Cognome"}
	
    var nemail=document.getElementById("nemail");
	nemail.value="Email";
    nemail.onclick=function(){if(nemail.value=="Email") nemail.value=""}
	nemail.onblur=function(){if(nemail.value=="") nemail.value="Email"}	
}

function changeheader() { 
	if (imghead == 1) {
		setTimeout("document.getElementById('imghead').src = 'imgs_grafiche/header-donna.gif'; changeheader();",4000); 
		imghead = 0;
	} else {
		setTimeout("document.getElementById('imghead').src = 'imgs_grafiche/header-uomo.gif'; changeheader();",4000); 
		imghead = 1;
	}
}

function indietro1(codice){
	numero=numero-1
	if (numero<1) {
		numero=massimo
	}
	document.getElementById('img_rot').src="imgs_img/"+codice+"_"+(numero-0)+".jpg"
}

function avanti1(codice,massimo){
	numero=numero+1
	if (numero>massimo) {
		numero=1
	}
	document.getElementById('img_rot').src="imgs_img/"+codice+"_"+(numero-0)+".jpg"
}

function avviso(url,mess) {
	if (confirm(mess)) {
		location = url;
	}
}

function intercetta() { 
    for (var i=0; i<document.links.length; i++)
        if (document.links[i].className=="blank") {
            document.links[i].target="_blank";
        } 
}
window.onload = intercetta;

function popup1(theURL,winName,features){
	window.open(theURL,winName,features);
}

function popup(theURL,winName,features){  
	// Set up Page Colors & Table  
	var testo
	var DQUOTE = '\"'
	var s1 = "<TITLE>"+winName+"</TITLE><link href='style/default.css' rel='stylesheet' type='text/css'>" +    
	"<BODY BGCOLOR='ffffff' topmargin='0' leftmargin='0'>"+
	"<TABLE width='100%' height='100%' align='center' BGCOLOR='FFFFFF' BORDER=0 cellspacing=0 cellpadding=0>" +        
	"<TR><TR><TD height=5 WIDTH=100%></TD></tr><TD VALIGN=TOP ALIGN=center>"    
	var s2 = "<img src='"+theURL+"' alt='popup'>"   
	var s3 = "</TD></TR><TR><TD height=5></TD></tr>"+    
	"<tr><TR><TD height=5></TD></tr><td valign=middle align=center>"+    
	"<a href='#' class='link2' "+                   
	"onClick='self.close()'>chiudi<br></a></TD></TR></TABLE></BODY>"   
	popupn = window.open("",winName,features)  
	popupn.document.write(s1+s2+s3)  
	popupn.document.close()
}


// this function generates the actual toolbar buttons with localized text
// we use it to avoid creating the toolbar where javascript is not enabled
function addButton(imageFile, speedTip, tagOpen, tagClose, sampleText, nomeTag) {

	// Don't generate buttons for browsers which don't fully
	// support it.
	if(!document.selection && !is_gecko) {
		return false;
	}
	imageFile=escapeQuotesHTML(imageFile);
	speedTip=escapeQuotesHTML(speedTip);
	tagOpen=escapeQuotes(tagOpen);
	tagClose=escapeQuotes(tagClose);
	sampleText=escapeQuotes(sampleText);
	var mouseOver="";
	document.write("<a href=\"javascript:insertTags");
	document.write("('"+tagOpen+"','"+tagClose+"','"+sampleText+"','"+nomeTag+"');\">");
	document.write("<img width=\"23\" height=\"22\" src=\""+imageFile+"\" border=\"0\" alt=\""+speedTip+"\" title=\""+speedTip+"\""+mouseOver+">");
	document.write("</a>");
	return;
}

function escapeQuotes(text) {
	var re=new RegExp("'","g");
	text=text.replace(re,"\\'");
	re=new RegExp("\\n","g");
	text=text.replace(re,"\\n");
	return escapeQuotesHTML(text);
}

function escapeQuotesHTML(text) {
	var re=new RegExp('&',"g");
	text=text.replace(re,"&amp;");
	var re=new RegExp('"',"g");
	text=text.replace(re,"&quot;");
	var re=new RegExp('<',"g");
	text=text.replace(re,"&lt;");
	var re=new RegExp('>',"g");
	text=text.replace(re,"&gt;");
	return text;
}

// apply tagOpen/tagClose to selection in textarea,
// use sampleText instead of selection if there is none
// copied and adapted from phpBB
function insertTags(tagOpen, tagClose, sampleText, nomeTag) {
	var txtarea = eval(nomeTag);
	// IE
	if(document.selection) {
		var theSelection = document.selection.createRange().text;
		if(!theSelection) { theSelection=sampleText;}
		txtarea.focus();
		if(theSelection.charAt(theSelection.length - 1) == " "){// exclude ending space char, if any
			theSelection = theSelection.substring(0, theSelection.length - 1);
			document.selection.createRange().text = tagOpen + theSelection + tagClose + " ";
		} else {
			document.selection.createRange().text = tagOpen + theSelection + tagClose;
		}

	// Mozilla
	} else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
		var replaced = false;
 		var startPos = txtarea.selectionStart;
		var endPos = txtarea.selectionEnd;
		if(endPos-startPos) replaced=true;
		var scrollTop=txtarea.scrollTop;
		var myText = (txtarea.value).substring(startPos, endPos);
		if(!myText) { myText=sampleText;}
		if(myText.charAt(myText.length - 1) == " "){ // exclude ending space char, if any
			subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " ";
		} else {
			subst = tagOpen + myText + tagClose;
		}
		txtarea.value = txtarea.value.substring(0, startPos) + subst +
		  txtarea.value.substring(endPos, txtarea.value.length);
		txtarea.focus();
		//set new selection
		if(replaced){
			var cPos=startPos+(tagOpen.length+myText.length+tagClose.length);
			txtarea.selectionStart=cPos;
			txtarea.selectionEnd=cPos;
		}else{
			txtarea.selectionStart=startPos+tagOpen.length;   
			txtarea.selectionEnd=startPos+tagOpen.length+myText.length;
		}	
		txtarea.scrollTop=scrollTop;

	// All other browsers get no toolbar.
	// There was previously support for a crippled "help"
	// bar, but that caused more problems than it solved.
	}
	// reposition cursor if possible
	if (txtarea.createTextRange) txtarea.caretPos = document.selection.createRange().duplicate();
}

function AggiungiAPreferiti() {
	if ((navigator.appName.indexOf("Microsoft",0)>=0) && (parseInt(navigator.appVersion)>=4)) {
		window.external.AddFavorite("http://www.aziendeservizi.it","Aziende servizi" );
	} else {
		alert("Premi CTRL + D per aggiungere AziendeServizi ai Preferiti.")
	}
}

function homepage() { 
	if(document.all) {
		document.body.style.behavior='url(#default#homepage)'
		document.body.setHomePage('http://www.aziendeservizi.it')
	}
} 