var imagenumber = 5 ;
var randomnumber = Math.random() ;
var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1 ;
images = new Array
images[1] = "img/grx1.jpg"
images[2] = "img/grx2.jpg"
images[3] = "img/grx3.jpg"
images[4] = "img/grx4.jpg"
images[5] = "img/grx5.jpg"
var image = images[rand1]

IE4 = document.all;

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_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_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 newAlert(title,mess,icon,mods) {
   (IE4) ? makeMsgBox(title,mess,icon,0,0,mods) : alert(mess);
}

function newConfirm(title,mess,icon,defbut,mods) {
   if (IE4) {
      icon = (icon==0) ? 0 : 2;
      defbut = (defbut==0) ? 0 : 1;
      retVal = makeMsgBox(title,mess,icon,4,defbut,mods);
      retVal = (retVal==6);
   }
   else {
      retVal = confirm(mess);
   }
   return retVal;
}

function newPrompt(title,mess,def) {
   retVal = (IE4) ? makeInputBox(title,mess,def) : prompt(mess,def);
   return retVal;
}

function IEBox(title,mess,icon,buts,defbut,mods) {
   retVal = (IE4) ? makeMsgBox(title,mess,icon,buts,defbut,mods) : null;
   return retVal;
}

function jhref(url)
  {
   var x;
   var finalURL;
   x=newConfirm("Logout","Are you sure you want to log out?",1,1,0);
   if(x == true){ finalURL = url;  
   document.location.href=finalURL;}
  }

function confirmUpgrade(url)
  {
   var x;
   var finalURL;
   x=newConfirm("Confirm","Are you sure you want to proceed? This use will be billed to your account.",1,1,0);
   if(x == true){ finalURL = url;  
  // document.location.href=finalURL;
   document.upgradeform.submit()
    }
  }

function confirmUpgrade2(url)
  {
   var x;
   var finalURL;
   x=newConfirm("Confirm","Are you sure you want to proceed? This use will be billed to your account.",1,1,0);
   if(x == true){ finalURL = url;  
  // document.location.href=finalURL;
   document.upgradeform2.submit()
    }
  }

function emailCheck (emailStr) {
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|COM|NET|ORG|EDU|INT|MIL|GOV|ARPA|BIZ|AERO|NAME|COOP|INFO|PRO|MUSEUM)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);

if (matchArray==null) {
alert("The email address is not correct (check the @ and the .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("The mail user is not correct (the part to the left of the @).");
return false;
}
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("The email domain is not correct (the part to the right of the period(.).");
return false;
}
}

if (user.match(userPat)==null) {
alert("The email address is incorrect.");
return false;
}

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("The IP number for the addressee is incorrect!");
return false;
}
}
return true;
}

var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The email address has an incorrect or invalid domain.");
return false;
}
}


if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The email suffix is incorrect.");
return false;
}

if (len<2) {
alert("The email address has an incorrect or invalid domain.");
return false;
}

return true;
}

function process_valueform()
 {
//valueForm
if (document.valueForm.address.value=='') 
       {
       alert("Please fill in the property address.");
       document.valueForm.address.focus();
       return;
      }

  if ((document.valueForm.zip.value=='') && (document.valueForm.city.value==''))
       {
       alert("Please fill in either the city and state or the zip code.");
       document.valueForm.city.focus();
       return;
      }


  if (document.valueForm.zip.value=='')
   {

 if (document.valueForm.city.value=='')
   { alert("Please fill in the city.");
     document.valueForm.city.focus();
     return; }

  if (document.valueForm.state.value=='Select')
    {  alert("Please select a state.");
      document.valueForm.state.focus();
     return; }
     
    }
else
  {
// zip
}

   document.valueForm.submit();

  }
///////////////////////////////

