//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",textbox);
			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,textbox);
			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,textbox);
}

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",textbox);
			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  \"",textBox);
			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",pincode);
				break;
			}
		}
	}
}

function validateEmail(emailT1,emailT2)
{
	var t0 = emailT1.value;
	if(isEmpty(stripWhitespace(t0))){
		printMsg("Please enter the first half of your Email ID",emailT1);
	}
	
	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 @",emailT1);
			break;
		}
	}

	var t1 = emailT2.value;
	t1 = t1.toUpperCase();
	
	if(isEmpty(stripWhitespace(t1)))
	{
		printMsg("Please enter the second half of your Email ID",emailT2);		
	}
	
	if(t1.indexOf("R2H") != -1)
	{		
		printMsg("Email id should not end with r2h.com",emailT2);		
	}
	else if(t1.indexOf("TIMESOFMONEY") != -1)
	{
		printMsg("Email id should not end with timesofmoney.com",emailT2);	
	}
	else if(t1.indexOf("REMIT2HOME") != -1)
	{
		printMsg("Email id should not end with remit2home.com",emailT2);	
	}
	else if(t1.indexOf("R2I") != -1)
	{
		printMsg("Email id should not end with r2i.com",emailT2);	
	}
	else if(t1.indexOf("REMIT2INDIA") != -1)
	{
		printMsg("Email id should not end with remit2india.com",emailT2);	
	}


	
	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 @",emailT2);		
			break;			
		}
	}
	
	var temp1 = t0+"@"+t1;
	if((isEmail(temp1))==false)
	{
		printMsg("Please enter a valid Email ID",emailT1);		
	}
}

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,textBox);
				break;
			}
		}
	}
}
function isYear (s)
{   if (isEmpty(s)) 
       if (isYear.arguments.length == 1) return defaultEmptyOK;
       else return (isYear.arguments[1] == true);
    if (!isNonnegativeInteger(s)) return false;
    return ((s.length == 2) || (s.length == 4));
}

function isDay (s)
{   if (isEmpty(s)) 
       if (isDay.arguments.length == 1) return defaultEmptyOK;
       else return (isDay.arguments[1] == true);   
    return isIntegerInRange (s, 1, 31);
}
function isMonth (s)
{   if (isEmpty(s)) 
       if (isMonth.arguments.length == 1) return defaultEmptyOK;
       else return (isMonth.arguments[1] == true);
    return isIntegerInRange (s, 1, 12);
}

function isNonnegativeInteger (s)
{   var secondArg = defaultEmptyOK;

    if (isNonnegativeInteger.arguments.length > 1)
        secondArg = isNonnegativeInteger.arguments[1];

    // The next line is a bit byzantine.  What it means is:
    // a) s must be a signed integer, AND
    // b) one of the following must be true:
    //    i)  s is empty and we are supposed to return true for
    //        empty strings
    //    ii) this is a number >= 0

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) >= 0) ) );
}

function isSignedInteger (s)

{   if (isEmpty(s)) 
       if (isSignedInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isSignedInteger.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = defaultEmptyOK;

        if (isSignedInteger.arguments.length > 1)
            secondArg = isSignedInteger.arguments[1];

        // skip leading + or -
        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;    
        return (isInteger(s.substring(startPos, s.length), secondArg))
    }
}

function isInteger (s)

