//common validations
function validateAlpaNumeric(textbox,message)
{
	var amtinv = textbox.value;
	var validStr = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890- ";
	  
	for(i=0;i<=textbox.value.length-1;i++)
	{
		if(validStr.indexOf(amtinv.charAt(i))==-1)
		{
			printMsg("Only alphabets and numbers are allowed in "+message+" field");
			break;
		}
	}
}

function validateAlpaNumericSpecialChars(textbox,message)
{
	var thisStr = textbox.value;
	var validStr = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-()_,:./& ";
	  
	for(i=0;i<=thisStr.length-1;i++)
	{
		if(validStr.indexOf(thisStr.charAt(i))==-1)
		{
			printMsg("Invalid character ' "+thisStr.charAt(i)+" ' entered in "+message);
			break;
		}
	}
}

function compareDate(startdate,enddate,datestring,separator)
{
	brkStdate = startdate.split(separator);
	brkEdate = enddate.split(separator);
	datestr = datestring.split(separator);

	for (var i = 0; i < 3; i++) 
	{   
		if(datestr[i] == "dd")
		{
			//alert(i + " DD " + datestr[i] + " -- " + brkndate[i]);
			DDSt=brkStdate[i];
			DDE=brkEdate[i];
		}
		else
		if(datestr[i] == "mm")
		{
			//alert(i + " MM " + datestr[i] + " -- " + brkndate[i]);
			MMSt=brkStdate[i];
			MME=brkEdate[i];
		} 
		else 
		if((datestr[i] == "yy")  || (datestr[i] == "yyyy"))
		{     
			// alert(i + " YY " + datestr[i] + " -- " + brkndate[i]);
			YearSt=brkStdate[i];
			YearE=brkEdate[i];
		}
	} 
	
	if(parseInt(YearSt) == parseInt(YearE) && parseInt(MMSt) == parseInt(MME) && parseInt(DDSt) == parseInt(DDE))
	{
		return(-1);
	}
	if ( parseInt(YearE) > parseInt(YearSt))
	{
		return (1);
	}
	else if (parseInt(YearE) == parseInt(YearSt))
	{
		if (parseInt(MME) > parseInt(MMSt))
		{
			return (1);
		}
		else if (parseInt(MME) == parseInt(MMSt))
		{
			if(DDSt.substring(0,1)=="0")
			{
				DDSt=DDSt.substring(1,2);
			}
			if (parseInt(DDE) > parseInt(DDSt))
			{
				return (1);
			}	
		}
	}	
	return (-1);
}

function checkBeginningSpace(textbox,msg)
{
	chkString = escape(textbox.value)
    if(chkString.substring(0,3)=="%20")
		printMsg("Space not allowed at the beginning of "+msg);
}

function getnMonth(mm) 
{
	var nMonth;
	if((mm=="JAN") || (mm=="January")) nMonth="1";
	else  if((mm=="FEB") || (mm=="February")) nMonth="2";
	else  if((mm=="MAR") || (mm=="March")) nMonth="3";
	else  if((mm=="APR") || (mm=="April")) nMonth="4";
	else  if((mm=="MAY") || (mm=="May")) nMonth="5";
	else  if((mm=="JUN") || (mm=="June")) nMonth="6";
	else  if((mm=="JUL") || (mm=="July")) nMonth="7";
	else  if((mm=="AUG") || (mm=="August")) nMonth="8";
	else  if((mm=="SEP") || (mm=="September")) nMonth="9";
	else  if((mm=="OCT") || (mm=="October")) nMonth="10";
	else  if((mm=="NOV") || (mm=="November")) nMonth="11";
	else  if((mm=="DEC") || (mm=="December")) nMonth="12";
	return nMonth;
}

function validateStringValue(textbox,msg)
{
	var amtinv = textbox.value;
	var validStr = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ- ";
	  
	for(i=0;i<=textbox.value.length-1;i++)
	{
		if(validStr.indexOf(amtinv.charAt(i))==-1)
		{
			printMsg("Only alphabets are allowed in "+msg+" field");
			break;
		}
	}
}

function validateTextField(textBox,msg)
{
	var fieldValue = textBox.value;
	var ln = fieldValue.length;
	for(var i=0;i<ln;i++) 
	{
		if((fieldValue.charAt(i)=='|') || (fieldValue.charAt(i)=='\'') || (fieldValue.charAt(i)=='"')) 
		{
			printMsg(msg + " cannot contain  |  or  '  or  \"");
			break;		
		}
	}
}

function validatePincode(pincode)
{
	var pin = pincode.value;
	if(isEmpty(stripWhitespace(pin))==false)
	{
		len = pin.length;
		for(x=0;x<len;x++) 
		{
			if( ((pin.charAt(x)<'0') || (pin.charAt(x)>'9'))&& ((pin.charAt(x)<'a') || (pin.charAt(x)>'z')) && ((pin.charAt(x)<'A') || (pin.charAt(x)>'Z'))&&(pin.charAt(x)!=' ') )
			{
				printMsg("Please enter a valid Pincode");
				break;
			}
		}
	}
}

function validateEmail(emailT1,emailT2)
{
	var t0 = emailT1.value;
	if(isEmpty(stripWhitespace(t0))){
		printMsg("Please enter the first half of your Email Id");
	}
	
	var length1 = t0.length;
  	for(var i=0;i<length1;i++)
	{
		if((t0.charAt(i)=='@')||(t0.charAt(i)=='|')||(t0.charAt(i)=='"')||(t0.charAt(i)=='\''))
		{
			printMsg("First word of Email cannot contain |, ', \" or @");
			break;
		}
	}

	var t1 = emailT2.value;
	if(isEmpty(stripWhitespace(t1))){
		printMsg("Please enter the second half of your Email Id");		
	}
	
	length1 = t1.length;
	for(var i=0;i<length1;i++) 
	{
		if((t1.charAt(i)=='@')||(t1.charAt(i)=='|')||(t1.charAt(i)=='"')||(t1.charAt(i)=='\'')) {
			printMsg("Second word of Email cannot contain |, ', \" or @");		
			break;			
		}
	}
	
	var temp1 = t0+"@"+t1;
	if((isEmail(temp1))==false)
	{
		printMsg("Please enter a valid Email Id");		
	}
}

function validatePhoneNumber(textBox,msg)
{
	if((isEmpty(stripWhitespace(textBox.value)))==false)
	{
		pass = textBox.value;
		len = pass.length;
		for(x=0;x<len;x++) 
		{
			if(((pass.charAt(x)<'0') || (pass.charAt(x)>'9')) && ((pass.charAt(x)<'a') || (pass.charAt(x)>'z')) && ((pass.charAt(x)<'A') || (pass.charAt(x)>'Z')) && (pass.charAt(x)!='(') && (pass.charAt(x)!=')') && (pass.charAt(x)!='-') && (pass.charAt(x)!=' ')) 
			{
				printMsg(msg);
				break;
			}
		}
	}
}

/*function validateSSN()
{
	if(document.imtRegn.country[document.imtRegn.country.selectedIndex].value == "United States")
	{
		var s1 = stripWhitespace(document.imtRegn.ssn1.value);
		var s2 = stripWhitespace(document.imtRegn.ssn2.value);
		var s3 = stripWhitespace(document.imtRegn.ssn3.value);
		
		if(isEmpty(s1) || isEmpty(s2) || isEmpty(s3)) 
		{
			printMsg("Please enter your Social Security Number");
		}
		else
		{
			if(s1.length != 3)
			{
				printMsg("The first section of Social Security Number should be of 3 numerals");
				document.imtRegn.ssn1.value = "";
			}
			if(s2.length != 2)
			{
				printMsg("The second section of Social Security Number should be of 2 numerals");
				document.imtRegn.ssn2.value = "";
			}
			if(s3.length != 4)
			{
				printMsg("The third section of Social Security Number should be of 4 numerals");
				document.imtRegn.ssn3.value = "";
			}
			
			if(isNaN(s1) || isNaN(s2) || isNaN(s3))
			{
				printMsg("Please enter a valid numeric Social Security Number");
				document.imtRegn.ssn1.value = "";
				document.imtRegn.ssn2.value = "";
				document.imtRegn.ssn3.value = "";
			}
		}
	}
	else
	{
		document.imtRegn.ssn1.value = "";
		document.imtRegn.ssn2.value = "";
		document.imtRegn.ssn3.value = "";
	}
}*/

