function goTo(vs_urlParam)
{
var url = '';
	switch(vs_urlParam)
	{
		case 'imb':
			url = "http://www.immobiliare.it";
			break;
		case 'eur':
			url = "http://www.eurekasa.it";
			break;
		case 'nuo':
			url = "http://www.nuovecostruzioni.it";
			break;
		case 'chi':
			url = "http://www.immobiliare.it/casa/informazioni/immobiliare.php";
			break;
		case 'lav':
			url = "http://www.immobiliare.it/casa/informazioni/lavora-con-immobiliare.php";
			break;
		case 'sta':
			url = "http://www.immobiliare.it/casa/informazioni/ufficio-stampa.php";
			break;
		case 'con':
			url = "http://www.immobiliare.it/casa/informazioni/contatti.php";
			break;
		case 'pro':
			url = "http://www.immobiliare.it/annunci_nuove_costruzioni.php";
			break;
		default:
			url = "http://www.immobiliare.it";
			break;
	}
	window.open(url, '', 'width=' + (screen.width - 100) + ',height=' + (screen.height - 100) + ',top=0,left=0,scrollbars=yes,resizable=yes,location=yes');
}

function showDynFooter(sId)
{
	if (!vslGetHTMLElement(sId))
		return false;

	var sFooterContent = '';
	var oFooterNode = vslGetHTMLElement(sId);
	var oCurrentTime = new Date();

	sFooterContent = '\
		<div class="normal">\
			<hr class="footerHr" />\
			<div class="floatLeft footerLargeInfo">\
			 	<strong class="footerLinks">NuoveCostruzioni.it</strong>\
					<br />\
					&#169; ' + oCurrentTime.getFullYear() + ' tutti i diritti riservati.\
					<br />P.IVA 08435221000 <a href="#" rel="nofollow" onclick="window.open(\'http://www.immobiliare.it/dati_societari.html\',null,\'top=250,left=100,height=280,width=450,status=no, directories=no, toolbar=no, location=no, menubar=no,scrollbars=no, resizable=no\'); return false;">Dati Societari</a>\
			</div>\
			<div class="floatLeft" style="width: 200px; margin-left: 20px; margin-right: 60px;">\
					<strong class="footerLinks">Termini di utilizzo</strong><br />\
					Accedendo al servizio, l\'utente dichiara di avere visionato e di accettare le <a href="#" rel="nofollow" onclick="Lightbox.init(); Lightbox.showBoxByIFrame(\'/over/privacy.php\', 400,300,\'auto\'); return false;">regole sulla privacy</a>.\
			</div>\
			<div class="floatLeft footerLinks" style="width: 140px;">\
					<strong>Il Gruppo</strong><br />\
					<a href="#" rel="nofollow" onclick="goTo(\'chi\'); return false;">Chi siamo</a><br />\
					<a href="#" rel="nofollow" onclick="goTo(\'lav\'); return false;">Lavora con noi</a><br />\
					<a href="#" rel="nofollow" onclick="goTo(\'sta\'); return false;">Ufficio stampa</a><br />\
					<a href="#" rel="nofollow" onclick="goTo(\'con\'); return false;">Contatti</a>\
			</div>\
			<div class="floatLeft footerLinks" style="width: 190px; margin-left: 40px;">\
					<strong>Network Immobiliare.it</strong><br />\
					<a href="#" rel="nofollow" onclick="goTo(\'imb\'); return false;">www.immobiliare.it</a><br />\
					<a href="#" rel="nofollow" onclick="goTo(\'eur\'); return false;">www.eurekasa.it</a><br />\
					<a href="#" rel="nofollow" onclick="goTo(\'nuo\'); return false;">www.nuovecostruzioni.it</a>\
			</div>\
			<div class="clear"></div>\
			<div class="small gray marginTopSmall">\
				Gli annunci immobiliari presenti su NuoveCostruzioni.it vengono pubblicati da agenzie immobiliari e costruttori. La pubblicazione degli annunci non comporta l\'approvazione o l\'avallo da parte di NuoveCostruzioni.it né implica alcuna forma di garanzia da parte di quest\'ultima. NuoveCostruzioni.it quindi non è responsabile della veridicità, della correttezza, della completezza, della normativa in materia di privacy e/o di alcun altro aspetto dei suddetti annunci.\
			</div>\
		</div>';

	oFooterNode.innerHTML = sFooterContent;
}

