
function fillCategory(){ 
 // this function is used to fill the category list on load
addOption(document.drop_list.Category, "EastZone", "EastZone", "");
addOption(document.drop_list.Category, "WestZone", "WestZone", "");
addOption(document.drop_list.Category, "NorthZone", "NorthZone", "");
addOption(document.drop_list.Category, "SouthZone", "SouthZone", "");

}

function SelectSubCatUpd(preVal){
// ON selection of category this function will work

removeAllOptions(document.drop_list.SubCat);
removeAllOptions(document.drop_list.town);

addOption(document.drop_list.SubCat, "", "Select State", "");

if(document.drop_list.Category.value == 'NorthZone'){
addOptionUpd(document.drop_list.SubCat,"Uttar Pradesh", "Uttar Pradesh", preVal);
addOptionUpd(document.drop_list.SubCat,"Haryana", "Haryana", preVal);
addOptionUpd(document.drop_list.SubCat,"Punjab", "Punjab", preVal);
addOptionUpd(document.drop_list.SubCat,"Delhi", "Delhi", preVal);

}
if(document.drop_list.Category.value == 'WestZone'){
addOptionUpd(document.drop_list.SubCat,"Maharastra", "Maharastra", preVal);
addOptionUpd(document.drop_list.SubCat,"Rajasthan", "Rajasthan", preVal);
addOptionUpd(document.drop_list.SubCat,"Gujrat", "Gujrat", preVal);
addOptionUpd(document.drop_list.SubCat,"Madhya Pradesh", "Madhya Pradesh", preVal);
}


if(document.drop_list.Category.value == 'SouthZone'){
addOptionUpd(document.drop_list.SubCat,"Kerela", "Kerela", preVal);
addOptionUpd(document.drop_list.SubCat,"Andhra Pradesh", "Andhra Pradesh", preVal);
addOptionUpd(document.drop_list.SubCat,"Karnatka", "Karnatka", preVal);
addOptionUpd(document.drop_list.SubCat,"Tamilnadu", "Tamilnadu", preVal);
}


if(document.drop_list.Category.value == 'EastZone'){
addOptionUpd(document.drop_list.SubCat,"Bihar", "Bihar", preVal);
addOptionUpd(document.drop_list.SubCat,"Orissa", "Orissa", preVal);
addOptionUpd(document.drop_list.SubCat,"West Bengal", "West Bengal", preVal);
addOptionUpd(document.drop_list.SubCat,"Jharkhand", "Jharkhand", preVal);
addOptionUpd(document.drop_list.SubCat,"Assam", "Assam", preVal);
}



}