function validateDOB()
{
    var dd = document.imtRegn.D1.options[document.imtRegn.D1.options.selectedIndex].value;
	var mm = document.imtRegn.D2.options[document.imtRegn.D2.options.selectedIndex].value;
	var yy = document.imtRegn.D3.options[document.imtRegn.D3.options.selectedIndex].value;

	if(dd == "" || mm == "" || yy == "")
	{
		//alert("In Check Blank");
		printMsg("Please select your Date of Birth");
	}
	else
	{
		document.imtRegn.dob.value = dd+"-"+mm+"-"+yy;
		
		if(!isDate(yy,getnMonth(mm),dd)) 			
		{
			//alert("In not isDate");
			printMsg("Please select a valid Date of Birth");			
		}
		else
		{
			var servdate_val = document.imtRegn.date2.value;
			var date  = servdate_val.substring(0,2); 
			var month = servdate_val.substring(3,5);
			var year  = servdate_val.substring(6,10);
			
			var frmdate  = dd;
			//alert(frmdate);
			var frmmonth = getnMonth(mm);
			//alert(frmmonth);
			var frmyear  = yy;
			//alert(frmyear);
			
			if(parseFloat(frmyear)>parseFloat(year))
			{
				printMsg("Date of Birth cannot be a future date");
				
			}// end -if frmyear > server year
			else if(parseFloat(frmyear)==parseFloat(year))
			{
				if(parseFloat(frmmonth)>parseFloat(month))
				{
					printMsg("Date of Birth cannot be a future date");
					
				}//end-if frm month>server month
				else if(parseFloat(frmmonth)==parseFloat(month))
				{
					if(parseFloat(frmdate)>parseFloat(date))
					{
						printMsg("Date of Birth cannot be a future date");
						
					}// end if frm day== server day
				}//end if month == server
			}// end if year == server year
		}
	}
}
//end common validations


function validateReceiver(address,city,state,pincode,country,emailT1,emailT2,resPh1,resPh2,resPh3,offPh1,offPh2,offPh3,mobileNo,accNumber,accType,micr,bankName,bankBranch,bankCity,bankState,payableAt,nearestLogisticCity,mrzLine2,imtRegn)
{
	initialize_error_msgs();
	
	validateEmail(emailT1,emailT2);
	
	if((resPh1.value == "Country Code") || (resPh2.value == "Area Code") || (resPh3.value == "Tel No"))
	{
		printMsg("Please enter a valid Home Phone");		
	}
	validate_mandatory_tb_with_message(resPh1, "Please enter Country Code for Home Phone");
	validate_numeric_value_with_msg(resPh1, "Country Code for Home Phone");
	checkBeginningSpace(resPh1, "Country Code for Home Phone");
	validate_mandatory_tb_with_message(resPh2, "Please enter Area Code for Home Phone");
	validate_numeric_value_with_msg(resPh2, "Area Code for Home Phone");
	checkBeginningSpace(resPh2, "Area Code for Home Phone");
	validate_mandatory_tb_with_message(resPh3, "Please enter Home Telephone No");
	validate_numeric_value_with_msg(resPh3, "Home Telephone No");
	checkBeginningSpace(resPh3, "Home Telephone No");
	var resPhonelen = document.imtRegn.resPh1.value + document.imtRegn.resPh2.value + document.imtRegn.resPh3.value;
	if((resPhonelen.length) > 25)
	{
	  	printMsg("Length of Home Phone No cannot exceed 25 characters");
	}

	if((offPh1.value == "Country Code") || (offPh2.value == "Area Code") || (offPh3.value == "Tel No"))
	{
		printMsg("Please enter a valid Work Phone");		
	}
	validate_mandatory_tb_with_message(offPh1, "Please enter Country Code for Work Phone");
	validate_numeric_value_with_msg(offPh1, "Country Code for Work Phone");
	checkBeginningSpace(offPh1, "Country Code for Work Phone");	
	validate_mandatory_tb_with_message(offPh2, "Please enter Area Code for Work Phone");
	validate_numeric_value_with_msg(offPh2, "Area Code for Work Phone");
	checkBeginningSpace(offPh2, "Area Code for Work Phone");
	validate_mandatory_tb_with_message(offPh3, "Please enter Work Telephone No");
	validate_numeric_value_with_msg(offPh3, "Work Telephone No");
	checkBeginningSpace(offPh3, "Work Telephone No");
	var offPhonelen = document.imtRegn.offPh1.value + document.imtRegn.offPh2.value + document.imtRegn.offPh3.value;
	if((offPhonelen.length) > 25)
	{
	  	printMsg("Length of Work Phone No cannot exceed 25 characters");
	}
	
	if(mobileNo.value == "Mobile No")
	{
		printMsg("Please enter a valid Mobile Phone No or leave it blank");		
	}
	checkBeginningSpace(mobileNo,"Mobile Phone Number ");
	validate_numeric_value_with_msg(mobileNo,"Mobile Phone Number");
	var mobPhonelen = document.imtRegn.mobileNo.value;
	if((mobPhonelen.length) > 25)
	{
	  	printMsg("Length of Mobile Phone No cannot exceed 25 characters");
	}
	
	validate_mandatory_tb_with_message(address, "Please enter your Address");
	checkBeginningSpace(address,"Address");
	validateTextField(address,"Address");
	
	validate_mandatory_tb_with_message(city, "Please enter your City");
	checkBeginningSpace(city,"City");
	validateStringValue(city,"City");
	
	validate_mandatory_tb_with_message(state, "Please enter your State");
	checkBeginningSpace(state,"State");
	validateStringValue(state,"State");
	
	validate_mandatory_tb_with_message(pincode, "Please enter your Pincode");
	checkBeginningSpace(pincode,"Pincode");
	validatePincode(pincode);
	
	validate_mandatory_tb_with_message(country, "Please select your Country");
	
	validate_mandatory_tb_with_message(accNumber,"Please enter Account Number");
	validateAlpaNumeric(accNumber,"Account Number");
	checkBeginningSpace(accNumber,"Account Number");
	
	validate_mandatory_tb_with_message(accType, "Please select your Account Type");
	
	checkBeginningSpace(micr,"MICR code");
	var micrLen = micr.value.length;
	if(micrLen != 9)
	{
		printMsg("MICR code should be a 9 digit numeric value");
	}	
	else
	{
		validate_numeric_value_with_msg(micr,"MICR code");
	}
	
	validate_mandatory_tb_with_message(bankName, "Please enter Bank Name");
	checkBeginningSpace(bankName,"Bank Name");
	validateStringValue(bankName,"Bank Name");
	
	validate_mandatory_tb_with_message(bankBranch, "Please enter Bank Branch");
	checkBeginningSpace(bankBranch,"Bank Branch");
	validateStringValue(bankBranch,"Bank Branch");
		
	validate_mandatory_tb_with_message(bankCity, "Please enter Bank City");
	checkBeginningSpace(bankCity,"Bank City");
	validateStringValue(bankCity,"Bank City");	
	
	validate_mandatory_tb_with_message(bankState, "Please enter Bank State");
	checkBeginningSpace(bankState,"Bank State");
	validateStringValue(bankState,"Bank State");
		
	var val = document.imtRegn.nearestLogisticCity.value;
	if(val=="")
	{
		printMsg("Please select DD Payable location");
	}

	/*if(document.imtRegn.operatingmodeId.value == "INTL")
	{
		validateSSN();
	}*/

	validate_mandatory_tb_with_message(document.imtRegn.mrzLine2, "Please enter MRZ No");
	var mrzLen = document.imtRegn.mrzLine2.value.length;
	if(mrzLen < 44)
	{
		printMsg("Mrz No should be of 44 characters.");
	}
			
	return check_display_errors(imtRegn);
}

