// JavaScript Document
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.id; if (trim(val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } 
 
  if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}


function MM_validateForm130() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm130.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.id; if (trim(val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } 


var checkbox_choice = false; 
for (counter = 0; counter < form1.product.length; counter++) 
{ 
if (form1.product[counter].checked) 
checkbox_choice = true; 
} 

if (!checkbox_choice) 
{ 
errors+='- Please select a product.\n';
} 

if(document.form1.CBcustomer[0].checked && document.form1.AccountNo.value==""){
	errors+='- Account Number is required.\n';
}

if(document.form1.CBcustomer[1].checked && document.form1.Branch.value==""){
	errors+='- Branch is required.\n';
}

if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue130 = (errors == '');
}


function showTypes(){
		document.form1.flag.value='';
		form1.submit();
}


function rentType(frm){
		if (document.frm.type.value == "Rent"){
			docuemnt.frm.renttype.style = true;
		}
}

function confirmDel(frm,msg){
	if(confirm(msg) == true){
		frm.submit();
	}
}


function signup()
{
var membership_choice = false;
	for (counter = 0;  counter < frmsignup1.membership.length; counter++)
	{
		if (frmsignup1.membership[counter].checked){
		membership_choice = true; 
		}
	}
		if (!membership_choice)
		{
		alert("Please select membership type.");
		return (false);
		}
return (true);
}


function compareOptionValues(a, b) 
{ 
  // Radix 10: for numeric values
  // Radix 36: for alphanumeric values
  var sA = parseInt( a.value, 36 );  
  var sB = parseInt( b.value, 36 );  
  return sA - sB;
}
// Compare two options within a list by TEXT
function compareOptionText(a, b) 
{ 
  // Radix 10: for numeric values
  // Radix 36: for alphanumeric values
  var sA = parseInt( a.text, 36 );  
  var sB = parseInt( b.text, 36 );  
  return sA - sB;
}
// Dual list move function
function moveDualList( srcList, destList, moveAll ) 
{
  // Do nothing if nothing is selected
  if (  ( srcList.selectedIndex == -1 ) && ( moveAll == false )   )
  {
    return;
  }
  newDestList = new Array( destList.options.length );
  var len = 0;
  for( len = 0; len < destList.options.length; len++ ) 
  {
    if ( destList.options[ len ] != null )
    {
//      newDestList[ len ] = new Option( destList.options[ len ].text, destList.options[ len ].value, destList.options[ len ].defaultSelected, destList.options[ len ].selected );
      newDestList[ len ] = new Option( destList.options[ len ].text, destList.options[ len ].value);
    }
  }
  for( var i = 0; i < srcList.options.length; i++ ) 
  { 
    if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) )
    {
       // Statements to perform if option is selected
       // Incorporate into new list
       newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );
       len++;
    }
  }
  // Sort out the new destination list
  //////////newDestList.sort( compareOptionValues );   // BY VALUES
  //newDestList.sort( compareOptionText );   // BY TEXT
  // Populate the destination with the items from the new array
  for ( var j = 0; j < newDestList.length; j++ ) 
  {
    if ( newDestList[ j ] != null )
    {
      destList.options[ j ] = newDestList[ j ];
    }
  }
  // Erase source list selected elements
  for( var i = srcList.options.length - 1; i >= 0; i-- ) 
  { 
    if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) )
    {
       // Erase Source
       //srcList.options[i].value = "";
       //srcList.options[i].text  = "";
       srcList.options[i]       = null;
    }
  }
} // End of moveDualList()
//  End -->
function selectAllOptions(id,id2)
{
var ref = document.getElementById(id);
for(i=0; i<ref.options.length; i++)
ref.options[i].selected = true;

var ref = document.getElementById(id2);
for(i=0; i<ref.options.length; i++)
ref.options[i].selected = true;

}


function isemail(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}


