﻿//Opt=1 apre; Opt=0 chiude
function ShowHideElement(ElementName,Opt)
{
    if (ElementName =="")
    {
        return;
    }
    
    if (Opt==0)
    {
        document.getElementById(ElementName).style.display='none';
        return;
    }
    
    switch (ElementName)
    {
        case 'seo':
            document.getElementById('seo').style.display='block';
            document.getElementById('cloud').style.display='none';
            break;
            
        case 'cloud':
            document.getElementById('seo').style.display='none';
            document.getElementById('cloud').style.display='block';
            break;
    }
}

function SetArea(nazione,regione){
    var query = parseQueryString(location.search);
    var ContractType = "VE";
    var BuildingType = "RES";
    
    if (query["ContractType"])
        ContractType = query["ContractType"];
        
    if (query["BuildingType"])
        BuildingType = query["BuildingType"];
        
    window.location.href="/AdvancedSearch.aspx?ContractType=" + ContractType +"&BuildingType=" + BuildingType + "&n="+ nazione + "&r=" + regione;
    return false;
}

function pulisci(val) 
{ 
	if (val.value=="Località / Cod. Annuncio") val.value='';
}

function caricadefault(val) 
{ 
	if (val.value=='') val.value="Località / Cod. Annuncio";
}

function Verifica()
{
    var city = document.getElementById("ctl00_MasterContentPlaceHolder_txtCity");
    if (city.value == "Località / Cod. Annuncio")
    {
        document.getElementById("CityError").className = document.getElementById("CityError").className.split(' ')[0];
        return false;
    }
    
    return true;
}

function trapEnter(e){
    e = e || window.event;
    var code = e.keyCode || e.which;                    
    if(code == 13){
        location.href = document.getElementById("ctl00_MasterContentPlaceHolder_btnFind").href;
        cancelEvent(e);
        return false;
     }else{
        return true;
     }
}