﻿// JScript File

var JobSeekerMasterName = 'ctl00_contentplaceholder1_';

//Change the color for the login status
function fnLoginStatus(Type)
{
	try
	{
		var loginstatus = document.getElementById("ctl00_ucHeader_LoginStatus");
		if(Type == 'over')
			loginstatus.className="loginmouseover";
		else
			loginstatus.className="loginmouseout";
	}
	catch(err)
	{
	}
}
function fnClearChangePassword()
{
	try
	{
		ClearObject('ChangePassword1_ChangePasswordContainerID_CurrentPassword');
		ClearObject('ChangePassword1_ChangePasswordContainerID_NewPassword');
		ClearObject('ChangePassword1_ChangePasswordContainerID_ConfirmNewPassword');
		document.getElementById("divFailureText").innerText = "";
		return false;
	}
	catch(err)
	{
		return false;
	}
}
function fnValidateChangePassword()
{
	try
	{
		document.getElementById("divFailureText").innerText = "";
		if(!ValidateTextBox('ChangePassword1_ChangePasswordContainerID_CurrentPassword','Password is required.'))
				return false;
		if(!ValidateTextBox('ChangePassword1_ChangePasswordContainerID_NewPassword','New Password is required.'))
				return false;
		if(!ValidateTextBox('ChangePassword1_ChangePasswordContainerID_ConfirmNewPassword','Confirm New Password is required.'))
				return false;
		//Compare the new & confirm password
		if(!ValidateCompareField('ChangePassword1_ChangePasswordContainerID_NewPassword','ChangePassword1_ChangePasswordContainerID_ConfirmNewPassword','The Confirm New Password must match the New Password entry.'))
				return false;
				
		return true;
	}
	catch(err)
	{
		return false;
	}
}
function fnValidateForgotPassword()
{
	try
	{
		document.getElementById("tdFailureText").innerText = "";
		if(!ValidateTextBox('PasswordRecovery1_UserNameContainerID_UserName','User Name is required.'))
				return false;
		return true;
	}
	catch(err)
	{
		return false;
	}
}
function fnValidateSearch(SearchType)
{ //SEarch creteria validation
	try
	{
		if(SearchType == 'N') //Normal Search
		{
			if(!ValidateTextBox('txtNormalSearch','search item required'))
				return false;
		}
		else //Advanced Search
		{
			//Check the minimum exp is less than max
			var MinExp = document.getElementById(JobSeekerMasterName + 'ddlMinExperience');
			var MaxExp = document.getElementById(JobSeekerMasterName + 'ddlMaxExperience');
			if(MinExp.selectedIndex > MaxExp.selectedIndex)
			{
				alert('Maximum experience should be greater than minimum experience');
				MaxExp.focus();
				return false;
			}
		}
		return true;
	}
	catch(err)
	{
		return false;
	}
}
function fnHideSearchPanel(SearchType)
{ //Hide the Normal Search
	try
	{
		
		var NormalSearch = document.getElementById(JobSeekerMasterName + "divSearchNormal");
		var AdvancedSearch = document.getElementById(JobSeekerMasterName + "divSearchAdvanced");
		var divSearchResults = document.getElementById(JobSeekerMasterName + "divSearchResults");
		var pnlJobs = document.getElementById(JobSeekerMasterName + "pnlJobs");
		var txtTitle = document.getElementById(JobSeekerMasterName + "txtTitle");
		txtTitle.value = "";
		var txtNormalSearch = document.getElementById(JobSeekerMasterName + "txtNormalSearch");
		txtNormalSearch.value = "";
		divSearchResults.style.display = "none";
		pnlJobs.style.display = "block";
		//Hide the Normal Search
		if(SearchType == 'N')
		{
			NormalSearch.style.display = "none";
			AdvancedSearch.style.display = "block";
			txtTitle.focus();
		}
		else //IF 'A' means , Hide the Advance Search
		{
			NormalSearch.style.display = "block";
			AdvancedSearch.style.display = "none";
			txtNormalSearch.focus();
		}
		//Default focus for Sorting Controls
		document.getElementById(JobSeekerMasterName + "ddlSortBy").selectedIndex = 0;
		document.getElementById(JobSeekerMasterName + "lstLocations").selectedIndex = 0;
		document.getElementById(JobSeekerMasterName + "ddlCategory").selectedIndex = 0;
		document.getElementById(JobSeekerMasterName + "ddlMaxExperience").selectedIndex = 0;
		document.getElementById(JobSeekerMasterName + "ddlMinExperience").selectedIndex = 0;
		document.getElementById(JobSeekerMasterName + "rblSorting").selectedValue = "Asc";
	}
	catch(err)
	{
		return false;
	}
}

