// Charecter Decleration
//............................................................................
var SPECIAL_CHARACTERS_NUMBERS = "`~!@#$%^&*()_-+=|\\}}{{\"':;<,>.?/0123456789"
var ALL_SPECIAL_CHARACTERS = "`~!@#$%^&*()_-+=|\\}}{{\"':;<,>.?/"
var ALL_NUMBERS = "0123456789"
var ALL_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
var SP_CHAR_DOT = "`~!@#$%^&*()_-+=|\\}[{]\"':;<,>?/0123456789"
var VALID_APP_NO = "`~!@#$%^&*()+=|\\{[}]\"':;<,>.?"
var VALID_RECEIPT_NO = "`~!@#$%^&*()+=\|{[}]\"':;<,>.?"

//sadashiv
var TAKEONLY_NUMBER = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`~!@#$%^&*()=\\|}]{[\"':;?><"


//...............................................................................
// These charecters are not allowed
var VALID_NAME_CHAR="`~!@#$%^&*()_-+=|\\}[{]\"':;<,>?/0123456789";
var ADDRESS_CHAR="\"'";
var NAME_CHAR="`~@#$%^&*()_-+=|\\}]{[\"':;?/><,";
var STATE_CHAR="`~!@#$%^*+=|\\}{\"':;?><";
var CITY_CHAR="`~!@#$%^*+=|\\}{\"':;?><";
var PHONE_CHAR="`~!@#$%^*=|\\]}[{\"':;?/><"
var UPLINE_CHAR="`~!@#$%^&*()_+=\\|]}{[\"':;?/>.<,/";
var USERID_CHAR="`~!@#$%^&*()+=\\|}]{[\"':;?><,";

//alert messages
var AMOUNT = "Please enter the Amount"
var VALID_AMOUNT="Amount should be Numeric"
var YEARS = "Please enter the Months"
var VALID_YEARS="Year should be Numeric"
var VALID_MONTHS="Month should be Numeric"
var PURPOSE = "Please tell us Purpose Of Loan"
var FULL_NAME="Please enter the Full Name"
var FIRST_NAME="Please enter the First Name"
var MIDDLE_NAME="Please enter the Middle Name"
var LAST_NAME="Please enter the Last Name"
var DAYS="Please select the date from drop Down Menu"
var MONTH="Please select the Month from drop Down Menu"
var MONTHS="Please select the Months from drop Down Menu"
var YEAR="Please select the Year from drop Down Menu"
var MARITALSTATUS="Please select the Marital status from drop Down Menu"
var POST_CODE="Plese enter the Post Code"
var VALID_CODE="Post Code should be Numeric"
var EMAIL = "Please enter the Email Address"
var VALID_EMAIL = "Please enter valid Email Address"
var TELEPHONE="Please provide us your telephone number"
var EMP_STATUS="Please select the Employment Status"
var OCCUPATION="Please enter the Occuption"
var INCOME_TYPE="Please select the Income Type"
var INCOME="Please enter the Income"
var VALID_INCOME="Income should be Numeric"
var ALL_BALANCE="Current Balance for all accounts is Mandatory"
var V_ALL_BALANCE="Current Balance for all accounts should be Numeric"
var MONTHLY_REP="Please enter the Monthly Repayments"
var VALID_MONTHLY_REP="Monthly Repayments Should be Numeric"
var CUR_ARREARS="Please enter the Current Arrears"
var VALID_CUR_ARREARS="Current Arrears Should be Numeric"
var M12_ARREARS="Please enter the Highest Arrears in Last 12 Months "
var VALID_M12_ARREARS="Highest Arrears in Last 12 Months Should be Numeric"
var CUR_BALANCE="Please enter the Current Balance"
var VALID_CUR_BALANCE="Current Balance should be Numeric"
var PAY="Please enter How Much Did You Pay"
var VALID_PAY="Pay should be Numeric"
var WORTH="Please tell us What Is It Worth Now ?"
var VALID_WORTH="Worth should be Numeric"
var STREET="Please enter the Street"
var TOWN="Please enter the Town / City"
var COUNTRY="Please enter the County"
var ADDRESS="Please enter the full address"
var HLYEARS="Please enter the years"
var HLMONTHS="Please enter months"
var VALID_YEARS="Year should be Numeric"
var VALID_MONTHS="Month should be Numeric"
var VALID_TELEPHONE="Phone number should be numeric"
var EMPSTATUS="Please select Employee Status"
var OCCUPATION="Please enter occupation"
var GROSSINCOME="please enter Gross income"
var VALID_INCOME="income should be Numeric"
var HOUSEWORTH="please enter your House worth"
var MORTAGE="please enter your Mortage"
var FINDUS="please choose how did you find us"
var WRONG_ENTRY = "Please Enter Proper Entry"

