var Muslim = new Array();
Muslim["01_SH"]="SHIA";
Muslim["02_SU"]="SUNNI";
Muslim["999_OT"]="OTHER";

var Christian = new Array();
Christian["01_CA"]="CATHOLIC";
Christian["02_PR"]="PROTESTANT";
Christian["999_OT"]="OTHER";

var Hindu = new Array();
Hindu["001_AGH"]="AGHRIA";
Hindu["005_BAD"]="BADHEI";
Hindu["010_BAI"]="BAISHNAV";
Hindu["013_BAT"]="BANAYAT";
Hindu["015_BAN"]="BANIA/GOLDSMITH";
Hindu["020_BAR"]="BARANWAL";
Hindu["022_BAT"]="BATHUDI";
Hindu["023_BAU"]="BAURI";
Hindu["025_BHA"]="BHANDARI";
Hindu["027_BHU"]="BHULIA";
Hindu["030_BRA"]="BRAHMIN";
Hindu["030_BRD"]="BRAHMIN-Danua";
Hindu["030_BRH"]="BRAHMIN-Halua";
Hindu["030_BRJ"]="BRAHMIN-Jhadua";
Hindu["030_BRP"]="BRAHMIN-Panda";
Hindu["035_CHR"]="CHAMAR/MOCHI";
Hindu["040_CHS"]="CHASA";
Hindu["045_DHO"]="DHOBA";
Hindu["050_DAL"]="DALUA";
Hindu["052_DUM"]="DUMAL/DUMBAL";
Hindu["055_EZH"]="EZHAVA";
Hindu["058_GAU"]="GAUDA";
Hindu["060_GOL"]="GOLDSMITH";
Hindu["062_GOL"]="GOLA";
Hindu["062_GON"]="GOND/GANDA";
Hindu["065_GOP"]="GOPAL";
Hindu["070_GUD"]="GUDIA";
Hindu["072_HAN"]="HANSI";
Hindu["075_JAI"]="JAISWAL";
Hindu["080_JYO"]="JYOTISH";
Hindu["082_KAC"]="KACHARA";
Hindu["085_KAI"]="KAIBARTA";
Hindu["087_KAL"]="KALANJI/KALINJI";
Hindu["087_KAM"]="KAMARA/BLACKSMITH";
Hindu["089_KAD"]="KANDHA";
Hindu["090_KAN"]="KANSARI";
Hindu["095_KAR"]="KARAN/KARANA";
Hindu["098_KAY"]="KAYASTA";
Hindu["100_KDR"]="KHADURA/KANSARI";
Hindu["105_KDT"]="KHANDAYAT";
Hindu["110_KDA"]="KANDARA";
Hindu["115_KSH"]="KSHATRIYA";
Hindu["120_KUB"]="KUBERA";
Hindu["125_KUR"]="KUMBHARA";
Hindu["130_KUL"]="KULTA";
Hindu["135_KUM"]="KUMUTI";
Hindu["136_KUR"]="KUDUMI/KURUMI";
Hindu["136_LAX"]="LAXMINARAYAN GOLA";
Hindu["137_MAL"]="MALLA/MALHA";
Hindu["137_MAN"]="MAHANTA";
Hindu["137_MAH"]="MAHARANA";
Hindu["140_MAL"]="MALI";
Hindu["145_MAR"]="MARWARI";
Hindu["147_NIA"]="NIARI/NIHARI";
Hindu["150_ORR"]="ORIYA RAJPUR";
Hindu["155_PAI"]="PAIKA";
Hindu["157_PAA"]="PANA";
Hindu["158_PAN"]="PANDARA";
Hindu["160_PAT"]="PATARA";
Hindu["162_RAD"]="RADHI";
Hindu["165_RAJ"]="RAJPUT";
Hindu["166_RAU"]="RAJU";
Hindu["167_RAN"]="RANGANI";
Hindu["170_RAU"]="RAULO";
Hindu["175_SC"]="SCHEDULED CASTE";
Hindu["180_ST"]="SCHEDULED TRIBE";
Hindu["185_SIN"]="SINDHI";
Hindu["187_SIY"]="SIYAL (KHAJURIA)";
Hindu["190_SUD"]="SUDRA";
Hindu["195_SUN"]="SUNDHI";
Hindu["200_TAN"]="TANTI";
Hindu["205_TAM"]="TAMBULI";
Hindu["210_TEL"]="TELI";
Hindu["215_TLK"]="TELIKULA";
Hindu["220_VAI"]="VAISHYA/BAISHYA";
Hindu["225_VIS"]="VISHWAKARMA";
Hindu["227_YOG"]="YOGI";
Hindu["999_OT"]="OTHER";