function fnPostJobs()
{
	try
	{
		//text box
		if(!ValidateTextBox('txtconatctperson','Required contact person'))
			return false;
		if(!ValidateTextBoxMinMax('txtconatctperson',3,50,'contact person'))
			return false;
		if(!ValidateTextBox('txttitle','Required title'))
			return false;
		if(!ValidateTextBoxMinMax('txttitle',3,30,'title'))
			return false;
		if(!ValidateTextBox('txtDepart','Required department'))
			return false;
		if(!ValidateTextBoxMinMax('txtDepart',3,30,'department'))
			return false;
		if(!ValidateTextBox('txtjobcode','Required job code'))
			return false;
		if(!ValidateTextBoxMinMax('txtjobcode',3,15,'job code'))
			return false;
		//DDL
		if(!ValidateDropDownlist('ddlcountry','Required to select country'))
			return false;
		if(!ValidateDropDownlist('ddlstate','Required to select state'))
			return false;
		if(!ValidateDropDownlist('ddlcity','Required to select city'))
			return false;
		if(!ValidateDropDownlist('ddlEdecationlevel','Required to select education'))
			return false;
		if(!ValidateDropDownlist('ddlJobtype','Required to select job type'))
			return false;
		if(!ValidateDropDownlist('ddlindustry','Required to select industry'))
			return false;
		if(!ValidateDropDownlist('ddlfunctionalarea','Required to select functional area'))
			return false;		
		if(!ValidateDropDownlist('ddlminexp','Required to select minimum experience'))
			return false;
		if(!ValidateDropDownlist('ddlmaxexp','Required to select maximum experience'))
			return false;
		//Check the minimum exp is less than max
		var MinExp = document.getElementById(JobSeekerMasterName + 'ddlminexp');
		var MaxExp = document.getElementById(JobSeekerMasterName + 'ddlmaxexp');
		if(MinExp.selectedIndex > MaxExp.selectedIndex)
		{
			alert('Maximum experience should be greater than minimum experience');
			MaxExp.focus();
			return false;
		}
		//Check the minimum and maximum exp
	  if(!ValidateValueGreater('txtminsal',0,'Min Salary( Rs )'))
		  return false;			
		if(!ValidateMinMaxSalary('txtminsal',4,8,'minimum salary'))
			return false;
			 	  if(!ValidateValueGreater('txtmaxsal',0,'Max Salary( Rs )'))
		  return false;		 	
		if(!ValidateMinMaxSalary('txtmaxsal',4,8,'maximum salary'))
			return false;
		if(!ValidateValueGreaterMinimum('txtminsal','txtmaxsal','salary'))
			return false;
		if(!ValidateDropDownlist('ddldegreeid','Required to select degree'))
			return false;
		if(!ValidateDropDownlist('ddlspecializationid','Required to select specialization'))
			return false;
		if(!ValidateTextBox('txtpostclosedt','Required closing date'))
			return false;
		return true;
	}
	catch(err)
	{
		alert(err.message)
		return false;
	}
}
//Delete Jobs
function fnDeleteJobs()
{
	try
	{
		//Resume
		if(confirm('Are you sure to delete the posted job'))
			return true;
		else
			return false;
	}
	catch(err)
	{
		return false;
	}
}
//Apply New Jobs
function fnApplyJobs()
{
	try
	{
		//Resume
		if(!ValidateDropDownlist('ddlResume','Required to select resume'))
			return false;
		return true;
	}
	catch(err)
	{
		return false;
	}
}
function fnCheckResume()
{
	try
	{
		//Resume Title
		if(!ValidateTextBox('txtResumeTitle','Required resume title'))
			return false;
		if(!ValidateTextBoxMinMax('txtResumeTitle',3,50,'resume title'))
			return false;
		if(!checkFileExt('fupResume',true,'D'))
				return false;
		return true;
	}
	catch(err)
	{
		return false;
	}
}
function CheckSelectedJobs(id , Message)
{
	try
	{
		//get reference of GridView control
		var grid = document.getElementById(JobSeekerMasterName + id);
		if(grid != null)
		{
			//variable to contain the cell of the grid
			var cell;
			if (grid.rows.length > 0)
			{
				 //loop starts from 1. rows[0] points to the header.
				 for (i=1; i<grid.rows.length; i++)
				 {
					  //get the reference of first column
					  cell = grid.rows[i].cells[0];
					  //loop according to the number of childNodes in the cell
					  for (j=0; j<cell.childNodes.length; j++)
					  {           
							//if childNode type is CheckBox   
							if (cell.childNodes[j].type =="checkbox")
							{
								//assign the status of the Select All checkbox to the cell checkbox within the grid
								 if(cell.childNodes[j].checked == true)
										return true;
							}
					  }
				 }
			}
		}
		alert(Message);
		return false;
	}
	catch(err)
	{
		return false;
	}
}

