// JavaScript Document
function submitPersonal()
{
flag= Validator("frm")

if (flag!=false)
{
	document.frm.Save.value=true;
	document.frm.Fid.value=2;
	
	document.frm.submit();
	return true;
}
else
	return false;
}
function submitFinalDD()
{
	//alert('Development in process ,just testing');
	//document.frm.action="JoSaveMe.asp";
	//IsLastPage
	document.frm.IsLastPage.value="true";
//	document.frm.submit();
	//return true;
}
function submitMe()
{
	//document.frm.action="JOSave.asp";
	document.frm.submit();
	return true;
}
function submitOrg()
{


flag = Validator("frm");

	if (flag!=false)
	{
		if (document.frm.IsSubmit.value=='True')
		{
			document.frm.IsLastPage.value="true";
	//		document.frm.action="JOSaveMe.asp";
		//	document.frm.Fid.value=6;
		//	document.frm.submit();
		//	return true;
		}
		document.frm.Save.value=true;		
		document.frm.Fid.value++;
		
		document.frm.submit();
		return true;
	}
	else
	return false;
}
function submitback()
{

	if (document.frm.Prev.value=='True' )
	{
		//alert(document.frm.Fid.value)
		document.frm.Fid.value--;
		document.frm.Fid.value--;
	//alert(document.frm.Fid.value)
	}
	else
	{
		document.frm.Prev.value=false;
		document.frm.Fid.value--;
		document.frm.Save.value=false;
		if (document.frm.IsLastPage)
                document.frm.IsLastPage.value=false;
		document.frm.submit();
		return true;
	}
}




function help()
{
	window.open("PostCodeHelp.htm","Help","fullscreen=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizeable=no,width=420,height=355")	
}

 function FindAddress()
 {
	
	Pcode=document.frm.post_code.value;
	country=document.frm.country.value;
	//alert(country)
	if (Pcode!="" && country=="UK")
	{
		
		if (document.frm.houseNo)
		house=document.frm.houseNo.value
		else
		house=document.frm.home_Address1.value
		path="FindAddress.asp?Pcode=" + Pcode + "&HouseID=" + house
		window.open(path,"FindAddress","fullscreen=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizeable=no,width=400,height=400")	
		window.name="postcode"	
	}
	else
	{
		if (country!="UK")
		alert("Only for UK address.")
		else
		alert("Please enter home postcode.")
	}

 }

function FindCompanyAddress()
 {
	
	Pcode=document.frm.com_postcode.value
	company_country=document.frm.company_country.value
	//alert(country)

		if (Pcode!="" && company_country=="UK")
		{
			if(document.frm.CompanyhouseNo)
			Company=document.frm.CompanyhouseNo.value
			else
			Company=document.frm.Company_Address1.value
			path="FindAddress.asp?Pcode=" + Pcode + "&CompanyHouse=" + Company
			window.open(path,"FindAddress","fullscreen=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizeable=no,width=400,height=400")	
			window.name="postcode"	
		}
		else
		{
			if (company_country!="UK")
			alert("Only for UK address.")
			else
			alert("Please enter company postcode.")
		}


 }



 
 
 function path(abc)
  {
  alert("Please wait remaining address will fill")
  document.frm.action=abc
  document.frm.submit()
  }

 function foc()
 {
 //window.defaultStatus='Welcome from Target System'
 document.frm.linkFT.value=parent.location.href;
 //alert(document.frm.linkFT.value)
 document.frm.Last_name.focus();
 
 }


function isBetween (val, lo, hi) {
	if ((val < lo) || (val > hi)) { return(false); }
	else { return(true); }
}


function isEmpty (str) {
	if ((str==null)||(str.length==0)) return true;
	else return(false);

}

function validnull(item3)
      {
         if (item3.length==0)
          {
            return false;
          }
         return true;
     }


