<!--
//set values to hidden fields before submitting the form in default.asp
function apply(frm,jb,jbnm,sk,str1,str2,str3)
{
	jb.value=str1;
	jbnm.value=str2;
	sk.value=str3;
	frm.submit();
}
function checksearch(frm) //check whether user has entered any search string in the textbox in default.asp
{
	var a;
	a=ckstr(frm.val,'an Agency Name',"Y");
	if(a==true)
	{
		return true;
	}
	else
	{
		return false;
	}	
}

//validate string form fields
function ckstr(str,txtname,flag)
{
	if(flag=='Y')
	{
		if(str.value.length==0)
		{
			alert("Please enter '"+txtname+"'");
			str.focus();
			return false;
		}
	}
	if(str.value.indexOf(" ")==0)
	{
		alert("Leading spaces are not allowed in '"+txtname+"'");
		str.focus();
		return false;
	}
	return true;
}

//validate password form fields
function ckpass(str,txtname,flag)
{
	if(flag=='Y')
	{
		if(str.value.length==0)
		{
			alert("Please enter '"+txtname+"'");
			str.focus();
			return false;
		}
	}
	if(str.value.indexOf(" ")==0)
	{
		alert("leading spaces are not allowed in '"+txtname+"'");
		str.focus();
		return false;
	}
	if(str.value.length<8)
	{
		alert("password should be atleast 8 characters...");
		str.focus();
		return false;
	}	
	return true;
}			

//check numeric form fields
function cknum(str,txtname,flag)
{	
	var len;
	len=str.value.length-1;
	if(flag=='Y')
	{
		if(str.value.length==0)
		{
			alert("Please enter '"+txtname+"'");
			str.focus();
			return false;
		}
	}	

	for(i=0;i<=len;i++) 
	{
		if((str.value.charAt(i)<"0" || str.value.charAt(i)>"9")) 
		{
			alert("Enter only numbers in '"+txtname+"'");
			str.value="";
			str.focus();
			return false;
		}
	}
	return true;
}

//check currency form fields
function ckcurr(str,str1,txtname,txtname1,flag)
{	
	var len;
	len=str.value.length-1;
	if(flag=='Y')
	{
		if(str.value.length==0)
		{
			alert("Please enter '"+txtname+"'");
			str.focus();
			return false;
		}
	}	

	for(i=0;i<=len;i++) 
	{
		if((str.value.charAt(i)<"0" || str.value.charAt(i)>"9")) 
		{
			alert("Enter only numbers in '"+txtname+"'");
			str.value="";
			str.focus();
			return false;
		}
	}
	if(str.value.length!=0)
	{
		if(str1.selectedIndex==0)
		{	
			alert("please select '"+txtname1+"'");
			str1.focus();
			return false;
		}	
	}
	return true;
}

//check select box
function cksel(str,txtname)
{
	if(str.selectedIndex==0)
	{
		alert("please select '"+txtname+"'");
		str.focus();
		return false;
	}
	return true;	
}

//check option box
function ckselsp(str,txtname)
{
	if (str.options.length=="0")
	{
		alert("Please select a '"+txtname+"'");
		str.focus();
		return false;
	}
	return true;
}

//check remarks
function ckrem(str,txtname,flag,maxnum)
{
	if(flag=='Y')
	{
		if(str.value.length==0)
		{
			alert("please enter '"+txtname+"'");
			str.focus();
			return false;
		}
	}
	if(str.value.length>maxnum)
	{
		alert("'"+txtname+"' cannot exceed "+maxnum+" characters");
		str.focus();
		return false;
	}
	return true;	
}

//date validation
function ckdt(day,mth,yr)
{
var str_ddval;
var index_dd;
var str_mmval;
var index_mm;
var str_yyval;
var index_yy;	
var str_ddname;
var str_mmname;
var str_yyname;	


str_ddname=day;
index_dd=str_ddname.selectedIndex;
str_ddval=str_ddname.options[index_dd].value;


str_mmname=mth;
index_mm=str_mmname.selectedIndex;
str_mmval=str_mmname.options[index_mm].value;


str_yyname=yr;
index_yy=str_yyname.selectedIndex;
str_yyval=str_yyname.options[index_yy].value;

if((index_dd!=0) && ((index_mm==0) || (index_yy==0)))
{
 alert("Invalid Date Format");
 str_ddname.focus();
 return false;
}
if((index_mm!=0) &&  ((index_dd==0)|| (index_yy==0)))
{
 alert("Invalid Date Format");
 str_ddname.focus();
 return false;
}
if((index_yy!=0) && ((index_mm==0) || (index_dd==0)))
{
 alert("Invalid Date Format");
 str_ddname.focus();
 return false;
}

if((index_dd!=0) && (index_mm!=0) && (index_yy!=0))
{
 dat=str_ddval;
 mont=str_mmval;
 yea=str_yyval;
 

			if (mont>12)
				{
				 alert("Invalid Date, Check the month..");
				str_ddname.focus();
				return false;
				 }
			if (dat>31)
				{
					alert("Invalid Date, Check the date..");
					dstr_ddname.focus();
					return false;
				}
			else if ((mont==04)||(mont==06)||(mont==08)||(mont==10)||(mont==12))
				{
					if (dat>30)
        			{
						alert("Invalid Date, Check the month and date..");
						str_ddname.focus();
        				return false;
					}	                    
				}	
			else if (mont==02)
				{
					if (((yea%4)>0)&&(dat>28))
					{
					alert("Invalid date, Check the leap year");
					str_ddname.focus();
					return false;
					}
					else if (dat >29)
					{
		    		alert("Invalid date, Check the leap year");
					str_ddname.focus();
					return false;
					}
				 } 
	
	}
	return true;
}
	