function SelectSubCat(preVal){
// ON selection of category this function will work  
removeAllOptions(document.drop_list.SubCat);
removeAllOptions(document.drop_list.town);

addOption(document.drop_list.SubCat, "", "Select State", "");

if(document.drop_list.Category.value == 'NorthZone'){
addOption(document.drop_list.SubCat,"Uttar Pradesh", "Uttar Pradesh");
addOption(document.drop_list.SubCat,"Haryana", "Haryana");
addOption(document.drop_list.SubCat,"Punjab", "Punjab");
addOption(document.drop_list.SubCat,"Delhi", "Delhi");

}
if(document.drop_list.Category.value == 'WestZone'){
addOption(document.drop_list.SubCat,"Maharastra", "Maharastra");
addOption(document.drop_list.SubCat,"Rajasthan", "Rajasthan");
addOption(document.drop_list.SubCat,"Gujrat", "Gujrat" );
addOption(document.drop_list.SubCat,"Madhya Pradesh", "Madhya Pradesh" );
}


if(document.drop_list.Category.value == 'SouthZone'){
addOption(document.drop_list.SubCat,"Kerela", "Kerela");
addOption(document.drop_list.SubCat,"Andhra Pradesh", "Andhra Pradesh");
addOption(document.drop_list.SubCat,"Karnatka", "Karnatka");
addOption(document.drop_list.SubCat,"Tamilnadu", "Tamilnadu");
}


if(document.drop_list.Category.value == 'EastZone'){
addOption(document.drop_list.SubCat,"Bihar", "Bihar");
addOption(document.drop_list.SubCat,"Orissa", "Orissa");
addOption(document.drop_list.SubCat,"West Bengal", "West Bengal");
addOption(document.drop_list.SubCat,"Jharkhand", "Jharkhand");
addOption(document.drop_list.SubCat,"Assam", "Assam");
}



}
////////////////// 
function Selecttown(){
// ON selection of category this function will work

removeAllOptions(document.drop_list.town); 

for(i=0; i<document.drop_list.SubCat.options.length; i++) { 
    if (document.drop_list.SubCat.options[i].selected == true && document.drop_list.SubCat.options[i].value != '') {
        if(document.drop_list.SubCat.options[i].value == 'Bihar'){
                                                   
        addOption(document.drop_list.town,"Dhanbad", "Dhanbad");
        //addOption(document.drop_list.town,"Ranchi", "Ranchi");
        addOption(document.drop_list.town,"Patna", "Patna");


        }
        if(document.drop_list.SubCat.options[i].value == 'Orissa'){
        addOption(document.drop_list.town,"Bhuwaneshwar", "Bhuwaneshwar");
        addOption(document.drop_list.town,"Cuttack", "Cuttack");

        }



        if(document.drop_list.SubCat.options[i].value == 'Assam'){
        addOption(document.drop_list.town,"Guwahati", "Guwahati");

        }


        if(document.drop_list.SubCat.options[i].value == 'Haryana'){
        addOption(document.drop_list.town,"Rohtak", "Rohtak");
        addOption(document.drop_list.town,"Faridabad", "Faridabad");
        addOption(document.drop_list.town,"Gurgaon", "Gurgaon");


        }

        if(document.drop_list.SubCat.options[i].value == 'Uttar Pradesh'){
        addOption(document.drop_list.town,"Lucknow", "Lucknow");
        addOption(document.drop_list.town,"Kanpur", "Kanpur");
        addOption(document.drop_list.town,"Allahabad", "Allahabad");
        addOption(document.drop_list.town,"Agra", "Agra");
        addOption(document.drop_list.town,"Gorakhpur", "Gorakhpur");
        addOption(document.drop_list.town,"Varanasi", "Varanasi");
        addOption(document.drop_list.town,"Meerut", "Meerut");
        addOption(document.drop_list.town,"Bareilly", "Bareilly" );
        addOption(document.drop_list.town,"Dehradoon", "Dehradoon");
        }



        if(document.drop_list.SubCat.options[i].value == 'Punjab'){
        addOption(document.drop_list.town,"Ludhiana", "Ludhiana");
        addOption(document.drop_list.town,"Amritsar", "Amritsar");
        addOption(document.drop_list.town,"Abohar", "Abohar");
        addOption(document.drop_list.town,"Jalandhar", "Jalandhar");


        }




        if(document.drop_list.SubCat.options[i].value == 'Madhya Pradesh'){
        addOption(document.drop_list.town,"Indore", "Indore" );
        addOption(document.drop_list.town,"Raipur", "Raipur" );
        addOption(document.drop_list.town,"Bhopal", "Bhopal" );
        addOption(document.drop_list.town,"Jabalpur", "Jabalpur" );
        addOption(document.drop_list.town,"Gwalior", "Gwalior" );

        }



        if(document.drop_list.SubCat.options[i].value == 'Gujrat'){
        addOption(document.drop_list.town,"Baroda", "Baroda" );
        addOption(document.drop_list.town,"Surat", "Surat" );
        addOption(document.drop_list.town,"Rajkot", "Rajkot" );
        addOption(document.drop_list.town,"Ahmedabad", "Ahmedabad");
        addOption(document.drop_list.town,"Jamnagar", "Jamnagar" );

        }

        if(document.drop_list.SubCat.options[i].value == 'Rajasthan'){
        addOption(document.drop_list.town,"Kota", "Kota" );
        addOption(document.drop_list.town,"Jodhpur", "Jodhpur" );
        addOption(document.drop_list.town,"Udaipur", "Udaipur" );
        addOption(document.drop_list.town,"Jaipur", "Jaipur" );
        addOption(document.drop_list.town,"Kota", "Kota" );
        addOption(document.drop_list.town,"Bhilwara", "Bhilwara" );
        addOption(document.drop_list.town,"GangaNagar", "GangaNagar" );
        }

        if(document.drop_list.SubCat.options[i].value == 'Maharastra'){
        addOption(document.drop_list.town,"Nagpur", "Nagpur" );
        addOption(document.drop_list.town,"Goa", "Goa" );
        addOption(document.drop_list.town,"Pune", "Pune" );
        addOption(document.drop_list.town,"Mumbai", "Mumbai");
        addOption(document.drop_list.town,"Nasik", "Nasik" );
        addOption(document.drop_list.town,"Aurangabad", "Aurangabad" )
        addOption(document.drop_list.town,"Kolhapur", "Kolhapur" );
        addOption(document.drop_list.town,"Sholapur", "Sholapur" );
        }



        if(document.drop_list.SubCat.options[i].value == 'Tamilnadu'){
        addOption(document.drop_list.town,"Chennai", "Chennai");
        addOption(document.drop_list.town,"Coimbatore", "Coimbatore");
        addOption(document.drop_list.town,"Madurai", "Madurai");
        addOption(document.drop_list.town,"Pondicherry", "Pondicherry");
        addOption(document.drop_list.town,"Trichy", "Trichy");
        }




        if(document.drop_list.SubCat.options[i].value == 'Karnatka'){
        addOption(document.drop_list.town,"Mysore", "Mysore");
        addOption(document.drop_list.town,"Bangalore", "Bangalore");
        addOption(document.drop_list.town,"Hubli", "Hubli");

        }

        if(document.drop_list.SubCat.options[i].value == 'Andhra Pradesh'){
        addOption(document.drop_list.town,"Hyderabad", "Hyderabad");
        addOption(document.drop_list.town,"Vishakhapatnam", "Vishakhapatnam");
        addOption(document.drop_list.town,"Vijaywada", "Vijaywada");
        addOption(document.drop_list.town,"Rajahmundry", "Rajahmundry");
        }

        if(document.drop_list.SubCat.options[i].value == 'Kerela'){
        addOption(document.drop_list.town,"Cochin", "Cochin");
        addOption(document.drop_list.town,"Trichur (Thrissur)", "Trichur (Thrissur)");
        addOption(document.drop_list.town,"Trivandrum", "Trivandrum");
        addOption(document.drop_list.town,"Calicut (Kozhikode)", "Calicut (Kozhikode)");
        }

        if(document.drop_list.SubCat.options[i].value == 'Delhi'){
        addOption(document.drop_list.town,"Delhi", "Delhi");

        }

        if(document.drop_list.SubCat.options[i].value == 'West Bengal'){
        addOption(document.drop_list.town,"Siliguri", "Siliguri");
        addOption(document.drop_list.town,"Kolkata", "Kolkata");
        }

        if(document.drop_list.SubCat.options[i].value == 'Jharkhand'){
        addOption(document.drop_list.town,"Jamshedpur", "Jamshedpur");
        addOption(document.drop_list.town,"Ranchi", "Ranchi");
        }
    }
}
                                          

/*



*/
}






///////////////////////

function removeAllOptions(selectbox)
{
	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		//selectbox.options.remove(i);
		selectbox.remove(i);
	}
}


function addOption(selectbox, value, text )
{
    var optn = document.createElement("OPTION");
    optn.text = text;
    optn.value = value;

    selectbox.options.add(optn);
}


function addOptionUpd(selectbox, value, text, sel)
{
    var optn = document.createElement("OPTION");
    optn.text = text;
    optn.value = value; 
    arrVal = sel.split(',');  
    
    selectbox.options.add(optn);
    
    for(i=0; i<arrVal.length; i++) {
        if (arrVal[i] == optn.value) { 
            selectbox.options.selected = true;
        }
    }  
}

function removeOption(selectbox, value, text )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;

	selectbox.options.remove(optn);
}