function ShowMenuHighlight()
{
	try
	{
		//Hide All the highlighted menus
		HideAllMenuHighlight();
		//Get the URL
		var URL = location.href;
		//For the Employeer
		if(URL.indexOf("/ChangePassword.aspx") >= 0)
		{
			//For the My Profile
			document.getElementById("imgMyProfileR").style.display = "block";
			document.getElementById("imgMyProfileL").style.display = "block";
			document.getElementById("aMyProfile").className="clsAnchorHeader";
			
			//For the My Profile
			document.getElementById("imgMyProfileRE").style.display = "block";
			document.getElementById("imgMyProfileLE").style.display = "block";
			document.getElementById("aMyProfileE").className="clsAnchorHeader";
			return;
		}
		if(URL.indexOf("/JobSeeker") >= 0)
		{
			if(URL.indexOf("JSregistration.aspx") >= 0)
			{
				//For the Manage Profile
				document.getElementById("imgManageProfileR").style.display = "block";
				document.getElementById("imgManageProfileL").style.display = "block";
				document.getElementById("aManageProfile").className="clsAnchorHeader";
			}
			else
			{
				//For the My Profile
				document.getElementById("imgMyProfileR").style.display = "block";
				document.getElementById("imgMyProfileL").style.display = "block";
				document.getElementById("aMyProfile").className="clsAnchorHeader";
				
				//For the My Profile , becoz here we using some my profile pages here for employer
				document.getElementById("imgMyProfileRE").style.display = "block";
				document.getElementById("imgMyProfileLE").style.display = "block";
				document.getElementById("aMyProfileE").className="clsAnchorHeader";
			}
		}
		//For the Jobseeker
		else if(URL.indexOf("/Employer") >= 0)
		{
			if(URL.indexOf("EmployerRegistration.aspx") >= 0)
			{
				//For the Manage Profile
				document.getElementById("imgManageProfileRE").style.display = "block";
				document.getElementById("imgManageProfileLE").style.display = "block";
				document.getElementById("aManageProfileE").className="clsAnchorHeader";
			}
			else
			{
				//For the My Profile
				document.getElementById("imgMyProfileRE").style.display = "block";
				document.getElementById("imgMyProfileLE").style.display = "block";
				document.getElementById("aMyProfileE").className="clsAnchorHeader";
			}
		}
		else
		{
			//For the Home
			document.getElementById("imgHomeRight").style.display = "block";
			document.getElementById("imgHomeLeft").style.display = "block";
			document.getElementById("aHome").className="clsAnchorHeader";
		}
		var divMenuJobSeeker = document.getElementById("ctl00_ucMenuControl_divMenuJobSeeker").style.display;
		var divMenuEmployeer = document.getElementById("ctl00_ucMenuControl_divMenuEmployeer").style.display; 
		if(divMenuJobSeeker == 'none' && divMenuEmployeer == 'none')
		{	//When the user are not logged in , we highlight the homw
			//For the Home
			document.getElementById("imgHomeRight").style.display = "block";
			document.getElementById("imgHomeLeft").style.display = "block";
			document.getElementById("aHome").className="clsAnchorHeader";
		}
		
	}
	catch(err)
	{
		//alert(err.message);
	}
}
function HideAllMenuHighlight()
{
	try
	{
		var URL = location.href;
		//For the Home
		document.getElementById("imgHomeRight").style.display = "none";
		document.getElementById("imgHomeLeft").style.display = "none";
		document.getElementById("aHome").className="";
		//For the Manage Profile Job
		document.getElementById("imgManageProfileR").style.display = "none";
		document.getElementById("imgManageProfileL").style.display = "none";
		document.getElementById("aManageProfile").className="";
		//For the My Profile Job
		document.getElementById("imgMyProfileR").style.display = "none";
		document.getElementById("imgMyProfileL").style.display = "none";
		document.getElementById("aMyProfile").className="";
		//For the Manage Profile Emp
		document.getElementById("imgManageProfileRE").style.display = "none";
		document.getElementById("imgManageProfileLE").style.display = "none";
		document.getElementById("aManageProfileE").className="";
		//For the My Profile Emp
		document.getElementById("imgMyProfileR").style.display = "none";
		document.getElementById("imgMyProfileL").style.display = "none";
		document.getElementById("aMyProfileE").className="";
		
	}
	catch(err)
	{
		//alert(err.message);
	}
}
function fnSelectResume()
{
	try
	{
		if(!ValidateDropDownlist('ddlResume','Required to select resume'))
			return false;
		return true;
	}
	catch(err)
	{
		//alert(err.message);
	}
}