{   var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    // All characters are numbers.
    return true;
}
function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}
function isIntegerInRange (s, a, b)
{   if (isEmpty(s)) 
       if (isIntegerInRange.arguments.length == 1) return defaultEmptyOK;
       else return (isIntegerInRange.arguments[1] == true);

    // Catch non-integer strings to avoid creating a NaN below,
    // which isn't available on JavaScript 1.0 for Windows.
    if (!isInteger(s, false)) return false;

    // Now, explicitly change the type to integer via parseInt
    // so that the comparison code below will work both on 
    // JavaScript 1.2 (which typechecks in equality comparisons)
    // and JavaScript 1.1 and before (which doesn't).
    var num = parseInt (s);
    return ((num >= a) && (num <= b));
}
/*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",document.imtRegn.D1);
	}
	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",document.imtRegn.D1);			
		}
		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",document.imtRegn.D1);
				
			}// 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",document.imtRegn.D1);
					
				}//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",document.imtRegn.D1);
						
					}// 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",resPh1);		
	}
	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",resPhonelen);
	}

	if((offPh1.value == "Country Code") || (offPh2.value == "Area Code") || (offPh3.value == "Tel No"))
	{
		printMsg("Please enter a valid Work Phone",offPh1);		
	}
	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",offPhonelen);
	}
	
	if(mobileNo.value == "Mobile No")
	{
		printMsg("Please enter a valid Mobile Phone No or leave it blank",mobileNo);		
	}
	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",mobileNo);
	}
	
	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(country.value == "United Kingdom")
	{
		if((document.imtRegn.resPh3.value.length) > 7)
		{
			printMsg("The maximum limit for a Home Phone Number is 7 digits");
		}
	}
	else 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 validateSenderR2HRegLanding(firstName,lastName,gender,D1,D2,D3,destCountry,emailT1,emailT2,resPh1,resPh2,resPh3,mobile1,mobile3,loginname,regPassword,retypepwd,marketing,marketing1,regtnc,imtRegn)
{
	//alert("in validateSenderR2HRegLanding");
	initialize_error_msgs();
	var country = document.getElementById("country").value;
	
	validateEmail(emailT1,emailT2);
	
	var pwdLabel = "Password";
	var strPwd =document.imtRegn.regPassword.value;
	if(strPwd.indexOf(" ")!=-1)
	{
			printMsg("Password should not have space",document.imtRegn.regPassword);
	}
			
	if(isEmpty(stripWhitespace(document.imtRegn.regPassword.value)))
	{
		
		printMsg("Please enter 8 digit alphanumeric "+pwdLabel,document.imtRegn.regPassword);  
	} 
	
	checkBeginningSpace(regPassword,document.imtRegn.regPassword);	
	validateTextField(regPassword,document.imtRegn.regPassword);
	
	if(!((/\d/.test(regPassword.value)) && (/[a-z]/i.test(regPassword.value))))
	{
		
		 printMsg(pwdLabel+" should be alpha-numeric",document.imtRegn.regPassword);
	}
	
	var passLn = regPassword.value.length;
	if(passLn < 8 || passLn > 20)
	{
		printMsg(pwdLabel+" should be of minimum 8 and maximum 20 characters",document.imtRegn.regPassword);
	}
	validate_mandatory_tb_with_message(regPassword, "Please enter a Password");

	if(regPassword.value != retypepwd.value)
	{
	  	printMsg("Please retype your "+pwdLabel,retypepwd);
	}
	if(document.imtRegn.regPassword.value != "")
	{
		var alPhab = /[^0-9a-zA-Z]/;

		 if(strPwd.indexOf(alPhab) != -1)
		{
			printMsg(pwdLabel+ "should be alpha-numeric",document.imtRegn.regPassword.value);
		}
	}

	checkBeginningSpace(firstName," First Name");
	validateStringValue(firstName,"First Name");
	if((firstName.value == "FIRST NAME")||(firstName.value == "First Name"))
	{
		 printMsg("Please enter your First Name",firstName);
	}

	if(firstName.value.length <=1)
	{
		printMsg("First Name cannot be a single alphabet. Please enter your complete First Name",firstName);
	}

	if(lastName.value.length <=1)
	{
		printMsg("Last Name cannot be a single alphabet. Please enter your complete Last Name",lastName);
	}	
	
/*	if(((middleName.value != "MIDDLE NAME")||(middleName.value != "Middle Name")) && middleName.value != "")
	{
		checkBeginningSpace(middleName," Middle Name");
		validateStringValue(middleName,"Middle Name");
	}
	if(middleName.value == "Middle Name")
	{
		 printMsg("Please enter your Middle Name",middleName);
	}
*/	
	checkBeginningSpace(lastName," Last Name");
	validateStringValue(lastName,"Last Name");

	if((lastName.value == "LAST NAME")||(lastName.value == "Last Name"))
	{	
		 printMsg("Please enter your Last Name",lastName);
	}

	if(document.imtRegn.userTypeId.value == "INDIV")
	{
		validate_mandatory_tb_with_message(gender, "Please select Gender");
    	validateDOB();
	}

	if((document.imtRegn.resPh1.value == "Country Code"))
	{
		printMsg("Please enter a valid Country Code",resPh1);		
	}

	if(country != "Singapore")
	{
		if((document.imtRegn.resPh2.value == "Area Code"))
		{
			printMsg("Please enter a valid Area Code",resPh2);	
		}
	}

	if((document.imtRegn.resPh3.value == "Phone no."))
	{
		printMsg("Please enter a valid Phone no.",resPh3);	
	}

	if(document.imtRegn.resPh1.value != "Country Code")
	{
		//alert("Country Code");
		//validate_mandatory_tb_with_message(resPh1, "Please enter Country Code for Alternete No");
		validate_numeric_value_with_msg(resPh1, "Country Code for Alternate No");
		checkBeginningSpace(resPh1, "Country Code for Alternate No");
	}
 	
	if(country != "Singapore")
	{
		if(document.imtRegn.resPh2.value != "Area Code")
		{
			//alert("Area Code");
			//validate_mandatory_tb_with_message(resPh2, "Please enter Area Code for Alternete No");
			validate_numeric_value_with_msg(resPh2, "Area Code for Alternate No");
			checkBeginningSpace(resPh2, "Area Code for Alternate No");
		}
	}

	if(document.imtRegn.resPh3.value != "Phone no.")
	{
		//alert("Phone no.");
		//validate_mandatory_tb_with_message(resPh3, "Please enter Alternete Telephone No");
		validate_numeric_value_with_msg(resPh3, "Phone No.");
		checkBeginningSpace(resPh3, "Phone no.");
	}
	//alert("country:"+country.value);
	if(country !="United States" && country != "Singapore")
	{		
		if(document.imtRegn.resPh2.value.length != 3 && document.imtRegn.resPh2.value.length != 4)
		{
			printMsg("Length of Area Code for Day-Time Phone No has to be 3 or 4 digits",resPh2);
		}
		if(document.imtRegn.resPh2.value.length ==3)
		{
			if(document.imtRegn.resPh3.value.length !=7)
			{
				printMsg("Length of Phone No has to be 7 digits",resPh3);
			}
		}
		if(document.imtRegn.resPh2.value.length ==4)
		{
			if(document.imtRegn.resPh3.value.length !=6)
			{
				printMsg("Length of Phone No has to be 6 digits",resPh3);
			}
		}
	}
	else if(country =="United States")
	{
		if((document.imtRegn.resPh2.value.length) != 3)
		{
			printMsg("Length of Area Code for Day-Time Phone No has to be 3 digits",resPh2);
		}
		if((document.imtRegn.resPh3.value.length) != 7)
		{
			printMsg("Length of Day-Time Phone No has to be 7 digits",resPh3);
		}
	}

	var resPhonelen = document.imtRegn.resPh1.value + document.imtRegn.resPh2.value + document.imtRegn.resPh3.value;
	
	if((resPhonelen.length) > 25)
	{
	  	if(country == "United Kingdom")
		{
			printMsg("The maximum limit for a Home Phone Number is 7 digits",document.imtRegn.resPhoneLength);
		}
		else
		{
			printMsg("The maximum limit for a Home Phone Number is 25 digits",document.imtRegn.resPhoneLength);
		}
	}

	
	

	if((document.imtRegn.mobile1.value == "Country Code"))
	{
		printMsg("Please enter a valid Country Code",mobile1);		
	}