function validateSender(address,city,state,pincode,country,emailT1,emailT2,resPh1,resPh2,resPh3,offPh1,offPh2,offPh3,mobileNo,industry,mrzLine2,imtRegn)
{
	initialize_error_msgs();
	
	validateEmail(emailT1,emailT2);

	if((resPh1.value == "Country Code") || (resPh2.value == "Area Code") || (resPh3.value == "Tel No"))
	{
		printMsg("Please enter a valid Home Phone");		
	}
	validate_mandatory_tb_with_message(resPh1, "Please enter Country Code for Home Phone");
	validate_numeric_value_with_msg(resPh1, "Country Code for Home Phone");
	checkBeginningSpace(resPh1, "Country Code for Home Phone");
	validate_mandatory_tb_with_message(resPh2, "Please enter Area Code for Home Phone");
	validate_numeric_value_with_msg(resPh2, "Area Code for Home Phone");
	checkBeginningSpace(resPh2, "Area Code for Home Phone");
	validate_mandatory_tb_with_message(resPh3, "Please enter Home Telephone No");
	validate_numeric_value_with_msg(resPh3, "Home Telephone No");
	checkBeginningSpace(resPh3, "Home Telephone No");
	var resPhonelen = document.imtRegn.resPh1.value + document.imtRegn.resPh2.value + document.imtRegn.resPh3.value;
	if((resPhonelen.length) > 25)
	{
	  	printMsg("Length of Home Phone No cannot exceed 25 characters");
	}

	if((offPh1.value == "Country Code") || (offPh2.value == "Area Code") || (offPh3.value == "Tel No"))
	{
		printMsg("Please enter a valid Work Phone");		
	}
	validate_mandatory_tb_with_message(offPh1, "Please enter Country Code for Work Phone");
	validate_numeric_value_with_msg(offPh1, "Country Code for Work Phone");
	checkBeginningSpace(offPh1, "Country Code for Work Phone");	
	validate_mandatory_tb_with_message(offPh2, "Please enter Area Code for Work Phone");
	validate_numeric_value_with_msg(offPh2, "Area Code for Work Phone");
	checkBeginningSpace(offPh2, "Area Code for Work Phone");
	validate_mandatory_tb_with_message(offPh3, "Please enter Work Telephone No");
	validate_numeric_value_with_msg(offPh3, "Work Telephone No");
	checkBeginningSpace(offPh3, "Work Telephone No");
	var offPhonelen = document.imtRegn.offPh1.value + document.imtRegn.offPh2.value + document.imtRegn.offPh3.value;
	if((offPhonelen.length) > 25)
	{
	  	printMsg("Length of Work Phone No cannot exceed 25 characters");
	}
	
	if(mobileNo.value == "Mobile No")
	{
		printMsg("Please enter a valid Mobile Phone No or leave it blank");		
	}
	checkBeginningSpace(mobileNo,"Mobile Phone Number ");
	validate_numeric_value_with_msg(mobileNo,"Mobile Phone Number");
	var mobPhonelen = document.imtRegn.mobileNo.value;
	if((mobPhonelen.length) > 25)
	{
	  	printMsg("Length of Mobile Phone No cannot exceed 25 characters");
	}
	
	validate_mandatory_tb_with_message(address, "Please enter your Address");
	checkBeginningSpace(address,"Address");
	validateTextField(address,"Address");
	
	validate_mandatory_tb_with_message(city, "Please enter your City");
	checkBeginningSpace(city,"City");
	validateStringValue(city,"City");
	
	validate_mandatory_tb_with_message(state, "Please enter your State");
	checkBeginningSpace(state,"State");
	validateStringValue(state,"State");
	
	validate_mandatory_tb_with_message(pincode, "Please enter your Pincode");
	checkBeginningSpace(pincode, "Pincode");
	validatePincode(pincode);
	
	validate_mandatory_tb_with_message(country, "Please select your Country");
	
	validate_mandatory_tb_with_message(industry, "Please select Industry");

	/*if(document.imtRegn.operatingmodeId.value == "INTL")
	{
		validateSSN();
	}*/

	validate_mandatory_tb_with_message(document.imtRegn.mrzLine2, "Please enter MRZ No");
	var mrzLen = document.imtRegn.mrzLine2.value.length;
	if(mrzLen < 44)
	{
		printMsg("Mrz No should be of 44 characters.");
	}
	
	return check_display_errors(imtRegn);
}

