
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 moveOptions(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++;
		}
	}
	
	for(i=selectedCount-1; i>=0; i--)
	{
		addOption(theSelTo, selectedText[i], selectedValues[i]);
	}
	
	//if(NS4) history.go(0);
}

function removearry_left(obj)
{
	for (var i=0;i<obj.length;) {
		if (obj.options[i]) {
			obj.remove(i);
		}
		else {
			i++;
		};
	};	

}

function single_save()
{
	
	if(frmregular.search_name.value=="")
	{
		alert("Search Name Can Be Empty");
		frmregular.search_name.focus();
		return false;
	}
	if(frmregular.search_name.value!="")
	{
		y=frmregular.search_name.value;	
		z=frmregular.uid.value;			
		x=new ActiveXObject("Microsoft.XMLHTTP")
			x.open("post","../script/checkname.php?call=1&uid="+z+"&name="+y,false)
			x.send(null)			
			if(x.responseText=="1")
				{
					alert("this name is already taken by you")
					frmregular.search_name.focus();
					return false
				}
	}
}

function submitform()
{	
	selectal(frmregular.height1,frmregular.height2)
	selectal(frmregular.SUBCASTE1,frmregular.subcaste2)
	selectal(frmregular.EDUCATIONAL1,frmregular.education2)
	selectal(frmregular.OCCUPATIONAL1,frmregular.occupational2)
	selectal(frmregular.CITIZENSHIP1,frmregular.citizenship2)
	selectal(frmregular.COUNTRY1,frmregular.country2)
	selectal(frmregular.RESIDINGSTATE1,frmregular.state2)	

}
function selectal(obj,x) {	
	obj = (typeof obj == "string") ? document.getElementById(obj) : obj;
	if (obj.tagName.toLowerCase() != "select")
		return;
	for (var i=0; i<obj.length; i++) {	
		if(i==0)
		{
		obj[i].selected = true;
		x.value=x.value+obj[i].value;
		}
		else
		{
			x.value=x.value+","+obj[i].value;
		}

	}	
} 