/*	if((document.imtRegn.mobile2.value == "Area Code"))
	{
		printMsg("Please enter a valid Area Code",mobile2);	
	}
*/

	if((document.imtRegn.mobile3.value == "Phone no."))
	{
		printMsg("Please enter a valid Phone no.",mobile3);	
	}

	if(document.imtRegn.mobile1.value != "Country Code")
	{
		//alert("Country Code");
		//validate_mandatory_tb_with_message(resPh1, "Please enter Country Code for Alternete No");
		validate_numeric_value_with_msg(mobile1, "Country Code for Mobile No");
		checkBeginningSpace(mobile1, "Country Code for Mobile No");
	}

//	if((document.imtRegn.resPh2.value.length) != 3)
//	{
//		printMsg("Length of Area Code for Day-Time Phone No has to be 3 digits",resPh2);
//	}
//	if((document.imtRegn.resPh3.value.length) != 7)
//	{
//		printMsg("Length of Day-Time Phone No has to be 7 digits",resPh3);
//	}
	
/*	if(document.imtRegn.mobile2.value != "Area Code")
	{
		//alert("Area Code");
		//validate_mandatory_tb_with_message(resPh2, "Please enter Area Code for Alternete No");
		validate_numeric_value_with_msg(mobile2, "Area Code for Mobile No");
		checkBeginningSpace(mobile2, "Area Code for Mobile No");
	}
*/

	if(document.imtRegn.mobile3.value != "Phone no.")
	{
		//alert("Phone no.");
		//validate_mandatory_tb_with_message(resPh3, "Please enter Alternete Telephone No");
		validate_numeric_value_with_msg(mobile3, "Phone No. for Mobile No");
		checkBeginningSpace(mobile3, "Mobile no.");
	}
	
	//var mobilePhonelen = document.imtRegn.mobile1.value + document.imtRegn.mobile2.value + document.imtRegn.mobile3.value;
	var mobilePhonelen = document.imtRegn.mobile1.value + document.imtRegn.mobile3.value;
	if((mobilePhonelen.length) > 25)
	{
	  	printMsg("The maximum limit for a Mobile Number is 25 digits",document.imtRegn.mobileLength);
	}
	
	/*
	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);
	if(country.value!="United States")
	{	
		var len = document.imtRegn.pincode.value.length;

		var validchars = "0123456789abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		var currChar, prevChar, nextChar;
		var validAlph = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		var validNum = "0123456789";
		var validAlphFlag = false;
		var validNumFlag = false;


		for(i = 0; i <= len - 1; i++)
		{
			currChar = document.imtRegn.pincode.value.charAt(i);
			prevChar = document.imtRegn.pincode.value.charAt(i-1);
			nextChar = document.imtRegn.pincode.value.charAt(i+1);

			if(!(validAlph.indexOf(currChar) == -1) && validAlphFlag == false)
			{
				validAlphFlag = true;
			}

			if(!(validNum.indexOf(currChar) == -1) && validNumFlag == false)
			{
				validNumFlag = true;
			}

			if(validchars.indexOf(currChar) == -1)
			{
				if(country.value == "United Kingdom")
				{
					printMsg("Invalid character '" + currChar + "' entered in the post code.",pincode);
					break;
				}
				else
				{
					printMsg("Invalid character '" + currChar + "' entered in the Postal Code.",document.imtRegn.pincode);
					break;
				}
			}

			if(currChar == " " && prevChar == " " || prevChar == " " && currChar == " " && nextChar == " " || prevChar == " " && currChar == " " && i == len-1 || currChar == " " && i == len-1)
			{
				if(country.value == "United Kingdom")
				{
					if(i == len-1)
					{
						add_error_msg("Remove Unnecessary Space in the End of Postcode",pincode);
					}
					else
					{
						add_error_msg("Remove Unnecessary Space in the Postcode. Only one space is allowed in middle.",pincode);
					}
				}
				else
				{
					if(i == len-1)
						{
							add_error_msg("Remove Unnecessary Space in the End of Postal Code",document.imtRegn.pincode);
						}
						else
						{
							//add_error_msg("Remove Unnecessary Space in the Postcode. Only one space is allowed in middle.");
							add_error_msg("Remove Unnecessary Space in the Postal Code.",document.imtRegn.pincode);
						}
				}

				break;
			}
		}

		if((document.imtRegn.country.value != "United Arab Emirates") && (document.imtRegn.country.value != "Hong Kong")) //country check for HK & UAE
		{		
			if((document.imtRegn.country.value == "Singapore") || (document.imtRegn.country.value == "Australia") || (document.imtRegn.country.value == "United States") ||(document.imtRegn.country.value == "Portugal"))
			{
				validate_numeric_value_with_msg(pincode, "Postal Code");
				if((document.imtRegn.country.value == "Singapore") && (len != 6))
				{
					printMsg("Postal Code should be of 6 characters",document.imtRegn.pincode);
				}
				else if((document.imtRegn.country.value == "Australia") && (len != 4))
				{
					printMsg("Postal Code should be of 4 characters",document.imtRegn.pincode);
				}
				else if((document.imtRegn.country.value == "United States") && (len != 5))
				{
					printMsg("Postal Code should be of 5 characters",document.imtRegn.pincode);
				}
				else if((document.imtRegn.country.value == "Portugal") && ( len < 3 || len > 8) )
				{
					printMsg("Postal Code should be of minimum 3 and maximum 8 characters",document.imtRegn.pincode);
				}

			}
			else
			{
				if(document.imtRegn.country.value == "Canada")
				{
					var pcode = document.imtRegn.pincode.value;
					if(len != 7)
					{
						printMsg("Postal Code should be of 7 characters",document.imtRegn.pincode);
					}
					else if(pcode.indexOf(" ") != 3)
					{
						printMsg("There must be a space after 3rd character in Postal Code",document.imtRegn.pincode);
					}
				}
				else if(country.value == "United Kingdom")
				{			
					if( len < 5 || len > 8)
					{
						printMsg("Postal Code should be of minimum 5 and maximum 8 characters",document.imtRegn.pincode);
					}

					if(!(validAlphFlag == true && validNumFlag == true))
					{
						add_error_msg("Postcode must be Alpha Numeric",pincode);
					}
				}
				else
				{
					if( len < 3 || len > 8)
					{
						printMsg("Postal Code should be of minimum 3 and maximum 8 characters",document.imtRegn.pincode);
					}				
				}

				if((document.imtRegn.country.value == "France") || (document.imtRegn.country.value == "Germany") || (document.imtRegn.country.value == "Italy") || (document.imtRegn.country.value == "Euroland"))
				{
					var pncode = document.imtRegn.pincode.value;
					if(pncode.split(" ").length > 2)
					{
						add_error_msg("Only one single space is allowed in Postal Code",document.imtRegn.pincode);
					}
						
					if(!validNumFlag == true)
					{
						add_error_msg("Only Alphanumeric or Numeric is allowed in Postal Code",document.imtRegn.pincode);
					}
				}
				else if(document.imtRegn.country.value == "Belgium")
				{
					validate_numeric_value_with_msg(pincode, "Postal Code");
					if(len != 4)
					{
						printMsg("Postal Code should be of 4 characters",document.imtRegn.pincode);
					}
				}
				else if(document.imtRegn.country.value == "Spain")
				{
					if( !(validAlphFlag == true || validNumFlag == true))
					{
						add_error_msg("Postal code can be numeric",document.imtRegn.pincode);
					}
				}
				else
				{
					if(!(validAlphFlag == true && validNumFlag == true))
					{
						add_error_msg("Postal Code must be Alpha Numeric",document.imtRegn.pincode);
					}
				}
			}
		}
	}
	else if(country.value=="United States")
	{
		//alert("country:"+country.value);
		var len = document.imtRegn.pincode.value.length;
			
		var validchars = "0123456789abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ";		
		var currChar, prevChar, nextChar;
		var validAlph = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		var validNum = "0123456789";
		var validAlphFlag = false;
		var validNumFlag = false;

		for(i = 0; i <= len - 1; i++)
		{
			currChar = document.imtRegn.pincode.value.charAt(i);
			prevChar = document.imtRegn.pincode.value.charAt(i-1);
			nextChar = document.imtRegn.pincode.value.charAt(i+1);

			if(!(validAlph.indexOf(currChar) == -1) && validAlphFlag == false)
			{
				validAlphFlag = true;
			}

			if(!(validNum.indexOf(currChar) == -1) && validNumFlag == false)
			{
				validNumFlag = true;
			}

			if(validchars.indexOf(currChar) == -1)
			{
				printMsg("Invalid character '" + currChar + "' entered in the Postal Code.",pincode);
				break;
			}

			if(currChar == " " && prevChar == " " || prevChar == " " && currChar == " " && nextChar == " " || prevChar == " " && currChar == " " && i == len-1 || currChar == " " && i == len-1)
			{
				if(i == len-1)
				{
					add_error_msg("Remove Unnecessary Space in the End of Postal Code",pincode);
				}
				else
				{
					//add_error_msg("Remove Unnecessary Space in the Postcode. Only one space is allowed in middle.");
					add_error_msg("Remove Unnecessary Space in the Postal Code.",pincode);
				}

				break;
			}
		}
		
		validate_numeric_value_with_msg(pincode, "Postal Code");
		if(len != 5)
		{
			printMsg("Postal Code should be of 5 characters",pincode);
		}
	}*/

	validate_mandatory_tb_with_message(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",marketing1);
	}
	else
	{
		validateAlpaNumeric(marketing1, "How did you hear about us");
	}

	validate_mandatory_tb_with_message(document.imtRegn.callDate, "Please select Date");
	var date2 = document.imtRegn.callDate.value;
	var date1	= document.imtRegn.todayDate.value;
	
	date1 = date1.replace("-"," , ");
	date1 = date1.replace("-"," , ");
	date2 = date2.replace("-"," , ");
	date2 = date2.replace("-"," , ");
	date1 = new Date(date1);
	date2 = new Date(date2);

	var daysApart = Math.round((date1-date2)/86400000);
	if (daysApart > 0)
	{
		printMsg("Date cannot be a past date",document.imtRegn.callDate);
	}

	//alert(check_display_errors(imtRegn));


	if(document.imtRegn.regtnc.checked == false)
	{
		printMsg("Please read and accept the Terms And Conditions",regtnc);
	}

	if(check_display_errors(imtRegn) == true)
	{
		// Added by Divesh Tejnani on 01-Jan-2012
		//passEncode Function Added for Salt Hashing of password.
		passEncode();
		document.imtRegn.submit();
	}
	else
	{
		return false;
	}


}

