function width_vetrina() {
//Larghezza dei box della timeline
	var box = 895;
// differente con ie6
	var ievs = (/MSIE (\d+\.\d+);/.test(navigator.userAgent));
	if (ievs){
		var iev=new Number(RegExp.$1);
		if (iev==6){
			box = 884;
		}
	}
	document.write("<div id=\"timeline\" title=\"" + box + "-112\" style=\"width:" + box + "px;height:115px;\">");
}




function check_boxes(form, field, state) {
    for (i=0; i<form.length; i++){
		 if (form.elements[i].name == field)
		     form.elements[i].checked = state;
    }
}

function popupCartina(url){
  window.open(url,"popupcartina","location=no,width=600,height=400");
}

function popupfoto(imgURL){
  window.open(imgURL,"popupfoto","location=no,width=700,height=600");
}

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit)
	field.value = field.value.substring(0, maxlimit);
else
	 countfield.value = maxlimit - field.value.length;
}

function centerThumb(img, width, height){
	if (img.width)
			imgwidth = img.width;
	else
			imgwidth=width;
	if (img.height)
			imgheight=img.height;
	else
			imgheight=height;
	moveleft = Math.round((width - imgwidth) / 2);
	if (moveleft>0)
			img.style.marginLeft= moveleft + "px";
	movetop = Math.round((height - imgheight) / 2);
	if (movetop>0)
			img.style.marginTop= movetop + "px";
}
function show(tagId){
	document.getElementById(tagId).style.display='block';
}
function hide(tagId){
	document.getElementById(tagId).style.display='none';
}

function toggleVisible(tagId){
	visibilityStatus = document.getElementById(tagId).style.display;
	if (visibilityStatus=='none')
		document.getElementById(tagId).style.display='block';
	else
		document.getElementById(tagId).style.display='none';
}

function switchText(node, tagId, showText, hideText){
	visibilityStatus = document.getElementById(tagId).style.display;
	if (visibilityStatus=='none')
		node.innerHTML = showText;
	else
		node.innerHTML = hideText;
	
}

function addToFavorites(url, title) {
	var sURL = window.location;
	var sText = title;

	try
	{	if (window.sidebar)
			window.sidebar.addPanel(sText, sURL, "");
		else if (window.external)
			window.external.AddFavorite(sURL, sText);
		else if (window.opera && window.print)
		{	var oA = document.createElement('a');
			oA.setAttribute('rel','sidebar');
			oA.setAttribute('href', sURL);
			oA.setAttribute('title', sText);
			oA.click();
		}
	}
	catch (e)
	{	
	}
}

function setAsHome(url){
	if (window.external){ //IE
		document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage(url);
	}
		else alert("Spiacenti, il tuo browser non supporta questa funzione");
}

function clickCounter(counterID){
	counterImg = new Image;
	counterImg.src='/img2/blank.gif?counter=' + counterID + '&amp;ts=' + (new Date()).getTime();
}

function validateFormContatti(formObj){
	formObj.nome.value=formObj.nome.value.replace(/obbligatorio/, '');
	formObj.nome.value=formObj.nome.value.replace(/^\s+|\s+$/, '');
	formObj.telefono.value=formObj.telefono.value.replace(/obbligatorio tel. o email/, '');
	formObj.telefono.value=formObj.telefono.value.replace(/^\s+|\s+$/, '');
	formObj.email.value=formObj.email.value.replace(/obbligatorio tel. o email/, '');
	formObj.email.value=formObj.email.value.replace(/^\s+|\s+$/, '');
	errore ="";
	if (formObj.nome.value=="")
		errore = errore + " - Το όνομα είναι υποχρεωτικό\n";
	if (formObj.email.value=="" && formObj.telefono.value=="")
		errore = errore + " - Απαιτείται τηλεφωνικός αριθμός ή διεύθυνση email\n";
	if (formObj.email.value!="" && !/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(formObj.email.value))
		errore = errore + " - Είναι υποχρεωτικό να υποδείξετε μια ισχύουσα διεύθυνση email\n";
	if (formObj.telefono.value!="" && !/^\d+$/.test(formObj.telefono.value))
		errore = errore + " - Ο τηλεφωνικός αριθμός δεν ισχύει\n";

	if (errore!=""){
		errore = "Σφάλμα στην εισαγωγή στοιχείων:\n" + errore;
		alert(errore);
		return false;
	}else{
		if (formObj.commento.value=="")
			formObj.commento.value="Επιθυμώ να λάβω περισσότερες πληροφορίες σχετικά με το ακίνητο";
		return true;
	}
}