function setVisibility(objId, sVisibility) {
    var obj = document.getElementById(objId);
    obj.style.visibility = sVisibility;
}

function display(objId, value) {
    var obj = document.getElementById(objId);
    obj.style.display = value;
}

function validateSearch(){
var error = "";

var strSearch = document.getElementById("SiteSearch1_txtSearch").value;
		if(trim(strSearch) == ""){
			error = "Please enter a search string!";
		}else{
			if (/[^a-zA-Z0-9\s$]/.test(strSearch)) {
				error = 'Please enter alphanumeric characters only';
				}
		}
		if(error){
			alert(error);
			return false;
		}
return true;		
}

function ValidateStep1(){
	var errors = "";
	var salutation = trim(document.getElementById("salutation").value);
	var fname = trim(document.getElementById("fname").value);
	var lname = trim(document.getElementById("lname").value);
	var passportname = trim(document.getElementById("passportname").value);
	var nationality = document.getElementById("nationality").options[document.getElementById("nationality").selectedIndex].value;
	var securitycode = trim(document.getElementById("securitycode").value);
	var dob = trim(document.getElementById("dob").value);
	var cob = document.getElementById("cob").options[document.getElementById("cob").selectedIndex].value;
	var qid = trim(document.getElementById("qid").value);
	var idexp = trim(document.getElementById("idexp").value);
	var gender = trim(document.getElementById("gender").value);
	var marital = trim(document.getElementById("marital").value);
	var ppnumber = trim(document.getElementById("ppnumber").value);
	var ppissue = trim(document.getElementById("ppissue").value);
	var ppexpiry = trim(document.getElementById("ppexpiry").value);
	
	if(salutation == "" || fname == "" || lname == "" || qid == "" || idexp == "" || !validDate(idexp) || nationality == "" || securitycode == "" || isNaN(securitycode) || !validDate(dob) || dob == "" || cob == "" || gender == "" || marital == "" || (nationality != "Qatar" && !validDate(ppissue)) || (nationality != "Qatar" && !validDate(ppexpiry))){
		
		errors = "Following field(s) are required\n";
		
		if(salutation == ""){
			errors += " - Salutation is required.\n";	
		}
		if(fname == ""){
			errors += " - First Name is required.\n";	
		}
		if(lname == ""){
			errors += " - Last Name is required.\n";	
		}
		if(nationality == ""){
			errors += " - Nationality is required.\n";	
		}
		if(qid == ""){
			errors += " - Qatar ID is required.\n";	
		}	
		if(idexp == "" || idexp == "dd/mm/yyyy"){
			errors += " - ID Expiry Date is required.\n";	
		}	
		if(idexp != "" && idexp != "dd/mm/yyyy" && !validDate(idexp)){
			errors += " - ID Expiry Date should be in dd/mm/yyyy format.\n";	
		}	
		if(securitycode == ""){
			errors += " - Security Code is required.\n";	
		}		
		if(securitycode != "" && isNaN(securitycode)){
			errors += " - Security Code is a number.\n";				
		}		
		if(dob == "" || dob == "dd/mm/yyyy"){
			errors += " - Date of Birth is required.\n";	
		}
		if(dob != "" && dob != "dd/mm/yyyy" && !validDate(dob)){
			errors += " - Date of Birth should be in dd/mm/yyyy format.\n";	
		}
		if(cob == ""){
			errors += " - Country of Birth is required.\n";	
		}

		if(nationality != "Qatar" && ppnumber == ""){
			errors += " - Passport Number is required.\n";				
		}
		if(nationality != "Qatar" && (ppissue == "" || ppissue == "dd/mm/yyyy")){
			errors += " - Passport Issue Date is required.\n";				
		}
		if(nationality != "Qatar" && (ppissue != "" && ppissue != "dd/mm/yyyy" && !validDate(ppissue))){
			errors += " - Passport Issue Date should be in dd/mm/yyyy format.\n";				
		}
		if(nationality != "Qatar" && (ppexpiry == "" || ppexpiry == "dd/mm/yyyy")){
			errors += " - Passport Expiry Date is required.\n";				
		}
		if(nationality != "Qatar" && (ppexpiry != "" && ppexpiry != "dd/mm/yyyy" && !validDate(ppexpiry))){
			errors += " - Passport Expiry Date should be in dd/mm/yyyy format.\n";				
		}

		if(gender == ""){
			errors += " - Gender is required.\n";	
		}
		if(marital == ""){
			errors += " - Marital Status is required.\n";	
		}
		
	}
	
	if(errors){
		alert(errors);
		return false;
	}
return true;
}