//check email
	function valemail(str,fl)
	{
	var int_i;			 //used for looping	
	var str_emailval;	 //stores the text entered in the textbox
	var int_emaillen;	 //stores the length of text
	var int_checkforat;	 //stores the position of @ character 
	var int_chechfordot; //stores the position "." character
	var str_email;
	var flag;
	var ok = "yes";
	var temp;
	var at_count=0;
	var j;
	
	flag=fl;
	str_email=str;
	str_emailval=str.value;
	int_emaillen=str_emailval.length;
	int_checkforat=str_emailval.indexOf("@");
	int_checkforat1=str_emailval.indexOf("@@");
	int_checkfordot=str_emailval.indexOf(".");
	
	if(flag=='Y')
	{
	if(int_emaillen==0)
	{		alert("Please fill-up email address...");
		str_email.focus();
		return false;
	}
	}
	for (j=0;j<int_emaillen;j++)
	{
	 if (str_emailval.charAt(j)=="@")
		{
		 at_count=at_count+1;
		}
	}
	
	if (at_count>1)
	{
	 alert("Check for '@' symbol in email address...");
	 str_email.focus();
	 return false;
	}
	
	if((int_emaillen>0) && (int_emaillen<5))
	{
		alert("Invalid number of characters in email address...");
		str_email.focus();
		str_email.select();
		return false;
	}
	if(((str_emailval.indexOf("@",0))==-1) && (int_emaillen>0))		
	{		alert("Please check for @ symbol in email address...");
		str_email.focus();
		str_email.select();
		return false;
	}
	if((str_emailval.indexOf(".",0))==-1 && (int_emaillen>0))		
	{
		alert("Please check for '.' symbol in email address...");
		str_email.focus();
		str_email.select();
		return false;
	}
		
	if(((str_emailval.charAt(0)=="@") || (str_emailval.charAt(0)==".")) && (int_emaillen>0))
	{
		alert("Sorry, @ and . symbols are not allowed as first character in email address...");
		str_email.focus();
		str_email.select();
		return false;
	}
	for(int_i=0;int_i<=int_emaillen-1;int_i++)
	{
		if((str_emailval.charAt(int_i))==" ")
		{
			alert("Sorry, spaces are not allowed in email address...");
			str_email.focus();
			str_email.select();
			return false;
		}
	}
	return true;
}

function ckcontactall(ph,pg,mb,fx,em)
{
	if(ph.value=="" && pg.value=="" && mb.value=="" && fx.value=="" && em.value=="")
	{
		alert("Please enter atleast one of Phone No/Pager No/Mobile No/Fax No/Email.");
		ph.focus();
		return false;
	}
	return true;
}

//function to validate resume submission form - career/resume.asp
function checkresumeform(frm)
{
	var a;
	a=ckstr(frm.pname,'Full Name','Y');
	if(a==true)
	{
		a=cknum(frm.age,'Age','Y');
		if(a==true)
		{
			a=ckdt(frm.day,frm.month,frm.year);
			if(a==true)
			{
				a=ckstr(frm.add1,'Address Line 1','Y');
				if(a==true)
				{
					a=cksel(frm.country,'Country','Y');
					if(a==true)
					{
						a=cknum(frm.pin,'Postal/Zip Code','Y');
						if(a==true)
						{
							a=cknum(frm.ph,'Contact Number','N');
							if(a==true)
							{
								a=ckcurr(frm.cpay,frm.cpaycurr,'Current Salary','Currency','N');
								if(a==true)
								{
									a=ckcurr(frm.epay,frm.epaycurr,'Expected Salary','Currency','N')
									if(a==true)
									{
										a=cksel(frm.pos,'Position Applying For','Y');
										if(a==true)
										{
											a=valemail(frm.em,'Y');
											if(a==true)
											{
												a=ckpass(frm.pass,'Login Password','Y');
												if(a==true)
												{
													a=ckpass(frm.rpass,'Re-Type Login Password','Y');
													if(a==true)
													{
														if(frm.pass.value==frm.rpass.value)
														{
															return true;
														}
														else
														{
															alert("Sorry, your passwords do not match.\n\nPlease re-enter them.");
															frm.pass.value="";
															frm.rpass.value="";
															frm.pass.focus();
															return false;
														}
													}
													else
													{
														return false;
													}			
												}
												else
												{
													return false;
												}	
											}
											else
											{
												return false;
											}	
										}
										else
										{
											return false;
										}	
									}
									else
									{
										return false;
									}		
								}
								else
								{
									return false;
								}	
							}
							else
							{
								return false;
							}	
						}
						else
						{
							return false;
						}	
					}
					else
					{
						return false;
					}	
				}
				else
				{
					return false;
				}	
			}
			else
			{
				return false;
			}	
		}
		else
		{
			return false;
		}	
	}
	else
	{
		return false;
	}

}

