/*
AUTHOR  -  T.Salam
DATE    -  12-03-2009
DESC    -  Validation Script
TITLE   -  SOFM
	0 - No Validation
	1 - Not Empty Validation
	2 - Alphabetic Validation
	3 - Alphanumeric Validation(User Name validation)
	4 - Email Validation
	5 - Mobile Validation
	6 - Phone Validation
	7 - Password Validation
	8 - Image Type Validation(user defined)
	9 - Numeric Validation
   10 - Confirm Password and Confirm Email validation	
   11 - Custom Validation;   
   12 - Edit Image Validation
   13 - Phone 3 input type validation
   14 - Min and Max validation
*/
var cursor='1';
var focus_id = '';
var dateFocus = 0;
var descFocus = 0;

Class={
	explodeArray:function(item, delimiter){
		tempArray = new Array(1);
		var Count = 0;
		var tempString = new String(item);
		while (tempString.indexOf(delimiter)>0){
			tempArray[Count] = tempString.substr(0,tempString.indexOf(delimiter));
			tempString = tempString.substr(tempString.indexOf(delimiter)+1, tempString.length-tempString.indexOf(delimiter)+1);
			Count = Count+1
		}
		tempArray[Count] = tempString;
		return tempArray;
	},
	trim:function(name){
		
		 
		
		return name.replace(/^\s+|\s+$/g, '');
	},
	checkType:function(id, label, exp, type, errorType, previousFieldId){
		switch(errorType){
		 case 1:
			 Class.emptyValidation(type, id, label, type);
			 break;
		 case 2:
			 Class.checkExp(id, exp, label);
			 break;
		 case 3:
			 Class.bothValidation(id, exp, label, type);
			 break;
		 case 5:
			 (Class.trim(document.getElementById(id).value)!='') ? Class.checkConfirm(id, previousFieldId, label): Class.emptyValidation(type, id, label, type);
			 break;	
		 case 6:			
			 if(Class.trim(document.getElementById(id).value)!='' && Class.trim(document.getElementById(previousFieldId).value)!=''){
				
				  Class.checkConfirmMin(id, previousFieldId, label);
			 }
			 else if(Class.trim(document.getElementById(previousFieldId).value) == 'fresher'){
				 Class.messageNoneValidation(label, 'basic', id);	
				 Class.messageNoneValidation(label, 'adv', id);	
			 }
			 else{
				 if(Class.trim(document.getElementById(id).value)==''){					
				     Class.emptyValidation(type, id, label, type);
				 }
				 else{
					 Class.emptyValidation(type, previousFieldId, label, type);
				 }
			 }
			 break;	
		}
	},	
	editNotEmptyValidation:function(type, id, label, errorType){	
		if((document.getElementById(id).value) != ''){
		var exp = null;
		Class.checkType(id, label, exp, type, errorType);
		}
	},
	notEmptyValidation:function(type, id, label, errorType){
		
		var exp = null;
		Class.checkType(id, label, exp, type, errorType);		
	},
	notEmptyMonthValidation:function(type, id, label, errorType){
		var exp = null;
		if((document.getElementById("exp1").value) != 'Fresher'){
			Class.checkType(id, label, exp, type, errorType);	
		}
	},	
	notEmptyNonMonthValidation:function(type, id, label, errorType){
		var exp = null;
		if((document.getElementById("it1").value) != 'Fresher'){
			Class.checkType(id, label, exp, type, errorType);	
		}
	},	
	specharNumericValidation:function(type, id, label, errorType){
		//alert(document.getElementById(id).value);
		if(document.getElementById(id).value !=''){
			if(!IsNumeric(document.getElementById(id).value)){
				document.getElementById('phone_adv').style.display = "block";
				document.getElementById('phone_basic').style.display = "none";
				document.getElementById(id).style.borderColor = '#FF240F';
				errMsg = 'failed';
			}else{
				document.getElementById('phone_adv').style.display = "none";
				document.getElementById('phone_basic').style.display = "none";
				document.getElementById(id).style.borderColor = '';
			}
		}else{
			var exp = null;
			Class.checkType(id, label, exp, type, errorType);
		}
		
	},	
	cityNotEmptyValidation:function(type, id, label, errorType){

		if(document.getElementById(id).style.display !=''){		
			var exp = null;
			Class.checkType(id, label, exp, type, errorType);	
		}else{
			Class.messageNoneValidation(label, 'basic', id)
		}
	},
	profileNotEmptyValidation:function(type, id, label, errorType){	
		var exp = null;
		if((document.getElementById("Designation_22").value) != ''){
			
		Class.checkType(id, label, exp, type, errorType);
		}
	},
	educateNotEmptyValidation:function(type, id, label, errorType){	
		var exp = null;
		if((document.getElementById("Degree_24").value) != ''){
		Class.checkType(id, label, exp, type, errorType);
		}
	},
	desigNotEmptyValidation:function(type, id, label, errorType){	
		var exp = null;
		if(document.getElementById("Company_21").value != '' || document.getElementById("Detail_21").value != '' || document.getElementById("dm").value != '' ||  
			document.getElementById("dy").value != ''	|| document.getElementById("tm").value != '' ||  document.getElementById("ty").value != ''){
			Class.checkType(id, label, exp, type, errorType);
		
		}
	},
	qualificationNotEmptyValidation:function(type, id, label, errorType){	
		var exp = null;		
		if(document.getElementById("Institute_23").value != '' || document.getElementById("DetailOther_23").value != '' || document.getElementById("daym").value != '' ||  document.getElementById("dayy").value != '' ||
		document.getElementById("datem").value != '' || document.getElementById("datey").value != ''){
			Class.checkType(id, label, exp, type, errorType);
		}
		
	},
	alphabeticValidation:function(type, id, label, errorType){	
		var exp = /^[a-zA-Z]+$/;
		Class.checkType(id, label, exp, type, errorType);		
	},
	alphanumericValidation:function(type, id, label, errorType){	
		var exp=new RegExp("^[a-zA-Z0-9]{6,30}$");
		Class.checkType(id, label, exp, type, errorType);		
	},
	allCharWithMinMaxValidation:function(type, id, label, errorType, min, max){
		
		 
		var exp=new RegExp("^[a-zA-Z0-9\w_|@|#|!|$|%|^|&|*|(|)|+|.|,|-|:|;|\|`|~|'|+|<|>| |]{"+min+","+max+"}$");
		 
		Class.checkType(id, label, exp, type, errorType);		
	},
	emailValidation:function(type, id, label, errorType){		
		var exp = /^\w+([\.-]?\w+)*@\w+([\.-]?\w\{2,3}+)*(\.\w{2,3})+$/;
		//alert(document.getElementById(id).value);
		Class.checkType(id, label, exp, type, errorType);		
	},
	indiamobileValidation:function(type, id, label, errorType){		
		var exp = "^([9]{1})([234789]{1})([0-9]{8})$";//Indian Mobile number
		Class.checkType(id, label, exp, type, errorType);		
	},
	tocheckSpace:function(type, id, label, errorType){
		if(document.getElementById(id).value !=''){

			var my_string = document.getElementById(id).value;

			var where_is_space = my_string.indexOf(' ');
										
			if(where_is_space==-1){
 			//if(my_string.indexOf(' ')){
				Class.messageNoneValidation(label, 'adv', id);
			}else{
				dateFocus = 1;
				Class.messageValidation(label, 'adv');
			}
			//var exp = new RegExp("/^[a-zA-Z0-9\-\_\s]{2,}$/");
			//Class.checkType(id, label, exp, type, errorType);		
		}else{		

			Class.messageNoneValidation(label, 'adv', id);
		}
	},
	mobileValidation:function(type, id, label, errorType){		
		var exp=new RegExp("^([\+]?([0-9]{0,3}[-| |]))?([\+]?([0-9]{10,14}))?$");
		Class.checkType(id, label, exp, type, errorType);				
	},
	mobile1Validation:function(type, id, label, errorType){	
		
		if(document.getElementById("Pho_13_Pho2,Pho3").value =='' && document.getElementById("Pho2").value == '' && document.getElementById("Pho3").value == ''){
			//alert("true");
		var exp=new RegExp("^([\+]?([0-9]{0,3}[-| |]))?([\+]?([0-9]{10,14}))?$");
		Class.checkType(id, label, exp, type, errorType);
		}else{
			
			Class.messageNoneValidation(label, 'basic', id)
		}
		
	},
	customCommentValidation:function(type, id, label, errorType){
		if(document.getElementById(id).value!=''){	
			if(document.getElementById(id).value.length > 500){
				var exp = null;
				Class.checkType(id, label, exp, type, errorType);
			}else{
				Class.messageNoneValidation(label, 'adv',id)
			}
		}		
	},
	customCommentValidation1:function(type, id, label, errorType){
		if(document.getElementById(id).value!=''){
			if(document.getElementById(id).value.length > 500){
				descFocus = 1;
				Class.messageValidation(label, 'adv', id)
			}else{
				Class.messageNoneValidation(label, 'adv',id)
			}
		}else{
			var exp = null;
			Class.checkType(id, label, exp, type, errorType);
		}		
	},
	phoneValidation:function(type, id, label, errorType){		
		//var exp=new RegExp("^([\(]?[\+]?([0-9]{0,3})?[\)]?[\-\ ])?(([0-9]{0,5})[\-\ ])?([0-9]{7,14})$");
		var exp=new RegExp("^([\+ ]?([0-9 ]{0,3}[-| | ]))?([\+ ]?([0-9 ]{10,14}))?$");
		Class.checkType(id, label, exp, type, errorType);		
	},
	passwordValidation:function(type, id, label, errorType){	
		var exp=new RegExp("\^(?=.*[A-Za-z])(?=.*[0-9])(?=.*[\w_|@|#|!|$|%|^|&|*|(|)|+|.|,|-|:|;|\|`|~|'|+|<|>|]).{6,30}$");
		Class.checkType(id, label, exp, type, errorType);		
	},
	customValidation:function(type, id, label, exp, errorType){
		var exp=new RegExp(exp);
		//alert(document.getElementById(id).value);
		Class.checkType(id, label, exp, type, errorType);	
	},
	editCustomValidation:function(type, id, label, exp, errorType){
		if((document.getElementById(id).value) != ''){
		var exp=new RegExp(exp);
		Class.checkType(id, label, exp, type, errorType);	
		}else{
			Class.messageNoneValidation(label, 'basic',id);
			Class.messageNoneValidation(label, 'adv',id);
		}
	},
	threeInputValidation:function(type, id, label, exp, errorType){

		myPhone = Class.explodeArray(exp, ',');	

			 if((Class.trim(document.getElementById(id).value) != '') && (Class.trim(document.getElementById(myPhone[0]).value) != '')  && (Class.trim(document.getElementById(myPhone[1]).value) != '')){
				//alert("fdsgdfgdfgdfg");
				 var exp1 = "^[0-9.+-]+$";	
				var exp2 =  "^[0-9.+-]+$";
				var exp3 =  "^[0-9.+-]+$";

				if(document.getElementById(id).value.match(exp1)  && document.getElementById(myPhone[0]).value.match(exp2) && document.getElementById(myPhone[1]).value.match(exp3)){
						Class.messageNoneValidation(label, 'basic',id)						
					        document.getElementById(myPhone[0]).style.borderColor = '';
				
				}else{
					document.getElementById(myPhone[0]).style.borderColor = '#FF240F';
					Class.messageValidation(label, 'adv', id);
				}
			}else{
				//alert("dfsd");
			Class.messageValidation(label, 'basic', id);
					document.getElementById(myPhone[0]).style.borderColor = '#FF240F';
			}

	},
	threeInputValidationyear:function(type, id, label, exp, errorType){

		myPhone = Class.explodeArray(exp, ',');		

		if((Class.trim(document.getElementById(id).value) != '') && (Class.trim(document.getElementById(myPhone[0]).value) != '')){
			Class.messageNoneValidation(label, 'basic', id);
		}else{
			Class.messageValidation(label, 'basic', id);
		}
	},
	
editThreeInputValidation:function(type, id, label, exp, errorType){
		myPhone = Class.explodeArray(exp, ',');	
		if((Class.trim(document.getElementById(id).value) == '') || (Class.trim(document.getElementById(myPhone[0]).value) == '') || (Class.trim(document.getElementById(myPhone[1]).value) == '')){
			Class.messageValidation(label, 'basic', id)
			}
		else{
			Class.messageNoneValidation(label, 'basic', id)
			}
		}
	,
	
	
	
	
	
	
	editexperienceInputValidation:function(type, id, label, exp, errorType){
		 if(document.getElementById("exp1_78").value == '' && document.getElementById("exp2").value == ''){
			 document.getElementById("exp1_basic").style.display = "block";
		 }else{
			 document.getElementById("exp1_basic").style.display = "none";
			 
		 }	 
		}
	,
	
	editdateofbirthInputValidation:function(type, id, label, exp, errorType){
		 if(document.getElementById("dob1_79").value == '' || document.getElementById("dob2").value == '' ||  document.getElementById("dob3").value == ''){
			 document.getElementById("dob1_basic").style.display = "block";
			 document.getElementById(id).style.borderColor = '#FF240F';
			 document.getElementById("dob2").style.borderColor = '#FF240F';
			 document.getElementById("dob3").style.borderColor = '#FF240F';
		 }else{
			 document.getElementById("dob1_basic").style.display = "none";
			 document.getElementById(id).style.borderColor = '';
			 document.getElementById("dob2").style.borderColor = '';
			 document.getElementById("dob3").style.borderColor = '';			 
		 }	 
		}
	,
	
	
	editnonitexpInputValidation:function(type, id, label, exp, errorType){
		 if(document.getElementById("it1_80").value == '' && document.getElementById("it2").value == ''){
			 document.getElementById("it1_basic").style.display = "block";
			 document.getElementById(id).style.borderColor = '#FF240F';
		 }else{
			 document.getElementById("it1_basic").style.display = "none";
			 document.getElementById(id).style.borderColor = '';
			 
		 }	 
		}
	,
	
	
	editareacodeInputValidation:function(type, id, label, exp, errorType){
//alert("test");
		 if(document.getElementById("areacode1_81").value == '' || document.getElementById("areacode2").value == ''){
			 document.getElementById("areacode1_basic").style.display = "block";
			 document.getElementById(id).style.borderColor = '#FF240F';
		 }else{
//alert(id);
			//var exp=new RegExp("0123456789.-,+");
			//var testvalue = Class.checkType(id, label, exp, type, errorType);
//alert(testvalue);		
			document.getElementById("areacode1_basic").style.display = "none";
			document.getElementById(id).style.borderColor = '';
			 
		 }	 
		}
	,
	
	
	editcontactInputValidation:function(type, id, label, exp, errorType){
		 if(document.getElementById("eve1_82").value == '' || document.getElementById("eve2").value == ''){
			 document.getElementById("evecode1_basic").style.display = "block";
			 document.getElementById(id).style.borderColor = '#FF240F';
		 }else{
			 document.getElementById("evecode1_basic").style.display = "none";
			document.getElementById(id).style.borderColor = '';			 
		 }	 
		}
	,

	editThreeInputOptionalValidation:function(type, id, label, exp, errorType){
		myPhone = Class.explodeArray(exp, ',');	
		//alert(Class.trim(document.getElementById(id).value));
		if((Class.trim(document.getElementById(id).value) == '') && (Class.trim(document.getElementById(myPhone[0]).value) == '')  && (Class.trim(document.getElementById(myPhone[1]).value) == '')){
			
			Class.messageNoneValidation(label, 'basic', id)			
		}
		else if((Class.trim(document.getElementById(id).value) != '') && (Class.trim(document.getElementById(myPhone[0]).value) != '')  && (Class.trim(document.getElementById(myPhone[1]).value) != '')){
			
			Class.messageNoneValidation(label, 'basic', id)			
		}
		else if((Class.trim(document.getElementById(id).value) != '') || (Class.trim(document.getElementById(myPhone[0]).value) != '')  || (Class.trim(document.getElementById(myPhone[1]).value) != '')){			
			
			Class.messageValidation(label, 'basic', id)
		}
		else{
			
			Class.messageNoneValidation(label, 'basic', id)
		}
	},
	editDateInputValidation:function(type, id, label, exp, errorType){
		myPhone = Class.explodeArray(exp, ',');	
		//if((document.getElementById("Designation_22").value) != ''){
		if((Class.trim(document.getElementById(id).value) == '') || (Class.trim(document.getElementById(myPhone[0]).value) == '')  || (Class.trim(document.getElementById(myPhone[1]).value) == '')){
			
		
			Class.messageValidation(label, 'basic', id)
		}
		else{
			
			Class.messageNoneValidation(label, 'basic', id)
		}
	},
rentTwoInputValidation:function(type, id, label, exp, errorType,name){ 
		
		var imagePath1 = document.getElementById("projectattach_77_project1").value;
		var pathLength1 = imagePath1.length;
		var lastDot1 = imagePath1.lastIndexOf(".");
		var fileType1 = imagePath1.substring(lastDot1,pathLength1);
		
		 
		if(document.getElementById("project1").value != '' && document.getElementById("projectattach_77_project1").value != ''){
		
		 if(document.getElementById("project1").value != '' && document.getElementById("projectattach_77_project1").value != ''){
			 document.getElementById("UploadFile_adv").style.display = "block";
			 document.getElementById("UploadFile_adv").innerHTML='Please enter the Description or Select a valid file to upload';
		 }else{			 
			 document.getElementById("UploadFile_adv").style.display = "none";
		 }		 
		}else{ 
			if(document.getElementById("project1").value == '' && document.getElementById("projectattach_77_project1").value != ''){
		 
			 	if((fileType1 != ".pdf") && (fileType1  !=  ".doc") && (fileType1 !=  ".rtf")) {
					 document.getElementById("UploadFile_adv").style.display = "block";
					 document.getElementById("UploadFile_adv").innerHTML='Please select Valid Attachment';
					 document.getElementById("projectattach_77_project1").value = '';
				 }else{			 
				 	document.getElementById("UploadFile_adv").style.display = "none";
				 }  
			}else if(document.getElementById('project1').value != ''  && document.getElementById("project1").value == ''){
				if(document.getElementById('project1').value.length > 500){
					//document.getElementById("project1_adv").style.display = 'block';
					Class.messageValidation('project1', 'adv')	
				}else{
					//document.getElementById("project1_adv").style.display = 'none';
					Class.messageNoneValidation('project1', 'adv', id)	
				}
			}		
		 
		}
	},
	
	
	editFromToDateValidation:function(type, id, label, exp, errorType){
		
		//alert(document.getElementById("Designation_22").value);
		if((document.getElementById("Designation_22").value) != ''){
		myPhone = Class.explodeArray(exp, ',');
		fromDate = document.getElementById(""+myPhone[0]+"_28_"+myPhone[1]+","+myPhone[2]+"").value;
		fromMonth = document.getElementById(myPhone[1]).value;
		fromYear = document.getElementById(myPhone[2]).value;
		toDate = document.getElementById(""+myPhone[3]+"_28_"+myPhone[4]+","+myPhone[5]+"").value;
		toMonth = document.getElementById(myPhone[4]).value;
		toYear = document.getElementById(myPhone[5]).value;
		var fromdt =new Date(fromYear, fromMonth-1, fromDate) ;
		var todt =new Date(toYear, toMonth-1, toDate) ;
		var from = fromdt.getTime();
		var to = todt.getTime();
		//alert(from);
		//alert(to);
		if(fromDate !='' && fromMonth !='' && fromYear !='' && toDate !='' && toMonth !='' && toYear !=''){
			if(from > to){
				//alert(""+myPhone[0]+"_19_"+myPhone[1]+","+myPhone[2]+"");
				Class.messageValidation(label, 'adv', ""+myPhone[0]+"_28_"+myPhone[1]+","+myPhone[2]+"");
			}
			else{
				Class.messageNoneValidation(label, 'adv', id)
			}		
		}
	
		}
	},
	educateDateInputValidation:function(type, id, label, exp, errorType){
		myPhone = Class.explodeArray(exp, ',');	
		if((document.getElementById("Degree_24").value) != ''){
		if((Class.trim(document.getElementById(id).value) == '') || (Class.trim(document.getElementById(myPhone[0]).value) == '')  || (Class.trim(document.getElementById(myPhone[1]).value) == '')){
			
		
			Class.messageValidation(label, 'basic', id)
		}
		else{
			
			Class.messageNoneValidation(label, 'basic', id)
		}
		

	}
	},
	educateFromToDateValidation:function(type, id, label, exp, errorType){
		
		//alert(document.getElementById("Designation_22").value);
		if((document.getElementById("Degree_24").value) != ''){
		myPhone = Class.explodeArray(exp, ',');
		fromDate = document.getElementById(""+myPhone[0]+"_30_"+myPhone[1]+","+myPhone[2]+"").value;
		fromMonth = document.getElementById(myPhone[1]).value;
		fromYear = document.getElementById(myPhone[2]).value;
		toDate = document.getElementById(""+myPhone[3]+"_30_"+myPhone[4]+","+myPhone[5]+"").value;
		toMonth = document.getElementById(myPhone[4]).value;
		toYear = document.getElementById(myPhone[5]).value;
		var fromdt =new Date(fromYear, fromMonth-1, fromDate) ;
		var todt =new Date(toYear, toMonth-1, toDate) ;
		var from = fromdt.getTime();
		var to = todt.getTime();
		//alert(from);
		//alert(to);
		if(fromDate !='' && fromMonth !='' && fromYear !='' && toDate !='' && toMonth !='' && toYear !=''){
			if(from > to){
				//alert(""+myPhone[0]+"_19_"+myPhone[1]+","+myPhone[2]+"");
				Class.messageValidation(label, 'adv', ""+myPhone[0]+"_30_"+myPhone[1]+","+myPhone[2]+"");
			}
			else{
				Class.messageNoneValidation(label, 'adv', id)
			}		
		}
	
		}
	},
	fromToDateValidation:function(type, id, label, exp, errorType){
		myPhone = Class.explodeArray(exp, ',');	
		
		fromDate = document.getElementById(""+myPhone[0]+"_19_"+myPhone[1]+","+myPhone[2]+"").value;
		fromMonth = document.getElementById(myPhone[1]).value;
		fromYear = document.getElementById(myPhone[2]).value;
		toDate = document.getElementById(""+myPhone[3]+"_19_"+myPhone[4]+","+myPhone[5]+"").value;
		toMonth = document.getElementById(myPhone[4]).value;
		toYear = document.getElementById(myPhone[5]).value;
		var fromdt =new Date(fromYear, fromMonth-1, fromDate) ;
		var todt =new Date(toYear, toMonth-1, toDate) ;
		var from = fromdt.getTime();
		var to = todt.getTime();
		//alert(from);
		//alert(to);
		if(fromDate !='' && fromMonth !='' && fromYear !='' && toDate !='' && toMonth !='' && toYear !=''){
			if(from > to){
				//alert(""+myPhone[0]+"_19_"+myPhone[1]+","+myPhone[2]+"");
				Class.messageValidation(label, 'adv', ""+myPhone[0]+"_19_"+myPhone[1]+","+myPhone[2]+"");
			}
			else{
				Class.messageNoneValidation(label, 'adv', id)
			}		
		}
	},
	fromToDateOptionalValidation:function(type, id, label, exp, errorType){
		myPhone = Class.explodeArray(exp, ',');	
		
		fromDate = document.getElementById(""+myPhone[0]+"_32_"+myPhone[1]+","+myPhone[2]+"").value;
		fromMonth = document.getElementById(myPhone[1]).value;
		fromYear = document.getElementById(myPhone[2]).value;
		toDate = document.getElementById(""+myPhone[3]+"_32_"+myPhone[4]+","+myPhone[5]+"").value;
		toMonth = document.getElementById(myPhone[4]).value;
		toYear = document.getElementById(myPhone[5]).value;
		var fromdt =new Date(fromYear, fromMonth-1, fromDate) ;
		var todt =new Date(toYear, toMonth-1, toDate) ;
		var from = fromdt.getTime();
		var to = todt.getTime();
		//alert(from);
		//alert(to);
		if(fromDate !='' && fromMonth !='' && fromYear !='' && toDate !='' && toMonth !='' && toYear !=''){
			if(from > to){
				//alert(""+myPhone[0]+"_19_"+myPhone[1]+","+myPhone[2]+"");
				Class.messageValidation(label, 'adv', ""+myPhone[0]+"_32_"+myPhone[1]+","+myPhone[2]+"");
			}
			else{
				Class.messageNoneValidation(label, 'adv', id)
			}		
		}
	},
	imageTypeValidation:function(type, id, label, errorType){
		var exp = "^.+\.((jpg)|(gif)|(jpeg)|(png)|(JPG)|(GIF)|(PNG)|(JPEG))$";	
		Class.checkType(id, label, exp, type, errorType);		
	},
	imageFileValidation:function(type, id, label, formats, errorType){		
		myArray = Class.explodeArray(formats, ',');	
		var length = myArray.length;
		var exp1 = "^.+\.(";			
		exp2=formats;
		exp3=")$";
		exp = exp1.concat(exp2, exp3);
		var exp=new RegExp(exp);
		Class.checkType(id, label, exp, type, errorType);		
	},
	imageFileValidationOptional:function(type, id, label, formats, errorType){	
		if(document.getElementById(id).value !=''){
			myArray = Class.explodeArray(formats, ',');	
			var length = myArray.length;
			var exp1 = "^.+\.(";			
			exp2=formats;
			exp3=")$";
			exp = exp1.concat(exp2, exp3);
			var exp=new RegExp(exp);
			Class.checkType(id, label, exp, type, errorType);		
		}
	},
	imageFileValidation2:function(type, id, label, formats, errorType){		
		myArray = Class.explodeArray(formats, ',');	
		var length = myArray.length;
		var exp1 = "^.+\.(";			
		exp2=formats;
		exp3=")$";
		exp = exp1.concat(exp2, exp3);
		var exp=new RegExp(exp);		
		Class.checkExp2(id, exp, label);
	},
	numberValidation:function(type, id, label, errorType){
		var max = document.getElementById(id).maxLength;	
		var exp=new RegExp("^[0-9]$");		
		Class.checkType(id, label, exp, type, errorType);			
	},	
	confirmValidation:function(type, currentFieldId, currentLabel, previousFieldId, errorType){			
		var exp = null;	
		Class.checkType(currentFieldId, currentLabel, exp, type, 5, previousFieldId);
		
	},
	tinyMceValidation:function(type, id, label, errorType, strlength){
		var exp = null;	
		strInputCode =tinyMCE.get(id).getContent();
		strInputCode = strInputCode.replace(/&(lt|gt);/g, function (strMatch, p1){
			return (p1 == "lt")? "<" : ">";
		});
		var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, "");
		for(i=1;i<50;i++){
		strTagStrippedText=strTagStrippedText.replace("&nbsp;","");
		}	
		if(tinyMCE.get(id).getContent()=="" || strTagStrippedText==""){	
			
			tiny_edit = 1;
			Class.messageValidation(label, 'basic', id);	
			
		}
		else{
			Class.messageNoneValidation(label, 'basic', id);
			if(strTagStrippedText.length > strlength){
				tiny_edit = 1;
				Class.messageValidation(label, 'adv', id);	
			}
			else{
				Class.messageNoneValidation(label, 'adv', id)
			}
		}
				
	},
	editConfirmValidation:function(type, currentFieldId, currentLabel, previousFieldId, errorType){
		if(document.getElementById(currentFieldId).value !='' || document.getElementById(previousFieldId).value !=''){
		var exp = null;	
		Class.checkType(currentFieldId, currentLabel, exp, type, 5, previousFieldId);
		}else{
			Class.messageNoneValidation(currentLabel, 'basic', id);
			Class.messageNoneValidation(currentLabel, 'adv', id);
		}
		
	},