function isInt (item) {
	var flag = true;

	if (isEmpty(item)) { flag=false; }
	else
	{	for (var i=0; i< item.length; i++) {
			if (isDigit(item.substring(i,i+1)) == false) {
				flag = false; break;
			}
		}
	}
	return(flag);
}

function isDigit(theNum) {
	var theMask = '0123456789';
	
	if (isEmpty(theNum)) return(false);
	else if (theMask.indexOf(theNum) == -1) return(false);
	
	return(true);
}


function CheckDay()
{
if (document.frm.day)
{
	var  item=document.frm.day.value;
	
	if ((document.frm.day.value=="None") || (document.frm.month.value=="None") || (document.frm.year.value=="None"))
		{
			
			
			if ((document.frm.day.value=="None") && (document.frm.month.value=="None") && (document.frm.year.value=="None"))
			{
			//	alert("All valid");
				//return(true);
			}
			else
			{
				alert("Please enter valid date of birth")	
				document.frm.day.focus();
				return(false);
			}
	
		}
		
	else
	{
			
			if (!isDate(item)) 
			{
			alert("Please enter valid date of birth")
			document.frm.day.focus();
			return(false);
			}
	}

}
}

function isDate (item) 
{
	if (document.frm.month)
	{
				var maxDays
				var now=new Date()
				var year=now.getFullYear()
				//alert(now.getFullYear())
				m=document.frm.month.value
				y=document.frm.year.value
				
		if (!validnull(item)) {return true;}
		
		if (isInt(y)==false) { return(false); }
		
		else 
			if (y.length < 4 || y.length > 4 || y > year ) { return(false); }
		
			else 
				
				if (m=="April" || m=="June" || m=="September" || m=="November") maxDays = 30;
			
				else 
				
					if (m=="February") 
					
					{ if (y % 4 > 0) maxDays = 28;
					
					else 
					
						if (y % 100 == 0 && y % 400 > 0) maxDays = 28;           	
					else
					maxDays = 29;
					}
				
				if (isBetween(item, 1, maxDays) == false) {  return(false); }
				else { return(true); }
	}
}	
	function EmailAddress(str)
{
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_@.";
	emailstr=str
	len=emailstr.length
	if (len==0)	
	return(true);
	if (len < 8)
	{
	//alert("Please enter valid home email address");
	return(false);
	}
	
	flag=false
	pos=0
	posdot=0
	for(i = 0;i < len;++i)
        {
          if(emailstr.charAt(i) =="@") 
          {
			pos=pos+1
			if (i==0 || i==len-1)
				{	
				flag=true
				break;
				}
			
		  }
          if(emailstr.charAt(i) ==".") 
          {
			if (i==0 || i==len-1)
				{	
				flag=true
				break;
				}
			posdot=posdot+1
          }
		}
	var allValid = true;
	for (i = 0;  i < emailstr.length;  i++)
  {
    ch = emailstr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
	if (!allValid)
  {
    //alert("Please enter valid home email address");
    return (false);
  }

		
	if (flag==true)
	{
	//alert("Please enter valid home email address");
	return(false);
	}
	if (posdot==0 || pos==0 || pos > 1 )
	{
	//alert("Please enter valid home email address");
	return(false);
	}
	return(true);
}



function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;

	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces

function trim( value ) {
	
	return LTrim(RTrim(value));
	
}

function Validator(theForm)
{

if (document.frm.Last_name)
{ ///For Personal Start 
	if (document.all) 
	{
		var str = document.frm.Last_name.value;
	}
	else
	{
	
		var tempstr =  document.getElementById("Last_name");
		var str= tempstr.value;
	}
	
	
			var len=str.length
	
			var i
			var j=0
			for(i = 0;i < len;++i)
			 {
				 
				 if((str.charAt(i) !=" ") && (str.charAt(i) !="-") && (str.charAt(i) !="'") )
							j++;
				 
						
			 }
			
			if (j>=2)
			{
			//return(true);
			}
			else
			
			{
	
			alert("Please enter valid last name");
			document.frm.Last_name.focus();
			return(false);
			}
			
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ'- \t\r\n\f";
	
	if (document.all) 
	{
	
		var checkStr = document.frm.Last_name.value;
	}
	else
	{
	
		var tempcheckStr =  document.getElementById("Last_name");
		var checkStr= tempcheckStr.value;
	}
	
	 
	  var allValid = true;
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		  if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length)
		{
		  allValid = false;
		  break;
		}
	  }
	  if (!allValid)
	  {
	
		alert("Please enter valid last name.");
		document.frm.Last_name.focus();
	
		return (false);
	  }
		
		
	
	if (document.all)
	{
	  var str = document.frm.First_Name.value;
	}
	else
	{
		var tempstr =  document.getElementById("First_Name");
		var str= tempstr.value;
	}
	
		

	//function isBlank(str) {
			var len=str.length
		   
			var i
			var j=0
			for(i = 0;i < len;++i)
			 {
				 
				 if((str.charAt(i) !=" ") && (str.charAt(i) !="-") && (str.charAt(i) !="'") )
							j++;
						
			 }
			
			if (j>=2)
			{
			//return(true);
			}
			else
			
			{
			alert("Please enter valid first name(s)")
			document.frm.First_Name.focus();
			return(false);
			}
	var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ'- \t\r\n\f";

	
	if (document.frm.First_Name)
	{
		if (document.all)
		{
		  var checkStr = document.frm.First_Name.value;
		}
		else
		{
			var tempcheckStr =  document.getElementById("First_Name");
			var checkStr= tempcheckStr.value;
		
		}
	
	}
	
	  var allValid = true;
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		  if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length)
		{
		  allValid = false;
		  break;
		}
	  }
	  if (!allValid)
	  {
		alert("Please enter valid firstname(s).");
		document.frm.First_Name.focus();
		return (false);
	  }
		
		if (CheckDay()==false)
		 return(false);
			
		
	  

	//  alert(document.frm.country.value)
	  if ((document.frm.post_code.value.length) < 1 && (document.frm.country.value == 'UK'))
	  {
		alert("Please enter home postcode.");
		document.frm.post_code.focus();
		return (false);
	  }
	
	if (document.frm.home_Address1.value.length > 35)
	{
		alert("Address line can't be more then 35 characters.");
		document.frm.home_Address1.focus();
	   return (false);
	}
	
	if (document.frm.home_Address2.value.length > 35)
	{
		alert("Address line can't be more then 35 characters.");
		document.frm.home_Address2.focus();
	   return (false);
	}
	if (document.frm.home_Address3.value.length > 35)
	{
		alert("Address line can't be more then 35 characters.");
		document.frm.home_Address3.focus();
	   return (false);
	}
	if (document.frm.home_Address4.value.length > 35)
	{
		alert("Address line can't be more then 35 characters.");
		document.frm.home_Address4.focus();
	   return (false);
	}
	
	if ((document.frm.home_Address1.value.length < 1) && (document.frm.post_code.value.length > 0))
	{
		alert("Please enter House No/Name and Street.");
		document.frm.home_Address1.focus();
		return (false);
	}
	/**********************************Noman------Email Address Mandatory**********************************/
} ///For Personal End 