var EMP_NAME = "Please enter 1st applicant's Employer name "
var EMP_NAME1 = "Please enter 2nd applicant's Employer name "
var EMP_ADDR = "Please enter 1st applicant's Employer address "
var EMP_ADDR1 = "Please enter 2nd applicant's Employer address "
var EMP_DUR = "Please enter 1st applicant's duration of employment"
var EMP_DUR1 = "Please enter 2nd applicant's duration of employment"
var PREV_EMP_NAME = "Please enter 1st applicant's Previous Employer name "
var PREV_EMP_NAME1 = "Please enter 2nd applicant's Previous Employer name "
var PREV_EMP_ADDR = "Please enter 1st applicant's Previous Employer Address "
var PREV_EMP_ADDR1 = "Please enter 2nd applicant's Previous Employer Address "
var PREV_EMP_DUR = "Please enter 1st applicant's duration of employment with previous company "
var PREV_EMP_DUR1 = "Please enter 2nd applicant's duration of employment with previous company"
var BANK_NAME = "Please enter bank name" 
var BANK_ADDRESS = "Please enter bank address"
var CHILDREN	 = "Please enter how many children"
var MRP = "Please enter Monthly Rental Payment"
var MCT = "Please enter Monthly Council Tax"

var mpymt = "Monthly payment should be numeric"

var Max_Number="Max Number of Results should be Numeric";
var IE = document.all? true : false;
var NN = document.layers? true : false;

//..............................................................................
//To check for special characters.
function funHideCtrl()
{		
 	window.divGroupAll.style.display =  "none";		
	reff=document.URL
	refnum=reff.indexOf("val=all")
	if (refnum!=-1)
	{	alert("Please Fill-UP all Fields")
		window.divGroupAll.style.display ="";	
	}
	
}		

function fnIsValidChar(txtfld,  spChar, mes)
{
	var txtString= fnTrim(txtfld.value);
	for(var i=0; i<txtString.length; i++)
	{
	if(spChar.indexOf(txtString.charAt(i))!= -1)
	{
	alert(mes)
	txtfld.focus();
	txtfld.select();
	return true;
	}
	}
	return false;
		
}

//..............................................................................
//To check for special characters.

function fnIsValidChar2(txtfld, mes)
{
	spChar = "`~!@#$%^&*()_-+=|\\}}{{\"' :;<>?/abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ£";
	var txtString= fnTrim(txtfld.value);
	for(var i=0; i<txtString.length; i++)
	{
	if(spChar.indexOf(txtString.charAt(i))!= -1)
	{
	alert(mes)
	txtfld.focus();
	txtfld.select();
	return true;
	}
	}
	return false;
		
}
//..............................................................................
//To check for special characters.

function fnIsValidChar1(txtfld, mes)
{
	spChar = "`~!@#$%^&*()_-+=|\\}}{{\"':;<,>.?/123456789";
	var txtString= fnTrim(txtfld.value);
	for(var i=0; i<txtString.length; i++)
	{
	if(spChar.indexOf(txtString.charAt(i))!= -1)
	{
	alert(mes)
	txtfld.focus();
	txtfld.select();
	return true;
	}
	}
	return false;
		
}

//..............................................................................
//To check for fullstop

function fnIsValidChar3(txtfld, mes)
{
	spChar = "`~!@#$%^&*()_-+=|\\}}{{\"':;<,>.?/";
	var txtString= fnTrim(txtfld.value);
	for(var i=0; i<txtString.length; i++)
	{
	if(spChar.indexOf(txtString.charAt(i))!= -1)
	{
	alert(mes)
	txtfld.focus();
	txtfld.select();
	return true;
	}
	}
	return false;
		
}