var Sikh = new Array(); 
Sikh["999_OT"]= "OTHER";

var Jain = new Array(); 
Jain["999_OT"]= "OTHER";

var Buddhist = new Array(); 
Buddhist["999_OT"]= "OTHER";

var Zorastrian = new Array(); 
Zorastrian["999_OT"]= "OTHER";

var PickOne = new Array("Pick One"); 
var NoBar = new Array(""); 
var None = new Array(" "); 

function getCastes (theArrayName, selectedElement)
{
	
	if (theArrayName == "Pick One") {
		theArrayName = "PickOne";
	}

	if (theArrayName == "No Bar") {
		theArrayName = "NoBar";
	}
	var theArray = eval(theArrayName);


	var arrLength = 0;
	for (name in theArray)
		arrLength++;
    selectedElement.options.length = arrLength;
    //selectedElement.options.length = theArray.length;

	//clearing loop
	for (i = 0; i < selectedElement.options.length; i++){
		selectedElement.options[i].text = "";
		selectedElement.options[i].value = "";
	}//ends clearing FOR loop

	setOptionText(selectedElement, theArray, theArrayName);
}

function setOptionText(selectedElement, theArray, theArrayName)
{
    //selectedElement.options.length = theArray.length;

	var arrLength = 0;
	for (name in theArray)
		arrLength++;

	if (theArrayName != "PickOne") {
    	selectedElement.options.length = arrLength + 1;
	}
	else {
    	selectedElement.options.length = arrLength;
	}

	var loop=0;
	if (theArrayName != "PickOne") {
        selectedElement.options[loop].value = "";
        selectedElement.options[loop].text = "Pick One";
		loop++;
	}

	for (name in theArray)
    {
        selectedElement.options[loop].value = name;
        selectedElement.options[loop].text = theArray[name];
		loop++;
    }
	if (theArrayName == "PickOne") {
		selectedElement.disabled = true;
	}
	else {
		selectedElement.disabled = false;
	}
}

function casteLoad () {
	//alert("loading castes");
	getCastesMulti(window.document.matrimSearchForm.Religion.options[window.document.matrimSearchForm.Religion.selectedIndex].text, window.document.matrimSearchForm.Caste);
}

function getCastesMulti (theArrayName, selectedElement)
{
//alert ('Am I here');
	
	if (theArrayName == "Pick One") {
		theArrayName = "PickOne";
	}

	if (theArrayName == "No Bar") {
		theArrayName = "NoBar";
	}
	var theArray = eval(theArrayName);

	var arrLength = 0;
	for (name in theArray)
		arrLength++;

	if (arrLength  < 3) {
		selectedElement.size = arrLength;
	}
	else {
		selectedElement.size = 3;
	}
    selectedElement.options.length = arrLength;
    //selectedElement.options.length = theArray.length;

	//clearing loop
	for (i = 0; i < selectedElement.options.length; i++){
		selectedElement.options[i].text = "";
		selectedElement.options[i].value = "";
		selectedElement.options[i].selected = false;
	}//ends clearing FOR loop

	setOptionTextMulti(selectedElement, theArray, theArrayName);
}

function setOptionTextMulti(selectedElement, theArray, theArrayName)
{
    //selectedElement.options.length = theArray.length;

	var arrLength = 0;
	for (name in theArray)
		arrLength++;

	if (selectedElement.size == 1) {
    	selectedElement.options.length = arrLength + 1;
	}
	else {
		// If the select list is multi select to begin with
		// this part of the code will play a role.  Basically we set
		// the size to the length of the array or 5
		// which ever is less
    	selectedElement.options.length = arrLength;
		// This is also done in the calling function
		// not sure if it is required here as well
		if (arrLength  < 3) {
			selectedElement.size = arrLength;
		}
		else {
			selectedElement.size = 3;
		}
	}

	var loop=0;

	for (name in theArray)
    {
        selectedElement.options[loop].value = name;
        selectedElement.options[loop].text = theArray[name];
		loop++;
    }
	if (theArrayName == "PickOne") {
		selectedElement.disabled = true;
	}
	else {
		selectedElement.disabled = false;
	}
}
