function check_age(Form){
	if(Form=='Simple'){
		val_age_to 		= document.Search_02_Simple_Form.dd_age_to.value;
		val_age_from  	= document.Search_02_Simple_Form.dd_age_from.value;
		if(val_age_to < val_age_from){
			document.Search_02_Simple_Form.dd_age_to.value = val_age_from;
		}
	}else if(Form=='Mangalik'){
		val_age_to 		= document.Search_06_Mangalik_Form.dd_age_to.value;
		val_age_from  	= document.Search_06_Mangalik_Form.dd_age_from.value;
		if(val_age_to < val_age_from){
			document.Search_06_Mangalik_Form.dd_age_to.value = val_age_from;
		}
	}else{
		val_age_to 		= document.Search_03_Advance_Form.dd_age_to.value;
		val_age_from  	= document.Search_03_Advance_Form.dd_age_from.value;
		if(val_age_to < val_age_from){
			document.Search_03_Advance_Form.dd_age_to.value = val_age_from;
		}
	}
}

function SelectAll(){
	caste 		= document.Search_03_Advance_Form.dd_caste;
	gon 		= document.Search_03_Advance_Form.dd_gon;
	education 	= document.Search_03_Advance_Form.dd_education;
	occupation 	= document.Search_03_Advance_Form.dd_occupation;
	country 	= document.Search_03_Advance_Form.dd_country;

	if(caste.length>10){
		document.getElementById("span_caste").innerHTML="Only 10 items can be selected";
		document.Search_03_Advance_Form.list2.focus();
		return false;
	}
	for(var i=0; i<caste.length; i++){
		caste[i].selected = true;
	}
	if(gon.length>2){
		document.getElementById("span_caste").innerHTML="";
		document.getElementById("span_gon").innerHTML="Only 2 items can be selected";
		document.Search_03_Advance_Form.list3.focus();
		return false;
	}
	for(var i=0; i<gon.length; i++){
		gon[i].selected = true;
	}
	if(education.length>10){
		document.getElementById("span_caste").innerHTML="";
		document.getElementById("span_gon").innerHTML="";
		document.getElementById("span_education").innerHTML="Only 10 items can be selected";
		document.Search_03_Advance_Form.list5.focus();
		return false;
	}
	for(var i=0; i<education.length; i++){
		education[i].selected = true;
	}
	if(occupation.length>10){
		document.getElementById("span_caste").innerHTML="";
		document.getElementById("span_gon").innerHTML="";
		document.getElementById("span_education").innerHTML="";
		document.getElementById("span_occupation").innerHTML="Only 10 items can be selected";
		document.Search_03_Advance_Form.list4.focus();
		return false;
	}
	for(var i=0; i<occupation.length; i++){
		occupation[i].selected = true;
	}
	if(country.length>10){
		document.getElementById("span_caste").innerHTML="";
		document.getElementById("span_gon").innerHTML="";
		document.getElementById("span_education").innerHTML="";
		document.getElementById("span_occupation").innerHTML=""
		document.getElementById("span_country").innerHTML="Only 10 items can be selected";
		document.Search_03_Advance_Form.list6.focus();
		return false;
	}
	for(var i=0; i<country.length; i++){
		country[i].selected = true;
	}
	return true;
}

function addOption(theSel, theText, theValue){
	var newOpt=new Option(theText, theValue);
	var selLength=theSel.length;
	theSel.options[selLength]=newOpt;
}

function deleteOption(theSel, theIndex){	
	var selLength=theSel.length;
	if(selLength>0)	{
		theSel.options[theIndex]=null;
	}
}
function chkAny(theSelFrom, theSelTo){
	alert(theSelTo.length);
	selLength=theSelFrom.length;
	for(i=selLength-1; i>=0; i--){
		
		if(theSelFrom.options[i].value=="0"){
			
			var newOpt=new Option("- Any -", "0");
			alert(newOpt);
	
	theSelFrom.options[0]=newOpt;
			moveOptions(theSelFrom, theSelTo);
			
			
		}
	}
	
}

function moveOptions(theSelFrom, theSelTo){	
	var selLength=theSelFrom.length;
	var selectedText=new Array();
	var selectedValues=new Array();
	var selectedCount=0;
	var cou1=1;
	var adflag=0;
	var i;

	for(i=selLength-1; i>=0; i--){
		if(theSelFrom.options[i].selected){
			if (cou1==1){
				selectedText[selectedCount]=theSelFrom.options[i].text;
				selectedValues[selectedCount]=theSelFrom.options[i].value;
				selectedCount++;
			}
		}			
	}

	if (theSelTo.length>0){
		for(i=selectedCount-1; i>=0; i--){	
			adflag=0;
			for (j=0;j<theSelTo.length;j++)	{
				if(selectedText[i]==theSelTo.options[j].text && adflag==0){
					adflag=1
				}
			}
			if(adflag==0){
				addOption(theSelTo, selectedText[i], selectedValues[i]);
			}
		}
	}else{
		for(i=selectedCount-1; i>=0; i--){
			addOption(theSelTo, selectedText[i], selectedValues[i]);
		}
	}
}

function moveOptions1(theSelFrom, theSelTo){
	var selLength=theSelFrom.length;
	var selectedText=new Array();
	var selectedValues=new Array();
	var selectedCount=0;
	var i;
	for(i=selLength-1; i>=0; i--){
		if(theSelFrom.options[i].selected){
			selectedText[selectedCount]=theSelFrom.options[i].text;
			selectedValues[selectedCount]=theSelFrom.options[i].value;
			deleteOption(theSelFrom, i);
			selectedCount++;
		}
	}
	if(NS4) history.go(0);
}

function check_height(){
	val_height_to 		= document.Search_03_Advance_Form.dd_to_height.value;
	val_height_from  	= document.Search_03_Advance_Form.dd_from_height.value;
	if(val_height_to < val_height_from){
		document.Search_03_Advance_Form.dd_to_height.value = val_height_from;
	}
}