function validateFormContatti4Multilingua(formObj){
	formObj.nome.value=formObj.nome.value.replace(/obbligatorio/, '');
	formObj.nome.value=formObj.nome.value.replace(/^\s+|\s+$/, '');
	formObj.telefono.value=formObj.telefono.value.replace(/obbligatorio tel. o email/, '');
	formObj.telefono.value=formObj.telefono.value.replace(/^\s+|\s+$/, '');
	formObj.email.value=formObj.email.value.replace(/obbligatorio tel. o email/, '');
	formObj.email.value=formObj.email.value.replace(/^\s+|\s+$/, '');
	errore ="";
	if (formObj.nome.value=="")
		errore = errore + " - " + errore_nome + "\n";
	if (formObj.email.value=="" && formObj.telefono.value=="")
		errore = errore + " - " + errore_mail_o_tel + "\n";
	if (formObj.email.value!="" && !/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(formObj.email.value))
		errore = errore + " - " + errore_mail + "\n";
	if (formObj.telefono.value!="" && !/^\d+$/.test(formObj.telefono.value))
		errore = errore + " - " + errore_tel + "\n";

	if (errore!=""){
		errore = errori_riscontrati + ":\n" + errore;
		alert(errore);
		return false;
	}else{
		if (formObj.commento.value=="")
			formObj.commento.value=commento_default;
		return true;
	}
}

// Nuova gestione delle fotoplus
var objOmbra;
var objImage;
var objImageOver;
var objImg;

var position = "out";
var idFoto = 0;
var aperta = false;

function fotoplus(indice,imageid,op,outmin){

	//settiamo i valori per fa vedere la fotoplus
	if (op=='none' && position == "over" && idFoto != 0){
		if (!aperta || !outmin || (idFoto != indice))
		{
			position = "out";
			idFoto = 0;
			hideFotoPlus(indice,imageid);
		}
	}
	else{
		position = "over";
		idFoto = indice;
		setTimeout("showFotoPlus(" + indice + "," + imageid + ")", 1000);
	}
}

function showFotoPlus(indice,imageid){

	objOmbra = window.document.getElementById('popupOmbra_'+indice);
	objImage = window.document.getElementById('popupImage_'+indice);
	objImageOver = window.document.getElementById('popupImageOverlay_'+indice);
	objImg = window.document.getElementById('img_'+indice);

	if (position == "over" && idFoto == indice && !aperta){
		objImage.style.display='block';
		objOmbra.style.display='block';
		objImageOver.style.display='block';
		objImg.onload=initImage;
		objImg.src = "http://www.spiti24.gr/image/" + imageid + "/print.jpg";
		aperta = true;
	}
}

function hideFotoPlus(indice,imageid){

	objOmbra = window.document.getElementById('popupOmbra_'+indice);
	objImage = window.document.getElementById('popupImage_'+indice);
	objImageOver = window.document.getElementById('popupImageOverlay_'+indice);
	objImg = window.document.getElementById('img_'+indice);
	if (aperta){
		objImage.style.display='none';
		objOmbra.style.display='none';
		objImageOver.style.display='none';
		objImg.style.visibility='hidden';
		aperta = false;
	}
}

function initImage() {
	objImg.style.marginLeft = Math.round((600-objImg.width)/2) + "px";
	objImg.style.marginTop = Math.round((440-objImg.height)/2) + "px";
	setOpacity(0);
	objImg.style.visibility='visible';
	fadeIn(0);
}

function setOpacity(opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  // IE/Win
  objImg.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  objImg.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  objImg.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  objImg.style.opacity = opacity/100;
}

function fadeIn(opacity) {
    if (opacity <= 100) {
      setOpacity(opacity);
      opacity += 10;
      window.setTimeout("fadeIn("+opacity+")", 50);
    }
}