function fnValidateJobseekerProfile()
{	
	try
	{
	  if (document.getElementById('ctl00_contentplaceholder1_txtPhone').value.length != 0)
             {            
                 var Alphaname = document.getElementById('ctl00_contentplaceholder1_txtPhone').value;    
                 var regex1 = /^\+91\-((\d{1})?[0-9]\d{1,3})\-?[1-9]\d{5,8}$/;          
                //var regex1 = /^[+]?\91\-((\d{1})?[0-9]\d{1,3})\-?[1-9]\d{5,8}$/;                            
                 if (!regex1.test(Alphaname)) 
                 {           
                   alert("Please Enter Valid Phone Number");           
                   document.getElementById('ctl00_contentplaceholder1_txtPhone').focus();
                   return false;
                 }       
            }            
         if (document.getElementById('ctl00_contentplaceholder1_txtPincode').value.length != 0)
             {            
                 var Alphaname = document.getElementById('ctl00_contentplaceholder1_txtPincode').value;    
                 var regex1 = /^[0-9]+$/;          
                 if (!regex1.test(Alphaname)) 
                 {
                   alert("Please Enter Valid PinCode");           
                   document.getElementById('ctl00_contentplaceholder1_txtPincode').focus();
                   return false;
                 }
                  else 
                    {   
                     
                    }
        
            }   
            
		//First Name
		if(!ValidateTextBox('txtFirstName','Required first name'))
		return false;
		if(!ValidateTextBoxMinMax('txtFirstName',3,40,'firstname'))
			return false;
		//First Name
		if(!ValidateTextBox('txtLastName','Required last name'))
			return false;
		if(!ValidateTextBoxMinMax('txtLastName',3,40,'lastname'))
			return false;
		//DOB
		if(!ValidateDropDownlist('ddlYear','Required to select year'))
			return false;
		if(!ValidateDropDownlist('ddlMonth','Required to select month'))
			return false;
		if(!ValidateDropDownlist('ddldate','Required to select date'))
			return false;
		//Email
		var txtEmail = document.getElementById(JobSeekerMasterName + 'txtEmail');
		if(!echeck(txtEmail.value))
		{
			txtEmail.focus();
			return false;
		}
		//Phone
		if(!ValidateTextBox('txtPhone','Required phone number'))
			return false;
		//Mobile
		if(!ValidateTextBox('txtMobile','Required mobile number'))
			return false;
		if(!ValidateTextBoxMinMax('txtMobile',10,22,'mobile number'))
			return false;
		//Country
		if(!ValidateDropDownlist('ddlCountry','Required to select country'))
			return false;
		//State
		if(!ValidateDropDownlist('ddlState','Required to select state'))
			return false;
		//City
		if(!ValidateDropDownlist('ddlCity','Required to select city'))
			return false;
		//Address
		if(!ValidateTextBox('txtAddress','Required address'))
			return false;
		if(!ValidateTextBoxMinMax('txtAddress',3,250,'address'))
			return false;
		//Pincode
		if(!ValidateTextBox('txtPincode','Required pincode'))
			return false;
		if(!ValidateTextBoxLength('txtPincode',6))
			return false;
		//UG
		if(!ValidateDropDownlist('ddlUGDegree','Required to select UG degree'))
			return false;
		if(!ValidateDropDownlist('ddlUniversity','Required to select UG university'))
			return false;
		//Professional Information
		if(!ValidateDropDownlist('ddlCurrentIndustry','Required to select current industry'))
			return false;
		if(!ValidateDropDownlist('ddlFunctionalArea','Required to select functional area'))
			return false;
		if(!ValidateTextBox('txtCurrentEmployer','Required current employer'))
			return false;
		if(!ValidateTextBoxMinMax('txtCurrentEmployer',3,60,'current employer'))
			return false;
		if(!ValidateTextBox('txtCurrentRole','Required current role'))
			return false;
		if(!ValidateTextBoxMinMax('txtCurrentRole',3,60,'current role'))
			return false;
		if(!ValidateDropDownlist('ddlYears','Required to select years'))
			return false;			
		if(!ValidateDropDownlist('ddlMonths','Required to select months'))
			return false;
		var ddlYears = document.getElementById(JobSeekerMasterName + 'ddlYears');
		var ddlMonths = document.getElementById(JobSeekerMasterName + 'ddlMonths');
		if(ddlYears.selectedIndex == 1 && ddlMonths.selectedIndex == 0)
		{	
			alert('Required to select more than a month of experience.')
			ddlMonths.focus();
			return false;
		}
		//General Information
		if(!ValidateTextBox('txtCurrentCTC','Required current CTC'))
			return false;	
	
		if((ddlYears.selectedIndex > 1  && ddlMonths.selectedIndex > 1) || (ddlYears.selectedIndex > 1  && ddlMonths.selectedIndex == 1) )
		{				       
		    if(!ValidateTextBoxMinMax('txtCurrentCTC',4,15,'current CTC'))
			    return false;
		    if(!ValidateValueGreater('txtCurrentCTC',0,'current CTC'))
			    return false;
		    if(!ValidateTextBox('txtExpectedCTC','Required expected CTC'))
			    return false;
		    if(!ValidateTextBoxMinMax('txtExpectedCTC',4,15,'expected CTC'))
			    return false;	
			   if(!ValidateValueGreater('txtExpectedCTC',0,'expected CTC'))
			  return false;	 
		}	
		
		//Check multiple items selected in the location
		var lstLocation = document.getElementById(JobSeekerMasterName + "lstPreferedLocation");
		var SelectedCount = 0;
		var SelectedValue = "0";
		if(lstLocation != null)
		{
			for(var i = 0; i < lstLocation.length; i++)
			{
				if(lstLocation.options[i].selected)
				{
					SelectedCount = SelectedCount + 1;
					SelectedValue = lstLocation.options[i].value;
				}
			}
			//VAlidate here
			if(SelectedCount < 2)
			{
				if(parseInt(SelectedValue) < 1)
				{
					alert("Required to select preferred location");
					lstLocation.focus();
					return false;
				}
			}
		}
		//End of the location 
		//Resume Information
		if(document.getElementById(JobSeekerMasterName + "Pnl_ResInfo").style.display == 'none')
		{
			return true;
		}
		else
		{
			if(!ValidateTextBox('txtResumeTitle','Required resume title'))
				return false;
			if(!ValidateTextBoxMinMax('txtResumeTitle',3,50,'resume title'))
				return false;
			if(!checkFileExt('FileUpload1',true,'D'))
				return false;
		}
		return true;
	}
	catch(err)
	{
		alert(err.message);
		return false;
	}
}