//..............................................................................
//To allow the passed characters.

function fnAllowThisChar(txtfld, spChar, mes)
{
	var txtString= fnTrim(txtfld.value);
	for(var i=0; i<txtString.length; i++)
	{
	if(spChar.indexOf(txtString.charAt(i))== -1)
	{
	alert(mes)
	txtfld.focus();
	txtfld.select();
	return true;
	}
	}
	return false;
		
}

//----------------------------------------------------------------------------------------------
//To check single and double quotes.

function fnIsQuotes(txtfld, mes){
	var a_strString = fnTrim(txtfld.value)
	if(a_strString.indexOf('"') != -1)
	  {
	alert(mes)
	txtfld.focus();
	txtfld.select();
	return true;
	}
	if(a_strString.indexOf("'") != -1)
	{
	alert(mes)
	txtfld.focus();
	txtfld.select();
	return true;
	}
	
	return false
}




//--------------------------------------------------------------------------------------------------------------------

// Validates email id.

function fnIsEmail(txtfld, mes)
{
	var strString=fnTrim(txtfld.value);
	if(strString.length==0)
	{
	return false
	}
	else if(strString.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+$/)== -1)
    {
	alert(mes);
	txtfld.select();
	txtfld.focus()
	return true;		
	}
	return false;
	
}


//--------------------------------------

/*function emailcheck(txtfld, mes)
{
var string1=txtfld.value;
if (string1.indexOf("@")==-1 && string1.indexOf("."))
{
alert(mes)
txtfld.select();
txtfld.focus();
return true
}
return false;
}

*/


function emailcheck(txtfld, mes)
{
var str;
var string1=txtfld.value;
 str = "";
if (string1.indexOf("@")==-1){
	str = "NO";}
else if (string1.indexOf("@")==0){
	str = "NO";}
else if (string1.indexOf(".")==-1){
	str = "NO";}
else if (string1.indexOf(".")==0){
	str = "NO";}
else if (string1.indexOf("@") + 1 == string1.indexOf(".")){
	str = "NO";}
else if (string1.indexOf("@") + 1== string1.length){
	str = "NO";}
else if(string1.lastIndexOf(".") + 1== string1.length){
	str = "NO";}
else if(string1.indexOf("@") != string1.lastIndexOf("@")){
	str = "NO";}

else{
	str = "YES";}

if (str=="NO"){	
	alert(mes);
	txtfld.select();
	txtfld.focus();
	return true;
	}
	else{
		return false;}
}











//---------------------------------------------------------------------------------------------------
//Validates website.
function fnIsWebsite(txtfld, mes)
{
	var strString=fnTrim(txtfld.value);
	if(strString.length==0)
	{
		return false
	}
	else if(strString.search(/^(\bwww\b)*\.[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9/]+$/)== -1)
    {
	alert(mes);
	txtfld.select();
	txtfld.focus()
	return true;		
	}
	return false;
	
}
//---------------------------------------------------------------------------------------------------

// Trims the input string of leading and trailing spaces and returns the new string

function fnTrim(string)
{
	var cnt;	
	len = string.length;
	str = string;
	begin = -1;
	for(cnt=0;cnt<len;cnt++)
	{
		if (str.charAt(cnt) == " ")
		{	
			begin = cnt;
		}	
		else
		break;
		
	}
	str = str.slice(begin+1,len);
	len = str.length;
	end = len;
	for(cnt=len-1;cnt>=0;cnt--)
	{
		if (str.charAt(cnt) == " ")
		{	
			end = cnt;
		}	
		else
		break;
	}
	str = str.slice(0,end);
	return str;
}
//---------------------------------------------------------------------------------------------------
//To trim leading and trialing spacing whiling submitting.

function fnTrimOnSumbit()
{
	frm=document.forms[0]
	for(i=0; i<frm.length; i++)
	{
		if(frm.elements[i].type=="text")
		{
			frm.elements[i].value=fnTrim(frm.elements[i].value);
		}
	}
}
//---------------------------------------------------------------------------------------------------

