﻿// JScript File

function getstatedata(ddlCountry,ddlState)
{
    var responsedata;
    var rawstate = new Array();
    var rawstatename1;
    var rawstateid1;
    var statename = new Array();
    var stateid = new Array();
    var loopcount;
    var i;
    var j = 0;
    var objHttp = new ActiveXObject("Microsoft.XMLHTTP");
    objHttp.OnReadyStateChange = function ()
    {
        if(objHttp.readyState == 4)
        {
            responsedata = objHttp.responseText;
            
            rawstate = responsedata.split("$");
			rawstatename1 = rawstate[0];
			rawstateid1 = rawstate[1];
			statename = rawstatename1.split("*");
			stateid = rawstateid1.split("_");
			loopcount = statename.length;
            
            for(i=0;i < loopcount ; i++)
            {
                while(j==0)
                {
                    funcClear(document.getElementById("ctl00_ContentPlaceHolder1_ddlState"));
                    funcOption(document.getElementById("ctl00_ContentPlaceHolder1_ddlState"),"Select","0")
                    j = 1;
                }
                funcOption(document.getElementById("ctl00_ContentPlaceHolder1_ddlState"),statename[i],stateid[i]);
            }
            
        }
    }
    //var countryId = document.getElementById(ctl00_ContentPlaceHolder1_ddlCountry).value;
    //var countryId = document.Form1.ctl00_ContentPlaceHolder1_ddlCountry.value;
    var countryId = document.getElementById("ctl00_ContentPlaceHolder1_ddlCountry").value;
    document.getElementById("ctl00_ContentPlaceHolder1_hCountryID").value = countryId;
    var strURL = "http://www.AutoBuyBids.com/ABB/AjaxServer.aspx?countryId=" + countryId;
    objHttp.Open("POST",strURL,true);
    objHttp.SetRequestHeader("Content-Type","application/x-www-form-urlencoded");
    objHttp.Send(null);
}
/*function checkModifyProfile()
{
    if (document.getElementById("ctl00_ContentPlaceHolder1_ddlCountry").value == "0")
    {
        alert("Please Select Country");
        return false;
    }
    if (document.getElementById("ctl00_ContentPlaceHolder1_ddlState").value) == "0")
    {
        alert("Please Select State");
        return false;
    }
}*/
function selectedState()
{
    var stateID = document.getElementById("ctl00_ContentPlaceHolder1_ddlState").value;
    document.getElementById("ctl00_ContentPlaceHolder1_hStateID").value = stateID;
}
function funcOption(e,newText,newValue)
{
    var objSelect = e;
    var objOption = document.createElement("option");
    if (newText != "" && newValue !="")
    {
        objOption.text = newText;
        objOption.value = newValue;
        if (document.all && !window.opera)
        {
            objSelect.add(objOption);
        }
        else
        {
            objSelect.add(objOption,null);   
        }
    }
}
function funcClear(e)
{
    var objSelect = e;
    while(objSelect.options.length > 0)
    {
        objSelect.remove(0);
    }
}