//function to validate profile updation form - career/myprofile.asp
function checkprofileform(frm)
{
	var a;
	a=ckdt(frm.day,frm.month,frm.year);
	if(a==true)
	{
		a=ckstr(frm.add1,'Address Line 1','Y');
		if(a==true)
		{
			a=cksel(frm.country,'Country','Y');
			if(a==true)
			{
				a=cknum(frm.pin,'Postal/Zip Code','Y');
				if(a==true)
				{
					a=cknum(frm.ph,'Contact Number','N');
					if(a==true)
					{
						a=ckcurr(frm.cpay,frm.cpaycurr,'Current Salary','Currency','N');
						if(a==true)
						{
							a=ckcurr(frm.epay,frm.epaycurr,'Expected Salary','Currency','N')
							if(a==true)
							{
								a=cksel(frm.pos,'Position Applying For','Y');
								if(a==true)
								{
									return true;
								}
								else
								{
									return false;
								}	
							}
							else
							{
								return false;
							}		
						}
						else
						{
							return false;
						}	
					}
					else
					{
						return false;
					}	
				}
				else
				{
					return false;
				}	
			}
			else
			{
				return false;
			}	
		}
		else
		{
			return false;
		}	
	}
	else
	{
		return false;
	}	
}

//function to validate job application submission form - career/apply.asp
function checkapplyform(frm)
{
	var a;
	a=ckstr(frm.pname,'Full Name','Y');
	if(a==true)
	{
		a=cknum(frm.age,'Age','Y');
		if(a==true)
		{
			a=ckdt(frm.day,frm.month,frm.year);
			if(a==true)
			{
				a=ckstr(frm.add1,'Address Line 1','Y');
				if(a==true)
				{
					a=cksel(frm.country,'Country','Y');
					if(a==true)
					{
						a=cknum(frm.pin,'Postal/Zip Code','Y');
						if(a==true)
						{
							a=cknum(frm.ph,'Contact Number','N');
							if(a==true)
							{
								a=cknum(frm.cpay,'Current Salary','N');
								if(a==true)
								{
									a=cknum(frm.epay,'Expected Salary','N')
									if(a==true)
									{
										a=valemail(frm.em,'Y');
										if(a==true)
										{
											a=ckpass(frm.pass,'Login Password','Y');
											if(a==true)
											{
												a=ckpass(frm.rpass,'Re-Type Login Password','Y');
												if(a==true)
												{
													if(frm.pass.value==frm.rpass.value)
													{
														return true;
													}
													else
													{
														alert("Sorry, your passwords do not match.\n\nPlease re-enter them.");
														frm.pass.value="";
														frm.rpass.value="";
														frm.pass.focus();
														return false;
													}
												}
												else
												{
													return false;
												}			
											}
											else
											{
												return false;
											}	
										}
										else
										{
											return false;
										}	
											
									}
									else
									{
										return false;
									}		
								}
								else
								{
									return false;
								}	
							}
							else
							{
								return false;
							}	
						}
						else
						{
							return false;
						}	
					}
					else
					{
						return false;
					}	
				}
				else
				{
					return false;
				}	
			}
			else
			{
				return false;
			}	
		}
		else
		{
			return false;
		}	
	}
	else
	{
		return false;
	}

}

//function to validate the login form in default.asp
function checklogin(frm)
{
	var a;
	a=valemail(frm.em,'Y');
	if(a==true)
	{
		a=ckpass(frm.pass,'Login Password','Y');
		if(a==true)
		{
			return true;	
		}
		else
		{
			return false;
		}
	}
	else
	{
		return false;
	}		
}

//function to check whether user has selected atleast one check box before submitting form in message.asp
function chkmessage(frm,chk)
{
	var ct;
	var i;
	ct=0
	
	if(chk.length) //if many checkboxes are generated by html
	{
		for (i=0; i<=chk.length-1; i++)
		{
			if(chk[i].checked==true)
			{
				ct=ct+1;
			}	
		}
	}
	else //if only one checkbox is generated by html
	{
		if(chk.checked)
		{
			ct=1;
		}
		else
		{
			ct=0;
		}		
	}
		
	if(ct==0)
	{
		alert("Please check the messages to acknowledge...");
		return false;
	}
	return true;
}
//--> 