﻿RentFromPrices = new Array();
RentFromPrices[1] = new Array("--請選擇--", "$0", "$2,500", "$5,000", "$7,500", "$10,000", "$15,000", "$20,000", "$25,000", "$30,000", "$50,000", "$70,000", "$100,000");
RentFromPrices[2] = new Array("N", 0, 2500, 5000, 7500, 10000, 15000, 20000, 25000, 30000, 50000, 70000, 100000);
RentToPrices = new Array();
RentToPrices[1] = new Array("--請選擇--", "$2,500", "$5,000", "$7,500", "$10,000", "$15,000", "$20,000", "$25,000", "$30,000", "$50,000", "$70,000", "$100,000", "--任何價錢--");
RentToPrices[2] = new Array("N", 2500, 5000, 7500, 10000, 15000, 20000, 25000, 30000, 50000, 70000, 100000, 0);
BuyFromPrices = new Array();
BuyFromPrices[1] = new Array("--請選擇--", "$0", "$1,000,000", "$2,000,000", "$3,000,000", "$4,000,000", "$5,000,000", "$6,000,000", "$7,000,000", "$8,000,000", "$9,000,000");
BuyFromPrices[2] = new Array("N", 0, 1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000);
BuyToPrices = new Array();
BuyToPrices[1] = new Array("--請選擇--", "$1,000,000", "$2,000,000", "$3,000,000", "$4,000,000", "$5,000,000", "$6,000,000", "$7,000,000", "$8,000,000", "$9,000,000", "--任何價錢--");
BuyToPrices[2] = new Array("N", 1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 0);

function fillPrices() {
    //alert (""OK!!") ;
    if (document.frmBasic.rentsell[0].checked == true) {
        document.frmBasic.pricefrom.length = 0;
        document.frmBasic.pricefrom.options[0] = new Option(BuyFromPrices[1][0], 0, 1, 1);
        for (count = 1; count < BuyFromPrices[1].length; count++)
            document.frmBasic.pricefrom.options[count] = new Option(BuyFromPrices[1][count], BuyFromPrices[2][count]);
        document.frmBasic.priceto.length = 0;
        document.frmBasic.priceto.options[0] = new Option(BuyToPrices[1][0], 0, 1, 1);
        for (count = 1; count < BuyToPrices[1].length; count++)
            document.frmBasic.priceto.options[count] = new Option(BuyToPrices[1][count], BuyToPrices[2][count]);
    }
    else {
        document.frmBasic.pricefrom.length = 0;
        document.frmBasic.pricefrom.options[0] = new Option(RentFromPrices[1][0], 0, 1, 1);
        for (count = 1; count < RentFromPrices[1].length; count++)
            document.frmBasic.pricefrom.options[count] = new Option(RentFromPrices[1][count], RentFromPrices[2][count]);
        document.frmBasic.priceto.length = 0;
        document.frmBasic.priceto.options[0] = new Option(RentToPrices[1][0], 0, 1, 1);
        for (count = 1; count < RentToPrices[1].length; count++)
            document.frmBasic.priceto.options[count] = new Option(RentToPrices[1][count], RentToPrices[2][count]);
    }
}



var district_region;
var agent_district;

// 



function check_selected_item() {

    //alert(me.sizefrom.selectedIndex);
    //alert(me.sizeto.selectedIndex);

    /*
    if ((document.frmBasic.pricefrom[document.frmBasic.pricefrom.selectedIndex].value =="N") ||(document.frmBasic.priceto[document.frmBasic.priceto.selectedIndex].value =="N") ) {	
    alert("請選擇其中一個價錢");
    return false;
    }
    else
    if ((document.frmBasic.sizefrom[document.frmBasic.sizefrom.selectedIndex].value =="N")||(document.frmBasic.sizeto[document.frmBasic.sizeto.selectedIndex].value =="N") ) {	
    alert("請選擇其中一個面積");
    return false;
    }
    else
    return true;
    */
    if ((document.frmBasic.pricefrom.selectedIndex == 0) && (document.frmBasic.priceto.selectedIndex != 0)) {

        alert("請選擇最低價錢");
        return false;
    }
    else {
        if ((document.frmBasic.pricefrom.selectedIndex != 0) && (document.frmBasic.priceto.selectedIndex == 0)) {
            alert("請選擇最高價錢");
            return false;
        }
        else {
            if ((document.frmBasic.sizefrom.selectedIndex == 0) && (document.frmBasic.sizeto.selectedIndex != 0)) {
                alert("請選擇最低面積");
                return false;
            }
            else {
                if ((document.frmBasic.sizefrom.selectedIndex != 0) && (document.frmBasic.sizeto.selectedIndex == 0)) {
                    alert("請選擇最高面積");
                    return false;
                }
                else {

                    return true;
                }
            }
        }
    }
}


function check_basic_search(me) {

    //alert(check_selected_item());
    if (check_selected_item()) {
        if (checkPrice(me) && checkSize(me) && checkDistrict(me))
            me.submit();
        else
            return false;
    }
    else
        return false;

}