function passEncode()
{
	var pass = document.getElementById('regPassword').value;	
	var retypepass = document.getElementById('retypepwd').value;
	var token = document.getElementById('formid').value;

	document.getElementById('regPassword').value = encodeValue(pass+token);
	document.getElementById('retypepwd').value = encodeValue(retypepass+token);
}

function checkRegLoginFormSelf(loginid,password,passwordENC,frmName){
	//alert("checkRegLoginFormSelf");
		//alert(loginid.value);
	var flag = 0;
	if(frmName.loginid.value == "")
	{
		//alert("checkRegLoginFormSelf loginid");
		printMsg("Please enter your Email ID",loginid);
		flag = 1;
		//return false;
	}
	
	if(frmName.password.value == "")
	{
		//alert("checkRegLoginFormSelf password");
		printMsg("Please enter your Password",password);
		flag = 1;
		//return false;
	}

	if(flag == 1)
	{
		return false;
	}
	else
	{
		var passLen = frmName.password.value.length;
		var newPass = "";

		for(var i=0; i<passLen; i++)
		{
			newPass += "x";
		}

		frmName.passwordENC.value = encodeValue(frmName.password.value);
		frmName.password.value = newPass;
		
		frmName.submit();
		return true;		
	}
}

function displayCtyCode(country)
{
	var xyz = country;
	
	var dispFlag = 0;
	var slab = 0;

	this.displayImg = function()
	{
		
				
		if(country =="United States")
		{
			countryCode = "1";
		}
		else if(country =="United Kingdom")
		{
			countryCode = "44";
		}
		else if(country =="Australia")
		{
			countryCode = "61";
		}
		else if(country =="Canada")
		{
			countryCode = "1";
		}
		else if(country =="Euroland")
		{
			countryCode = "0";
		}
		else if(country =="Singapore")
		{
			countryCode = "65";
		}
		else if(country =="Hong Kong")
		{
			countryCode = "852";
		}
		else if(country =="Japan")
		{
			countryCode = "81";
		}
		else if(country =="United Arab Emirates")
		{
			countryCode = "971";
		}
		else if(country =="Austria")
		{
			countryCode = "43";
		}
		else if(country =="Belgium")
		{
			countryCode = "32";
		}
		else if(country =="France")
		{
			countryCode = "33";
		}
		else if(country =="Germany")
		{
			countryCode = "49";
		}
		else if(country =="Ireland")
		{
			countryCode = "353";
		}
		else if(country =="Italy")
		{
			countryCode = "39";
		}
		else if(country =="Portugal")
		{
			countryCode = "351";
		}
		else if(country =="Netherlands")
		{
			countryCode = "599";
		}
		else if(country =="Spain")
		{
			countryCode = "34";
		}
		else if(country =="Cyprus")
		{
			countryCode = "357";
		}
		else if(country =="Finland")
		{
			countryCode = "358";
		}
		else if(country =="Greece")
		{
			countryCode = "30";
		}
		else if(country =="Luxembourg")
		{
			countryCode = "352";
		}
		else if(country =="Malta")
		{
			countryCode = "356";
		}
		else if(country =="Slovakia")
		{
			countryCode = "421";
		}
		else if(country =="Slovenia")
		{
			countryCode = "386";
		}
		else
		{
			countryCode = "0"
		}
		
		return countryCode;
	};
}