function ValidateStep2(){
	
	var errors="";
	var ownership="";
	var haddress=""
	var homecountry=""
	var hcity=""
	var hometele=""
	var homemobile=""
	
	
	
	
	
	var cor = document.getElementById("cor").options[document.getElementById("cor").selectedIndex].value;
	
	
	
	var pobox = trim(document.getElementById("pobox").value);
	var maddress = trim(document.getElementById("maddress").value);
	var mcity = trim(document.getElementById("mcity").value);
	var nation = trim(document.getElementById("nation").value);
	
	
	if(document.getElementById("haddress") != null){
	haddress = (document.getElementById("haddress").value);
	}
	
	if(document.getElementById("haddress") != null){
	homecountry = document.getElementById("homecountry").options[document.getElementById("homecountry").selectedIndex].value;	
	}
	if(document.getElementById("haddress") != null){
	hcity = trim(document.getElementById("hcity").value);
	}
	
	if(document.getElementById("haddress") != null){
	hometele = trim(document.getElementById("hometele").value);
	}
	
	if(document.getElementById("haddress") != null){
	homemobile = trim(document.getElementById("homemobile").value);
	}

	var since = trim(document.getElementById("since").value);
	var rarea = trim(document.getElementById("rarea").value);
	var flatno = trim(document.getElementById("flatno").value);
	var street = trim(document.getElementById("street").value);
	var building = trim(document.getElementById("building").value);
	var mobile = trim(document.getElementById("mobile").value);
	
	
	
	
	 var rad = document.form1.ownership;



	for(i=0; i<rad.length; i++){
			if(rad[i].checked){
				ownership = rad[i].value;
			}
		}
		

	
	if(cor == "" || cor != "Qatar" || maddress == "" || mcity == "" || mobile == "" || isnan(mobile) || ownership == "" || rarea == "" || flatno == "" || street == "" || building == "" || pobox == "" || since == "" || isnan(since) || (nation != "Qatar" && haddress == "" && homecountry == "" && hcity == "" && hometele == "" && homemobile == "")){
		
		errors = "Following field(s) are required\n";
		if(maddress == ""){
			errors += " - Mailing Address is required.\n";	
		}
		if(cor == ""){
			errors += " - Country of Residence is required.\n";	
		}
		if(cor != "Qatar"){
			errors += " - Qatari residents can apply only.\n";
		}
		if(mcity == ""){
			errors += " - Mailing City is required.\n";	
		}
		if(pobox == ""){
			errors += " - P.O. Box is required.\n";	
		}
		if(nation != "Qatar"){
			if(haddress == ""){
			errors += " - Home Address is required.\n";					
			}
			if(homecountry == ""){
			errors += " - Home Country is required.\n";					
			}
			if(hcity == ""){
			errors += " - Home City is required.\n";					
			}
			if(hometele == ""){
				errors += " - Home Country Tele is required.\n";					
			}
			if(hometele != "" && isnan(hometele)){
				errors += " - Home Country Tele should be number.\n";					
			}
			if(homemobile == ""){
			errors += " - Home Country Mobile is required.\n";					
			}
			if(homemobile != "" && isnan(homemobile)){
			errors += " - Home Country Mobile should be number.\n";					
			}
		}
		if(rarea == ""){
			errors += " - Residential Area is required.\n";	
		}
		if(flatno == ""){
			errors += " - Villa / Flat Number is required.\n";	
		}
		if(street == ""){
			errors += " - Street Name is required.\n";	
		}
		if(building == ""){
			errors += " - Building Name / Number is required.\n";	
		}
		if(ownership == ""){
			errors += " - Ownership is required.\n";	
		}
		if(since == ""){
			errors += " - Same address since is required.\n";	
		}
		if(since != "" && isnan(since)){
			errors += " - Same address since should be a year.\n";	
		}
		if(mobile == ""){
			errors += " - Mobile Number is required.\n";	
		}
				
		if(mobile != "" && isnan(mobile)){
			errors += " - Mobile Number should be a number.\n";	
		}
				
	}
	
	
	if(errors){
		alert(errors);
		return false;
	}
return true;
}