function checkPrice(me) {
    if ((me.pricefrom.selectedIndex > me.priceto.selectedIndex) && (me.priceto.selectedIndex != 0)) {
        alert("不正確的價錢!");
        return false;
    } else {
        return true;
    }
}

function checkPrice_old(me) {
    if (me.srchtype[2].checked) {
        if (((me.buy_from_price.selectedIndex > me.buy_to_price.selectedIndex) && (me.buy_to_price.selectedIndex != 0)) || ((me.rent_from_price.selectedIndex > me.rent_to_price.selectedIndex) && (me.rent_to_price.selectedIndex != 0))) {
            alert("不正確的價錢!");
            return false;
        } else {
            return true;
        }
    } else {
        if (me.srchtype[0].checked) {
            if ((me.buy_from_price.selectedIndex > me.buy_to_price.selectedIndex) && (me.buy_to_price.selectedIndex != 0)) {
                alert("不正確的售價!!");
                return false;
            } else {
                return true;
            }
        } else {
            if ((me.rent_from_price.selectedIndex > me.rent_to_price.selectedIndex) && (me.rent_to_price.selectedIndex != 0)) {
                alert("不正確的租價!");
                return false;
            } else {

                return true;
            }
        }
    }
}

function checkSize(me) {
    if ((me.sizefrom.selectedIndex > me.sizeto.selectedIndex) && (me.sizeto.selectedIndex != 0)) {
        alert("不正確的面積!");
        return false;
    } else {
        return true;
    }
}

function checkDistrict(me) {
    if (me.district.value == "0") {
        alert("請選擇地區!");
        return false;
    } else {
        return true;
    }
}

function listing_code_search(me) {


    if (isNaN(me.code_1.value) || isNaN(me.code_2.value)) {
        alert("請輸入正確的樓盤編號");
        return false;
    }


    else {



        if ((me.code_1.value.length == 0) || (me.code_2.value.length == 0)) {
            alert("不正確的樓盤編號");
            return false;
        } else {

            document.frmListCode.action = "result/listing.asp?listingcode=" + me.code_1.value + "-" + me.code_2.value;
            document.frmListCode.submit();
            //return true;
        }


    }
}

function CheckJump() {

    if (document.frmListCode.code_1.value.length == 4) {
        document.frmListCode.code_2.focus();
    }

} //end function



function CheckNull() {

    if ((document.login.username.value == "") || (document.login.password.value == "")) {
        alert("請輸入使用者編號及密碼");
        return false;
    }
    else
        return true;
}


function CheckQuickSearch() {
    //alert(document.LatestSearch.QuickSrh[document.LatestSearch.QuickSrh.selectedIndex].value);




    if (document.LatestSearch.QuickSrh[document.LatestSearch.QuickSrh.selectedIndex].value == "0") {
        alert("請選擇其中一項");
        return false;
    }
    else {
        //  alert ( document.LatestSearch.QuickSrh[document.LatestSearch.QuickSrh.selectedIndex].value );

        document.LatestSearch.action = document.LatestSearch.QuickSrh[document.LatestSearch.QuickSrh.selectedIndex].value;
        document.LatestSearch.submit();
        return true;
    }

}

function VotePolling() {

    if ((!document.Polling.elements[1].checked) && (!document.Polling.elements[2].checked)) {
        alert("請選擇其中一個");
        return false;

    }

    else {
        var optID;


        if (document.Polling.elements[1].checked)
            optID = document.Polling.elements[1].value;
        else
            optID = document.Polling.elements[2].value;


        //alert(document.Polling.PollingID.value);
        PWindow = window.open("../Polling/AddVote.asp?PollingID=" + document.Polling.PollingID.value + "&Option=" + optID, "PopUpWin", "toolbar=no,width=300,height=100;,location=no,directories=no,status=no,scrollbars=yes,resizable=no,menubar=no,alwaysRaised=yes");
        PWindow.focus();
        PWindow.moveTo(400, 300);
    }




    /*       
	           
    if ( (!document.forms[4].elements[1].checked) && (!document.forms[4].elements[2].checked) ) {
    alert ("請選擇其中一個");
    return false;
      		   	
    }
      		
    else {
    var optID ;
	                
	                
    if (document.forms[4].elements[1].checked)
    optID = document.forms[4].elements[1].value ;
    else
    optID = document.forms[4].elements[2].value ;
	                
	                
    //alert(document.Polling.PollingID.value);
    PWindow = window.open("../Polling/AddVote.asp?PollingID="+  document.Polling.PollingID.value + "&Option=" + optID ,"PopUpWin" ,"toolbar=no,width=300,height=100;,location=no,directories=no,status=no,scrollbars=yes,resizable=no,menubar=no,alwaysRaised=yes");
    PWindow.focus();
    PWindow.moveTo(400,300);
    }
	      	
    */

}