function process_contact()
{
  if (document.contactform.first.value=='') 
       {
       alert("Please fill in your first name.");
       document.contactform.first.focus();
        return;
      }

  if (document.contactform.last.value=='') 
       {
       alert("Please fill in your last name.");
       document.contactform.last.focus();
        return;
      }


     if (document.contactform.email.value=="") {
       alert("Please fill in your email address.");
       document.contactform.email.focus();
       return;
       }

  if  (emailCheck(document.contactform.email.value) ==false)
    { 
     document.contactform.email.focus();
     return;
     }

 if (document.contactform.phone.value=='') 
       {
       alert("Please fill in your phone number");
       document.contactform.phone.focus();
       return;
       }

 if (document.contactform.mysubject.value=='') 
       {
       alert("Please fill in your last name.");
       document.contactform.mysubject.focus();
        return;
      }



if (document.contactform.message.value=='') 
       {
       alert("Please fill in your message");
       document.contactform.message.focus();
       return;
       }


  document.contactform.submit();


}
//////////////////////

  function join_form_verify()
   {

     if (document.joinform.first.value=='') 
       {
       alert("Please fill in the billing first name.");
       document.joinform.first.focus();
        return;
       }

     if (document.joinform.last.value=='') 
       {
       alert("Please fill in the billing last name.");
       document.joinform.last.focus();
       return;
       }

   if (document.joinform.address.value=='') 
       {
       alert("Please fill in the billing street address.");
       document.joinform.address.focus();
       return;
       }

 if (document.joinform.city.value=='') 
       {
       alert("Please fill in the billing city.");
       document.joinform.city.focus();
       return;
       }

 if (document.joinform.state.value=='Select a state') 
       {
       alert("Please select the billing state.");
       document.joinform.state.focus();
       return;
       }

 
if (document.joinform.zipp.value=='') 
       {
       alert("Please fill in the Zip Code.");
       document.joinform.zipp.focus();
       return;
       }


if (document.joinform.company.value=='') 
       {
       alert("Please fill in the company.");
       document.joinform.company.focus();
       return;
       }


if (document.joinform.phone.value=='') 
       {
       alert("Please fill in the phone.");
       document.joinform.phone.focus();
       return;
       }

  if (document.joinform.email.value=="") {
       alert("An billing email address is required.");
       document.joinform.email.focus();
       return;
       }

    if  (emailCheck(document.joinform.email.value) ==false)
    { 
     document.joinform.email.focus();
     return;
     }

// if (document.joinform.plan.value=='') 
 //      {
 //      alert("You must choose a membership plan.");
 //      document.joinform.plan.focus();
 //      return;
 //      }

if (document.joinform.cardholder_name.value=='') 
       {
       alert("Please fill in the full cardholder name.");
       document.joinform.cardholder_name.focus();
       return;
       }


 if (document.joinform.card_number.value=='') 
       {
       alert("Please fill in the credit card number.");
       document.joinform.card_number.focus();
       return;
       }



if (document.joinform.cin.value=='') 
       {
       alert("Please fill in the Card Identification Number (this is a three or four digit security code printed on the back of the creditv card).");
       document.joinform.cin.focus();
       return;
       }

 var err_result=0;

  err_result=lun_check();
  if (err_result==0)
  {
   var x;
   var finalURL;
   x=newConfirm("Confirm Payment","Your credit card will be billed. \r\nAre you sure you wish to proceed?",1,1,0);
   if(x == true){ 
       //finalURL = url;  
       document.joinform.submit();
    }}

   }