function ValidateStep3(){
	var errors = "";
	var employment = "";

	var emp = document.form1.employment;

	for(i=0; i<emp.length; i++){
		if(emp[i].checked){
			employment = emp[i].value;
		}
	}

	var employername = trim(document.getElementById("employername").value);
	var natureofbusiness = trim(document.getElementById("natureofbusiness").value);
	var workaddress = trim(document.getElementById("workaddress").value);
	var officepobox = trim(document.getElementById("officepobox").value);
	var workcity = trim(document.getElementById("workcity").value);
	var empstartdate = trim(document.getElementById("empstartdate").value);
	
	if(employment == "" || (employment == "Employed" && (employername == "" || natureofbusiness == "" || (empstartdate != "" && !validDate(empstartdate)))) || workaddress == "" || officepobox == "" || workcity == ""){
		
	errors = "Following field(s) are required\n";

	if(employment == ""){
		errors += " - Employment type is required.\n";
	}

	if(employment == "Employed"){			
			if(employername == ""){
				errors += " - Employer/Sponsor Name is required.\n";
			}
			if(natureofbusiness == ""){
				errors += " - Nature of Business is required.\n";
			}
			if(empstartdate == "" || empstartdate == "dd/mm/yyyy"){
				errors += " - Employment Start Date is required.\n";
			}
			if(empstartdate != "" && empstartdate != "dd/mm/yyyy" && !validDate(empstartdate)){
				errors += " - Employment Start Date should be in dd/mm/yyyy format.\n";
			}
	}
			if(workaddress == ""){
				errors += " - Address is required.\n";
			}
			if(officepobox == ""){
				errors += " - P.O Box is required.\n";
			}
			if(workcity == ""){
				errors += " - City is required.\n";	
			}
				
	}
	
	if(errors){
		alert(errors);
		return false;
	}
return true;
}

function ValidateStep4(){
	var errors = "";
	var type = "";
	var incomesource = "";
	var products = "";

	var custtype = document.form1.customertype;
	var isource = document.form1.incomesource;
	var prod = document.form1.products;

	for(i=0; i<custtype.length; i++){
		if(custtype[i].checked){
			type = custtype[i].value;
		}
	}
	for(i=0; i<isource.length; i++){
		if(isource[i].checked){
			incomesource = isource[i].value;
		}
	}
	for(i=0; i<prod.length; i++){
		if(prod[i].checked){
			products = prod[i].value;
		}
	}

	var accountno = trim(document.getElementById("accountno").value);
	var deposit = trim(document.getElementById("deposit").value);
	var localbank = trim(document.getElementById("localbank").value);
	var otherbank = trim(document.getElementById("otherbank").value);
	var specify = trim(document.getElementById("specify").value);
	
	if(type == "" || isnan(deposit) || deposit == "" || deposit < 20000 || (incomesource == "" && specify == "") || ((localbank != "" || otherbank != "") && products == "") || (type == "Existing" && accountno == "")){
		
		errors = "Following field(s) are required\n";
		
		if(type == ""){
			errors += " - Please specify whether you are existing or new customer.\n";
		}
		if(type == "Existing" && accountno == ""){
			errors += " - Account number is required.\n";
		}
		if(deposit == ""){
			errors += " - Initial Deposit is required.\n";
		}		
		if(deposit != "" && deposit < 20000){
			errors += " - Initial Deposit should be minimum 20000.\n";
		}
		if(deposit != "" && isnan(deposit)){
			errors += " - Initial Deposit should be a number.\n";	
		}
		if(incomesource == "" && specify == ""){
			errors += " - Income Source is required.\n";
		}
		if((localbank != "" || otherbank != "") && products == ""){
			errors += " - Banking Product is required.\n";
		}
	}
	
	if(errors){
		alert(errors);
		return false;
	}
return true;
}