if (document.all)
{

	if (document.frm.maddress)
	{
		if (!(document.frm.maddress(0).checked || document.frm.maddress(1).checked))
		{
		alert("Please select correspondence address.")
		document.frm.maddress(0).focus();
		return (false);
		}
	}
	//if ((document.frm.maddress) && (document.frm.home_Email1))
	//if (document.frm.maddress(0).checked &&	document.frm.home_Email1.value=="")
	if (document.frm.HHEmail)
	if ((document.frm.Hhome_Address1.value=='' || document.frm.HHEmail.value=='' || document.frm.HHTel.value=='') && document.frm.maddress(0).checked )
	{
	
	alert("You have not entered the house no/name or email or telephone in your home address. Please go back and enter home email and house no/name and telephone on the My Detail Page.");	        
	return (false);
	}
	if (document.frm.HCEmail)
	if ((document.frm.HCEmail.value=='' || document.frm.HCompanyName.value=='' || document.frm.HCTEL.value=='') && document.frm.maddress(1).checked )
	{
	
	alert("You have not entered the email or telephone or organisation name in your work address. Please go back and enter organisation email, organisation telephone and organisation name on the My Organisation Page.");		
	return (false);
	}

	if (document.frm.home_Email1)
	if (document.frm.home_Email1.value=='')
	{
	
	//alert("Please enter home email.");
	//document.frm.home_Email1.focus();
	//return (false);
	}
	
	if (document.frm.home_Email1)
	if (document.frm.home_Email1.value!=document.frm.home_Emai2.value)
	{
	
	alert("Please re-type Confirm Home email.");
	document.frm.home_Emai2.focus();
	return (false);
	}
	//if ((document.frm.maddress) && (document.frm.Company_Email))
//	if (document.frm.maddress(1).checked &&	document.frm.Company_Email.value=="")
	if (document.frm.CompanyName)
	{
		if (document.frm.CompanyName.value!=''  &&	document.frm.Company_Email.value=='')
		{
		//alert("Please enter Organisation email.");
		//document.frm.Company_Email.focus();
		//return (false);
		}
		if (document.frm.Con_Email.value!=document.frm.Company_Email.value)
		{
		alert("Please re-type Confirm direct email");
		document.frm.Con_Email.focus();
		return false;
		}
	}
}
else
{
	
	if (document.frm.maddress)
	{
		if (!(document.frm.maddress[0].checked || document.frm.maddress[1].checked))
		{
		alert("Please select correspondence address.")
		document.frm.maddress[0].focus();
		return (false);
		}
	}
	
	//if ((document.frm.maddress) && (document.frm.home_Email1))
	//if (document.frm.maddress[0].checked &&	document.frm.home_Email1.value=="")
	if (document.frm.HHEmail)
	if ((document.frm.Hhome_Address1.value=='' || document.frm.HHEmail.value=='' || document.frm.HHTel.value=='') && document.frm.maddress[0].checked )
	{
	alert("You have not entered the house no/name or email or telephone in your home address. Please go back and enter home email and house no/name and telephone on the My Detail Page.");	        
	return (false);
	} 
	if (document.frm.HCEmail)
	if ((document.frm.HCEmail.value=='' || document.frm.HCompanyName.value=='' || document.frm.HCTEL.value=='' ) && document.frm.maddress[1].checked )
	{
	
	alert("You have not entered the email or telephone or organisation name in your work address. Please go back and enter organisation email, organisation telephone and organisation name on the My Organisation Page.");		
	return (false);
	}
	if (document.frm.home_Email1)
	if (document.frm.home_Email1.value=='')
	{
	
	//alert("Please enter home email.");
	//document.frm.home_Email1.focus();
	//return (false);
	}
	
	if (document.frm.home_Email1)
	if (document.frm.home_Email1.value!=document.frm.home_Emai2.value)
	{
	
	alert("Please re-type Confirm Home email.");
	document.frm.home_Emai2.focus();
	return (false);
	}
	
//	if ((document.frm.maddress) && (document.frm.Company_Email))
	//if (document.frm.maddress[1].checked &&	document.frm.Company_Email.value=="")
	if (document.frm.CompanyName)
	{
		if (document.frm.CompanyName.value!='' &&	document.frm.Company_Email.value=='')
		{
		//alert("Please enter Organisation email.");
		//document.frm.Company_Email.focus();
		//return (false);
		}
		if (document.frm.Con_Email.value!=document.frm.Company_Email.value)
		{
		alert("Please re-type Confirm direct email");
		document.frm.Con_Email.focus();
		return false;
		}
	}

}
	if (document.frm.home_Email1)
	if (EmailAddress(document.frm.home_Email1.value)==false)
		{
		alert("Please enter valid home email address");
		document.frm.home_Email1.focus();
		return(false);
		}
	
	if (document.frm.Company_Email)
	if (EmailAddress(document.frm.Company_Email.value)==false)
		{
		alert("Please enter valid company email address");
		document.frm.Company_Email.focus();
		return(false);
		} 