function fnValidateEmployerProfile()
{
	try
	{
	
	   if (document.getElementById('ctl00_contentplaceholder1_txtPhone').value.length != 0)
             {
                        
                 var Alphaname = document.getElementById('ctl00_contentplaceholder1_txtPhone').value;    
                 var regex1 = /^\+91\-((\d{1})?[0-9]\d{1,3})\-?[1-9]\d{5,8}$/; 
                 if (!regex1.test(Alphaname)) 
                 {          
                   alert("Please Enter Valid Phone Number");           
                   document.getElementById('ctl00_contentplaceholder1_txtPhone').focus();
                   return false;
                 }
        
            }            
             if (document.getElementById('ctl00_contentplaceholder1_txtPincode').value.length != 0)
             {
            
                 var Alphaname = document.getElementById('ctl00_contentplaceholder1_txtPincode').value;    
                 var regex1 = /^[0-9]+$/;          
                 if (!regex1.test(Alphaname)) 
                 {
                   alert("Please Enter Valid PinCode");           
                   document.getElementById('ctl00_contentplaceholder1_txtPincode').focus();
                   return false;
                 }          
            } 	
	
		var btnSubmit = document.getElementById(JobSeekerMasterName + "Submit");
		//First Name
		if(!ValidateTextBox('txtFirstName','Required first name'))
			return false;
		if(!ValidateTextBoxMinMax('txtFirstName',3,40,'first name'))
			return false;
		//First Name
		if(!ValidateTextBox('txtLastName','Required last name'))
			return false;
		if(!ValidateTextBoxMinMax('txtLastName',3,40,'last name'))
			return false;		
		//Email
		var txtEmail = document.getElementById(JobSeekerMasterName + 'txtEmail');
		if(!echeck(txtEmail.value))
		{
			txtEmail.focus();
			return false;
		}		
		//Phone
		if(!ValidateTextBox('txtPhone','Required phone number'))
			return false;
		if(!ValidateTextBoxMinMax('txtPhone',8,20,'phone number'))
			return false;
		//company name
		if(!ValidateTextBox('txtCompanyName','Required company name'))
		    return false;
		if(!ValidateTextBoxMinMax('txtCompanyName',3,50,'company name'))
			return false;
		//Validate URL
//		if(!validateURL('txtImageLink'))
//			return false;
		//Country
		if(!ValidateDropDownlist('ddlCountry','Required to select country'))
			return false;
		//State
		if(!ValidateDropDownlist('ddlState','Required to select state'))
			return false;
		//City
		if(!ValidateDropDownlist('ddlCity','Required to select city'))
			return false;
		//Address
		if(!ValidateTextBox('txtAddress','Required address'))
			return false;
		if(!ValidateTextBoxMinMax('txtAddress',3,250,'address'))
				return false;
		//Pincode
		if(!ValidateTextBox('txtPincode','Required pincode'))
			return false;
		if(!ValidateTextBoxLength('txtPincode',6))
			return false;	
		//Company Email
		var txtCompanyEmail = document.getElementById(JobSeekerMasterName + 'txtCompanyEmail');
		if(!echeck(txtCompanyEmail.value))
		{
			txtCompanyEmail.focus();
			return false;
		}
		//Phone
		if(!ValidateTextBox('txtCompanyPhone','Required company phone number'))
			return false;	
		if(!ValidateTextBoxMinMax('txtCompanyPhone',8,20,'company phone number'))
			return false;	
		//Check Image File
		if(btnSubmit.value != 'Update')
		{
			if(!checkFileExt('flCompanyLogo',true,'I'))
				return false;
		}
		else
		{
			if(!checkFileExt('flCompanyLogo',false,'I'))
				return false;
		}
		return true;				
	}
	catch(err)
	{
		alert(err.message);
		return false;
	}
}