function validateReceiver2(firstName,lastName,gender,D1,D2,D3,address,city,state,pincode,country,emailT1,emailT2,resPh1,resPh2,resPh3,offPh1,offPh2,offPh3,mobileNo,accNumber,accType,micr,bankName,bankBranch,bankCity,bankState,payableAt,nearestLogisticCity,loginname,password,retypepwd,mrzLine2,imtRegn)
{
	initialize_error_msgs();
	
	validate_mandatory_tb_with_message(firstName, "Please enter your First Name");
	checkBeginningSpace(firstName," First Name");
	validateStringValue(firstName,"First Name");
	if(firstName.value == "First Name")
	{
		 printMsg("Please enter your First Name");
	}
	
	validate_mandatory_tb_with_message(lastName, "Please enter your Last Name");
	checkBeginningSpace(lastName," Last Name");
	validateStringValue(lastName,"Last Name");
	if(lastName.value == "Last Name")
	{
		 printMsg("Please enter your Last Name");
	}
	
	if(document.imtRegn.userTypeId.value == "INDIV")
	{
		validate_mandatory_tb_with_message(gender, "Please select Gender");
	
		validateDOB();
	}
	
	validateEmail(emailT1,emailT2);

	if((resPh1.value == "Country Code") || (resPh2.value == "Area Code") || (resPh3.value == "Tel No"))
	{
		printMsg("Please enter a valid Home Phone");		
	}
	validate_mandatory_tb_with_message(resPh1, "Please enter Country Code for Home Phone");
	validate_numeric_value_with_msg(resPh1, "Country Code for Home Phone");
	checkBeginningSpace(resPh1, "Country Code for Home Phone");
	validate_mandatory_tb_with_message(resPh2, "Please enter Area Code for Home Phone");
	validate_numeric_value_with_msg(resPh2, "Area Code for Home Phone");
	checkBeginningSpace(resPh2, "Area Code for Home Phone");
	validate_mandatory_tb_with_message(resPh3, "Please enter Home Telephone No");
	validate_numeric_value_with_msg(resPh3, "Home Telephone No");
	checkBeginningSpace(resPh3, "Home Telephone No");
	var resPhonelen = document.imtRegn.resPh1.value + document.imtRegn.resPh2.value + document.imtRegn.resPh3.value;
	if((resPhonelen.length) > 25)
	{
	  	printMsg("Length of Home Phone No cannot exceed 25 characters");
	}

	if((offPh1.value == "Country Code") || (offPh2.value == "Area Code") || (offPh3.value == "Tel No"))
	{
		printMsg("Please enter a valid Work Phone");		
	}
	validate_mandatory_tb_with_message(offPh1, "Please enter Country Code for Work Phone");
	validate_numeric_value_with_msg(offPh1, "Country Code for Work Phone");
	checkBeginningSpace(offPh1, "Country Code for Work Phone");	
	validate_mandatory_tb_with_message(offPh2, "Please enter Area Code for Work Phone");
	validate_numeric_value_with_msg(offPh2, "Area Code for Work Phone");
	checkBeginningSpace(offPh2, "Area Code for Work Phone");
	validate_mandatory_tb_with_message(offPh3, "Please enter Work Telephone No");
	validate_numeric_value_with_msg(offPh3, "Work Telephone No");
	checkBeginningSpace(offPh3, "Work Telephone No");
	var offPhonelen = document.imtRegn.offPh1.value + document.imtRegn.offPh2.value + document.imtRegn.offPh3.value;
	if((offPhonelen.length) > 25)
	{
	  	printMsg("Length of Work Phone No cannot exceed 25 characters");
	}
	
	if(mobileNo.value == "Mobile No")
	{
		printMsg("Please enter a valid Mobile Phone No or leave it blank");		
	}
	checkBeginningSpace(mobileNo,"Mobile Phone Number ");
	validate_numeric_value_with_msg(mobileNo,"Mobile Phone Number");
	var mobPhonelen = document.imtRegn.mobileNo.value;
	if((mobPhonelen.length) > 25)
	{
	  	printMsg("Length of Mobile Phone No cannot exceed 25 characters");
	}

	validate_mandatory_tb_with_message(address, "Please enter your Address");
	checkBeginningSpace(address,"Address");
	validateTextField(address,"Address");
	
	validate_mandatory_tb_with_message(city, "Please enter your City");
	checkBeginningSpace(city,"City");
	validateStringValue(city,"City");
	
	validate_mandatory_tb_with_message(state, "Please enter your State");
	checkBeginningSpace(state,"State");
	validateStringValue(state,"State");
	
	validate_mandatory_tb_with_message(pincode, "Please enter your Pincode");
	checkBeginningSpace(pincode, "Pincode");
	validatePincode(pincode);
	
	validate_mandatory_tb_with_message(country, "Please select your Country");
	
	validate_mandatory_tb_with_message(loginname, "Please enter a Login Name");
	checkBeginningSpace(loginname,"Login Name");
	
	var login = document.imtRegn.loginname.value;
	var logLength = login.length;	
	if(logLength < 3 || logLength > 20)
	{
		printMsg("Login Name should be of minimum 3 and maximum 20 characters");
	}

	if(logLength > 1)
	{
		if(((login.charAt(0)<'a') || (login.charAt(0)>'z')) && ((login.charAt(0)<'A') || (login.charAt(0)>'Z')))
		{
			printMsg("Login Name must begin with an alphabet");
		}
	}
	
	for(var i=0;i<logLength;i++) 
	{
		if(((login.charAt(i)<'0') || (login.charAt(i)>'9')) && ((login.charAt(i)<'a') || (login.charAt(i)>'z')) && ((login.charAt(i)<'A') || (login.charAt(i)>'Z')) && (login.charAt(i)!='_'))
		{
			printMsg("Login Name can only contain alphabets and numbers separated by underscore if needed");
			break;
		}
	}

	var pwdLabel = "Password";
	if(document.imtRegn.partnerId.value == "SMT")
	{
		pwdLabel = "Money Transfer Pin";
	}
	
	if(isEmpty(stripWhitespace(document.imtRegn.password.value)))
	{
		printMsg("Please enter a "+pwdLabel);  
	} 
	checkBeginningSpace(password,pwdLabel);	
	validateTextField(password,pwdLabel);

	if(!((/\d/.test(password.value)) && (/[a-z]/i.test(password.value))))
	{
		 printMsg(pwdLabel+" should be alpha-numeric");
	}
	
	var passLn = password.value.length;
	if(passLn < 8 || passLn > 20)
	{
		printMsg(pwdLabel+" should be of minimum 8 and maximum 20 characters");
	}
	
	if(password.value != retypepwd.value)
	{
	  	printMsg("Please retype your "+pwdLabel);
	}
	
	if(document.imtRegn.payDlyMode.value == "DD")
	{
		validate_mandatory_tb_with_message(nearestLogisticCity, "Please select DD Payable Location");
		
		if((accNumber.value != "") || (bankName.value != "") || (bankBranch.value != "") || (bankCity.value != ""))
		{
			validate_mandatory_tb_with_message(accNumber, "Please enter the Beneficiary's Account Number");
			validate_mandatory_tb_with_message(bankName, "Please enter the Beneficiary's Bank Name");
			if(document.imtRegn.partnerId.value == "IOB")
			{
				validate_mandatory_tb_with_message(accType, "Please enter the Beneficiary's Account Type");
			}
			else
			{
				validate_mandatory_tb_with_message(bankBranch, "Please enter the Beneficiary's Bank Branch");
				validate_mandatory_tb_with_message(bankCity, "Please enter the Beneficiary's Bank City");
			}
		}
		
		checkBeginningSpace(accNumber,"Account Number");
		validateAlpaNumeric(accNumber,"Account Number");
		
		checkBeginningSpace(bankName,"Bank Name");
		validateStringValue(bankName,"Bank Name");
		
		checkBeginningSpace(bankBranch,"Bank Branch");
		validateAlpaNumericSpecialChars(bankBranch,"Bank Branch");
		
		checkBeginningSpace(bankCity,"Bank City");
		validateStringValue(bankCity,"Bank City");
	}
	else if(document.imtRegn.payDlyMode.value == "DC")
	{
		validate_mandatory_tb_with_message(accNumber, "Please enter your Beneficiary's Account Number");
		checkBeginningSpace(accNumber,"Account Number");
		validateAlpaNumeric(accNumber,"Account Number");
		
		if(document.imtRegn.bankId.value == "PNB" || bankName.value == "Punjab National Bank")
		{
			if(accNumber.value.length != 16)
			{
				printMsg("Please enter the 16 digit Account Number");
			}
		}

		validate_mandatory_tb_with_message(accType, "Please select your Beneficiary's Account Type");
		
		if(document.imtRegn.isPartnerBank.value == "N")
		{
			if(micr.value.length != 9)
			{
				printMsg("Please enter the 9 digit MICR code for the branch of the bank chosen");
			}
			else
			{
				validate_numeric_value_with_msg(micr,"MICR Code");
				
				var micr1 = micr.value;
				var micrCityId = micr1.substring(0,3);
				if(document.imtRegn.bankCityId.value != '' && document.imtRegn.bankCityId.value != micrCityId)
				{
					printMsg("The MICR Code does not match with the City you have selected");
				}
			}
		}

		validate_mandatory_tb_with_message(bankName, "Please enter your Beneficiary's Bank Name");
		checkBeginningSpace(bankName,"Bank Name");
		validateStringValue(bankName,"Bank Name");
		
		validate_mandatory_tb_with_message(bankBranch, "Please enter your Beneficiary's Bank Branch");
		checkBeginningSpace(bankBranch,"Bank Branch");
		validateAlpaNumericSpecialChars(bankBranch,"Bank Branch");
		
		validate_mandatory_tb_with_message(bankCity, "Please enter your Beneficiary's Bank City");
		checkBeginningSpace(bankCity,"Bank City");
		validateStringValue(bankCity,"Bank City");
		
		if(document.imtRegn.partnerId.value == "TOML")
		{
			var bankNm1 = document.imtRegn.bankData.options[document.imtRegn.bankData.selectedIndex].value;
			var bankNm  = document.imtRegn.bankName.value;
			if(bankNm1 == "ZZZ~Other Bank~N")
			{
				if(document.imtRegn.payDlyMode.value == "DC")
				{
					printMsg("Please select one of the listed Banks to use Direct Credit facility");
				}
				else if(document.imtRegn.payDlyMode.value != "" && bankNm == "Other Bank")
				{
					printMsg("Please enter the name of the Bank");
				}
			}
			
			var bankCt1 = document.imtRegn.cityData.options[document.imtRegn.cityData.selectedIndex].value;
			var bankCt  = document.imtRegn.bankCity.value;
			if(bankCt1 == "000~Other City")
			{
				if((document.imtRegn.payDlyMode.value == "DC") && (isPartnerBank.value == "N"))
				{
					printMsg("Please select one of the listed Bank Cities to use Direct Credit facility");
				}
				else if(document.imtRegn.payDlyMode.value != "" && bankCt == "Other City")
				{
					printMsg("Please enter the Bank City");
				}
			}
		}
		
		//validate_mandatory_tb_with_message(bankState, "Please enter your Beneficiary's Bank State");
		//checkBeginningSpace(bankState,"Bank State");
		//validateStringValue(bankState,"Bank State");
	}
	else if(document.imtRegn.payDlyMode.value == "SBI")
	{
		validate_mandatory_tb_with_message(accNumber, "Please enter your Beneficiary's Account Number");
		checkBeginningSpace(accNumber,"Account Number");
		validateAlpaNumeric(accNumber,"Account Number");
		validate_mandatory_tb_with_message(accType, "Please select your Beneficiary's Account Type");
				
		validate_mandatory_tb_with_message(bankBranch, "Please use the search facility to select Beneficiary's Bank Branch");	
	}
	else if(document.imtRegn.payDlyMode.value == "CASH")
	{
		validate_mandatory_tb_with_message(nearestLogisticCity, "Please select Cash Collectable Location");	
	}
	else if(document.imtRegn.payDlyMode.value == "UCC")
	{
		validate_mandatory_tb_with_message(bankName, "Please select Bank Branch");	
	}
	else if(document.imtRegn.payDlyMode.value == "AGENT")
	{
		validate_mandatory_tb_with_message(nearestLogisticCity, "Please select Agent Collectable Location");
	}
	else if(document.imtRegn.payDlyMode.value == "SHOP")
	{
		validate_mandatory_tb_with_message(document.imtRegn.responseURL, "Please enter a response URL");
		checkBeginningSpace(document.imtRegn.responseURL, "response URL");

		validate_mandatory_tb_with_message(document.imtRegn.mastheadImage, "Please enter a Mast Head Image value");
		checkBeginningSpace(document.imtRegn.mastheadImage, "Mast Head Image");
	}

	/*if(document.imtRegn.operatingmodeId.value == "INTL")
	{
		validateSSN();
	}*/

	if(document.imtRegn.userTypeId.value == "INDIV")
	{
		validate_mandatory_tb_with_message(document.imtRegn.marketing, "Please select how did you hear about us");	
		var marketText = document.imtRegn.marketing1.value;
		var indx = marketText.indexOf("Enter");
		if (indx != -1)
		{
	      	printMsg("Please enter how did you hear about us");
		}
		else
		{
			validateAlpaNumeric(document.imtRegn.marketing1, "How did you hear about us");
		}
		
		if(!(document.imtRegn.terms.checked))
		{
			printMsg("Please read and accept the Terms And Conditions");
		}
	}

	validate_mandatory_tb_with_message(document.imtRegn.mrzLine2, "Please enter MRZ No");
	var mrzLen = document.imtRegn.mrzLine2.value.length;
	if(mrzLen < 44)
	{
		printMsg("Mrz No should be of 44 characters.");
	}
		
	return check_display_errors(imtRegn);
}