/**********************************Noman------Email Address Mandatory**********************************/

if (document.frm.home_fax1)
if (document.frm.home_fax1.value.length > 0)
{
  var checkOK = "0123456789- \t\r\n\f";
  var checkStr = document.frm.home_fax1.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  var k
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
      {
		if (ch!=" ")
			k++; 
        break;
      }
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter valid home fax number.");
    document.frm.home_fax1.focus();
    return (false);
  }
  if (k < 4)
  {
    alert("Please enter valid home fax number.");
    document.frm.home_fax1.focus();
    return (false);
  }
 
}
if (document.frm.jobTitle)
if (document.frm.jobTitle.value.length < 1)
  {
   // alert("Please enter job title.");
   // document.frm.jobTitle.focus();
   // return (false);
  }
if (document.frm.CompanyName) ///Start Org
{
	if ((document.frm.CompanyName.value.length > 0) && (document.frm.com_postcode.value.length < 1) && (document.frm.company_country.value == 'UK'))
	  {
		alert("Please enter Organisation postcode.");
		document.frm.com_postcode.focus();
		return (false);
	  }
	
	if ((document.frm.Company_Address1.value.length < 1) && (document.frm.com_postcode.value.length > 0))
		{
			alert("Please enter Building Name/Floor No.");
			document.frm.Company_Address1.focus();
			return (false);
		}
	
	if (document.frm.Company_Address1.value.length > 35)
	{
		alert("Address line can't be more then 35 characters.");
		document.frm.Company_Address1.focus();
	   return (false);
	}
	if (document.frm.Company_Address2.value.length > 35)
	{
		alert("Address line can't be more then 35 characters.");
		document.frm.Company_Address2.focus();
	   return (false);
	}
	if (document.frm.Company_Address3.value.length > 35)
	{
		alert("Address line can't be more then 35 characters.");
		document.frm.Company_Address3.focus();
	   return (false);
	}
	if (document.frm.Company_Address4.value.length > 35)
	{
		alert("Address line can't be more then 35 characters.");
		document.frm.Company_Address4.focus();
	   return (false);
	}
}//End Org
if(document.frm.CompanyName)
if ((document.frm.maddress) && (document.frm.CompanyName))
{
	if (document.all)
	{
		if (document.frm.maddress(1).checked && document.frm.CompanyName.value.length < 1)
		{
		alert("Please enter Organisation name.")
		document.frm.CompanyName.focus();
		return (false);
		}
	}
	else
	{
		if (document.frm.maddress[1].checked && document.frm.CompanyName.value.length < 1)
		{
		alert("Please enter Organisation name.")
		document.frm.CompanyName.focus();
		return (false);
		}
	}
}
	if (document.frm.Company_Fax)
	if (document.frm.Company_Fax.value.length > 0)
	{
	  
	
	  var checkOK = "0123456789- \t\r\n\f";
	  var checkStr = document.frm.Company_Fax.value;
	  var allValid = true;
	  var decPoints = 0;
	  var allNum = "";
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		  if (ch == checkOK.charAt(j))
		  {
			if (ch!=" ")
				k++; 
			break;
		  }
		   
		if (j == checkOK.length)
		{
		  allValid = false;
		  break;
		}
		allNum += ch;
	  }
	  if (!allValid)
	  {
		alert("Please enter valid company fax number.");
		document.frm.Company_Fax.focus();
		return (false);
	  }
	  if (k < 4)
	  {
		alert("Please enter valid company fax number.");
		document.frm.Company_Fax.focus();
		return (false);
	  }
	 }
	if (document.frm.Accept)
	{
		if (!document.frm.Accept.checked)
		{
			alert("Please Accept terms and condition to continue");
			return false;
		}
			
	}