function lun_check()
{
   error=0;
    var cc_owner = document.joinform.cardholder_name.value;
    var cc_number = document.joinform.card_number.value;
    if (cc_owner == "" || cc_owner.length < 3) {
      error_message = error_message + "* The owner's name of the credit card must be at least 3 characters.\n";
      error = 1;
    }
    if (cc_number == "" || cc_number.length < 10) {
      error_message = error_message + "* The credit card number must be at least 10 characters.\n";
      error = 1;
    }

   var error_message='';
   var card_type='~'+document.joinform.card_number.value;
   var cctype='~';
   var cctype2='~';

    cc_type2="~"+cc_number.substring(0,1);
    cc_type="~"+cc_number.substring(0,2);

   // alert( "CCTYPE ="+cc_type);
   // alert( "CCTYPE2 ="+cc_type2);

    if ((cc_type=='~51') ||  (cc_type=='~52') || (cc_type=='~53') ||  (cc_type=='~54')   ||  (cc_type=='~55'))
      {  card_type="MASTERCARD";  };
  
 
     if (cc_type2=='~4') {  card_type="VISA"; };
 
// alert("cctype="+card_type);

/*
   if (((card_type=="VISA") || (card_type=="MASTERCARD")) !=true)     
    {
        error_message = error_message + "* Note: We accept only VISA or MasterCard. No AMEX or Discover please.\n";
        error = 1;
    }
*/

  if (error==1) 
        {  alert("Invalid credit card number format: "+error_message);
          document.joinform.card_number.focus();
        }
 return error;
}

////////// popups

function upgApp()
 {
  var upappurl='';
  document.location.href=upappurl;
 }
 
 function getAnother()
 {
  var upappurl='https://loandiligence.com/index.php?option=com_content&task=view&id=24&Itemid=37';
  document.location.href=upappurl;
 }

 
 function upRep()
 {
  confirmUpgrade();
 }


function upMem()
 {
 var url='https://www.loandiligence.com/index.php?option=com_content&task=view&id=25&Itemid=38&edit=upgrade';
  confirmUpgrade2(url);

 }

 function EvalSound(soundobj) {
   var thissound=document.getElementById(soundobj);
       thissound.Play();
   }

 function showPop1()
  {
  }

function showPop2()
  {
  }

function showPop3()
  {
  }

function showPop4(plan)
  {

   
  }

function closePops()
 {
 
 }

function pview(xproduct,xurl)
 {
   popUp(xurl,'repwin','elastic','800','800');
 }


function popStart(report)
  {
  }

function popUp(strURL,strType,strHeight,strWidth) {
var strOptions="";
if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;
if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth;
window.open(strURL, 'newWin', strOptions);
}

function ajaxLoader(url,id) {
  if (document.getElementById) {
    var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
  }
  if (x) {
    x.onreadystatechange = function() {
      if (x.readyState == 4 && x.status == 200) {
        el = document.getElementById(id);
        el.innerHTML = x.responseText;
      }
    }
    x.open("GET", url, true);
    x.send(null);
  }
}

function YY_checkform() { //v4.71
//copyright (c)1998,2002 Yaromat.com
  var a=YY_checkform.arguments,oo=true,v='',s='',err=false,r,o,at,o1,t,i,j,ma,rx,cd,cm,cy,dte,at;
  for (i=1; i<a.length;i=i+4){
    if (a[i+1].charAt(0)=='#'){r=true; a[i+1]=a[i+1].substring(1);}else{r=false}
    o=MM_findObj(a[i].replace(/\[\d+\]/ig,""));
    o1=MM_findObj(a[i+1].replace(/\[\d+\]/ig,""));
    v=o.value;t=a[i+2];
    if (o.type=='text'||o.type=='password'||o.type=='hidden'){
      if (r&&v.length==0){err=true}
      if (v.length>0)
      if (t==1){ //fromto
        ma=a[i+1].split('_');if(isNaN(v)||v<ma[0]/1||v > ma[1]/1){err=true}
      } else if (t==2){
        rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");if(!rx.test(v))err=true;
      } else if (t==3){ // date
        ma=a[i+1].split("#");at=v.match(ma[0]);
        if(at){
          cd=(at[ma[1]])?at[ma[1]]:1;cm=at[ma[2]]-1;cy=at[ma[3]];
          dte=new Date(cy,cm,cd);
          if(dte.getFullYear()!=cy||dte.getDate()!=cd||dte.getMonth()!=cm){err=true};
        }else{err=true}
      } else if (t==4){ // time
        ma=a[i+1].split("#");at=v.match(ma[0]);if(!at){err=true}
      } else if (t==5){ // check this 2
            if(o1.length)o1=o1[a[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!o1.checked){err=true}
      } else if (t==6){ // the same
            if(v!=MM_findObj(a[i+1]).value){err=true}
      }
    } else
    if (!o.type&&o.length>0&&o[0].type=='radio'){
          at = a[i].match(/(.*)\[(\d+)\].*/i);
          o2=(o.length>1)?o[at[2]]:o;
      if (t==1&&o2&&o2.checked&&o1&&o1.value.length/1==0){err=true}
      if (t==2){
        oo=false;
        for(j=0;j<o.length;j++){oo=oo||o[j].checked}
        if(!oo){s+='* '+a[i+3]+'\n'}
      }
    } else if (o.type=='checkbox'){
      if((t==1&&o.checked==false)||(t==2&&o.checked&&o1&&o1.value.length/1==0)){err=true}
    } else if (o.type=='select-one'||o.type=='select-multiple'){
      if(t==1&&o.selectedIndex/1==0){err=true}
    }else if (o.type=='textarea'){
      if(v.length<a[i+1]){err=true}
    }
    if (err){s+='* '+a[i+3]+'\n'; err=false}
  }
  if (s!=''){alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+s)}
  document.MM_returnValue = (s=='');
}