function validateSender2(firstName,lastName,gender,D1,D2,D3,address,city,state,pincode,country,emailT1,emailT2,resPh1,resPh2,resPh3,offPh1,offPh2,offPh3,mobileNo,industry,loginname,password,retypepwd,imtRegn)
{
	initialize_error_msgs();
	
	validate_mandatory_tb_with_message(firstName, "Please enter your First Name");
	checkBeginningSpace(firstName," First Name");
	  
	// included by mahender to check whether no space should be allowed in firstname field
	// Created Date : 08-09-2006

	var firstSt = document.imtRegn.firstName.value;

	var nameLength = firstSt.length;
	var validStr1 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-";

	if(firstName.value == "First Name")
	{
		 printMsg("Please enter your First Name");
	}
	else
	{
		for(i=0;i<nameLength;i++)
		{
			if(validStr1.indexOf(firstSt.charAt(i))==-1)
			{
				printMsg("Only alphabets with No Space should be allowed in First Name Field");
				break;
			}
		}
	}
	// end 
	
	validate_mandatory_tb_with_message(lastName, "Please enter your Last Name");
	checkBeginningSpace(lastName," Last Name");
	validateStringValue(lastName,"Last Name");
	if(lastName.value == "Last Name")
	{
		 printMsg("Please enter your Last Name");
	}
	
	if(document.imtRegn.userTypeId.value == "INDIV")
	{
		validate_mandatory_tb_with_message(gender, "Please select Gender");

    	validateDOB();
	}
	
	validateEmail(emailT1,emailT2);

	if((resPh1.value == "Country Code") || (resPh2.value == "Area Code") || (resPh3.value == "Tel No"))
	{
		printMsg("Please enter a valid Home Phone");		
	}
	validate_mandatory_tb_with_message(resPh1, "Please enter Country Code for Home Phone");
	validate_numeric_value_with_msg(resPh1, "Country Code for Home Phone");
	checkBeginningSpace(resPh1, "Country Code for Home Phone");
	validate_mandatory_tb_with_message(resPh2, "Please enter Area Code for Home Phone");
	validate_numeric_value_with_msg(resPh2, "Area Code for Home Phone");
	checkBeginningSpace(resPh2, "Area Code for Home Phone");
	validate_mandatory_tb_with_message(resPh3, "Please enter Home Telephone No");
	validate_numeric_value_with_msg(resPh3, "Home Telephone No");
	checkBeginningSpace(resPh3, "Home Telephone No");
	var resPhonelen = document.imtRegn.resPh1.value + document.imtRegn.resPh2.value + document.imtRegn.resPh3.value;
	if((resPhonelen.length) > 25)
	{
	  	printMsg("The maximum limit for a Home Phone Number is 25 digits");
	}

//	if((offPh1.value == "Country Code") || (offPh2.value == "Area Code") || (offPh3.value == "Tel No"))
//	{
//		printMsg("Please enter a valid Work Phone");		
//	}
//	validate_mandatory_tb_with_message(offPh1, "Please enter Country Code for Work Phone");
//	validate_numeric_value_with_msg(offPh1, "Country Code for Work Phone");
//	checkBeginningSpace(offPh1, "Country Code for Work Phone");	
//	validate_mandatory_tb_with_message(offPh2, "Please enter Area Code for Work Phone");
//	validate_numeric_value_with_msg(offPh2, "Area Code for Work Phone");
//	checkBeginningSpace(offPh2, "Area Code for Work Phone");
//	validate_mandatory_tb_with_message(offPh3, "Please enter Work Telephone No");
//	validate_numeric_value_with_msg(offPh3, "Work Telephone No");
//	checkBeginningSpace(offPh3, "Work Telephone No");
//	var offPhonelen = document.imtRegn.offPh1.value + document.imtRegn.offPh2.value + document.imtRegn.offPh3.value;
//	if((offPhonelen.length) > 25)
//	{
//	  	printMsg("The maximum limit for a Work Phone Number is 25 digits");
//	}
	
	if(mobileNo.value == "Mobile No")
	{
		printMsg("Please enter a valid Mobile Phone No or leave it blank");		
	}
	checkBeginningSpace(mobileNo,"Mobile Phone Number ");
	validate_numeric_value_with_msg(mobileNo,"Mobile Phone Number");
	var mobPhonelen = document.imtRegn.mobileNo.value;
	if((mobPhonelen.length) > 25)
	{
	  	printMsg("The maximum limit for a Mobile Phone Number is 25 digits");
	}
	
	validate_mandatory_tb_with_message(address, "Please enter your Door Number");
	checkBeginningSpace(address,"Address");
	validateTextField(address,"Address");
	
	validate_mandatory_tb_with_message(city, "Please enter your City");
	checkBeginningSpace(city,"City");
	validateStringValue(city,"City");
	
	validate_mandatory_tb_with_message(state, "Please enter your State");
	checkBeginningSpace(state,"State");
	validateStringValue(state,"State");
	
	validate_mandatory_tb_with_message(pincode, "Please enter your Pincode");
	checkBeginningSpace(pincode, "Pincode");
	validatePincode(pincode);
	
	validate_mandatory_tb_with_message(country, "Please select your Country");

	validate_mandatory_tb_with_message(loginname, "Please enter a Email Id");
	checkBeginningSpace(loginname,"Email Id");
	
//	var login = document.imtRegn.loginname.value;
//	var logLength = login.length;	
//	if(logLength < 3 || logLength > 70)
//	{
//		printMsg("Email Id should be of minimum 3 and maximum 70 characters");
//	}
//
//	if(logLength > 1)
//	{
//		if(((login.charAt(0)<'a') || (login.charAt(0)>'z')) && ((login.charAt(0)<'A') || (login.charAt(0)>'Z')))
//		{
//			printMsg("Email Id must begin with an alphabet");
//		}
//	}
//	
//	for(var i=0;i<logLength;i++) 
//	{
//		if(((login.charAt(i)<'0') || (login.charAt(i)>'9')) && ((login.charAt(i)<'a') || (login.charAt(i)>'z')) && ((login.charAt(i)<'A') || (login.charAt(i)>'Z')) && (login.charAt(i)!='_'))
//		{
//			printMsg("Email Id can only contain alphabets and numbers separated by underscore if needed");
//			break;
//		}
//	}

	var pwdLabel = "Password";
	if(document.imtRegn.partnerId.value == "SMT")
	{
		pwdLabel = "Money Transfer Pin";
	}

	if(isEmpty(stripWhitespace(document.imtRegn.password.value)))
	{
		printMsg("Please enter a "+pwdLabel);  
	} 
	checkBeginningSpace(password,pwdLabel);	
	validateTextField(password,pwdLabel);

	if(!((/\d/.test(password.value)) && (/[a-z]/i.test(password.value))))
	{
		 printMsg(pwdLabel+" should be alpha-numeric");
	}
	
	var passLn = password.value.length;
	if(passLn < 8 || passLn > 20)
	{
		printMsg(pwdLabel+" should be of minimum 8 and maximum 20 characters");
	}
	
	if(password.value != retypepwd.value)
	{
	  	printMsg("Please retype your "+pwdLabel);
	}

	//validate_mandatory_tb_with_message(industry, "Please select Industry");

	validate_mandatory_tb_with_message(document.imtRegn.marketing, "Please enter how did you hear about us");	
	var marketText = document.imtRegn.marketing1.value;
	var indx = marketText.indexOf("Enter");
	if (indx != -1)
	{
      	printMsg("Please enter how did you hear about us");
	}
	else
	{
		validateAlpaNumeric(document.imtRegn.marketing1, "How did you hear about us");
	}

	/*if(document.imtRegn.operatingmodeId.value == "INTL")
	{
		validateSSN();
	}*/

	if(!(document.imtRegn.terms.checked))
	{
		printMsg("Please read and accept the Terms And Conditions");
	}

	return check_display_errors(imtRegn);
}