//	alert(document.frm.AccountName)
	if (document.frm.AccountName)
	{
		return ValidatorDD();
	}

}
countryflag=false
company_countryflag=false
function postcheck(obj)
{
	switch(obj)
	{
		case "country":
			if(document.frm.country.value != 'UK')
			{
				if(document.frm.houseNo)
				{
					document.frm.houseNo.value=""
					document.frm.houseNo.disabled=true
				}
				if (countryflag==false)
					{
						alert("Postcode only mandatory for UK Applications")
						countryflag=true
					}
				//document.frm.post_code.style.background  = "lightgrey"
				strmand = ''
			}
			else
			{
				countryflag=false
				//document.frm.post_code.style.background  = "#a4b3f0"
				//document.frm.houseNo.disabled=false
			}
			break;
		case "company_country":
			
			if(document.frm.company_country.value != 'UK')
			{
				if(document.frm.CompanyhouseNo)
				{
					document.frm.CompanyhouseNo.value=""
					document.frm.CompanyhouseNo.disabled=true
				}
				if (company_countryflag==false)
				{	
					alert("Postcode only mandatory for UK Applications")
					company_countryflag=true
				}	
				//document.frm.com_postcode.style.background = "lightgrey" 
				
				strmand = ''
			}
			else
			{
				
				company_countryflag=false
				//document.frm.com_postcode.style.background = "#a4b3f0"
				//document.frm.CompanyhouseNo.disabled=false
			}
			break;
	}
}