function ctyCode(tt)
{
	var country = tt;
	var abc = new displayCtyCode(country);
	var r = abc.displayImg();
	document.getElementById('resPh1').value = r;	
	document.getElementById('mobile1').value = r;
}

function checkIfLoginExists(loginAvailPopUp)
{
	error = new Array();
	e = 0;
	var xmlHttp1;

	var emailT1	  = document.imtRegn.emailT1.value;
	var emailT2	  = document.imtRegn.emailT2.value;
	var login	  = emailT1+"@"+emailT2;
	var logLength = login.length;
	//alert("loginAvailPopUp:"+loginAvailPopUp);
	//alert("login:"+login);
	//alert("logLength:"+logLength);

	if(login=="0")
	{
		document.getElementById('loginDisp').innerHTML = '';
		add_error_msg("Please enter Email ID",document.imtRegn.emailT1);
	}
	else
	{
		
		validRegExp = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
		if(!(login.search(validRegExp) == -1 ))
		{
			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,160);
					xmlHttp1=GetXmlHttpObject()
					if (xmlHttp1==null)
					{
						alert ("Browser does not support HTTP Request")
						return
					} 
					//xmlHttp1.abort();
					//alert("loginAvailPopUp:"+loginAvailPopUp+escape(login));
					xmlHttp1.open("GET", loginAvailPopUp+escape(login), true);
					xmlHttp1.onreadystatechange=function()
					{
						if(xmlHttp1.readyState == 4)
						{
							//alert(xmlHttp1.responseText)
							document.getElementById('loginDisp').innerHTML =xmlHttp1.responseText;
						}
					}
					xmlHttp1.send(null);
			}

		}
		else
		{
			document.getElementById('loginDisp').innerHTML = '';
			add_error_msg("Please enter a valid Email id",document.imtRegn.emailT1);
		}
	}
}

function limitText(limitField, limitNum)
{
	if (limitField.value.length > limitNum)
	{
		limitField.value = limitField.value.substring(0, limitNum);
	} 
	else 
	{
		//limitCount.value = limitNum - limitField.value.length;
	}
}