UrlValidation2:function(type, id, label, formats, errorType){		
		
		
		
		myArray = Class.explodeArray(formats, ',');	
		var length = myArray.length;
		var exp1 = "^.+\.(";			
		exp2=formats;
		exp3=")$";
		exp = exp2;
		var exp=new RegExp(exp);		
		Class.checkExp2(id, exp, label);
	},
	minMaxValidation:function(type, currentFieldId, currentLabel, previousFieldId, errorType){			
		var exp = null;	
		Class.checkType(currentFieldId, currentLabel, exp, type, 6, previousFieldId);		
	},
	dateMinMaxValidation:function(type, currentFieldId, currentLabel, previousFieldId, errorType){	
		alert("validation");
		alert(document.getElementById(currentFieldId).value);
		var exp = null;	
		Class.checkType(currentFieldId, currentLabel, exp, type, 6, previousFieldId);		
	},
	radioButtonValidation:function(id, label){
		var checked = false;
		var names1 = document.getElementById(id).name;
		var x=document.getElementsByName(""+names1+"");
		for (var i=0; i<x.length; i++){
		    if (x[i].checked) {  
		    	checked = true; 
		    	break;  
		    }  
		} 
		(!checked) ? Class.messageValidation(label, 'basic', id): Class.messageNoneValidation(label, 'basic', id);
	},
	textBoxValidation:function(id, label){
		(Class.trim(document.getElementById(id).value) == '') ? Class.messageValidation(label, 'basic', id): Class.messageNoneValidation(label, 'basic', id);		
	},
	emptyValidation: function(type, id, label){
		(type == '3') ? Class.radioButtonValidation(id, label): Class.textBoxValidation(id, label);		
	},
	checkExp:function(id, exp, label){
		((document.getElementById(id).value).match(exp)) ? Class.messageNoneValidation(label, 'adv', id): Class.messageValidation(label, 'adv', id);
	},	
	checkExp2:function(id, exp, label){
		if(document.getElementById(id).value==''){
			Class.messageNoneValidation(label, 'adv', id) }
		else{ 
			if((document.getElementById(id).value).match(exp)){ 
				Class.messageNoneValidation(label, 'adv', id) 
			}
			else{ 
				Class.messageValidation(label, 'adv', id);
			}
			
		}
	},	
	bothValidation:function(id, exp, label, type){
		(Class.trim(document.getElementById(id).value) == '') ? Class.emptyValidation(type, id, label): Class.checkExp(id, exp, label);		
	},
	checkConfirm:function(currentFieldId, previousFieldId, currentLabel){	
		(document.getElementById(currentFieldId).value == document.getElementById(previousFieldId).value) ? Class.messageNoneValidation(currentLabel, 'adv'): Class.messageValidation(currentLabel, 'adv', currentFieldId);	
		
	},
	checkConfirmMin:function(currentFieldId, previousFieldId, currentLabel){	
		(parseInt(document.getElementById(currentFieldId).value) > parseInt(document.getElementById(previousFieldId).value)) ? Class.messageNoneValidation(currentLabel, 'adv'): Class.messageValidation(currentLabel, 'adv', currentFieldId);	
		
	},
	findType:function(type){
		if(type == 'text')
			type = '0';
		else if(type == 'password')
			type = '0';
		else if(type == 'select-one')
			type = '1';
		else if(type == 'file')
			type = '2';
		else if(type == 'radio')
			type = '3';
		return type;
	},
	messageValidation:function(label, msg, id){
		if(cursor=='1'){



			cursor++;
			focus_id = id;			
		}	
		Class.messageDisableValidation(label, msg, id);
		
		document.getElementById(""+label+"_"+msg+"").style.display = 'block';
		document.getElementById(id).style.borderColor = '#FF240F';		
		errMsg = 'failed';
	},
	messageNoneValidation:function(label, msg, id){
		Class.messageDisableValidation(label, msg, id);
		//alert(""+label+"_"+msg+"");
		document.getElementById(""+label+"_"+msg+"").style.display = 'none';
		document.getElementById(id).style.borderColor = '';
	},
	messageDisableValidation:function(label, msg, id, errtype){
		var x=document.getElementsByName(""+label+"_basic").length;	
		var y=document.getElementsByName(""+label+"_adv").length;
		if(msg == 'adv'){			
			if(x!=0){
				document.getElementById(""+label+"_basic").style.display = 'none';
			}
		}	
		else if(msg == 'basic'){			
			if(y!=0){
				document.getElementById(""+label+"_adv").style.display = 'none';
			}
		}	
	},countryDropDown:function(){
		var states = new Array("Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei", "Bulgaria", "Burkina Faso", "Burma", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Central African Republic", "Chad", "Chile", "China", "Colombia", "Comoros", "Congo, Democratic Republic", "Congo, Republic of the", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Fiji", "Finland", "France", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Greece", "Greenland", "Grenada", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Mongolia", "Morocco", "Monaco", "Mozambique", "Namibia", "Nauru", "Nepal", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Qatar", "Romania", "Russia", "Rwanda", "Samoa", "San Marino", " Sao Tome", "Saudi Arabia", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Yemen", "Zambia", "Zimbabwe");
		return states;
	}
}
/*
 * NAME      -	function valForm()
 * PARAM     -	name
 * DESC      -	this function is used for submit the form
*/
function callSofm(name){
	var divCollection = document.getElementsByTagName("div");
    for (var i=0; i<divCollection.length; i++) {
        if(divCollection[i].getAttribute("id") == "flash_id") {
        	document.getElementById('flash_id').style.display='none';
        } 
    }
	errMsg='success';		
	var length = name.elements.length;
	var type;
	var myArray;
	var myArray2;
	
	for(i=0; i<=length-1; i++){
		
		var errorType;
		myArray = Class.explodeArray(name.elements[i].id, '_');			
		type = name.elements[i].type;
		if((document.getElementById(""+myArray[0]+"_basic")) && (document.getElementById(""+myArray[0]+"_adv") == null)){
			errorType = 1;
		}
		else if((document.getElementById(""+myArray[0]+"_adv")) && (document.getElementById(""+myArray[0]+"_basic") == null)){			
			errorType = 2;
		}
		else if((document.getElementById(""+myArray[0]+"_adv")) && (document.getElementById(""+myArray[0]+"_basic"))){
			errorType = 3;
		}
		else if((document.getElementById(""+myArray[0]+"_adv")==null) && (document.getElementById(""+myArray[0]+"_basic") ==null)){
			errorType = 4;
		}		
		type = Class.findType(type);
		switch(myArray[1]){
			case '1':	
				Class.notEmptyValidation(type, name.elements[i].id, myArray[0], errorType);	
			break;
			case '2':
				Class.alphabeticValidation(type, name.elements[i].id, myArray[0], errorType);				
			break;
			case '3':
				Class.alphanumericValidation(type, name.elements[i].id, myArray[0], errorType);
			break;
			case '4':
				Class.emailValidation(type, name.elements[i].id, myArray[0], errorType);
			break;
			case '5':
				Class.mobileValidation(type, name.elements[i].id, myArray[0], errorType);
			break;
			
			case '6':
				Class.phoneValidation(type, name.elements[i].id, myArray[0], errorType);
			break;
			case '7':
				Class.passwordValidation(type, name.elements[i].id, myArray[0], errorType);
			break;
			case '8':
				Class.imageFileValidation(type, name.elements[i].id, myArray[0], myArray[2], errorType);
			break;			
			case '9':
				Class.numberValidation(type, name.elements[i].id, myArray[0], myArray[2], errorType);
			break;
			case '10':
				myArray2 = Class.explodeArray(name.elements[i-1].id, '_');
				Class.confirmValidation(type, name.elements[i].id, myArray[0], name.elements[i-1].id, myArray2[0], errorType);
			break;	
			case '11':	
				Class.customValidation(type, name.elements[i].id, myArray[0], myArray[2], errorType);
			break;	
			case '12':
				Class.imageFileValidation2(type, name.elements[i].id, myArray[0], myArray[2], '6');
			break;
			case '13':	
				Class.threeInputValidation(type, name.elements[i].id, myArray[0], myArray[2], errorType);
			break;	
			case '14':	
				myArray2 = Class.explodeArray(name.elements[i-1].id, '_');
				Class.minMaxValidation(type, name.elements[i].id, myArray[0], name.elements[i-1].id, myArray2[0], errorType);
			break;	
			case '15':
				myArray2 = Class.explodeArray(name.elements[i-1].id, '_');
				Class.editConfirmValidation(type, name.elements[i].id, myArray[0], name.elements[i-1].id, myArray2[0], errorType);
			break;	
			case '16':	
				Class.editCustomValidation(type, name.elements[i].id, myArray[0], myArray[2], errorType);
			break;
			case '17':	
				Class.editNotEmptyValidation(type, name.elements[i].id, myArray[0], errorType);	
			break;
			case '18':
				Class.mobile1Validation(type, name.elements[i].id, myArray[0], errorType);
			break;
			
			case '20':	
				myArray2 = Class.explodeArray(name.elements[i-1].id, '_');
				Class.dateMinMaxValidation(type, name.elements[i].id, myArray[0], name.elements[i-1].id, myArray2[0], errorType);
			break;
			case '21':	
				Class.profileNotEmptyValidation(type, name.elements[i].id, myArray[0], errorType);	
			break;
			case '22':	
				Class.desigNotEmptyValidation(type, name.elements[i].id, myArray[0], errorType);	
			break;
			case '23':	
				Class.educateNotEmptyValidation(type, name.elements[i].id, myArray[0], errorType);	
			break;
			case '24':	
				Class.qualificationNotEmptyValidation(type, name.elements[i].id, myArray[0], errorType);	
			break;
			case '25':
				Class.imageFileValidationOptional(type, name.elements[i].id, myArray[0], myArray[2], errorType);
			break;	
			case '26':
				//alert(myArray[2]);
				Class.fromToDateValidation(type, name.elements[i].id, myArray[0], myArray[2], errorType);
			break;	
			case '27':				
				strlength = myArray[2];
				Class.tinyMceValidation(type, name.elements[i].id, myArray[0], errorType, strlength);
			break;
			case '28':	
				Class.editDateInputValidation(type, name.elements[i].id, myArray[0], myArray[2], errorType);
			break;
			case '29':
				//alert(myArray[2]);
				Class.editFromToDateValidation(type, name.elements[i].id, myArray[0], myArray[2], errorType);
			break;
			case '30':	
				Class.educateDateInputValidation(type, name.elements[i].id, myArray[0], myArray[2], errorType);
			break;
			case '31':
				//alert(myArray[2]);
				Class.educateFromToDateValidation(type, name.elements[i].id, myArray[0], myArray[2], errorType);
			break;
			case '32':
				//alert(myArray[2]);
				Class.editThreeInputOptionalValidation(type, name.elements[i].id, myArray[0], myArray[2], errorType);
			break;
			case '33':
				//alert(myArray[2]);
				Class.fromToDateOptionalValidation(type, name.elements[i].id, myArray[0], myArray[2], errorType);
			break;
			case '34':	
				Class.cityNotEmptyValidation(type, name.elements[i].id, myArray[0], errorType);	
			break;
			case '39':				
				Class.allCharWithMinMaxValidation(type, name.elements[i].id, myArray[0], errorType, myArray[2], myArray[3]);
			break;
			case '40':	
				Class.customCommentValidation(type, name.elements[i].id, myArray[0], errorType);	
			break;
			case '41':	
				Class.customCommentValidation1(type, name.elements[i].id, myArray[0], errorType);	
			break;	
			case '42':
				Class.indiamobileValidation(type, name.elements[i].id, myArray[0], errorType);
			break;
			case '52':
				Class.UrlValidation2(type, name.elements[i].id, myArray[0], myArray[2], '6');
			break;
			
			case '77':	
				Class.rentTwoInputValidation(type, name.elements[i].id, myArray[0], myArray[2], errorType,name);
			break;
			case '78':	
				Class.editexperienceInputValidation(type, name.elements[i].id, myArray[0], myArray[2], errorType);
			break;
			case '79':	
				Class.editdateofbirthInputValidation(type, name.elements[i].id, myArray[0], myArray[2], errorType);
			break;
			case '80':	
				Class.editnonitexpInputValidation(type, name.elements[i].id, myArray[0], myArray[2], errorType);
			break;
			
			case '81':	
				Class.editareacodeInputValidation(type, name.elements[i].id, myArray[0], myArray[2], errorType);
			break;
			
			case '82':	
				Class.editcontactInputValidation(type, name.elements[i].id, myArray[0], myArray[2], errorType);
			break;
			case '83':
				Class.threeInputValidationyear(type, name.elements[i].id, myArray[0], myArray[2], errorType);
			break;	
			case '84':
				Class.tocheckSpace(type, name.elements[i].id, myArray[0], errorType);
			break;
			case '85':	
				Class.notEmptyMonthValidation(type, name.elements[i].id, myArray[0], errorType);	
			break;
			case '86':	
				Class.notEmptyNonMonthValidation(type, name.elements[i].id, myArray[0], errorType);	
			break;
			case '87':	
				Class.specharNumericValidation(type, name.elements[i].id, myArray[0], errorType);	
			break;
	
		}
	}
	if(errMsg == 'failed'){	
		myArrays = Class.explodeArray(focus_id, '_');
		if(myArrays[0] == 'UploadFiles'){
			window.location = "#UploadFiles";
		}else if(focus_id == "hidscope_1" || focus_id == "exp2" || focus_id == "exp3" || focus_id == "dob1_19_dob2,dob3" || focus_id == "dob2" ||  focus_id == "dob3"  || focus_id == "it2" || focus_id == "it3" || focus_id == "areacode1_13_areacode2,areacode3"  || focus_id == "areacode2" || focus_id == "areacode3" || focus_id == "eve1_13_eve2,eve3"  || focus_id == "eve2" || focus_id == "eve3"){
			//|| focus_id == "it1_83_it2,it3" || focus_id == "exp1_83_exp2,exp3"
		}else {
			if(dateFocus!=1)
			document.getElementById(focus_id).focus();
		}
		cursor=1;		
	}
	
	 
	if(errMsg == 'success'){		
		document.frm.submit();		
	}else{
		return false;
	}	

	
}
function resetSofm(name){	
	var length = name.elements.length;
	var type;
	var myArray;
	name.reset();	
	for(i=0; i<=length-1; i++){
		myArray = Class.explodeArray(name.elements[i].id, '_');	
		if(document.getElementById(""+myArray[0]+"_basic")){
			document.getElementById(""+myArray[0]+"_basic").style.display = 'none';
		}
		if(document.getElementById(""+myArray[0]+"_adv")){
			document.getElementById(""+myArray[0]+"_adv").style.display = 'none';
		}
	}
	return false;
}
/**************************************************************/
/****************NUMERIC VALUE VALIDATION**********************/
/**************************************************************/
	function IsNumeric(strString){
		var strValidChars = "0123456789+-^@*#|() ";
		var strChar;
		var blnResult = true;

		if (strString.length == 0) return false;

		for (i = 0; i < strString.length && blnResult == true; i++)
		   {
		   strChar = strString.charAt(i);
		   if (strValidChars.indexOf(strChar) == -1)
		      {
		      blnResult = false;
		      }
		   }
		return blnResult;
	}