// Checks if the input string is null or blanks

function fnIsNull(txtfld, mes)
{
	   var string=txtfld.value;
       if (fnTrim(string) == null || fnTrim(string) == "" )
       {
	   	alert(mes);
		txtfld.focus();
		txtfld.select();
     	return true;
       }
		return false;
}

function fnIsNull_nofocus(txtfld, mes)
{
	   var string=txtfld.value;
       if (fnTrim(string) == null || fnTrim(string) == "" )
       {
	   	alert(mes);
		return true;
       }
		return false;
}

//---------------------------------------------------------------------------------------------------
function fnCheckAllNew(chkName, chkList)
{
	frm=document.forms["cetdocumentsubmitentry"]
	if(chkName.checked==true)
	{
		chkList.checked=true;
	}
	if(chkName.checked==true)
	{
		for(var i=0; i<chkList.length; i++)
			{
			chkList[i].checked=true;
			}
	}
	if(chkName.checked!=true)
	{
		for(var i=0; i<chkList.length; i++)
			{
			if(chkList[i].checked==true)
			{
			chkList[i].checked=false;
			}
			}
	}
		
}
function fnUnCheckNew(chkName)
{
	//alert(chkName.name)
	frm=
		document.forms["cetdocumentsubmitentry"]
	chkName.checked=false;
}

//---------------------------------------------------------------------------------------------------

//For phone and fax validation
function fnIsPhone(txtfld, mes)
{
var string=txtfld.value;
if(fnIsValidPhoneNumber(string))
{
alert(mes);
txtfld.select();
txtfld.focus();
return true;
}
else
return false;
}

//---------------------------------------------------------------------------------------------------

//sadashiv

function checkPw(pw1,pw2,mes) {
var x=pw1.value;
var y=pw2.value;
if (x != y) {
alert (mes);
return true;
}
else return false;
}


//---------------------------
//check Passwords are same or not
function fnSamePassword(pw1,pw2,mes) {
var x=pw1.value;
var y=pw2.value;
if (x == y) {
alert (mes);
return true;
}
else return false;
}


//-------------------------------------
function dropDownMenu(menu, mes) 
   {
   var myindex=menu.selectedIndex;
   if (myindex==0)
      {
      alert(mes);
      menu.focus();
	  return true;
	  }
	else 
		{
		return false;
		}
   }



//-------------------------------------
//comparedropdown menu
function fncomparedropDownMenu(menu1, menu2, mes) 
   {
     if (menu1.selectedIndex>menu2.selectedIndex)
      {
      alert(mes);
      menu1.focus();
	  menu1.select();
	  return true;
	  }
	else 
		{
		return false;
		}
   }


   //----------------------------
   //Allow Numbers only to enter

function fnNumberOnly(txtfld, mes)
{
	var Num="0123456789";
	var txtString= fnTrim(txtfld.value)
	for(var i=0; i < txtString.length; i++)
	{
	if(Num.indexOf(txtString.charAt(i))== -1)
	{	
	alert(mes)
	txtfld.focus();
	txtfld.select();
	return true;
	}
	return false;
	}
			
}

//---------------------------------------
//check atleast one check box

function fnchekbox(chekbox, mes)
	{
     
     for (var i = 0; i <chekbox.length; i++)
	  {
      checked =chekbox[i].checked;
      if (!checked)
	   {
       alert(mes);
	   return true;
	   }
	   return false;
	  }
  
}

//-----------------------------------
//check atleast one rediobutton box

function fnchekrdiobutton(chekbox, mes){
	
	 var a=1;
	 for (var i = 0; i<chekbox.length; i++)
	  {
      checked =chekbox[i].checked;
      if (checked)
	   {
       a=a+1;
	   }
	   }


	   if(a>1)
	   {
	 return false;
	   }
	    else
		 {
	   alert(mes);
	   return true;
	    }

}