function QatarID(){
	var country = document.getElementById("cob").value;
	if(country == "Qatar"){
		document.getElementById("qatarid").style.display = "inline";	
	}else{
		document.getElementById("qatarid").style.display = "none";
	}
}

function Nationality(){
	var nationality = document.getElementById("Nationality").value;

	if(nationality == "Qatar"){
		document.getElementById("pp1").style.display = "none";
		document.getElementById("pp3").style.display = "none";
		document.getElementById("pp5").style.display = "none";

	}else{
		document.getElementById("pp1").style.display = "";
		document.getElementById("pp3").style.display = "";
		document.getElementById("pp5").style.display = "";
	}
}

function trim(str) 
{
	return str.replace(/^\s*|\s*$/g,"");
}

function validDate(fld) {
    var RegExPattern = /^((((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|[12]\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|1\d|2[0-8])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$/;
    var errorMessage = 'invalid date';
    if ((fld.match(RegExPattern)) && (fld != '')) {
        // alert('Date is OK'); 
	return true;
    } else {
       // alert(errorMessage);
       // fld.focus();
       return false;
    } 
}

function isnan(str){
	if(str != ""){
		if(str.match(/[^0-9 s+]/i)){
			return true;
		}
	}
return false;	
}

function openNewWindow(URLtoOpen, windowName, windowFeatures) { newWindow=window.open(URLtoOpen, windowName, windowFeatures); }

function openacct(URLtoOpen, windowName, windowFeatures) { newWindow=window.open(URLtoOpen, windowName, windowFeatures); }

function popup(url)
{
	newwindow=window.open(url,'eSavings','left=100, top=100, width=658, height=580, scrollbars=1,toolbar=no,status=no');

}

function validateQM8(){


	var attdates = "";
	var errors = "";
	var whowillattend = "";

	var name = document.getElementById("Name").value;
	var company = document.getElementById("Company").value;
	var telephone = document.getElementById("Telephone").value;
	var email = document.getElementById("Email").value;
	var whowillattend_ = document.form1.whowillattend;
	var attdates_ = document.form1.attdates;
	var	spousename = document.getElementById("spousename").value;
	var spousetel = document.getElementById("spousetel").value;
	var spouseemail = document.getElementById("spouseemail").value;
	var colleaguename = document.getElementById("colleaguename").value;
	var colleaguetel = document.getElementById("colleaguetel").value;
	var colleagueemail = document.getElementById("colleagueemail").value;


	
	for(i=0; i<whowillattend_.length; i++){
		if(whowillattend_[i].checked){
			whowillattend = whowillattend_[i].value;
		}
	}
	
	for(i=0; i<attdates_.length; i++){
		if(attdates_[i].checked){
			attdates = attdates_[i].value;
		}
	}
	
	
	if(name == ""){
		errors = errors + "- Name is required.\n";
	}

	if(company == ""){
		errors = errors + "- Company is required.\n";
	}

	if(telephone == ""){
		errors = errors + "- Telephone is required.\n";
	}

	if(email == ""){
		errors = errors + "- Email is required.\n";
	}
	
	if(whowillattend == "My spouse/partner will attend"){
		if(spousename == ""){
			errors = errors + "- Spouse Name is required.\n";
		}
		if(spousetel == ""){
			errors = errors + "- Spouse Telephone is required.\n";
		}
		if(spouseemail == ""){
			errors = errors + "- Spouse Email is required.\n";
		}
	}


	if(whowillattend == "I will not attend but in my place another senior colleague will attend"){
		if(colleaguename == ""){
			errors = errors + "- Name of colleague is required.\n";
		}
		if(colleaguetel == ""){
			errors = errors + "- Colleague telephone is required.\n";
		}
		if(colleagueemail == ""){
			errors = errors + "- Colleague Email is required.\n";
		}
	
	}
	
	if(attdates == ""){
			errors = errors + "- Attendance days are required.\n";
	}



	if(errors != ""){
		alert('Following errors occured:\n' + errors);
		return false;
	}
	
	return true;


}


function validateGolfCorporate(){

	var errors = "";
	var iscustomer = "";

	var company = document.getElementById("Company Name").value;
	var player1 = document.getElementById("Player1 Name").value;
	var tel1 = document.getElementById("Player1 Telephone").value;
	var email1 = document.getElementById("Player1 Email").value;
	var handicap1 = document.getElementById("Player1 Handicap").value;
	var player2 = document.getElementById("Player2 Name").value;
	var tel2 = document.getElementById("Player2 Telephone").value;
	var email2 = document.getElementById("Player2 Email").value;
	var handicap2 = document.getElementById("Player2 Handicap").value;
	var cbnumber1 = document.getElementById("cbnumber1").value;
	var cbnumber2 = document.getElementById("cbnumber2").value;
	var cbnumber3 = document.getElementById("cbnumber3").value;
	
	var iscustomer_ = document.form1.iscustomer;


	
	for(i=0; i<iscustomer_.length; i++){
		if(iscustomer_[i].checked){
			iscustomer = iscustomer_[i].value;
		}
	}
	
	
	if(company == ""){
		errors = errors + "- Company Name is required.\n";
	}

	if(player1 == ""){
		errors = errors + "- Player1 Name is required.\n";
	}

	if(tel1 == ""){
		errors = errors + "- Player1 Telephone is required.\n";
	}

	if(email1 == ""){
		errors = errors + "- Player1 Email is required.\n";
	}

	if(handicap1 == ""){
		errors = errors + "- Player1 Handicap is required.\n";
	}
	
	if(player2 == ""){
		errors = errors + "- Player2 Name is required.\n";
	}

	if(tel2 == ""){
		errors = errors + "- Player2 Telephone is required.\n";
	}

	if(email2 == ""){
		errors = errors + "- Player2 Email is required.\n";
	}

	if(handicap2 == ""){
		errors = errors + "- Player2 Handicap is required.\n";
	}
	
	if(iscustomer == "Yes"){
		if(cbnumber1 == "" || isNaN(cbnumber1) || cbnumber1.length < 4){
			errors = errors + "- Enter Account, Card or Loan number - first 4 digits\n";
		}
		if(cbnumber2 == "" || isNaN(cbnumber2) || cbnumber2.length < 6){
			errors = errors + "- Enter Account, Card or Loan number - middle 6 digits\n";
		}
		if(cbnumber3 == "" || isNaN(cbnumber3) || cbnumber3.length < 3){
			errors = errors + "- Enter Account, Card or Loan number - last 3 digits\n";
		}
	}

	if(errors != ""){
		alert('Following errors occured:\n' + errors);
		return false;
	}
	
	return true;
}


function validateGolfIndividual(){

	var errors = "";
	var iscustomer = "";

	var company = document.getElementById("Company Name").value;
	var player = document.getElementById("Name").value;
	var tel = document.getElementById("Telephone").value;
	var email = document.getElementById("Email").value;
	var handicap = document.getElementById("Handicap").value;
	var cbnumber1 = document.getElementById("cbnumber1").value;
	var cbnumber2 = document.getElementById("cbnumber2").value;
	var cbnumber3 = document.getElementById("cbnumber3").value;
	
	var iscustomer_ = document.form1.iscustomer;

	for(i=0; i<iscustomer_.length; i++){
		if(iscustomer_[i].checked){
			iscustomer = iscustomer_[i].value;
		}
	}
	
	if(company == ""){
		errors = errors + "- Company Name is required.\n";
	}

	if(player == ""){
		errors = errors + "- Name is required.\n";
	}

	if(tel == ""){
		errors = errors + "- Telephone is required.\n";
	}

	if(email == ""){
		errors = errors + "- Email is required.\n";
	}

	if(handicap == ""){
		errors = errors + "- Handicap is required.\n";
	}
	
	if(iscustomer == "Yes"){
		if(cbnumber1 == "" || isNaN(cbnumber1) || cbnumber1.length < 4){
			errors = errors + "- Enter Account, Card or Loan number - first 4 digits\n";
		}
		if(cbnumber2 == "" || isNaN(cbnumber2) || cbnumber2.length < 6){
			errors = errors + "- Enter Account, Card or Loan number - middle 6 digits\n";
		}
		if(cbnumber3 == "" || isNaN(cbnumber3) || cbnumber3.length < 3){
			errors = errors + "- Enter Account, Card or Loan number - last 3 digits\n";
		}
	}

	if(errors != ""){
		alert('Following errors occured:\n' + errors);
		return false;
	}
	
	return true;
}

function validateServicesForm(){

	var errors = "";

	var estatement = document.getElementById("chkestatement").checked;
	var email = document.getElementById("email").value;
	var chksms = document.getElementById("chksms").checked;
	var mprefix = document.getElementById("mprefix").value;
	var mobile = document.getElementById("mobile").value;
	var chkflexible = document.getElementById("chkflexible").checked;
	var percentage = document.getElementById("percentage").value;
	var cname = document.getElementById("cname").value;
	var caddress = document.getElementById("caddress").value;
	var cmobile = document.getElementById("cmobile").value;
	var telehome = document.getElementById("telehome").value;
	var teleoffice = document.getElementById("teleoffice").value;
	var cemail = document.getElementById("cemail").value;
	var idcard = document.getElementById("idcard").value;
	var cctype = document.getElementById("cctype").value;
	var ccnumber = document.getElementById("ccnumber").value;
	
	
	if(estatement){
		if(email == ""){
			errors = errors + "- Email address for e-statement is required.\n";
		}else{
			if(!isemail(email)){
				errors = errors + "- Email address for e-statement is invalid.\n";
			}
		}
	}


	if(chksms){
		if(isNaN(mobile)){
			errors = errors + "- Mobile number can contain only numbers.\n";
		}else{
			if(mobile == ""){
					errors = errors + "- Mobile number is required.\n";					
				}else{
				if(mobile.substring(0,1) != 3 && mobile.substring(0,1) != 5 && mobile.substring(0,1) != 6 && mobile.substring(0,1) != 7){
					errors = errors + "- Mobile number is invalid.\n";			
				}
			}
		}
	}


	if(chkflexible){
		if(percentage == ""){
			errors = errors + "- Minimum monthly repayment is required.\n";	
		}
	}


	if(!estatement && !chksms && !chkflexible){
			errors = errors + "- Please select a service.\n";	
	}

	if(cname == ""){
			errors = errors + "- Name is required.\n";
	}

	if(cmobile == ""){
			errors = errors + "- Mobile number is required.\n";
	}

	if(isNaN(cmobile)){
			errors = errors + "- Mobile number is not valid.\n";
	}

	if(telehome != "" && isNaN(telehome)){
			errors = errors + "- Home telephone number is invalid.\n";
	}

	if(teleoffice != "" && isNaN(teleoffice)){
			errors = errors + "- Office telephone number is invalid.\n";
	}


	if(cemail == ""){
		errors = errors + "- Email address is required.\n";
	}else{
		if(!isemail(cemail)){
			errors = errors + "- Email address is invalid.\n";
		}
	}
	
	if(idcard == ""){
		errors = errors + "- ID Card Number is required.\n";
	}else{
		if(idcard.length != 11 || isNaN(idcard)){
			errors = errors + "- ID Card Number is invalid.\n";
		}
	}

	if(ccnumber == ""){
		errors = errors + "- Credit Card Number is required.\n";
	}else{
		if(isNaN(ccnumber)){
			errors = errors + "- Credit Card Number is invalid.\n";			
		}else{
			if((cctype == "Visa" || cctype == "Mastercard") && ccnumber.length != 16){
				errors = errors + "- Credit Card Number is invalid.\n";					
			}
			if(cctype == "Diners Club" && ccnumber.length != 14){
				errors = errors + "- Credit Card Number is invalid.\n";					
			}
		}
	}

	if(errors != ""){
		alert('Following errors occured:\n' + errors);
		return false;
	}
	
	return true;
}




function validateCCForm(){

	var errors = "";
	var packages = "";
	var CBcustomer = "";

	var name = document.getElementById("name").value;
	var company = document.getElementById("company").value;
	var income = document.getElementById("income").value;
	var address = document.getElementById("address").value;
	var tel = document.getElementById("tel").value;
	var email = document.getElementById("email").value;

	var rpackage = document.form1.package;
	var m1 = document.getElementById("membership_no1").value;
	var m2 = document.getElementById("membership_no2").value;

	var rCBcustomer = document.form1.CBcustomer;

	var accountno = document.getElementById("accountno").value;

	var branch = document.getElementById("branch").value;

	for(i=0; i<rpackage.length; i++){
		if(rpackage[i].checked){
			packages = rpackage[i].value;
		}
	}
		
	for(i=0; i<rCBcustomer.length; i++){
		if(rCBcustomer[i].checked){
			CBcustomer = rCBcustomer[i].value;
		}
	}

	if(name == ""){
		errors = errors + "- Full Name is required.\n";
	}

	if(income == ""){
		errors = errors + "- Monthy Income is required.\n";
	}
	
	if(address == ""){
		errors = errors + "- Address is required.\n";
	}

	if(tel == ""){
		errors = errors + "- Contact Telephone Number is required.\n";
	}

	if(email != "" && !isemail(email)){
		errors = errors + "- Email is not valid.\n";
	}

	if(company == ""){
		errors = errors + "- Company/ Employer is required.\n";
	}

	if(packages == ""){
		errors = errors + "- Please select a package.\n";
	}

	if(CBcustomer == "I am existing customer" && accountno == ""){
		errors = errors + "- Account Number is required.\n";
	}

	if(CBcustomer == "New to CB" && branch == ""){
		errors = errors + "- Branch is required.\n";
	}

	if(errors != ""){
		alert('Following errors occured:\n' + errors);
		return false;
	}
	
	return true;

}

function showpackages(){
	var income = document.getElementById('income').value;
	 if(income != ""){
		 if(income == 'over QR 4,000'){
			 display('apply', '');
			 display('classic', '');
			 display('gold', 'none');
			 display('platinum', 'none');
		 }
		 if(income == 'over QR 8,500'){
			 display('apply', '');
			 display('classic', 'none');
			 display('gold', '');
			 display('platinum', 'none');
		 }
		 if(income == 'over QR 15,000'){
			 display('apply', '');
			 display('classic', 'none');
			 display('gold', 'none');
			 display('platinum', '');
		 }
	 }else{
		display('apply', 'none'); 
	 }
	
}
