﻿// JScript File

function promptText(thetxt) {
var s = document.getElementById('prompttxt')
    s.innerHTML = thetxt + "<br>"

}


function custVal_txname(source,args) {

    fsValid = true
  var myRegxp = /^[A-Za-zÀ-ÖØ-öø-ÿ '\-\.]{2,35}$/;

    if (myRegxp.test(args.Value) == false) {
        fsValid = false
    }

    if (args.Value == '' || args.Value == 'first name' || args.Value == 'surname' || fsValid == false ) {
            fsValid = false
           } else {
            fsValid = true
        }
        
        if (fsValid == true) {
          document.getElementById(source.controltovalidate).style.border =  '1px solid #7F9DB9';
          // document.getElementById(source.controltovalidate).style.padding =  '1px';
        }
        else {
   document.getElementById(source.controltovalidate).style.border = '2px red solid'
        }

        args.IsValid = fsValid 

}

function custVal_phone(source,args) {
 fsValid = true
var myRegxp = /^((\(?0\d{4}\)?\s?\d{3}\s?\d{3})|(\(?0\d{3}\)?\s?\d{3}\s?\d{4})|(\(?\d{5}\)?\s?\d{5})|(\(?\d{3}\)?\s?\d{3}\s?\d{4})|(\(?0\d{2}\)?\s?\d{4}\s?\d{4}))(\s?\#(\d{4}|\d{3}))?$/;




   if (myRegxp.test(args.Value) == false) {
        fsValid = false
  }
  
  
  var myRegxp2 = /0{5,}|1{5,}|2{5,}|3{5,}|4{5,}|5{5,}|6{5,}|7{5,}|8{5,}|9{5,}/;
  
    if (myRegxp2.test(args.Value) == true) {
        fsValid = false
  }

    if (args.Value == '' || fsValid == false) {
            fsValid = false
           } else {
            fsValid = true
        }
        
        if (fsValid == true) {
          document.getElementById(source.controltovalidate).style.border =  '1px solid #7F9DB9';
           document.getElementById(source.controltovalidate).style.padding =  '1px';
        }
        else {
   document.getElementById(source.controltovalidate).style.border = '2px red solid'
        }
        
        args.IsValid = fsValid 
  
}

function custVal_email(source,args) {
 fsValid = true
    var myRegxp = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;

   if (myRegxp.test(args.Value) == false) {
        fsValid = false
  }

    if (args.Value == ''  || fsValid == false) {
            fsValid = false
           } else {
            fsValid = true
        }
        
        if (fsValid == true) {
          document.getElementById(source.controltovalidate).style.border =  '1px solid #7F9DB9';
           document.getElementById(source.controltovalidate).style.padding =  '1px';
        }
        else {
   document.getElementById(source.controltovalidate).style.border = '2px red solid'
        }
        
        args.IsValid = fsValid 
  
}

function hideShowEquity()
{

for (var i=0; i < document.form1.rbhomeowner.length; i++)
   {
   if (document.form1.rbhomeowner[i].checked)
      {
      var rad_val = document.form1.rbhomeowner[i].value;
                
      }
   }
   
   
   if (rad_val == 'no') {
    document.getElementById('pnlEquityVal').style.display = 'none'; 

   } else {
    document.getElementById('pnlEquityVal').style.display = 'block';
   }

}

function custVal_TX_ApproxDebt(source,args) {

 fsValid = true
    if (args.Value == ''  || fsValid == false || args.Value < 1) {
            fsValid = false
           } else {
            fsValid = true
        }
        
        if (fsValid == true) {
          document.getElementById(source.controltovalidate).style.border =  '1px solid #7F9DB9';
           document.getElementById(source.controltovalidate).style.padding =  '1px';
        }
        else {
   document.getElementById(source.controltovalidate).style.border = '2px red solid'
        }
        
        args.IsValid = fsValid 
  
}


function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj1=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }

	if(obj1.display == 'block')
		obj1.display = 'none';
	else
		obj1.display = 'block';

	
	 }

}

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 clearfield(thedefault,thefield) {
    if (thefield.value == thedefault) {
    thefield.value = ''
    }
}