function checkEmailForm(bAjaxSubmit)
{
	var sPostfix = "";
	try
	{
		var bError = false;
		var sError = "Non tutti i campi obbligatori sono stati compilati correttamente: ";
		var oNome = document.getElementById("mail_form_name");
		if (!oNome) return(false);
		var oEmail = document.getElementById("mail_form_mail");
		if (!oEmail) return(false);
		var oTelefono = document.getElementById("mail_form_phone");
		if (!oTelefono) return(false);
		var oPrivacy = document.getElementById("mail_form_privacy");
		if (!oPrivacy) return (false);

		if (oNome.value == "")
			{
				bError = true;
				sError += "\n - Il campo 'Nome' deve essere obbligatoriamente compilato";
			}
		if (oEmail.value == "" && oTelefono.value == "")
			{
				bError = true;
				sError += "\n - Almeno uno tra i campi 'Email' e 'Telefono' deve essere obbligatoriamente compilato";
			}
		if (oPrivacy.checked != true)
		{
			bError = true;
			sError += "\n - Si deve acconsentire al trattamento dei dati personali";
		}

		if (bError)
		{
			alert(sError);
			return false;
		}
		else
		{
			if(bAjaxSubmit) {
				document.getElementById('formBackurl').value = 'ajaxReply';
				sAction = "/form/sendmail.php";
				new Ajax.Request(sAction, {
					method:'post',
					parameters: $('emailFormTemplate').serialize(true),
					onSuccess: function(transport) {
						var response = transport.responseXML;
						var ajaxReply = response.getElementsByTagName("ajaxReply")[0];
						if((ajaxReply.getAttribute("success")) == true)
						{
							alert("Email inviata con successo.\nGrazie per aver usato i nostri servizi");
						}
						else
						{
							if(ajaxReply.getElementsByTagName("string").length > 0)
							{
								sError +="\n\n - "+ajaxReply.getElementsByTagName("string")[0].childNodes[0].nodeValue;
							}
							else if(ajaxReply.getElementsByTagName("array").length > 0)
							{
								sError += "\n";
								var aRowErrors = ajaxReply.getElementsByTagName("row");
								for(var i = 0; i < aRowErrors.length; i++)
								{
									var sKey = aRowErrors[i].getAttribute("key");
									var sRowValue = aRowErrors[i].childNodes[0].nodeValue;
									if(sRowValue != null)
										sError += "\n - " + sRowValue;
								}
							}
							else
							{
								sError += "\n - Errore generico";
							}
							alert(sError);
						}
					},
					onFailure: function() {
						alert('Errore durante l\'invio dell\'email.');
					}
				});
			} else {
				return true;
			}
		}
	}
	catch(e)
	{
		alert('Errore durante l\'invio dell\'email.');
		return false;
	}
	return false;
}

function showAutoPromoBox(sId, sType)
{
	if (!vslGetHTMLElement(sId))
		return false;

	var sAutoPromoBoxContent = '';
	var oAutoPromoBoxNode = vslGetHTMLElement(sId);

	switch(sType)
	{
		case 'home':
			var sAutoPromoBoxContent = '\
				<div class="center" style="margin-top: 25px;">\
					<a class="black autoPromoBox strong" rel="nofollow" style="display: block;" onclick="goTo(\'pro\');">\
						<span>Sei un costruttore o un&#8217;agenzia immobiliare? Pubblica i tuoi annunci<br />\
						gratis 2 mesi, con <img src="/vimages/default/IT/immobiliare_pro.png" width="120" height="18" alt=\'ImmobiliarePro\' alt=""/> Scopri l&#8217;offerta!</span>\
					</a>\
				</div>';
		break;
		case 'list':
		default:
			var sAutoPromoBoxContent = '\
				<div class="center marginTop">\
					<a class="black autoPromoBox strong" rel="nofollow" style="display: block;" onclick="goTo(\'pro\');">\
						<span>Pubblica i tuoi annunci con <img src="/vimages/default/IT/immobiliare_pro.png" width="120" height="18" alt=\'ImmobiliarePro\' alt=""/>&nbsp;<img src="/vimages/default/IT/go.png" width="43" height="17" alt=\'Go\' alt=""/></span>\
					</a>\
				</div>';
		break;
	}

	oAutoPromoBoxNode.innerHTML = sAutoPromoBoxContent;
}
