// JavaScript Document

//function added by Sen K. Mathew 03/08/2005
function AdminEditResumeValidation()
{
		var objForm=document.frmResume;
		if(objForm.txtName.value=="")
	{
		alert("Please enter the name");
		objForm.txtName.focus();
		return false;
	}
	if(objForm.txtTelephone.value =="")
	{
		alert("Please enter the contact number");
		objForm.txtTelephone.focus();
		return false;
	}
	
	if(!checkEmail(objForm.txtEmail.value,1))
	{
		objForm.txtEmail.focus();
         return false;
	}
	
	if(objForm.txtAddress.value =="")
	{
		alert("Please enter the contact Address");
		objForm.txtAddress.focus();
		return false;
	}
	
	if(objForm.txtStreet.value =="")
	{
		alert("Please enter Street");
		objForm.txtStreet.focus();
		return false;
	}
	
	if(objForm.txtCityTown.value =="")
	{
		alert("Please enter City/Town");
		objForm.txtCityTown.focus();
		return false;
	}
	if(objForm.txtState.value =="")
	{
		alert("Please enter State");
		objForm.txtState.focus();
		return false;
	}
	if(objForm.txtCountry.value =="")
	{
		alert("Please enter Country");
		objForm.txtCountry.focus();
		return false;
	}
	if(objForm.txtPin.value =="")
	{
		alert("Please enter Pin");
		objForm.txtPin.focus();
		return false;
		
	}

	if(isNaN(objForm.txtPin.value))
	{
			alert("Please enter Correct Pin");
			objForm.txtPin.focus();
			return false;
	}
	
	if((objForm.txtPin.value.length) != 6)
	{
			alert("Please enter Correct Pin - 6 digits needed");
			objForm.txtPin.focus();
			return false;
	}
	
	return true;

}

// New function ends

function SubmitFrmValidation(uploadStatus)
{	
	var objForm=document.frmResume;
//	trimSpace(objForm.txtName);
//	trimSpace(objForm.txtEmail);
//	trimSpace(objForm.txtTelephone);
//	trimSpace(objForm.txtAddress);
//	trimSpace(objForm.fileUploader);
//	trimSpace(objForm.txtOtherTechnicalSkill1);
//	trimSpace(objForm.txtOtherTechnicalSkill2);
//	trimSpace(objForm.txtOtherTechnicalSkill3);
	var chkCount = objForm.hidChkCount.value;
	var bFlag = true;
	var i;
	for (i=1;i<=chkCount;i++)
	{
		if (func_IsCheckboxSelected(objForm,"chkCourse"+i))
		{
			bFlag = false;
		}
	}
	if(bFlag)
	{
		alert("Please Select a Program");
		return false;
	}

	if(objForm.txtName.value=="")
	{
		alert("Please enter the name");
		objForm.txtName.focus();
		return false;
	}
	if(objForm.txtTelephone.value =="")
	{
		alert("Please enter the contact number");
		objForm.txtTelephone.focus();
		return false;
	}
	
	if(!checkEmail(objForm.txtEmail.value,1))
	{
		objForm.txtEmail.focus();
         return false;
	}
	
	if(objForm.txtAddress.value =="")
	{
		alert("Please enter the contact Address");
		objForm.txtAddress.focus();
		return false;
	}
	
	if(objForm.txtStreet.value =="")
	{
		alert("Please enter Street");
		objForm.txtStreet.focus();
		return false;
	}
	
	if(objForm.txtCityTown.value =="")
	{
		alert("Please enter City/Town");
		objForm.txtCityTown.focus();
		return false;
	}
	if(objForm.txtState.value =="")
	{
		alert("Please enter State");
		objForm.txtState.focus();
		return false;
	}
	if(objForm.txtCountry.value =="")
	{
		alert("Please enter Country");
		objForm.txtCountry.focus();
		return false;
	}
	if(objForm.txtPin.value =="")
	{
		alert("Please enter Pin");
		objForm.txtPin.focus();
		return false;
		
	}

	if(isNaN(objForm.txtPin.value))
	{
			alert("Please enter Correct Pin");
			objForm.txtPin.focus();
			return false;
	}
	
	if((objForm.txtPin.value.length) != 6)
	{
			alert("Please enter Correct Pin - 6 digits needed");
			objForm.txtPin.focus();
			return false;
	}
		
	
	if(objForm.cboBirthYear.options[objForm.cboBirthYear.selectedIndex].value !="")
	{
		today1 		=	new	Date()
		yearNow1	=	today1.getFullYear()
		yearPre		=	yearNow1-18;
		if(objForm.cboBirthYear.options[objForm.cboBirthYear.selectedIndex].value > yearPre)
		{
			alert("Please select a valid birth date.")
			return false;
		}
	}


	if(objForm.cboEducation.options[objForm.cboEducation.selectedIndex].value =="")
	{
		alert("Please select the highest qualification");
		objForm.cboEducation.focus();
		return false;
	}
	
	/*if(objForm.cboEducation.options[objForm.cboEducation.selectedIndex].value ==8 || objForm.cboEducation.options[objForm.cboEducation.selectedIndex].value ==9 || objForm.cboEducation.options[objForm.cboEducation.selectedIndex].value ==10)
	{
		if(objForm.txtOtherEducation.value =="")
		{	
			alert("Please enter the highest qualification");
			objForm.txtOtherEducation.focus();
			return false;
		}
	}*/
	
	
	
	
	return true;
}