//Check the email
function echeck(str) 
{
	try
	{
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
 		 return true	
 	}
 	catch(err)
 	{
 		return true;
 	}			
}
function checkFileExt(id,isCheckNull,Type) 
{
	try
	{
		var ctrl = document.getElementById(JobSeekerMasterName + id);
		 //retrieve our control
		 if(ctrl.value == "" || ctrl.value == null)
		 {
				if(isCheckNull)
				{
					ctrl.focus();
					if(Type == 'I')
						alert("Company logo is required.");
					else //Resume
						alert("Resume to be uploaded.");
					return false;
				}
				return true;
		 }
		 var ext = ctrl.value.match(/\..+$/);
		 var validExtensions = new Array(".jpeg", ".jpg", ".bmp",".tif",".png",".JPEG", ".JPG", ".BMP",".TIF",".PNG");
		 if(Type != 'I')
			validExtensions = new Array(".doc", ".docx",".DOC", ".DOCX");
		 var allowSubmit = false;
		 for (var i = 0; i < validExtensions.length; i++) 
       {
         //check to see if it's the proper extension
         if (validExtensions[i] == ext) 
         { 
             //it's the proper extension
             allowSubmit = true; 
         }
      }
		 if (allowSubmit) 
		 {
			return allowSubmit;
		 }
		 else 
		 {
			  //let the user know they selected a wrong file extension
			  if(Type != 'I')
					alert("Only files with extensions .doc, .docx are allowed");
			  else
					alert("Only files with extensions  .jpeg, .jpg, .bmp, .tif, .png are allowed");
			  ctrl.focus();
			  return allowSubmit;
		 }
		 return allowSubmit;
	}
	catch(err)
	{
		alert(err.message);
		return false;
	}
}
function ValidateCompareField(txt1,txt2,Message)
{
	try
	{
		var obj1 = document.getElementById(JobSeekerMasterName + txt1);
		var obj2 = document.getElementById(JobSeekerMasterName + txt2);
		var vValue = obj1.value.replace(/^\s+|\s+$/g, '');
		if(obj1.value != obj2.value)
		{
			alert(Message);
			obj2.focus();
			return false;
		}
		return true;
	}
	catch(err)
	{
		return false;
	}
}
function ValidateTextBox(id,Message)
{
	try
	{
		var txt = document.getElementById(JobSeekerMasterName + id);
		var vValue = txt.value.replace(/^\s+|\s+$/g, '');
		if(vValue.length == 0)
		{
			alert(Message);
			txt.value = vValue;
			txt.focus();
			return false;
		}
		return true;
	}
	catch(err)
	{
		return false;
	}
}
function ValidateDropDownlist(id,Message)
{
	try
	{
		var ddl = document.getElementById(JobSeekerMasterName + id);
		if(ddl.selectedIndex == 0)
		{
			alert(Message);
			ddl.focus();
			return false;
		}
		return true;
	}
	catch(err)
	{
		return false;
	}
}
function ValidateTextBoxMinMax(id,Min,Max,Name)
{
	try
	{
		var txt = document.getElementById(JobSeekerMasterName + id);
		var vValue = txt.value.replace(/^\s+|\s+$/g, '');
		var vLength = vValue.length;
		if(vLength < Min || vLength > Max)
		{
			alert('Min ' + Min + ' and Max ' + Max + ' letters required for ' + Name);
			txt.focus();
			return false;
		}
		return true;
	}
	catch(err)
	{
		return false;
	}
}
function ValidateMinMaxSalary(id,Min,Max,Name)
{
	try
	{
		var txt = document.getElementById(JobSeekerMasterName + id);
		var vValue = txt.value.replace(/^\s+|\s+$/g, '');
		var vLength = vValue.length;
		if(vValue.length != 0 && vValue != "0")
		{
			if(vLength < Min || vLength > Max)
			{
				alert('Min ' + Min + ' and Max ' + Max + ' letters required for ' + Name);
				txt.focus();
				return false;
			}
		}
		return true;
	}
	catch(err)
	{
		return false;
	}
}
function ValidateTextBoxLength(id,Length)
{
	try
	{
		var txt = document.getElementById(JobSeekerMasterName + id);
		var vValue = txt.value.replace(/^\s+|\s+$/g, '');
		var vLength = vValue.length;
		if(vLength != Length)
		{
			alert('Pincode requires ' + Length + ' digits');
			txt.focus();
			return false;
		}
		else if(parseInt(vValue) == 0)
		{
			alert('Enter valid pincode.');
			txt.focus();
			return false;
		}
		else
			return true;
		return true;
	}
	catch(err)
	{
		return false;
	}
}
//Enter the Interger value should be greater than limit value
function ValidateValueGreater(id,Limit,Name)
{
	try
	{
		var txt = document.getElementById(JobSeekerMasterName + id);
		var vValue = txt.value.replace(/^\s+|\s+$/g, '');
		var vIntValue = parseInt(vValue);
		if(vIntValue <= Limit)
		{	  		
	      if(Limit==0)
	          {
                alert('Enter more than ' + Limit + ' for ' + Name);
			          txt.focus();
			          return false;
            }	  
       else
       {        
			      alert('Enter more than < ' + Limit + ' > for ' + Name);
			      txt.focus();
			      return false;
		    }	
		}
		return true;
	}
	catch(err)
	{
		return false;
	}
}
//check two object that greater than min
function ValidateValueGreaterMinimum(id1, id2 , Name)
{
	try
	{
		var txt1 = document.getElementById(JobSeekerMasterName + id1);
		var txt2 = document.getElementById(JobSeekerMasterName + id2);
		var vValue1 = txt1.value.replace(/^\s+|\s+$/g, '');
		var vValue2 = txt2.value.replace(/^\s+|\s+$/g, '');
		if(vValue1.length > 0 && vValue2.length > 0)
		{
			var vIntValue1 = parseInt(vValue1);
			var vIntValue2 = parseInt(vValue2);
			if(vIntValue2 < vIntValue1)
			{
				alert('Maximum ' + Name + ' should be greater than minimum ' + Name);
				txt2.focus();
				return false;
			}
		}
		return true;
	}
	catch(err)
	{
		return false;
	}
}
function ValidateTextBoxCharacter(id,Length,Name)
{
	try
	{
		var txt = document.getElementById(JobSeekerMasterName + id);
		var vValue = txt.value.replace(/^\s+|\s+$/g, '');
		var vLength = vValue.length;
		if(vLength > Length)
		{
			alert(Name + ' requires minimum ' + Length + ' characters.');
			txt.focus();
			return false;
		}
		return true;
	}
	catch(err)
	{
		return false;
	}
}
function isPhoneNumber(e)
{
    try
    {
        var key_code =(window.event) ? event.keyCode : e.which;
        //+ , - , ( , ).
        if(key_code == 40 || key_code == 41 || key_code == 43 || key_code == 45)
        {
			          return true;    
		    }
		    else if(key_code > 47 && key_code < 58)
		     {
			          return true;    
		    }
		     else if((key_code==8 || key_code==0 ))
		    {
           return true;        
         }
        else
        {
            return false;        
        }
    }
    catch(err)
    {
        //alert(err.message);
        return false;
    }
}
function isAlphabetOnly(e)
{
    try
    {
        var key_code =(window.event) ? event.keyCode : e.which;
        if(key_code == 32)
            return false;
        else if((key_code<=90 && key_code>64 ))
	        return true;
        else if((key_code<=122 && key_code>96 ))
	        return true;
        else if((key_code==8 || key_code==0 ))
            return true;        
        else
            return false;        
    }
    catch(err)
    {
        //alert(err.message);
        return false;
    }
}
function isAlphabetOnlyWithSpace(e)
{
    try
    {
        var key_code =(window.event) ? event.keyCode : e.which;
        if(key_code > 64 && key_code < 91)
	        return true;
        else if((key_code > 96 && key_code < 123))
	        return true;
        else if(key_code == 8 || key_code == 0 || key_code == 32)
            return true;        
        else
            return false;        
    }
    catch(err)
    {
        //alert(err.message);
        return false;
    }
}
function HideSpecialCharacter(e)
{
    try
    {
        var keycode =(window.event) ? event.keyCode : e.which;
        if( (keycode >= 47 && keycode <= 57) || (keycode >= 65 && keycode <= 90) || (keycode >= 97 && keycode <= 122) || keycode == 32 ) 
				return true; 
			else
				return false; 
    }
    catch(err)
    {
        //alert(err.message);
        return false;
    }
}