function changeup(obj)
{

	var Warr;
	upstr = ""
	switch(obj)
	{
		case "Last_name":
			 Warr = document.frm.Last_name.value.split(" ")
			 for (wcount in Warr)
				upstr = mstr(wcount,chupp(Warr[wcount]),upstr)
			 document.frm.Last_name.value = upstr
			 break;
		case "First_Name":
			 Warr = document.frm.First_Name.value.split(" ")
			 for (wcount in Warr)
				upstr = mstr(wcount,chupp(Warr[wcount]),upstr)
			 document.frm.First_Name.value = upstr
			break;
		case "home_Address1":
			 Warr = document.frm.home_Address1.value.split(" ")
			 for (wcount in Warr)
				upstr = mstr(wcount,chupp(Warr[wcount]),upstr)
			 document.frm.home_Address1.value = upstr
			break;
		case "home_Address2":
			 Warr = document.frm.home_Address2.value.split(" ")
			 for (wcount in Warr)
				upstr = mstr(wcount,chupp(Warr[wcount]),upstr)
			 document.frm.home_Address2.value = upstr
			break;
		case "home_Address3":
			 Warr = document.frm.home_Address3.value.split(" ")
			 for (wcount in Warr)
				upstr = mstr(wcount,chupp(Warr[wcount]),upstr)
			 document.frm.home_Address3.value = upstr
			break;
		case "home_Address4":
			 Warr = document.frm.home_Address4.value.split(" ")
			 for (wcount in Warr)
				upstr = mstr(wcount,chupp(Warr[wcount]),upstr)
			 document.frm.home_Address4.value = upstr
			break;
		case "CompanyName":
			 Warr = document.frm.CompanyName.value.split(" ")
			 for (wcount in Warr)
				upstr = mstr(wcount,chupp(Warr[wcount]),upstr)
			 document.frm.CompanyName.value = upstr
			break;
		case "Company_Address1":
			 Warr = document.frm.Company_Address1.value.split(" ")
			 for (wcount in Warr)
				upstr = mstr(wcount,chupp(Warr[wcount]),upstr)
			 document.frm.Company_Address1.value = upstr
			break;
		case "Company_Address2":
			 Warr = document.frm.Company_Address2.value.split(" ")
			 for (wcount in Warr)
				upstr = mstr(wcount,chupp(Warr[wcount]),upstr)
			 document.frm.Company_Address2.value = upstr
			break;
		case "Company_Address3":
			 Warr = document.frm.Company_Address3.value.split(" ")
			 for (wcount in Warr)
				upstr = mstr(wcount,chupp(Warr[wcount]),upstr)
			 document.frm.Company_Address3.value = upstr
			break;
		case "Company_Address4":
			 Warr = document.frm.Company_Address4.value.split(" ")
			 for (wcount in Warr)
				upstr = mstr(wcount,chupp(Warr[wcount]),upstr)
			 document.frm.Company_Address4.value = upstr
			break;

	}
}