//valdation for 1st registration screen; select user type and regn modes
function isChecked()
{
	if(document.rmtDisp.userTpId.value=="")
	{
		alert("Please select a User Type");
		return false;
	}

	if(parseInt(document.rmtDisp.cnt.value) == 0)
	{
   		alert("Please select atleast one mode of Registration");
   		return false;
 	}
 	else
	{
    	document.rmtDisp.submit();
 	}	
}

function setCount(val)
{
 	if(val.checked == true)
 	{
    	document.rmtDisp.cnt.value++;
    }
  	else
 	{
    	document.rmtDisp.cnt.value--;
    }
}

//registration form set functions
function setDdLocation()
{
	document.imtRegn.nearestLogisticCity.value = document.imtRegn.payableAt.options[document.imtRegn.payableAt.selectedIndex].text;
}

function setBankName()
{
	if(document.imtRegn.recvBankSameFlag.checked == true)
	{
  		document.imtRegn.bankName.value="UTI Bank";
 	}
 	
	if(document.imtRegn.recvBankSameFlag.checked == false)
	{
  		document.imtRegn.bankName.value="";
 	}
}

function assigntext()
{
	if(document.imtRegn.marketing.options[document.imtRegn.marketing.options.selectedIndex].value == "Internet")
	{
  		document.imtRegn.marketing1.value="Enter Internet Site";
 	}
	
	if(document.imtRegn.marketing.options[document.imtRegn.marketing.options.selectedIndex].value == "Television")
	{
  		document.imtRegn.marketing1.value="Enter Channel's Name";
 	}
	
	if(document.imtRegn.marketing.options[document.imtRegn.marketing.options.selectedIndex].value == "Newspaper") 
	{
  		document.imtRegn.marketing1.value="Enter Newspaper's Name";
 	}

	if(document.imtRegn.marketing.options[document.imtRegn.marketing.options.selectedIndex].value == "Radio") 
	{
  		document.imtRegn.marketing1.value="Enter Channel's Name";
 	}

	if(document.imtRegn.marketing.options[document.imtRegn.marketing.options.selectedIndex].value == "Cinema Hall") 
	{
  		document.imtRegn.marketing1.value="Enter Cinema Hall's Name";
 	}
	
	if(document.imtRegn.marketing.options[document.imtRegn.marketing.options.selectedIndex].value == "Word of Mouth")
	{
  		document.imtRegn.marketing1.value="Enter Source Name";
 	}
	
	if(document.imtRegn.marketing.options[document.imtRegn.marketing.options.selectedIndex].value == "Company") 
	{
  		document.imtRegn.marketing1.value="Enter Company's Name";
 	}

	if(document.imtRegn.marketing.options[document.imtRegn.marketing.options.selectedIndex].value == "Association")
	{
  		document.imtRegn.marketing1.value="Enter Association's Name";
 	}

	if(document.imtRegn.marketing.options[document.imtRegn.marketing.options.selectedIndex].value == "Referral Code") 
	{
  		document.imtRegn.marketing1.value="Enter Referral Code";
 	}

	if(document.imtRegn.marketing.options[document.imtRegn.marketing.options.selectedIndex].value == "Sales Person") 
	{
  		document.imtRegn.marketing1.value="Enter Sales Person's Name";
 	}

	if(document.imtRegn.marketing.options[document.imtRegn.marketing.options.selectedIndex].value == "Promotional Event") 
	{
  		document.imtRegn.marketing1.value="Enter Promotional Event";
 	}

	if(document.imtRegn.marketing.options[document.imtRegn.marketing.options.selectedIndex].value == "Remit2India Agent") 
	{
  		document.imtRegn.marketing1.value="Enter Remit2India Agent";
 	}

	if(document.imtRegn.marketing.options[document.imtRegn.marketing.options.selectedIndex].value == "Remit2India Franchise") 
	{
  		document.imtRegn.marketing1.value="Enter Remit2India Franchise";
 	}
	
	if(document.imtRegn.marketing.options[document.imtRegn.marketing.options.selectedIndex].value == "") 
	{
  		document.imtRegn.marketing1.value="";
 	}
}

//corporate registration validation
function validateCorpRegn(firstName,lastName,compName,designation,emailT1,emailT2,address,city,state,pincode,country,offPh1,offPh2,offPh3,mobileNo,usEmpNo,ukEmpNo,canEmpNo,euroEmpNo,message,remitCorpRegn)
{
	initialize_error_msgs();
	
	validate_mandatory_tb_with_message(firstName, "Please enter your First Name");
	checkBeginningSpace(firstName," First Name");
	validateStringValue(firstName,"First Name");
	if(firstName.value == "First Name")
	{
		 printMsg("Please enter your First Name");
	}
	
	validate_mandatory_tb_with_message(lastName, "Please enter your Last Name");
	checkBeginningSpace(lastName," Last Name");
	validateStringValue(lastName,"Last Name");
	if(lastName.value == "Last Name")
	{
		 printMsg("Please enter your Last Name");
	}
	
	validate_mandatory_tb_with_message(compName, "Please enter your Company's Name");
	checkBeginningSpace(compName," Company Name");
	validateAlpaNumericSpecialChars(compName,"Company Name");
	
	validate_mandatory_tb_with_message(designation, "Please enter your Designation");
	checkBeginningSpace(designation," Designation");
	validateAlpaNumericSpecialChars(designation,"Designation");
	
	validateEmail(emailT1,emailT2);

	validate_mandatory_tb_with_message(address, "Please enter your Office Address");
	checkBeginningSpace(address," Office Address");
	validateTextField(address,"Office Address");
	
	validate_mandatory_tb_with_message(city, "Please enter your City");
	checkBeginningSpace(city,"City");
	validateStringValue(city,"City");
	
	validate_mandatory_tb_with_message(state, "Please enter your State");
	checkBeginningSpace(state,"State");
	validateStringValue(state,"State");
	
	validate_mandatory_tb_with_message(pincode, "Please enter your Pincode");
	checkBeginningSpace(pincode, "Pincode");
	validatePincode(pincode);
	
	validate_mandatory_tb_with_message(country, "Please select your Country");

	if((offPh1.value == "Country Code") || (offPh2.value == "Area Code") || (offPh3.value == "Tel No"))
	{
		printMsg("Please enter a valid Office Phone No");		
	}
	validate_mandatory_tb_with_message(offPh1, "Please enter Country Code for Office Phone");
	validate_numeric_value_with_msg(offPh1, "Country Code for Office Phone");
	checkBeginningSpace(offPh1, "Country Code for Office Phone");	
	validate_mandatory_tb_with_message(offPh2, "Please enter Area Code for Office Phone");
	validate_numeric_value_with_msg(offPh2, "Area Code for Office Phone");
	checkBeginningSpace(offPh2, "Area Code for Office Phone");
	validate_mandatory_tb_with_message(offPh3, "Please enter Office Telephone No");
	validate_numeric_value_with_msg(offPh3, "Office Telephone No");
	checkBeginningSpace(offPh3, "Office Telephone No");
	var offPhonelen = document.remitCorpRegn.offPh1.value + document.remitCorpRegn.offPh2.value + document.remitCorpRegn.offPh3.value;
	if((offPhonelen.length) > 25)
	{
	  	printMsg("Length of Office Phone No cannot exceed 25 characters");
	}
	
	validate_mandatory_tb_with_message(mobileNo, "Please enter Mobile Phone Number");
	checkBeginningSpace(mobileNo,"Mobile Phone Number ");
	validate_numeric_value_with_msg(mobileNo,"Mobile Phone Number");
	var mobPhonelen = document.remitCorpRegn.mobileNo.value;
	if((mobPhonelen.length) > 25)
	{
	  	printMsg("Length of Mobile Phone No cannot exceed 25 characters");
	}
	
	if(!document.remitCorpRegn.usCheck.checked && !document.remitCorpRegn.ukCheck.checked && !document.remitCorpRegn.canCheck.checked && !document.remitCorpRegn.euroCheck.checked)
	{
		printMsg("Please select atleast 1 country where you have your office and specify an approximate number of personnel employed there");
	}
	
	if(document.remitCorpRegn.usCheck.checked)
	{
		validate_mandatory_tb_with_message(usEmpNo, "Please enter the number of employees in United States");
		validate_numeric_value_with_msg(usEmpNo, "Number of employees in United States");
		checkBeginningSpace(usEmpNo, "Number of employees in United States");
	}
	
	if(document.remitCorpRegn.ukCheck.checked)
	{
		validate_mandatory_tb_with_message(ukEmpNo, "Please enter the number of employees in United Kingdom");
		validate_numeric_value_with_msg(ukEmpNo, "Number of employees in United Kingdom");
		checkBeginningSpace(ukEmpNo, "Number of employees in United Kingdom");
	}
	
	if(document.remitCorpRegn.canCheck.checked)
	{
		validate_mandatory_tb_with_message(canEmpNo, "Please enter the number of employees in Canada");
		validate_numeric_value_with_msg(canEmpNo, "Number of employees in Canada");
		checkBeginningSpace(canEmpNo, "Number of employees in Canada");
	}
	
	if(document.remitCorpRegn.euroCheck.checked)
	{
		validate_mandatory_tb_with_message(euroEmpNo, "Please enter the number of employees in Euroland");
		validate_numeric_value_with_msg(euroEmpNo, "Number of employees in Euroland");
		checkBeginningSpace(euroEmpNo, "Number of employees in Euroland");
	}
	
	var cmt = message.value;	
	if((cmt.length) > 0)
	{
		checkBeginningSpace(message," Message");
		validateTextField(message,"Message");
		
		if((cmt.length) > 300)
		{
		  	printMsg("Length of Message cannot exceed 300 characters");
		}
	}
	
	return check_display_errors(remitCorpRegn);
}