//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}


  function join_form_verify2()
   {

     if (document.joinform.first.value=='') 
       {
       alert("Please fill in the billing first name.");
       document.joinform.first.focus();
        return;
       }

     if (document.joinform.last.value=='') 
       {
       alert("Please fill in the billing last name.");
       document.joinform.last.focus();
       return;
       }

   if (document.joinform.address.value=='') 
       {
       alert("Please fill in the billing street address.");
       document.joinform.address.focus();
       return;
       }

 if (document.joinform.city.value=='') 
       {
       alert("Please fill in the billing city.");
       document.joinform.city.focus();
       return;
       }

 if (document.joinform.state.value=='Select a state') 
       {
       alert("Please select the billing state.");
       document.joinform.state.focus();
       return;
       }

 
if (document.joinform.zipp.value=='') 
       {
       alert("Please fill in the Zip Code.");
       document.joinform.zipp.focus();
       return;
       }


if (document.joinform.company.value=='') 
       {
       alert("Please fill in the company.");
       document.joinform.company.focus();
       return;
       }


if (document.joinform.phone.value=='') 
       {
       alert("Please fill in the phone.");
       document.joinform.phone.focus();
       return;
       }

  if (document.joinform.email.value=="") {
       alert("An billing email address is required.");
       document.joinform.email.focus();
       return;
       }

    if  (emailCheck(document.joinform.email.value) ==false)
    { 
     document.joinform.email.focus();
     return;
     }

//document.write("a");
// if (document.joinform.plan.value=='') 
 //      {
 //      alert("You must choose a membership plan.");
 //      document.joinform.plan.focus();
 //      return;
 //      }

//document.write("b");

//if ( typeof document.joinform.cardholder_name.value == 'undefined' )
//       {
//       alert("Please fill in the full cardholder name.");
//       document.joinform.cardholder_name.focus();
//       return;
//       }

//document.write("c");

 if (document.joinform.card_number.value=='') 
       {
       alert("Please fill in the credit card number.");
       document.joinform.card_number.focus();
       return;
       }

//document.write("d");


if (document.joinform.cin.value=='') 
       {
       alert("Please fill in the Card Identification Number (this is a three or four digit security code printed on the back of the creditv card).");
       document.joinform.cin.focus();
       return;
       }

//document.write("e");

 var err_result=0;

  //err_result=lun_check();
  if (err_result==0)
  {
   var x;
   var finalURL;
//document.write("f");

   x=newConfirm("Confirm Payment","Your credit card will be billed. \r\nAre you sure you wish to proceed?",1,1,0);
   if(x == true){ 
       //finalURL = url;  
       document.joinform.submit();
    }}

   }




///////////////