//--------------------------------------------------------
// validate URL
function fnvalidateURL(txtfld, mes)
{
	var strString=fnTrim(txtfld.value);
	if(strString.length==0)
	{
		return false
	}
	else if(strString.search(/^(\http\:\/\/)[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9/]+$/)== -1)
  
	{
	alert(mes);
	txtfld.select();
	txtfld.focus()
	return true;		
	}
	return false;
	
}

//-----------------------------------
//check the spaces

function fnCheckSpace(txtfld, mes)
{
	var string = txtfld.value;
	for(i=0; i<=string.length; i++)
	{
	if(string.charAt(i)==" ")
	{
	alert(mes)
	txtfld.focus();
	txtfld.select();
	return true;
	}
	}
	return false;
		
}


//----------------------------------------------------
// validate URL
function fnvalidateURL(txtfld, mes)
{
	var strString=fnTrim(txtfld.value);
	if(strString.length==0)
	{
		return false
	}
	else if(strString.search(/^(\http\:\/\/)[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9/]+$/)== -1)
  
	{
	alert(mes);
	txtfld.select();
	txtfld.focus()
	return true;		
	}
	return false;
	
}

//------------------------------------------------------------------
//chech whether its numeric or not
function AllowNumeric(textfield, msg)
{
var val=textfield.value;
	if (val.length>0){
		var charBag = '<>/?;:"~`!#$%^&*()=+\|[]{}abcdefghijklmnopqrstuvwxyz';
		//loop for not allowed special chars
		for (j=0;j<charBag.length; j++){
			if (val.indexOf(charBag.charAt(j))==0){
				alert(msg);
				textfield.focus();
				textfield.select();
				return true;
			}
		}
	}
	return false;
}

function AllowNumeric1(textfield, msg)
{
var val=textfield.value;
	if (val.length>0){
		var charBag = '<>/?;:"~`!#$%^&*()=+\|[]{}';
		//loop for not allowed special chars
		for (j=0;j<charBag.length; j++){
			if (val.indexOf(charBag.charAt(j))==0){
				alert(msg);
				textfield.focus();
				textfield.select();
				return true;
			}
		}
	}
	return false;
}

function allowchar(textfield, msg){

	var val=textfield.value;
	if (val.length>0){
		var charBag = '<>/?;:"~`!#$%^&*()=+\|[]{}';
		//loop for not allowed special chars
		for (j=0;j<charBag.length; j++){
			if (val.indexOf(charBag.charAt(j))==0){
				alert(msg);
				textfield.focus();
				textfield.select();
				return true;
			}
		}
	}
	return false;
}
//.....................................................................................
// This is the jump menu comming on ebery page
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function disableEnterKey(){
	if (window.event.keyCode == 13)
		window.event.keyCode = 0;
}

function checkMonths(){
	frm=document.apply_1;
	if(frm.hlMonths.value>11){
		alert("Months should not be more than 11")
		frm.hlMonths.select();
		return true;
	}
	return false;
}

function checkAmount(){
	frm=document.frmindex;
	if(frm.AmtRequired.value<5000){
		alert("Imagine Finance loans start at £5000 ")
		frm.AmtRequired.select();
		return true;
	}
	return false;
}

