function GetXmlHttpObject()
{
	var objXMLHttp=null;
	try{
		objXMLHttp=new XMLHttpRequest();
	}
	catch(e)
	{
		try{
			objXMLHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try{
				objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	return objXMLHttp;
}

function isValidNumber(strMsg)
{
	var str2;
	var iCount;
	var i;
	iCount=-1;
	i=0;
	str2=strMsg.split(",");
	while(i!=-1){
		i=strMsg.indexOf(",",i+1);
		iCount=iCount+1;
	}
	for(i=0;i<=iCount;i++){
		if(isNaN(str2[i])===true){
			return false;
		}
	}
	return true;
}

function IsNumeric(sText){
	var ValidChars="0123456789.";
	var IsNumber=true;
	var Char;
	for(var i=0;i<sText.length&&IsNumber===true;i++){
		Char=sText.charAt(i);
		if(ValidChars.indexOf(Char)==-1)
		{
			IsNumber=false;
		}
	}
	return IsNumber;
}
function removeEnterKey(str1)
{
	var str2;
	var i;
	str2='';
	for(i=0;i<str1.length;i++)
	{
		if(str1.charCodeAt(i)!=10&&str1.charCodeAt(i)!=13)
		{
			str2=str2+str1.charAt(i);
		}
	}
	return str2;
}

function xyz()
{
	return true;
	window.event.returnValue=false;
	window.clipboardData.effectAllowed=true;
	window.clipboardData.clearData();
}

function trimAll(sString)
{
	while(sString.substring(0,1)==' ')
	{
		sString=sString.substring(1,sString.length);
	}
	while(sString.substring(sString.length-1,sString.length)==' ')
	{
		sString=sString.substring(0,sString.length-1);
	}
	while(sString.charCodeAt(sString.length-1)==10||sString.charCodeAt(sString.length-1)==13)
	{
		sString=sString.substring(0,sString.length-1);
	}
	return sString;
}

function echeck(str)
{
	var at='@';
	var dot='.';
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	var lastdot=str.lastIndexOf(dot);
	var stlen=str.split("@");
	if(stlen[0].length<1)
	{
		alert("Please Enter the E-mail Address");
		return false;
	}
	if(stlen[0].length<3)
	{
		alert("Invalid EmailID");
		return false;
	}
	if(str.substring(lat+2,lat+3)==dot)
	{
		alert("Invalid EmailID");
		return false;
	}
	if(str.indexOf(at)==-1){
		alert("Invalid E-mail ID");
		return false;
	}
	if(lstr==lastdot+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;
}

function validatemobilenumber(strmno)
{
	strmno=trimAll(strmno);
	if(strmno=='')
	{
		alert("Please Enter Mobile Number");
		return false;
	}
	if(strmno.charAt(0)=='+')
	{
		window.alert("No need to have a starting '+'. The mobile number should be a 10 digit number ");
		return false;
	}
	if(isNaN(strmno)==true||strmno.contains('.'))
	{
		alert("Enter Number Only");
		return false;
	}
	if(strmno.length<6)
	{
		window.alert("Short Code Mobile Number(s) are not supported !!");
		return false;
	}
	if(strmno.charAt(0)==0)
	{
		window.alert("No need to have a starting '0'. The mobile number should be a 10 digit number ");
		return false;
	}
	if(strmno.length!=10)
	{
		window.alert("Please check the Mobile Number. The mobile number should be a 10 digit number");
		return false;
	}
	if(strmno.charAt(0)!=9 && strmno.charAt(0)!=8 && strmno.charAt(0)!=7 )
	{
		window.alert('First digit of the Mobile No. should be either 9 or 8 0r 7');
		return false;
	}
	if((strmno.charAt(1)!=0)&&(strmno.charAt(1)!=1)&&(strmno.charAt(1)!=2)&&(strmno.charAt(1)!=3)&&(strmno.charAt(1)!=5)&&(strmno.charAt(1)!=4)&&(strmno.charAt(1)!=6)&&(strmno.charAt(1)!=7)&&(strmno.charAt(1)!=8)&&(strmno.charAt(1)!=9))
	{
		window.alert('This is not a valid india mobile number ! Please Check');
		return false;
	}
	return true;
}

function validatepincode(strmno)
{
	strmno=trimAll(strmno);
	if(strmno=='')
	{
		alert("Please Enter Pincode");
		return false;
	}
	if(isNaN(strmno)==true||strmno.contains('.'))
	{
		alert("Enter Number Only");
		return false;
	}
	if(strmno.length < 6)
	{
		window.alert("Short pin code Number(s) are not supported !!");
		return false;
	}
	if(strmno.length > 6)
	{
		window.alert("Please check the pincode. The pincode should be a 6 digit number");
		return false;
	}
	
	return true;
}


function validate_international_mobilenumber(strmno)
{
	strmno=trimAll(strmno);
	if(strmno=='')
	{
		alert("Please Enter Mobile Number");
		return false;
	}
	if(strmno.charAt(0)=='+')
	{
		window.alert("No need to have a starting '+'. The mobile number should be a 10 digit number ");
		return false;
	}
	if(isNaN(strmno)==true||strmno.contains('.'))
	{
		alert("Enter Number Only");
		return false;
	}
	if(strmno.length<5)
	{
		window.alert("Short Code Mobile Number(s) are not supported !!");
		return false;
	}
	if(strmno.charAt(0)==0)
	{
		window.alert("No need to have a starting '0'. The mobile number should be a 10 digit number ");
		return false;
	}
	
	/*if(strmno.length!=10)
	{
		window.alert("Please check the Mobile Number. The mobile number should be a 10 digit number");
		return false;
	}

	if(strmno.charAt(0)!=9)
	{
		window.alert('First digit of the Mobile No. should be 9');
		return false;
	}
	if((strmno.charAt(1)!=0)&&(strmno.charAt(1)!=1)&&(strmno.charAt(1)!=2)&&(strmno.charAt(1)!=3)&&(strmno.charAt(1)!=5)&&(strmno.charAt(1)!=4)&&(strmno.charAt(1)!=6)&&(strmno.charAt(1)!=7)&&(strmno.charAt(1)!=8)&&(strmno.charAt(1)!=9))
	{
		window.alert('This is not a valid india mobile number ! Please Check');
		return false;
	}*/


	return true;
}


String.prototype.contains=function(t)
{
	return this.indexOf(t)>=0?true:false;
};

function checkspecialcharchar(str) {
	var iChars = "!@#$%^&*()+=[]\\;,/{}|\":<>?";
	//alert(str.length);
	for (var i = 0; i < str.length; i++) {
	if (iChars.indexOf(str.charAt(i)) != -1) {
		return false;
	} 
	}
		return true;		
}

/*function checkspecialcharchar(str) {
	var iChars = "!@#$%^&*()+=[]\\;,/{}|\":<>?";
	//alert(str.length);
	for (var i = 0; i < str.length; i++) {
	if (iChars.indexOf(str.charAt(i)) != -1) {
		return false;
	} 
	}
		return true;		
}
*/
function validation()
{
	
		if((document.getElementById("jobtitle").value=="")|| (document.getElementById("conemail").value=="") || (document.getElementById("workexpx").value=="") || (document.getElementById("workexpy").value=="") || (document.getElementById("location").value==""))
	 {
	  alert("Please Enter The All *  Mandatory Field With Valid data");
	  return false;
	 }
	 if (document.getElementById("conemail").value=="")
	  {
		alert("Please enter your Username/Email_Id.");
		document.getElementById("conemail").focus();
		return false;
	  }

	if(!CheckEmail(document.getElementById("conemail").value))
	  {
    	alert("Please enter valid Email_Id");
		document.getElementById("conemail").focus();
		return false;
	 }
	   
	
	//Job Title field validation
	jobtitle=tocheckblankfield(document.getElementById("jobtitle").value,"Job Title");
	document.getElementById("divjobtitle").innerHTML=jobtitle;
		
	//Functional area field validation
	functional=tocheckblankselection(document.getElementById("cboPresFuncArea").value,"Functional Area");
	document.getElementById("divfunction").innerHTML=functional;
		
	//SubFunctional area field validation
	subfunctional=tocheckblankselection(document.getElementById("cboAreaSpecial").value,"Sub Functional Area");
	document.getElementById("divsubfunctional").innerHTML=subfunctional;
		
	//Description field validation
	description=tocheckblankfield(document.getElementById("description").value,"Description");
	document.getElementById("divdescription").innerHTML=description;
	
	/*Key Skills field validation
	keyskill=tocheckblankfield(document.getElementById("keyskill").value,"Key Skills");
	document.getElementById("divkeyskill").innerHTML=keyskill;*/
	
	//Qualification field validation/
	qualification=tocheckblankselectionv(document.getElementById("qualification").value,"Qualification"); 
	document.getElementById("divqualification").innerHTML=qualification;
	
	//minimum work Experiance  field validation
	workexp=titledfield(document.getElementById("workexpx").value,"Min Work Experience");
	document.getElementById("divexp").innerHTML=workexp;
	
	//maximum work Experiance  field validation
	workexpy=titledfield(document.getElementById("workexpy").value,"Max Work Experience");
	document.getElementById("divexpy").innerHTML=workexpy; 
	
	//compair the Expeiance  field values
	divexperr=expfield(document.getElementById("workexpx").value, document.getElementById("workexpy").value);
	document.getElementById("divexpmax").innerHTML=divexperr;
	
	//Username and email field validation	 
	emailr=emailfield(document.getElementById("conemail").value);
	document.getElementById("divcontactemail").innerHTML=emailr;
	    
	//Current Location field validation
	clocation=tocheckblankselection(document.getElementById("location").value,"Current Location");
	document.getElementById("divlocation").innerHTML=clocation;

	if(jobtitle=="" && functional=="" && description=="" && workexp=="" && divexperr=="" && workexpy=="" && emailr=="" && clocation=="" && qualification=="" ) 
	{
		return true;
	}
	else
	{
		return false;
	}
	
}

var temp = 'dummy';
function messagedisplay(msg)
{
	document.getElementById(msg).style.display = 'block';
	if (temp == msg)
	{
	temp = msg;
	}
	else
	{
	document.getElementById(temp).style.display = 'none';
	temp = msg;
	}
}

function messagehide(msg)
{
	document.getElementById(msg).style.display = 'none';
}

function makeAllReadOnlyExceptemail()
{
	var count = document.forms[0].elements.length;
	for (i=0; i<count; i++) 
  	{
		var element = document.forms[0].elements[i]; 
		element.disabled=true;
	}
	document.postForm.txtEmail1.disabled=false;
}

function makeAllenable()
{
	var count = document.forms[0].elements.length;
	for (i=0; i<count; i++) 
  	{
		var element = document.forms[0].elements[i]; 
		element.disabled=false;
	}
	document.postForm.txtEmail1.disabled=false;
	document.postForm.Submit.disabled=false;
}

function enableField(x)
{ 
	if(x==1)
	{
	 	makeAllenable();//document.postForm.txtPassword.disabled=false;
	}
	else
	{ 
		makeAllReadOnlyExceptemail(); //document.postForm.txtPassword.disabled=true;
		
	}
}

function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				req = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
	}
	
	
	
	function getCity(strURL) {		
		
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('emaildiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}
	
	
	function getFunctionqualification(strURL) {		
		
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('subdiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}
	
		
	function getFunction(strURL) {		
		
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('functiondiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}
	
function special(strString) 
{
   var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?~"; 
   for (var i = 0; i < data.length; i++) {
  	
	if (iChars.indexOf(data.charAt(i)) != -1) {
  	  alert ("Your string has special characters. \nThese are not allowed.");
	  
  	  return false;
  	}
	else {
		return true;		
	}
  }
}

function validatemobilenumber_landing(strmno)
{
	strmno=trimAll(strmno);
	if(strmno=='')
	{
		alert("Please Enter Mobile Number");
		return false;
	}
	if(strmno.charAt(0)=='+')
	{
		window.alert("No need to have a starting '+'. The mobile number should be a 11 digit number ");
		return false;
	}
	if(isNaN(strmno)==true||strmno.contains('.'))
	{
		alert("Enter Number Only");
		return false;
	}
	if(strmno.length<6)
	{
		window.alert("Short Code Mobile Number(s) are not supported !!");
		return false;
	}
	if(strmno.charAt(0)==0)
	{
		window.alert("No need to have a starting '0'. The mobile number should be a 11 digit number ");
		return false;
	}
	if(strmno.length!=11)
	{
		window.alert("Please check the Mobile Number. The mobile number should be a 11 digit number");
		return false;
	}
	if(strmno.charAt(0)!=9 && strmno.charAt(0)!=8 && strmno.charAt(0)!=7 )
	{
		window.alert('First digit of the Mobile No. should be either 9 or 8 0r 7');
		return false;
	}
	if((strmno.charAt(1)!=0)&&(strmno.charAt(1)!=1)&&(strmno.charAt(1)!=2)&&(strmno.charAt(1)!=3)&&(strmno.charAt(1)!=5)&&(strmno.charAt(1)!=4)&&(strmno.charAt(1)!=6)&&(strmno.charAt(1)!=7)&&(strmno.charAt(1)!=8)&&(strmno.charAt(1)!=9))
	{
		window.alert('This is not a valid india mobile number ! Please Check');
		return false;
	}
	return true;
}

function validation()
{
	//Name field validation
	namex=namefield(document.getElementById("txtFirstName").value);
	document.getElementById("divfirstname").innerHTML=namex;
		
	//Designation field validation	 
	designationx=tocheckblankfield(document.getElementById("designation").value,"Designation");
	document.getElementById("divdesignation").innerHTML=designationx;
		
	//Contact /Phone no field validation
	contactx=phonefield(document.getElementById("contact").value,"Phone number");
	document.getElementById("divcontact").innerHTML=contactx;
	
	//Company Name field validation	 
	companyname=tocheckblankfield(document.getElementById("companyname").value,"Company Name"); 
	document.getElementById("divcompanyname").innerHTML=companyname;
	
	//Company Address field validation	 
	companyaddress=tocheckblankfield(document.getElementById("companyaddress").value,"Company Address");
	document.getElementById("divcompanyaddress").innerHTML=companyaddress;
	
	//Industry area field validation
	industry=titledfield(document.getElementById("industry").value,"Industry");
	document.getElementById("divindustry").innerHTML=industry;
	
	//Website field validation	 
	website=websitefieldnotcompulsary(document.getElementById("website").value,"Website");
	document.getElementById("divwebsite").innerHTML=website;
	
	//Company Profile field validation	 
	companyprofile=tocheckblankfield(document.getElementById("companyprofile").value,"Company Profile");
	document.getElementById("divcompanyprofile").innerHTML=companyprofile;
	
	if( namex=="" && designationx=="" && contactx==""  && companyname=="" && companyaddress=="" && industry=="" && website=="" && companyprofile=="")
	{
		return true;
	}
	else
	{
		
		return false;
	}
	
}
function messagedisplay(msg)
{
	document.getElementById(msg).style.display = 'block';
	if (temp == msg)
	{
	temp = msg;
	}
	else
	{
	document.getElementById(temp).style.display = 'none';
	temp = msg;
	}
}

function messagehide(msg)
{
	document.getElementById(msg).style.display = 'none';
}

function makeAllReadOnlyExceptemail()
{
	var count = document.forms[0].elements.length;
	for (i=0; i<count; i++) 
  	{
		var element = document.forms[0].elements[i]; 
		element.disabled=true;
	}
	document.postForm.txtEmail1.disabled=false;
}
function makeAllenable()
{
	var count = document.forms[0].elements.length;
	for (i=0; i<count; i++) 
  	{
		var element = document.forms[0].elements[i]; 
		element.disabled=false;
	}
	document.postForm.txtEmail1.disabled=false;
	document.postForm.Submit.disabled=false;
}
function enableField(x)
{ 
	if(x==1)
	{
	 	makeAllenable();//document.postForm.txtPassword.disabled=false;
	}
	else
	{ 
		makeAllReadOnlyExceptemail(); //document.postForm.txtPassword.disabled=true;
		
	}
}

function sel()
{
	$chSelected=0;
	var lb = document.getElementById('cboLfCity');
	var flag = false;
	for(i=0; i<lb.length; i++)
	{
		if(lb.options[i].selected){
			$chSelected++; 
		}
	}
		if(chSelected > 3)
		{
		alert("you can select maximum of three options.");
		input.alCh.focus();
		doc=0;
		}
 } 



function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				req = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
	}
	
	
	
	function getCity(strURL) {		
		
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('emaildiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}
	
	
	function getFunctionqualification(strURL) {		
		
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('subdiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}
	
	function getFunction(strURL) {		
		
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById('functiondiv').innerHTML=req.responseText;						
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}
	
function special_dot(strString) 
{
   var iChars = "!@#$%^&*()+=-[]\\\';,/{}|\":<>?~"; 
   for (var i = 0; i < data.length; i++) {
  	
	if (iChars.indexOf(data.charAt(i)) != -1) {
  	  alert ("Your string has special characters. \nThese are not allowed.");
	  
  	  return false;
  	}
	else {
		return true;		
	}
  }
}

function is_username(name) {
		var pattern = new RegExp(/^[a-zA-Z]+[A-Za-z0-9_.@]{2,11}$/);
		return pattern.test(name);
	}