function addvalue(dateSelected,monthSelected,yearSelected,obj_element)
{
	var obj_form = document.forms[0];
	if (obj_element.name == "completionDate")
	{
		obj_form.cboCompletionDay.selectedIndex = dateSelected ;
		obj_form.cboCompletionMonth.selectedIndex = monthSelected+1 ;
		obj_form.cboCompletionYear.selectedIndex = func_returnselectedindex(yearSelected) ;
	}
	else if(obj_element.name == "birthDate")
	{
		today1 		=	new	Date()
		yearNow1	=	today1.getFullYear()
		yearPre		=	yearNow1-18;
		if(yearSelected > yearPre)
		{
			alert("Please select a valid birth date.")
			return false;
		}

		obj_form.cboBirthDay.selectedIndex = dateSelected ;
		obj_form.cboBirthMonth.selectedIndex = monthSelected+1 ;
		obj_form.cboBirthYear.selectedIndex = func_returnselectedindex(yearSelected) ;
	}
}
function func_returnselectedindex(par_selected)
{
	var dt_new =  new Date();
	var str_year = dt_new.getFullYear()
	var str_preyear = str_year - 40;
	for(i=str_preyear,j=0;i<str_year+1;i++,j++)
	{
		if (i==par_selected)
		{
			return j+1;
		}
	}
	if(par_selected < str_preyear){
		alert("Please select a valid year");
	}
	if( par_selected > str_year)
	{
		alert("Please select a valid year");
	}
	
}
/*
function FuncPostAppliedOnChange()
{	
	var objForm = document.forms[0];
	if(objForm.cboPostApplied.options[objForm.cboPostApplied.selectedIndex].value !="")
	{
		var cboType = objForm.cboPostApplied.options[objForm.cboPostApplied.selectedIndex].value;
		TechnicalSkillSelectBox(1,cboType);
		TechnicalSkillSelectBox(2,cboType);
		TechnicalSkillSelectBox(3,cboType);						
	} 
	else 
	{
	}
	
}
*/
function CallOtherQualification()
{
	var objElement = eval("document.forms[0].cboEducation.options[document.forms[0].cboEducation.selectedIndex]");
	var objDivElement = eval("document.getElementById('divEducation').style")
	if((objElement.value) == 8 || (objElement.value) == 9 || (objElement.value) == 10)
	{
		objDivElement.visibility = "visible";
	}
	else
	{
		objDivElement.visibility = "hidden";
	}
}

function CallOtherSkillBox(skillNum)
{
	var objElement = eval("document.forms[0].cboTechnicalSkill"+ skillNum +".options[document.forms[0].cboTechnicalSkill"+ skillNum +".selectedIndex]");
	var objDivElement = eval("document.getElementById('divTechSkill"+ skillNum +"').style")
	if((objElement.value) == 25)
	{
		objDivElement.visibility = "visible";
	}
	else
	{
		objDivElement.visibility = "hidden";
	}

}

function func_IsCheckboxSelected(objForm,strName)
{
	var bcorrect=false;
	for(var i=0; i<objForm.elements.length; i++)
	{
		var name=objForm.elements[i].name;
		var type=objForm.elements[i].type;
		if((type=="checkbox") && (name.indexOf(strName)!=-1))
		{
			var val=objForm.elements[i].checked;
			if(val==true)
			{
				bcorrect = true;
				break;
			}
		}
	}
	return bcorrect;
}

function ReferValidation()
{
	var objForm=document.frmEmail;
	if(objForm.txtName1.value=="")
	{
		alert("Please enter name")
		objForm.txtName1.focus();
         return false;
	}
	if(!checkEmail(objForm.txtEmail1.value,1))
	{
		objForm.txtEmail1.focus();
         return false;
	}
	if(objForm.txtEmail2.value!="" )
	{
		if(objForm.txtName2.value=="")
		{
			alert("Please enter name")
			objForm.txtName2.focus();
			 return false;
		}
		if(!checkEmail(objForm.txtEmail2.value,1))
		{
			objForm.txtEmail2.focus();
			 return false;
		}
	}
	if(objForm.txtEmail3.value!="" )
	{
		if(objForm.txtName3.value=="")
		{
			alert("Please enter name")
			objForm.txtName3.focus();
			 return false;
		}
		if(!checkEmail(objForm.txtEmail3.value,1))
		{
			objForm.txtEmail3.focus();
			 return false;
		}
	}
	if(objForm.txtEmail4.value!="" )
	{
		if(objForm.txtName4.value=="")
		{
			alert("Please enter name")
			objForm.txtName4.focus();
			 return false;
		}
		if(!checkEmail(objForm.txtEmail4.value,1))
		{
			objForm.txtEmail4.focus();
			 return false;
		}
	}
	if(objForm.txtEmail5.value!="" )
	{
		if(objForm.txtName5.value=="")
		{
			alert("Please enter name")
			objForm.txtName5.focus();
			 return false;
		}
		if(!checkEmail(objForm.txtEmail5.value,1))
		{
			objForm.txtEmail5.focus();
			 return false;
		}
	}
	return true
}