//corporate recommendation validation
function validateCorpRecommend(firstName,lastName,compName,designation,emailT1,emailT2,address,city,state,pincode,country,offPh1,offPh2,offPh3,mobileNo,empFirstName,empLastName,empDesignation,empOffPh1,empOffPh2,empOffPh3,empEmailT1,empEmailT2,remitCorpRecommend)
{
	initialize_error_msgs();
	
	validate_mandatory_tb_with_message(firstName, "Please enter your First Name of the contact person");
	checkBeginningSpace(firstName," First Name of the contact person");
	validateStringValue(firstName,"First Name of the contact person");
	if(firstName.value == "First Name")
	{
		 printMsg("Please enter the First Name of the contact person");
	}
	
	validate_mandatory_tb_with_message(lastName, "Please enter the Last Name of the contact person");
	checkBeginningSpace(lastName," Last Name of the contact person");
	validateStringValue(lastName,"Last Name of the contact person");
	if(lastName.value == "Last Name")
	{
		 printMsg("Please enter the Last Name of the contact person");
	}
	
	validate_mandatory_tb_with_message(compName, "Please enter your Company's Name");
	checkBeginningSpace(compName," Company Name");
	validateAlpaNumericSpecialChars(compName,"Company Name");
	
	validate_mandatory_tb_with_message(designation, "Please enter the Designation of the contact person");
	checkBeginningSpace(designation," Designation of the contact person");
	validateAlpaNumericSpecialChars(designation,"Designation of the contact person");
	
	validateEmail(emailT1,emailT2);

	validate_mandatory_tb_with_message(address, "Please enter your Office Address");
	checkBeginningSpace(address," Office Address");
	validateTextField(address,"Office Address");
	
	validate_mandatory_tb_with_message(city, "Please enter your City");
	checkBeginningSpace(city,"City");
	validateStringValue(city,"City");
	
	validate_mandatory_tb_with_message(state, "Please enter your State");
	checkBeginningSpace(state,"State");
	validateStringValue(state,"State");
	
	validate_mandatory_tb_with_message(pincode, "Please enter your Pincode");
	checkBeginningSpace(pincode, "Pincode");
	validatePincode(pincode);
	
	validate_mandatory_tb_with_message(country, "Please select your Country");

	if((offPh1.value == "Country Code") || (offPh2.value == "Area Code") || (offPh3.value == "Tel No"))
	{
		printMsg("Please enter a valid Company Office Phone No");		
	}
	validate_mandatory_tb_with_message(offPh1, "Please enter Country Code for Company Office Phone");
	validate_numeric_value_with_msg(offPh1, "Country Code for Company Office Phone");
	checkBeginningSpace(offPh1, "Country Code for Company Office Phone");	
	validate_mandatory_tb_with_message(offPh2, "Please enter Area Code for Company Office Phone");
	validate_numeric_value_with_msg(offPh2, "Area Code for Company Office Phone");
	checkBeginningSpace(offPh2, "Area Code for Company Office Phone");
	validate_mandatory_tb_with_message(offPh3, "Please enter Company Office Telephone No");
	validate_numeric_value_with_msg(offPh3, "Company Office Telephone No");
	checkBeginningSpace(offPh3, "Company Office Telephone No");
	var offPhonelen = document.remitCorpRecommend.offPh1.value + document.remitCorpRecommend.offPh2.value + document.remitCorpRecommend.offPh3.value;
	if((offPhonelen.length) > 25)
	{
	  	printMsg("Length of Company Office Phone No cannot exceed 25 characters");
	}
	
	//validate_mandatory_tb_with_message(mobileNo, "Please enter Mobile Phone Number");
	checkBeginningSpace(mobileNo,"Mobile Phone Number ");
	validate_numeric_value_with_msg(mobileNo,"Mobile Phone Number");
	var mobPhonelen = document.remitCorpRecommend.mobileNo.value;
	if((mobPhonelen.length) > 25)
	{
	  	printMsg("Length of Mobile Phone No cannot exceed 25 characters");
	}
	
	validate_mandatory_tb_with_message(empFirstName, "Please enter your First Name");
	checkBeginningSpace(empFirstName," First Name");
	validateStringValue(empFirstName,"First Name");
	if(empFirstName.value == "First Name")
	{
		 printMsg("Please enter your First Name");
	}
	
	validate_mandatory_tb_with_message(empLastName, "Please enter your Last Name");
	checkBeginningSpace(empLastName," Last Name");
	validateStringValue(empLastName,"Last Name");
	if(empLastName.value == "Last Name")
	{
		 printMsg("Please enter your Last Name");
	}
	
	validate_mandatory_tb_with_message(empDesignation, "Please enter your Designation");
	checkBeginningSpace(empDesignation," Designation");
	validateAlpaNumericSpecialChars(empDesignation,"Designation");
	
	if((empOffPh1.value == "Country Code") || (empOffPh2.value == "Area Code") || (empOffPh3.value == "Tel No"))
	{
		printMsg("Please enter a valid Office Phone No");		
	}
	validate_mandatory_tb_with_message(empOffPh1, "Please enter Country Code for your Office Phone");
	validate_numeric_value_with_msg(empOffPh1, "Country Code for your Office Phone");
	checkBeginningSpace(empOffPh1, "Country Code for your Office Phone");	
	validate_mandatory_tb_with_message(empOffPh2, "Please enter Area Code for your Office Phone");
	validate_numeric_value_with_msg(empOffPh2, "Area Code for your Office Phone");
	checkBeginningSpace(empOffPh2, "Area Code for your Office Phone");
	validate_mandatory_tb_with_message(empOffPh3, "Please enter your Office Telephone No");
	validate_numeric_value_with_msg(empOffPh3, "Your Office Telephone No");
	checkBeginningSpace(empOffPh3, "Your Office Telephone No");
	var offPhonelen = document.remitCorpRecommend.empOffPh1.value + document.remitCorpRecommend.empOffPh2.value + document.remitCorpRecommend.empOffPh3.value;
	if((offPhonelen.length) > 25)
	{
	  	printMsg("Length of your Office Phone No cannot exceed 25 characters");
	}
	
	validateEmail(empEmailT1,empEmailT2);
	
	return check_display_errors(remitCorpRecommend);
}

//validate employee corporate regn
function validateCorpEmpRegn(corpName,corpRegCode,corpEmpRegn)
{
	initialize_error_msgs();
	
	validate_mandatory_tb_with_message(corpName, "Please select your Company");
	
	validate_mandatory_tb_with_message(corpRegCode, "Please enter the Company Code provided to you");
	validateAlpaNumeric(corpRegCode, "Company Code");
	checkBeginningSpace(corpRegCode, "Company Code");	
	
	return check_display_errors(corpEmpRegn);
}

