function CloseAll()
{
	for(i=1;i<4;i++)
		{ 
		document.all["nav"+i].style.display = "none";
		}
	
}
function SwitchDiv(Section)
{

	if (document.all[Section].style.display == "none")
	{
		
		
		document.all[Section].style.display = "";
		
	}
	else
	{
		document.all[Section].style.display = "none";
	}
}

var isSubmitting = false;

function AddAll_onclick(liNotInList,liInList,saveToList) {
	Move(liNotInList,liInList,saveToList);
}

function Add_onclick(liNotInList,liInList,saveToList) {
	Move(liNotInList,liInList,saveToList);
}

function Remove_onclick(liInList1, liNotInList1, saveToList) {
	Move(liInList1, liNotInList1, saveToList);
}

function RemoveAll_onclick(liInList1, liNotInList1, saveToList) {
	Move(liInList1, liNotInList1, saveToList);
}

function Move(FromList, ToList, All, saveToList)
{
	var oOptions = document.all(FromList).options;
	var length = oOptions.length;
	var oToList = document.all(ToList).options;
	
	//remove all selection from ToList
	var lTo = oToList.length;
	for( i = 0; i< lTo; i++ )
		oToList(i).selected = false;

	for( i = 0; i < length; i++ )
	{

		if( oOptions[i].selected || All)
		{
			var strInnerText = oOptions[i].innerText;
			var value = oOptions[i].value;
			var index;
			if( oToList.length > 0 ) //if more than one item is already in list
				index = FindLocation( oToList, strInnerText ); //find where to put new item
			else 
				index = 0;
			var oO = document.createElement("OPTION");
			document.all(ToList).options.add( oO, index);
			oO.innerText = strInnerText;
			oO.value = value;
			oO.selected = true;
			document.all(FromList).options.remove( i );

			length--; //removed from list
			i--; //decrement index back
		}
	}
}
function FindLocationInRange( oOptions, str, beginRange, endRange)
{
	return BinaryFind(oOptions, str.toUpperCase(), beginRange, endRange );	
}

function FindLocation(oOptions, str)
{
	return FindLocationInRange(oOptions, str, 0, oOptions.length - 1);
}
function BinaryFind( oOptions, str, lowIndex, upIndex )
{
	//this is modified binary search. It returns the index of
	//where item should be inserted (unlike returning 'not found' if item not found)
	if( lowIndex >= upIndex || lowIndex+1 == upIndex )
	{
		//our stuff goes in the middle
		var txtFound = oOptions(lowIndex).innerText.toUpperCase();
//		if( str < txtFound )
		if( str.localeCompare(txtFound) < 0 )
			return lowIndex;
		else
		{
			txtFound = oOptions(upIndex).innerText.toUpperCase();
			if( str.localeCompare( txtFound) < 0 )
				return upIndex;
			else
				return upIndex+1;
		}
	}
	var middle = Math.ceil(lowIndex + ((upIndex-lowIndex)/2));
	var textFound = oOptions(middle).innerText.toUpperCase();
	if( textFound.localeCompare(str) < 0 )
		return BinaryFind( oOptions, str, middle+1, upIndex )
	else if( textFound.localeCompare( str ) > 0 )
		return BinaryFind( oOptions, str, lowIndex, middle-1);	
	else
		return middle; //same names
}

function onEducationalLevelChange()
{

	var pnlEdu=document.getElementById("pnlEducationalLevel");
	pnlEdu.style.display="none";
	var validator1=document.getElementById("rfvEducationalLevelOther")
	var validator2=document.getElementById("revEducationalLevelOther")
	ValidatorEnable(validator1,false);
		ValidatorEnable(validator2,false);
	
	
	for(var i=0;i<document.forms[0].ddlEducationLevel.options.length;i++)
	{
	if(document.forms[0].ddlEducationLevel.options[i].selected==true)
	{
		if(document.forms[0].ddlEducationLevel.options[i].value=="4")
		{
		pnlEdu.style.display="block";
		ValidatorEnable(validator1,true);
		ValidatorEnable(validator2,true);
		}
		
	}
	}
}
function onRegisteredTypeChange()
{

	var divcon=document.getElementById("pnlResearchCenter");
	divcon.style.display="none";
	
	var validator1=document.getElementById("rfvResearchCenter")
	ValidatorEnable(validator1,false);
	var validator2=document.getElementById("revResearchCenter")
	ValidatorEnable(validator2,false);
	var validator3=document.getElementById("revResearchCenterRole")
	ValidatorEnable(validator3,false);
	
	for(var i=0;i<document.forms[0].ddlRegistrationType.options.length;i++)
	{
	if(document.forms[0].ddlRegistrationType.options[i].selected==true)
	{
		if(document.forms[0].ddlRegistrationType.options[i].value=="2")
		{
		divcon.style.display="block";
		ValidatorEnable(validator1,true);
		ValidatorEnable(validator2,true);
		ValidatorEnable(validator3,true);
		}
		
	}
	}
}

function selectAll(var1)
{
var list=document.getElementById(var1);
	for(var i=0;i<list.length;i++)	
	{
		list.options[i].selected=true;
	}
}
function OpenWinStart(param){
	var e=document.getElementsByTagName('input'); 
	for(var i=0;i<e.length;i++){
		var ObjName; 
		ObjName=e[i].id; 
		if(ObjName.indexOf(param)!=-1){
			strName = ObjName;
			break;
		}
	}		
	window.open ('/English/Calendar/calendarStart.aspx?param=' + strName, "PopUpCalendar", "toolbar=0,location=0,directories=0,status=0,menubar=no,scrollbars=no,resizable=no,width=270,height=230"); 
}