function dynWriteFooter(sId,sUrl,lang){
	var oFooter = document.getElementById(sId);
	if (!oFooter || !sUrl)
		return;

	var copyrightFooterYear = new Date;
	var copyright = "Gruppo Immobiliare.it S.r.l. &#169; "+copyrightFooterYear.getFullYear()+"&nbsp; | ";
	switch (lang) {
		case "gr":
			copyright += "Όλα τα δικαιώματα είναι κατοχυρωμένα. Χρησιμοποιώντας τον δικτυακό μας τόπο, αποδέχεστε τους <a href='"+sUrl+"oroi_xrhshs.php' class='link_blu underline'>όρους και τις προϋποθέσεις χρήσης</a> του. Με την επιφύλαξη παντός νομίμου δικαιώματός μας.";
			break;
		case "it":
			copyright += "L'accesso o l'utilizzo di questo sito è subordinato all'accettazione delle <a class='link_blu underline pointer' onclick=\"popupFooter('/mappa_condizioni_generali.php');return false;\">Condizioni Generali</a> e delle <a class='link_blu underline pointer' onclick=\"popupFooter('/mappa_regole_privacy.php');return false;\">Regole della Privacy</a>";
			break;
		case "en":
			copyright += "Access or use of this site is subject to acceptance the <a class='link_blu underline pointer' onclick=\"popupFooter('/mappa_condizioni_generali.php');return false;\">General conditions</a> and the <a class='link_blu underline pointer' onclick=\"popupFooter('/mappa_regole_privacy.php');return false;\">Privacy rules</a>";
			break;
		case "es":
			copyright += "El acceso o uso de este sitio está sujeto a la aceptación de <a class='link_blu underline pointer' onclick=\"popupFooter('/mappa_condizioni_generali.php');return false;\">Condiciones generales</a> y de <a class='link_blu underline pointer' onclick=\"popupFooter('/mappa_regole_privacy.php');return false;\">Reglas de privacidad</a>";
			break;
		case "de":
			copyright += "Die Benutzung dieser Webseite setzt das Einverständnis unserer <a class='link_blu underline pointer' onclick=\"popupFooter('/mappa_condizioni_generali.php');return false;\">Allgemeine Geschäftsbedingungen</a> und von <a class='link_blu underline pointer' onclick=\"popupFooter('/mappa_regole_privacy.php');return false;\">Datenschutzbestimmungen</a>";
			break;
		case undefined:
			copyright += "Όλα τα δικαιώματα είναι κατοχυρωμένα. Χρησιμοποιώντας τον δικτυακό μας τόπο, αποδέχεστε τους <a href='"+sUrl+"oroi_xrhshs.php' class='link_blu underline'>όρους και τις προϋποθέσεις χρήσης</a> του. Με την επιφύλαξη παντός νομίμου δικαιώματός μας.";
			break;
		default:
			copyright += "Access or use of this site is subject to acceptance the <a class='link_blu underline pointer' onclick=\"popupFooter('/mappa_condizioni_generali.php');return false;\">General conditions</a> and the <a class='link_blu underline pointer' onclick=\"popupFooter('/mappa_regole_privacy.php');return false;\">Privacy rules</a>";
			break;
	}
	oFooter.innerHTML = copyright;
}

var box = null;
popupFooter = function (url) {
	if (!box)
		box = new boxOverlay("box_");
	var obj = new getMEAjaxObj();
	obj.Request('POST',url,context);
}

context = function(data){
	if (data.responseText!=null && data.responseText!="")
		box.setContent(data.responseText);
	else
		box.setContent("Errore");
	box.show();

	if(document.getElementById("close_box_"))
		document.getElementById("close_box_").innerHTML=Chiudi+" "+"<img src='MeOverlayBox/images/lightbox/chiudi.png'/>";
	if(document.getElementById("close_box_content"))
		document.getElementById("close_box_content").style.padding="0px";
}
// inserimento_annuncio.php (dati_immobile.tpl)
// Selezionando il campo "Διαθέσιμη κατόπιν επικοινωνίας" del menù a tendina "fasciaprezzo" si sostituisce il contenuto
// del campo "prezzo" con 0 e lo si rende immodificabile
function elimina_prezzo() {
	var fp = document.getElementById('fasciaprezzo');
	timì = document.getElementById('prezzo');
	timì.disabled = false;
	for(var k=0; k<fp.options.length; k++) {
		if ( fp.options[k].selected &&
		     fp.options[k].text=="Η τιμή είναι διαθέσιμη κατόπιν επικοινωνίας" ) {
			timì.value = "";
			timì.disabled = true;
		}
	}	
}