//validate Country Selection
function validateCountry(country, rmtDisp)
{
	initialize_error_msgs();
	
	validate_mandatory_tb_with_message(country, "Please select Country");
	
	return check_display_errors(rmtDisp);
}

//validate Country Selection
function validateCountry(country, destCountry, imtDisp)
{
	initialize_error_msgs();
	
	validate_mandatory_tb_with_message(country, "Please select Send Country");
	
	validate_mandatory_tb_with_message(destCountry, "Please select Receive Country");
	
	if((country.value != "") && (destCountry.value != ""))
	{
		if(country.value == destCountry.value)
		{
	  		printMsg("Send and Receive Country cannot be same. Please select Receive Country other than your Send Country");
			document.imtDisp.destCountry.value="";
			document.imtDisp.destCountry.focus();
		}
	}

	return check_display_errors(imtDisp);
}

//for validation of Login Name needed for the login present check done by Akshay 11/4/04
function checkLoginExistsForm(loginAvailPopUp)
{
	error = new Array();
	e = 0;

	var login1	  = document.imtRegn.emailT1.value;
	var login2	  = document.imtRegn.emailT2.value;
	var login	  = login1 + "@" +login2;
	var logLength = login.length;

	if(logLength < 3 || logLength > 70)
	{
		add_error_msg("Email Id should be of minimum 3 and maximum 70 characters");
	}

	if(logLength > 1)
	{
		if(((login.charAt(0) < 'a') || (login.charAt(0) > 'z')) && ((login.charAt(0) < 'A') || (login.charAt(0) > 'Z')))
		{
			add_error_msg("Email Id must begin with an alphabet");
		}
	}

//	for(var i = 0; i < logLength; i++)
//	{
//		if(((login.charAt(i) < '0') || (login.charAt(i) > '9')) && ((login.charAt(i) < 'a') || (login.charAt(i) > 'z')) && ((login.charAt(i) < 'A') || (login.charAt(i) > 'Z')) && (login.charAt(i) != '_'))
//		{
//			add_error_msg("Email Id can only contain alphabets and numbers separated by underscore if needed");
//			break;
//		}
//	}

	if(e > 0)
	{
		var errDes = "";
		for(n = 0; n <= error.length - 1; n++)
		{
			errDes = errDes + error[n] + "\n";
		}

		alert(errDes);
		document.imtRegn.emailT1.focus();
	}
	else
	{
		openPageNoScroll(loginAvailPopUp+login,'checkLogin',400,130);
	}
}


//Function Used for R2H Reg Landing Page Validation
function validateSenderR2HRegLanding(firstName,lastName,gender,D1,D2,D3,address,city,state,pincode,country,destCountry,emailT1,emailT2,resPh1,resPh2,resPh3,offPh1,offPh2,offPh3,mobileNo,industry,loginname,password,retypepwd,marketing,imtRegn)
{
	initialize_error_msgs();
	
	validate_mandatory_tb_with_message(firstName, "Please enter your First Name");
	checkBeginningSpace(firstName," First Name");
	  
	// included by mahender to check whether no space should be allowed in firstname field
	// Created Date :

	var firstSt = document.imtRegn.firstName.value;

	var nameLength = firstSt.length;
	var validStr1 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-";

	if(firstName.value == "First Name")
	{
		 printMsg("Please enter your First Name"); 
		 
	}
	else
	{
		for(i=0;i<nameLength;i++)
		{
			if(validStr1.indexOf(firstSt.charAt(i))==-1)
			{
				printMsg("Only alphabets with No Space should be allowed in First Name Field");
				break;
			}
		}
	}
	// end 
	
	validate_mandatory_tb_with_message(lastName, "Please enter your Last Name");
	checkBeginningSpace(lastName," Last Name");
	validateStringValue(lastName,"Last Name");
	if(lastName.value == "Last Name")
	{
		 printMsg("Please enter your Last Name");
	}
	
	if(document.imtRegn.userTypeId.value == "INDIV")
	{
		validate_mandatory_tb_with_message(gender, "Please select Gender");

    	validateDOB();
	}

	validateEmail(emailT1,emailT2);

	if((resPh1.value == "Country Code") || (resPh2.value == "Area Code") || (resPh3.value == "Tel No"))
	{
		printMsg("Please enter a valid Home Phone");		
	}
	validate_mandatory_tb_with_message(resPh1, "Please enter Country Code for Home Phone");
	validate_numeric_value_with_msg(resPh1, "Country Code for Home Phone");
	checkBeginningSpace(resPh1, "Country Code for Home Phone");
	validate_mandatory_tb_with_message(resPh2, "Please enter Area Code for Home Phone");
	validate_numeric_value_with_msg(resPh2, "Area Code for Home Phone");
	checkBeginningSpace(resPh2, "Area Code for Home Phone");
	validate_mandatory_tb_with_message(resPh3, "Please enter Home Telephone No");
	validate_numeric_value_with_msg(resPh3, "Home Telephone No");
	checkBeginningSpace(resPh3, "Home Telephone No");
	var resPhonelen = document.imtRegn.resPh1.value + document.imtRegn.resPh2.value + document.imtRegn.resPh3.value;
	if((resPhonelen.length) > 25)
	{
	  	printMsg("The maximum limit for a Home Phone Number is 25 digits");
	}

	if(mobileNo.value == "Mobile No")
	{
		printMsg("Please enter a valid Mobile Phone No or leave it blank");		
	}
	checkBeginningSpace(mobileNo,"Mobile Phone Number ");
	validate_numeric_value_with_msg(mobileNo,"Mobile Phone Number");
	var mobPhonelen = document.imtRegn.mobileNo.value;
	if((mobPhonelen.length) > 25)
	{
	  	printMsg("The maximum limit for a Mobile Phone Number is 25 digits");
	}
	
	validate_mandatory_tb_with_message(address, "Please enter your Door Number");
	checkBeginningSpace(address,"Address");
	validateTextField(address,"Address");
	
	validate_mandatory_tb_with_message(city, "Please enter your City");
	checkBeginningSpace(city,"City");
	validateStringValue(city,"City");
	
	validate_mandatory_tb_with_message(state, "Please enter your State");
	checkBeginningSpace(state,"State");
	validateStringValue(state,"State");
	
	validate_mandatory_tb_with_message(pincode, "Please enter your Pincode");
	checkBeginningSpace(pincode, "Pincode");
	validatePincode(pincode);
	
	validate_mandatory_tb_with_message(country, "Please select Send Country");
	validate_mandatory_tb_with_message(destCountry, "Please select Receive Country");

	if((country.value != "") && (destCountry.value != ""))
	{
		if(country.value == destCountry.value)
		{
	  		printMsg("Send and Receive Country cannot be same. Please select Receive Country other than your Send Country");
			document.imtRegn.destCountry.value="";
			document.imtRegn.destCountry.focus();
		}
	}

	if(emailT1.value == "" && emailT2.value == "")
	{
		loginname.value = "";
		//validate_mandatory_tb_with_message(loginname, "Please enter a Email Id");
		//checkBeginningSpace(loginname,"Email Id");
	}
	else
	{
		loginname.value = emailT1.value + "@" + emailT2.value;
	}
	
	var pwdLabel = "Password";

	if(isEmpty(stripWhitespace(document.imtRegn.password.value)))
	{
		printMsg("Please enter a "+pwdLabel);  
	} 

	checkBeginningSpace(password,pwdLabel);	
	validateTextField(password,pwdLabel);

	if(!((/\d/.test(password.value)) && (/[a-z]/i.test(password.value))))
	{
		 printMsg(pwdLabel+" should be alpha-numeric");
	}
	
	var passLn = password.value.length;
	if(passLn < 8 || passLn > 20)
	{
		printMsg(pwdLabel+" should be of minimum 8 and maximum 20 characters");
	}

	if(password.value != retypepwd.value)
	{
	  	printMsg("Please retype your "+pwdLabel);
	}

	//validate_mandatory_tb_with_message(industry, "Please select Industry");
	validate_mandatory_tb_with_message(document.imtRegn.marketing, "Please enter how did you hear about us");	


	var marketText = document.imtRegn.marketing1.value;
	var indx = marketText.indexOf("Enter");
	if (indx != -1)
	{
      	printMsg("Please enter how did you hear about us");
	}
	else
	{
		validateAlpaNumeric(document.imtRegn.marketing1, "How did you hear about us");
	}

	return check_display_errors(imtRegn);
}