function chupp(wchange)
{
	return(wchange.charAt(0).toUpperCase() + wchange.substr(1))	
}
function mstr(count,chstr,strmade)
{
	if(count == 0)
	{
		str = strmade + chstr
	}
	else
	{
		str = strmade + " " + chstr
	}
	return(str)
}

function pcupper(object)
{
	switch(object)
	{
		case "post_code":
			document.frm.post_code.value =  document.frm.post_code.value.toUpperCase()
			break;
		case "com_postcode":
			document.frm.com_postcode.value = document.frm.com_postcode.value.toUpperCase()
			break;
	}
}

//For DD
function ValidatorDD()
{
		if (document.frm.AccountName.value=='')
		{
			alert('Please enter Account name');
			document.frm.AccountName.focus();
			return false;
		}
		
		if (document.frm.SortCode.value=='')
		{
			alert('Please enter 6 digits Sort Code in numeric only.');
			document.frm.SortCode.focus();
			return false;
		}
		if (!IsNumeric(document.frm.SortCode.value))
		{
			alert('Please enter 6 digits Sort Code in numeric only.');
			document.frm.SortCode.focus();
			return false;
		}

		if (document.frm.SortCode.value.length!=6)
		{
			alert('Please enter 6 digits Sort Code in numeric only.');
			document.frm.SortCode.focus();
			return false;
		}
		if (document.frm.AccountNo.value=='')
		{
			alert('Please enter Account No.');
			document.frm.AccountNo.focus();
			return false;
		}
		if (!IsNumeric(document.frm.AccountNo.value))
		{
			alert('Please enter only numeric value in Account No.');
			document.frm.AccountNo.focus();
			return false;
		}
		if  (document.all)
		{
			if (document.frm.rdDDOption)
			if (document.frm.rdDDOption(0).checked==false && document.frm.rdDDOption(1).checked==false)
			{
				alert('Please select any given option from anuual or monthly payment.');
				return false;
			}
		}
		else
		{
			if (document.frm.rdDDOption)
			if (document.frm.rdDDOption[0].checked==false && document.frm.rdDDOption[1].checked==false)
			{
				alert('Please select any given option from anuual or monthly payment.');
				return false;
			}
		}
		if (document.frm.Accept)	
		if (document.frm.Accept.checked==false)
		{
				alert('Please accept the terms and condition to continue.');
				return false;
		}
}

function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
}


/*
function checkcursor(object)
{
	switch(object)
	{
		case "document.frm.home_tel1":
			document.frm.home_tel1.value = document.frm.home_tel1.value + " "
//			document.frm.home_tel1.style.cursor="move"
	}
}

function CheckHouseNo()
{
	if (document.frm.houseNo.value!="")
	{
		FindAddress();
	}
}

function CheckCompanyNo()
{
	if (document.frm.CompanyhouseNo.value!="")
	{
		FindCompanyAddress();
	}
}

*/

