function init(){
    document.frmASearch.destination.focus();
    if(document.frmASearch.searchby[1].checked)
        disableMileSDD();
}//end init

function disableMileSDD() {
    document.frmASearch.miles.disabled=true;
}//end disableMileSDD

function enableMileSDD(){
    document.frmASearch.miles.disabled=false;
}//end enableMileSDD

function movepic(img_name, img_src) {
    document[img_name].src=img_src;
}//end movepic


var calWin = null;
var calendarField;
function popCalendar(field, dt, choice ){
    calendarField = field;
    window.open( pathinfo + '/property/popcalendar.php?dialog=1&callback=setCalendar&date='+dt+"&choice="+choice,'calwin', 'top=250,left=250,width=200,height=155,scollbars=false' );
}//end popCalendar

function setCalendar(idate, fdate) {
    dt=idate.substr(4,2)+"/"+idate.substr(6,2)+"/"+idate.substr(0,4);
    fld_fdate = eval( 'document.frmASearch.' + calendarField );
    fld_fdate.value = dt;
    fld_fdate.focus();
}//end setCalendar

function submitform(){
    var dtfrom=document.frmASearch.fdate;
    var dtTo=document.frmASearch.tdate;
    var flag=true;

    if (dtTo.value != "") {
        if ((isDate(dtTo.value, 'To') == false) && (flag == true)) {
            dtTo.focus();
            flag = false;
        }
    }

    if (dtfrom.value != ""){
        if ((isDate(dtfrom.value, 'To') == false) && (flag == true)) {
            dtfrom.focus();
            flag= false;
        }
    }

    if ((dtTo.value != "") || (dtfrom.value != "")) {
        if ((compareDates(dtTo.value, dtfrom.value) == -1) && (flag == true)) {
            alert("The Arrival date must be before the Departure Date.  Please correct the dates to continue");
            dtfrom.focus();
            flag= false;
        }
    }

    if ((dtTo.value != "") || (dtfrom.value != "")) {
        if ((compareDates(dtfrom.value, document.frmASearch.curdt.value) == -1) && (flag == true)) {
            alert("The Arrival date is not to be a date in the past. Please enter today's date or a future date in the arrival date field.");
            dtTo.focus();
            flag= false;
        }
    }


    if ((dtTo.value != "") || (dtfrom.value != "")) {
        if ((compareDates(dtTo.value, document.frmASearch.curdt.value) == -1) && (flag == true)) {
            alert("The Arrival date must be before the Departure Date.  Please correct the dates to continue");
            dtTo.focus();
            flag= false;
        }
    }

    if(flag==true) {
        document.frmASearch.action=pathinfo + "/search/basicsearch.php";
        document.frmASearch.submit();
    }
}//end submitform

function loadXMLDoc(){
    //code for Mozilla, etc.
    stateid = document.frmASearch.state[document.frmASearch.state.selectedIndex].value;

    if (window.XMLHttpRequest) {
        xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange=state_Change;
        xmlhttp.open("GET",'getcitydetails.php?stateid=' +stateid,true)
        xmlhttp.send(null);
    }
    else if (window.ActiveXObject) { //code for IE
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        if (xmlhttp) {
            xmlhttp.onreadystatechange=state_Change;
            xmlhttp.open("GET",'getcitydetails.php?stateid=' +stateid,true)
            xmlhttp.send();
        }
    }
}//end loadXMLDoc

function state_Change(){
    var obj_form = document.frmASearch;

    //if xmlhttp shows "loaded"
    if (xmlhttp.readyState == 4) {
        // if "OK"
        if (xmlhttp.status == 200) {
            result = xmlhttp.responseText;

            result_arr = result.split(":");
            city_id = result_arr[0];
            cityname = result_arr[1];
            city_id = city_id.split("|");
            cityname = cityname.split("|");

            for(var i=obj_form.destination.options.length; i>0 ; i--)
                obj_form.destination.options[i] = null;

            obj_form.destination.options[0] = new Option("Select a City","");

            if(cityname[0]!="")
                for(var i=0; i<cityname.length; i++)
                    obj_form.destination.options[i] = new Option(cityname[i],city_id[i]);
        }
        else
            alert("Problem retrieving data")
    }
}//end state_change


function popup(img) {
 window.open( 'property/popuppics.php?img='+img, '','top=250,left=250,width=520, height=430,scrollbar=yes');
}//end popup

function advsearch(){
    document.frmASearch.action=pathinfo + "/search/findproperty.php";
    document.frmASearch.submit();
}//end advsearch