function CheckUserExist()
{
	var page;
	
	if ( trim(document.myform.ccStudentPersonalDetails_txtuser.value) != "" )
	{			
		if (document.myform.ccStudentPersonalDetails_txtuser.value.search(/[^a-zA-z0-9._]/) > 0 )
		{	
			alert("Please provide valid userid.");
			document.myform.ccStudentPersonalDetails_txtuser.focus();
			return false;
		}
		else
		{		
			page = "CheckAvailable.aspx?user_id=" + document.myform.ccStudentPersonalDetails_txtuser.value;										
			window.open(page,'','toolbars=0,width=400,height=150,scrollbars=yes,top=0,left=0,dependent=1,resizable=0,')					
		}
	}
	else
	{
		alert("Provide some User ID to be checked.")
		document.myform.ccStudentPersonalDetails_txtuser.value = "";
		document.myform.ccStudentPersonalDetails_txtuser.focus();
	}
}

function submitpersonalDetails()
{
	
	if (trim(document.myform.ccStudentPersonalDetails_txtuser.value)=="")
	{
		alert("Please enter User Id.")
		document.myform.ccStudentPersonalDetails_txtuser.focus();
		return false;
	}
	if ( trim(document.myform.ccStudentPersonalDetails_txtuser.value) != "" )
	{			
		if (document.myform.ccStudentPersonalDetails_txtuser.value.search(/[^a-zA-z0-9._]/) > 0 )
		{	
			alert("Please provide valid userid.");
			document.myform.ccStudentPersonalDetails_txtuser.focus();
			return false;
		}
	}
	
	if (trim(document.myform.pwd.value)=="")
	{
		alert("Please enter password.")
		document.myform.pwd.focus();
		return false;
	}
	if (document.myform.rpwd.value=="")
	{
		alert("Please retype password.")
		document.myform.rpwd.focus();
		return false;
	}
	if (document.myform.pwd.value!=document.myform.rpwd.value)
	{
		alert("Password and retype Password are not matching.Please re-enter.")
		document.myform.pwd.value="";
		document.myform.rpwd.value="";
		document.myform.pwd.focus();
		return false;
	}
	
	if (document.myform.fname.value=="")
	{
		alert("Please enter first name.")
		document.myform.fname.focus();
		return false;
	}
	if (document.myform.lname.value=="")
	{
		alert("Please enter last name.")
		document.myform.lname.focus();
		return false;
	}
	
	if (document.myform.ccStudentPersonalDetails_ddob.value=="Select")
	{
		alert("Please select day of your DOB.")
		document.myform.ccStudentPersonalDetails_ddob.focus();
		return false;
	}
	if (document.myform.ccStudentPersonalDetails_mdob.value=="0")
	{
		alert("Please select month of your DOB.")
		document.myform.ccStudentPersonalDetails_mdob.focus();
		return false;
	}
	if (document.myform.ccStudentPersonalDetails_ydob.value=="Select")
	{
		alert("Please select year of your DOB.")
		document.myform.ccStudentPersonalDetails_ydob.focus();
		return false;
	}
	
	if(document.myform.gender[0].checked == false && document.myform.gender[1].checked == false)
	{
		alert("Please Select Your Gender.")
		document.myform.gender[0].focus();
		return false;
	}
	
	if (document.myform.city.value=="")
	{
		alert("Please enter city.")
		document.myform.city.focus();
		return false;
	}
	
	if (document.myform.country.value=="0")
	{
		alert("Please select country.")
		document.myform.country.focus();
		return false;
	}	
	
	if(document.myform.cphone.value.search(/[^0-9\-\+\s]/) >= 0)
	{
		alert("please enter correct Country code.");
		document.myform.cphone.focus();
		return false;
	}
	
	if(document.myform.aphone.value.search(/[^0-9\-\+\s]/) >= 0)
	{
		alert("please enter correct Area code.");
		document.myform.aphone.focus();
		return false;
	}
	
	if(document.myform.pphone.value.search(/[^0-9\-\+\s]/) >= 0)
	{
		alert("please enter correct Phone No.");
		document.myform.pphone.focus();
		return false;
	}
	
	if (document.myform.email.value=="")
	{
		alert("Please enter Email address.")
		document.myform.email.focus();
		return false;
	}
	if ( document.myform.email.value.search(/([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})/) < 0 )
	{
		alert("Please provide valid Email ID.")
		document.myform.email.focus();
		return false;
	}		
	
	if(document.myform.studying[0].checked == false && document.myform.studying[1].checked == false)
	{
		alert("-Please Select Studying or Not Studying.")
		document.myform.studying[0].focus();
		return false;		
	}
	
	if (document.myform.terms.checked==false)
	{
		alert("Check Terms and Conditions before proceeding");
		document.myform.terms.focus();
		return false;
	} 	 	
	
	fileValue = document.myform.ccStudentPersonalDetails_studentimage.value;
	if (fileValue != "")
	{
		if (!CheckFileExt())
		{
			return false;
		}
	}
	
	return true;	
}