function fnKeyPressIsNumericjob(e) 
{    
 
    var bt=document.getElementById('ctl00_contentplaceholder1_btnNormalSearch');    
    try
    {
       var key_code =(window.event) ? event.keyCode : e.which;
       
       if(key_code == 13) 
       {          
          bt.click();
          return false;
       }
        else
            return true;
            
    }
    catch(err)
    {
        return false;
    }
} 


function isNumericOnly(e)
{
    try
    {
        var key_code =(window.event) ? event.keyCode : e.which;       
        if((key_code>47 && key_code<58 ))
            return true;
        else if((key_code==8 || key_code==0 ||key_code==43))
            return true;
        else
           return false;
    }
    catch(err)
    {
         //alert(err.message);
        return false;
    }
} 
function ClearObject(id)
{
    try
    {
			var txt = document.getElementById(JobSeekerMasterName + id);
			txt.value = "";
    }
    catch(err)
    {
        
    }
} 
function fnModalPopUpClose()
{
	$find('mdlBehaviourId').hide();
}
function validateURL(id)
{
	try
    {
			var txt = document.getElementById(JobSeekerMasterName + id);
			var vValue = txt.value.replace(/^\s+|\s+$/g, '');
			if(vValue.length > 0)
			{
				var j = new RegExp();
				j.compile("^[A-Za-z]+://[A-Za-z0-9-]+\.[A-Za-z0-9]+"); 
				if (!j.test(vValue))
				{ 
					alert("Please enter valid URL.");
					txt.focus();
					return false;
				}
			}
			return true;
    }
    catch(err)
    {
        return false;
    }
	
}