function fnvalidate() {
		frm=document.frmIndex;
	if(fnIsNull(frm.FirstName,FIRST_NAME))
		return false;
	else if(fnIsValidChar1(frm.FirstName,"First name is not valid name"))
		return false;
	//else if(fnIsValidChar1(frm.MiddleName,"Middle name is not a valid name"))
		//return false;	
	else if(fnIsNull(frm.LastName,LAST_NAME))
		return false;
	else if(fnIsValidChar1(frm.LastName,"Last name is not a valid name"))
		return false;
	else if(fnIsNull(frm.a_address1,"Please Enter the House number and Street"))
		return false;
	else if(fnIsQuotes(frm.a_address1,"Please Enter the House number and Street"))
		return false;	
	else if(fnIsNull(frm.Postcode,POST_CODE))
		return false;
	else if(fnIsQuotes(frm.Postcode,"Postcode is not valid"))
		return false;
	else if(fnIsNull(frm.hlYears,HLYEARS))
		return false;		
	else if(AllowNumeric(frm.hlYears,VALID_YEARS))
		return false;	
	else if(fnIsQuotes(frm.hlYears,HLYEARS))
		return false;
	else if(fnIsNull(frm.hlMonths,HLMONTHS))
		return false;		
	else if(AllowNumeric(frm.hlMonths,VALID_MONTHS))
		return false;	
	else if(fnIsQuotes(frm.hlMonths,HLMONTHS))
		return false;		
	else if(fnIsNull(frm.Telephone,"Please Provide us your Telephone number"))
		return false;
	else if(AllowNumeric(frm.Telephone,VALID_TELEPHONE))
		return false;		
	else if(fnIsValidChar2(frm.Telephone,VALID_TELEPHONE))
		return false;		
	else if(fnIsNull(frm.mnumber,"Please Provide us your Mobile number"))
		return false;	
	else if(AllowNumeric(frm.mnumber,"Please enter your mobile number"))
		return false;
	else if(fnIsValidChar2(frm.mnumber,"Mobile number is not valid"))
		return false;	
	else if(fnIsNull(frm.cmbDay,"Please Enter your day of Birth"))
		return false;	
	else if(AllowNumeric(frm.cmbDay,"Please Provide us a valid Date"))
			return false;	
	else if(checkDay())		
			return false;			
	else if(fnIsNull(frm.cmbMonth,"Please Enter your month of Birth"))
			return false;	
	else if(AllowNumeric(frm.cmbMonth,"Please Provide us a valid Date"))
			return false;	
	else if(checkMonth())		
			return false;					
	else if(fnIsNull(frm.cmbYear,"Please Enter your year of Birth"))
			return false;	
	else if(AllowNumeric(frm.cmbYear,"Please Provide us a valid Date"))
			return false;	
	else if(checkYear())		
			return false;	
	else if(fnIsNull(frm.Email,VALID_EMAIL))
		return false;	
	else if(fnIsQuotes(frm.Email,VALID_EMAIL))
		return false;				
	else if(emailcheck(frm.Email,VALID_EMAIL))
		return false;		
	else if(dropDownMenu(frm.LoanPurpose,"Please Select the purpose of loan"))		
		return false;	
	else if((frm.LoanPurpose.value=="Other")&&(fnTrim(frm.OtherPurpose.value) == null || fnTrim(frm.OtherPurpose.value) == "" ))
		{
			alert("Please enter Purpose");
			frm.OtherPurpose.focus();
			 return false;
	  	  	//if(fnIsNull_nofocus(frm.OtherPurpose,"Please enter Reason for other purpose"))
	   }
	else if(dropDownMenu(frm.AmtRequired,"Please Select the Loan Amount"))
		return false;		
	else if(dropDownMenu(frm.besttime,"Please Select the Best time to contact you"))
		return false;	
	else if(fnchekrdiobutton(frm.hometype, "Please Provide us your Homeowner Type"))
   		 return false;		
	else if(fnIsNull(frm.houseworth,"Please enter your houseworth"))
		return false;
	else if(fnNumberOnly(frm.houseworth,VALID_AMOUNT))
		return false;	
	else if(fnIsNull(frm.mortage,"Please enter your mortage"))
		return false;
	else if(fnNumberOnly(frm.mortage,VALID_AMOUNT))
		return false;	
	else if(fnIsValidChar2(frm.mortage,VALID_AMOUNT))
		return false;			 
	else if(fnJoint(frm.jointApp, "Please Provide us is it Joint Application?"))
   		 return false;		
	else if(dropDownMenu(frm.FmpStatus,"Please enter your employment status"))
		return false;
	else if(fnchekbox(frm.dprotect, "Please Check the data protection notice "))
		return false;	
	
		
	
}

function checkYear1(){
	frm=document.frmIndex;
	if(frm.cmbYear1.value<1920 || frm.cmbYear1.value>2000){
		alert("Year should be In between 1920 and 2000")
		frm.cmbYear1.select();
		return true;
	}
	return false;
	}

function checkMonth1(){
	frm=document.frmIndex;
	if(frm.cmbMonth1.value<1 || frm.cmbMonth1.value>12){
		alert("Month should be In between 1 and 12")
		frm.cmbMonth1.select();
		return true;
	}
	return false;
}


