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();
}
function Regolamento()
{
	window.open("/html/regolamento.html", "WinRegolamento", "width=500,height=500,top=0,left=0,scrollbars=1,status=0,resizable=0");
	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 RicercaAvanzata(Section)
{
	window.open("/public/"+Section+"/form_ricerca_avanzata.php","WinFormRicercaAvanzata","width=500,height=540,top=0,left=0,scrollbars=1,status=0,resizable=0");
	return false;
}
function CercaChiTiCerca()
{
	window.open("about:blank","WinCercaChiTiCerca","width=550,height=600,top=0,left=0,scrollbars=1,status=0,resizable=1");
	return true;
}
function Profilo()
{
	window.open("about:blank","WinProfilo","width=550,height=600,top=0,left=0,scrollbars=1,status=0,resizable=1");
	return true;
}
function Verificati()
{
	window.open("about:blank","WinVerificati","width=640,height=300,scrollbars=1,status=0,resizable=1");
	return true;
}
function NoSingoli()
{
	window.open("about:blank","WinNoSingoli","width=520,height=400,top="+(screen.availHeight/2-200)+",left="+(screen.availWidth/2-260)+",scrollbars=1,status=0,resizable=1");
	return true;
}
function MostraRegioni()
{
	document.forms["FormMostraRegioni"].submit();
	return false;
}
function MostraCategorie()
{
	document.forms["FormMostraCategorie"].submit();
	return false;
}
function MostraGeneriLast()
{
	document.forms["FormMostraGeneriLast"].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 ModificaAnnuncio()
{
	window.open("/public/gestione_annuncio/modifica/form_login.php?U="+document.forms["FormModificaAnnuncio"].elements["U"].value,"WinGestioneAnnuncio","width=550,height=600,top=0,left=0,scrollbars=1,status=0,resizable=1");
	document.forms["FormModificaAnnuncio"].elements["U"].value="";
	return false;
}
function GestioneAnnuncio()
{
	window.open("about:blank","WinGestioneAnnuncio","width=550,height=600,top=0,left=0,scrollbars=1,status=0,resizable=1");
	return true;
}
function liam(P1, P2, P3, P4, P5, P6)
{
	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 GestioneTelefono()
{
	window.open("about:blank","WinGestioneTelefono","width=700,height=600,top=0,left=0,scrollbars=1,status=0,resizable=1");
	return true;
}
function RichiestaCodice()
{
	window.open("/public/annunci/richiesta_codici_form.php","PopupRichiestaCodice","width=500,height=150,top=0,left=0,scrollbars=1,status=0,resizable=1");
	return false;
}
function TelefonoAnnuncio()
{
	window.open("about:blank","WinTelefonoAnnuncio","width=500,height=600,top=0,left=0,scrollbars=1,status=0,resizable=1");
	return true;
}
function Ultimaora()
{
	window.open("/public/ultimaora/ultimaora_form.php","PopupUltimaora","width=540,height=600,top=0,left=0,scrollbars=1,status=0,resizable=1");
	return false;
}
function CercoOffro()
{
	window.open("/public/gestione_annuncio/cerco_offro/form_login.php","PopupCercoOffro","width=540,height=600,top=0,left=0,scrollbars=1,status=0,resizable=1");
	return false;
}
function Feste(P, C)
{
	if ( C=="-E-" )
		window.open("/public/feste/form_esterni.php?P="+P,"PopupFeste","width=540,height=600,top=0,left=0,scrollbars=1,status=0,resizable=1");
	else
		window.open("/public/feste/form.php?P="+P+"&C="+C,"PopupFeste","width=540,height=600,top=0,left=0,scrollbars=1,status=0,resizable=1");
	return false;
}
function RicercaCon(W)
{
	if ( document.forms["FormRicercaCon"] )
	{
		var Form=document.forms["FormRicercaCon"];
		if ( Form.elements["categoria"] )
		{
			P=Form.elements["categoria"].value;
		}
		R=Form.elements["regione"].value;
		switch(W)
		{
			case 1:
				Form.elements["with_phone"].value=1;
				Form.elements["with_vid"].value=0;
				break;
			case 2:
				Form.elements["with_phone"].value=0;
				Form.elements["with_vid"].value=1;
				break;
		}
		if ( typeof(P)!="undefined" || typeof(R)!="undefined" )
		{
			Form.submit();
		}
	}
	return false;
}
function AmiciOnLine()
{
	window.open("/public/amicionline/amicionline_form.php","AmiciOnLine","width=540,height=400,top=0,left=0,scrollbars=1,status=0,resizable=1");
	return false;
}
function PromoRegione(Popup, Width, Height)
{
	var popup_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");
}
function popup_regioni(P)
{
	document.forms["FormRegioni"].elements["P"].value=P;
	document.forms["FormRegioni"].submit();
}
function Contattati()
{
	var popup_win=window.open("/html/popup_contattati.html", "WinContattati", "width=400,height=350,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1");
	popup_win.moveTo(screen.width/2-200, screen.height/2-175);
}
function Contatti()
{
	var popup_win=window.open("/html/homepage/contatti.html", "WinContatti", "width=330,height=290,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1");
	popup_win.moveTo(screen.width/2-165, screen.height/2-145);
	return false;
}
function verrts(rts)
{
	rtsl=rts.length;
	for (i=rtsl; i>=0; i--)
		rts+=rts.charAt(i);
	return rts.substr(rtsl, rtsl);
}
function Complimatch()
{
	var Win=window.open("/public/guscio.php?P=54","WinComplimatch");
	Win.focus();
	return false;
}
function PolePositionImmediate(ID)
{
	var Win=window.open("/public/pole_position_immediate/index.php?ID="+ID,"WinPolePositionImmediate");
	Win.focus();
	return false;
}
function Mailinglist()
{
	var Form=document.forms["FormMailinglist"];
	RegExp=/^([a-zA-Z0-9&_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
	if ( !Form.elements["E"].value || !RegExp.test(Form.elements["E"].value) )
	{
		alert("È necessario inserire un indirizzo e-mail valido!");
		Form.elements["E"].focus();
	}
	else if ( Form.elements["act"][0].checked && !Form.elements["R"].selectedIndex )
	{
		alert("È necessario selezionare una regione!")
	}
	else
	{
		window.open("about:blank", "WinMailinglist", "width=380,height=300,top=240,left=330,toolbar=0,scrollbars=0,resizable=1,menubar=0,location=0");
		if ( Form.elements["act"] && 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();
	}
	return false;
}
function MLCleanUp()
{
	var Form=document.forms["FormMailinglist"];
	Form.elements["E"].value='la tua e-mail';
	if ( Form.elements["act"] )
		Form.elements["act"][0].checked=true;
	Form.elements["R"].selectedIndex=0;
}