extArray = new Array(".jpg",".gif",".bmp");

function CheckFileExt()
{
	allowSubmit = false;
	fileValue = document.myform.ccStudentPersonalDetails_studentimage.value;
			
	while (fileValue.indexOf("\\") != -1)
	
	fileValue = fileValue.slice(fileValue.indexOf("\\") + 1);
	ext = fileValue.slice(fileValue.indexOf(".")).toLowerCase();
	
	for (var i = 0; i < extArray.length; i++)
	{
		if (extArray[i] == ext) 
		{ 
			allowSubmit = true; 
			break; 
		}
	}
	
	if (allowSubmit)
	{
		return true;
	}
	else
	{
		alert("Please only upload files that end in types:  " 
		+ (extArray.join("  ")) + "\nPlease select a new "
		+ "file to upload and submit again.");
		return false;
	}
}

function getColleges()
{
	try
	{
		
		if(document.myform.collegecountry.value != "0")
		{
			var xmlHttp = null 	
			if (typeof window.ActiveXObject != 'undefined' ) 
			{ 
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
			} 
			else 
			{ 
				xmlHttp = new XMLHttpRequest(); 
			}
			var url="/commonAjaxPages/getInstitutes.aspx?country="+document.myform.collegecountry.value;
		
			xmlHttp.open("GET", url, false);
			xmlHttp.send(null);
			
			if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete") 
			{	
				document.getElementById("divcolleges").style.display="block";
				document.getElementById("divcolleges").innerHTML=xmlHttp.responseText;
			}
		}
		else
		{
				document.getElementById("divcolleges").style.display="none";
		}
	}
	catch(e)
	{
		//do nothing
	}
}

function getInstitutes()
{
	try
	{
		if(document.myform.institutecountry.value != "0")
		{
			var xmlHttp = null 	
			if (typeof window.ActiveXObject != 'undefined' ) 
			{ 
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); 
			} 
			else 
			{ 
				xmlHttp = new XMLHttpRequest(); 
			}
			var url="/commonAjaxPages/getInstitutes1.aspx?country="+document.myform.institutecountry.value;
			
			xmlHttp.open("GET", url, false);
			xmlHttp.send(null);
			
			if (xmlHttp.readyState == 4 || xmlHttp.readyState=="complete") 
			{	
				document.getElementById("divinstitutes").style.display="block";
				document.getElementById("divinstitutes").innerHTML=xmlHttp.responseText;
			}
		}
		else
		{
				document.getElementById("divinstitutes").style.display="none";
		}
	}
	catch(e)
	{
		//do nothing
	}
}

function submitProfDetails()
{
	fileValue = document.myform.ccStudentProfessionalDetails_aprocedure.value;
	if (fileValue != "")
	{
		if (!CheckFileExt1())
		{
			return false;
		}
	}
	
	return true;	
}

extArray1 = new Array(".pdf",".doc",".rtf",".txt");
function CheckFileExt1()
{
	allowSubmit = false;
	fileValue = document.myform.ccStudentProfessionalDetails_aprocedure.value;
	
	while (fileValue.indexOf("\\") != -1)
	
	fileValue = fileValue.slice(fileValue.indexOf("\\") + 1);
	ext = fileValue.slice(fileValue.indexOf(".")).toLowerCase();
	
	for (var i = 0; i < extArray1.length; i++)
	{
		if (extArray1[i] == ext) 
		{ 
			allowSubmit = true; 
			break; 
		}
	}
	
	if (allowSubmit)
	{
		return true;
	}
	else
	{
		alert("Please only upload files that end in types:  " 
			+ (extArray1.join("  ")) + "\nPlease select a new "
			+ "file to upload and submit again.");
	
		return false;
	}
}

function chkTerms()
{
	if (document.myform.terms.checked==false)
	{
		alert("Check Terms and Conditions before proceeding");
		document.myform.terms.focus();
		return false;
	} 	 	
	return true;
}

//-----------------------------------------------------------------------------

function validInstitute()
{
	if ( document.myform.collegecountry.value != "0" )
	{
		if ( document.getElementById("ccStudentEducationDetails_collegename").value == "0" )
		{
			alert ("Please select college");
			return false;
		}
	}
	return true;
}