function fnJoint(chekbox, mes)
{
	
	 var a=0;
	 for (var i = 0; i<chekbox.length; i++)
	  {
      checked =chekbox[i].checked;
      if (checked)
	   {
         val=chekbox[i].value;
		 a=a+1;
		 if (val=="yes")
		 {
		 	if(fnIsNull(frm.B2_FirstName,"Please enter Joint applicant Name"))
			   return true;
			else if(fnIsValidChar1(frm.B2_FirstName,"Joint applicant Name is not valid "))
			   return true;
			else if(fnIsNull(frm.cmbDay1,"Please Enter Joint applicant day of Birth"))
				return true;	
			else if(AllowNumeric(frm.cmbDay1,"Please Provide us a valid Date"))
					return true;	
			else if(checkDay1())		
					return true;			
			else if(fnIsNull(frm.cmbMonth1,"Please Enter Joint applicant month of Birth"))
					return true;	
			else if(AllowNumeric(frm.cmbMonth1,"Please Provide us a valid Date"))
					return true;	
			else if(checkMonth1())		
					return true;					
			else if(fnIsNull(frm.cmbYear1,"Please Enter Joint applicant year of Birth"))
					return true;	
			else if(AllowNumeric(frm.cmbYear,"Please Provide us a valid Date"))
					return true;	
			else if(checkYear1())		
					return true;				
				 
		 }
	   }
	   }


	   if(a>0)
	   {
	 return false;
	   }
	    else
		 {
	   alert(mes);
	   return true;
	    }

}

function fnchekbox(chekbox, mes)
	{
      frm=document.frmIndex.dprotect;
	  checked =frm.checked;
      if (!checked)
	   {
       alert(mes);
	   return true;
	   }
	   else
	   {
	    return false;
	   }
  
}
function checkDay()
{
	frm=document.frmIndex;
	if(frm.cmbDay.value<1 || frm.cmbDay.value>31)
	{
		alert("Day should be In between 1 and 31")
		frm.cmbDay.select();
		return true;
	}
	return false;
}

function checkMonth(){
	frm=document.frmIndex;
	if(frm.cmbMonth.value<1 || frm.cmbMonth.value>12){
		alert("Month should be In between 1 and 12")
		frm.cmbMonth.select();
		return true;
	}
	return false;
}


function checkYear(){
	frm=document.frmIndex;
	if(frm.cmbYear.value<1920 || frm.cmbYear.value>2000){
		alert("Year should be In between 1920 and 2000")
		frm.cmbYear.select();
		return true;
	}
	return false;
	}
function checkDay1()
{
	frm=document.frmIndex;
	if(frm.cmbDay1.value<1 || frm.cmbDay1.value>31)
	{
		alert("Day should be In between 1 and 31")
		frm.cmbDay1.select();
		return true;
	}
	return false;
}

function funHideControl()
{		
 	window.divGroup.style.display =  "none";		
}		
function GetPurpose()
{
	mem=document.frmIndex.LoanPurpose;
	for(var i=0; i<mem.length; i++)
	  { if (mem.options[i].selected) 	
			{ 	
			  if(mem.options[i].value=="Other")
			  {
			  	window.divGroup.style.display ="";	
				//alert("Please Enter Other Loan Purpose")
				//document.frmIndex.OtherPurpose.focus();
			  }		
			  else
			  {
			   window.divGroup.style.display =  "none";	
			  }
			}
	 }	
}

joint="no";
var dge=document.getElementById;
function cl_colall(a){
  if(!dge)return;
  document.getElementById(a)
    document.getElementById(a).style.display='none';
  
}
function go1(vall)
{
stat=vall
//alert(stat)
if (stat=="yes")
 {cl_expcol('jointmarried')}
//alert(val)
//alert("MarStat"+val)
}
function cl_expcol(a){
  if(!dge)return;
    document.getElementById(a).style.display = 
      (document.getElementById(a).style.display=='none')?
      'block':'none';
}

var referingtest;
referingtest= document.referrer;
document.frmIndex.teting.value=referingtest;

								
