var ImgPath="/html/images/";
function SwapImg(Name, File)
{	
	document.images[Name].src=ImgPath+File;
}
function GoHome()
{
	if ( top && top.opener && !top.opener.closed )
	{
		top.opener.focus();
		top.close();
	}
	else
		top.location.href="/";
	return false;
}
function GoLast()
{
	if ( top )
		top.location.href="index.php";
	return false;
}
function GotoPage(Start, FormNum)
{
	document.forms["FormPaging"+FormNum].elements["S"].value=Start;
	document.forms["FormPaging"+FormNum].submit();
	return false;
}
function Iscriviti()
{
	var Win=window.open("about:blank","WinLogIn","width=900,height=650,top=0,left=0,scrollbars=1,status=0,resizable=1,menubar=1");
	Win.focus();
	return true;
}
function HPLogIn()
{
	var Win=window.open("/public/gestione/index.php?WF=1","WinLogIn","width=900,height=650,top=0,left=0,scrollbars=1,status=0,resizable=1,menubar=1");
	Win.focus();
	return false;
}
function LogIn()
{
	var Win=window.open("about:blank","WinLogIn","width=900,height=650,top=0,left=0,scrollbars=1,status=0,resizable=1,menubar=1");
	Win.focus();
	return true;
}
function LogInTo(URL)
{
	var Win=window.open(URL,"WinLogIn","width=900,height=650,top=0,left=0,scrollbars=1,status=0,resizable=1,menubar=1");
	Win.focus();
	return true;
}
function ChatIn()
{
	var Win=window.open("about:blank","WinChatIn","width=900,height=650,top=0,left=0,scrollbars=1,status=0,resizable=1,menubar=1");
	Win.focus();
	return true;
}
function ChatInTo(URL)
{
	var Win=window.open(URL,"WinChatIn","width=900,height=650,top=0,left=0,scrollbars=1,status=0,resizable=1,menubar=1");
	Win.focus();
	if ( typeof(divChatStatus=dojo.byId("DivChatStatus"))=="object" )
	{
		dojo.attr(divChatStatus, "style", {visibility:"hidden"});
	}
	if ( typeof(divChatWaiting=dojo.byId("DivChatWaiting"))=="object" )
	{
		dojo.attr(divChatWaiting, "style", {visibility:"hidden"});
	}
	return true;
}
function Chat()
{
	var Win=window.open("/public/web_chat/chat.php","WinChatIn","width=900,height=650,top=0,left=0,scrollbars=1,status=0,resizable=1,menubar=1");
	Win.focus();
	return false;
}
function Sorpresa()
{
	var Win=window.open("about:blank","WinSorpresa","width=900,height=650,top=0,left=0,scrollbars=1,status=0,resizable=1");
	Win.focus();
	return true;
}
function Contatto()
{
	var Win=window.open("about:blank","WinContatto","width=900,height=650,top=0,left=0,scrollbars=1,status=0,resizable=1");
	Win.focus();
	return true;
}
function Regolamento()
{
	var Win=window.open("/html/condizioni_di_utilizzo.html", "WinRegolamento", "width=800,height=600,top=0,left=0,scrollbars=1,status=0,resizable=1");
	Win.focus();
	return false;
}
function PerContattarci()
{
	var Win=window.open("/html/contatti.html", "WinPerContattarci", "width=800,height=620,top=0,left=0,scrollbars=1,status=0,resizable=1");
	Win.focus();
	return false;
}
function RicercaVeloce()
{
	if ( document.forms["FormRicerca"].elements["P"].value!="" )
	{
		document.forms["FormRicercaSend"].action="/public/annunci/ricerca_veloce.php";
		document.forms["FormRicercaSend"].elements["P"].value=document.forms["FormRicerca"].elements["P"].value;
		document.forms["FormRicercaSend"].submit();
	}
	return false;
}
function Profilo()
{
	var Win=window.open("about:blank","WinProfilo","width=550,height=600,top=0,left=0,scrollbars=1,status=0,resizable=1");
	Win.focus();
	return true;
}
function MostraRegioni()
{
	document.forms["FormMostraRegioni"].submit();
	return false;
}
function MostraCategorie()
{
	document.forms["FormMostraCategorie"].submit();
	return false;
}
function CategorieRegioni()
{
	var P=document.forms["FormCategorieRegioni"].elements["P"].selectedIndex;
	var R=document.forms["FormCategorieRegioni"].elements["R"].selectedIndex;
	if ( !P && !R )
	{
		alert("E' necessario specificare la categoria,\noppure la regione, oppure entrambe");
		return false;
	}
	if ( P )
		document.forms["FormCategorieRegioni"].action="/public/annunci/index.php?GO=annunci_categoria.php?P="+document.forms["FormCategorieRegioni"].elements["P"].options[P].value+(R?"&R="+document.forms["FormCategorieRegioni"].elements["R"].options[R].value:"");
	else
		document.forms["FormCategorieRegioni"].action="/public/annunci/annunci_regione.php?P="+document.forms["FormCategorieRegioni"].elements["R"].options[R].value;
	document.forms["FormCategorieRegioni"].submit();
	return false;
}
function liam(P1, P2, P3, P4, P5, P6)
{
	var P1=verrts(P1).replace(/>#</, "&#64;").replace(/ /g, ".");
	if ( P6!="-knilon-" )
		document.write("<a href=\"&#109;&#97;&#105;&#108;&#116;&#111;&#58;"+P1+((P2||P3)?"&#63;":"")+(P2?"&#115;&#117;&#98;&#106;&#101;&#99;&#116;&#61;"+P2:"")+((P2&&P3)?"&#38;":"")+(P3?"&#98;&#111;&#100;&#121;&#61;"+P3:"")+"\""+(P4?" class=\""+P4+"\"":"")+(P5?" style=\""+P5+"\"":"")+">"+(P6?P6:P1)+"</a>");
	else
		document.write(P1);
	return;
}
function PromoRegione(Popup, Width, Height)
{
	var Win=window.open(Popup, "WinPromoRegione", "width="+Width+",height="+Height+",top="+(screen.height-Height)/2+",left="+(screen.width-Width)/2+",scrollbars=auto,status=0,resizable=1");
	Win.focus();
}
function popup_regioni(P)
{
	document.forms["FormRegioni"].elements["P"].value=P;
	document.forms["FormRegioni"].submit();
}
function verrts(rts)
{
	var rtsl=rts.length;
	for (i=rtsl; i>=0; i--)
		rts+=rts.charAt(i);
	return rts.substr(rtsl, rtsl);
}
function Mailinglist()
{
	var Form=document.forms["FormMailinglist"];
	RegExp=/^([a-zA-Z0-9&_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	if ( !RegExp.test(Form.elements["E"].value) )
	{
		alert("Indirizzo e-mail non valido!");
		Form.elements["E"].focus();
	}
	else if ( Form.elements["act"][0].checked && !Form.elements["R"].value )
	{
		alert("È necessario specificare la regione");
	}
	else
	{
		window.open("about:blank", "WinMailinglist", "width=420,height=300,top=240,left=330,toolbar=0,scrollbars=0,resizable=0,menubar=0,location=0");
		if ( Form.elements["act"][1].checked )
			Form.action="/public/mailinglist/mailinglist_eliminazione.php";
		else
			Form.action="/public/mailinglist/mailinglist_iscrizione.php";
		Form.target="WinMailinglist";
 		Form.submit();
		Form.elements["E"].value='il tuo indirizzo e-mail';
		if ( Form.elements["act"] )
			Form.elements["act"][0].checked=true;
	}
	return false;
}

