function gows()
{ window.open("http://windgensuperstore.com")
}

var postline=""
var myref=window.location.href
if (myref.indexOf("creditck.html")>-1)
{  var postline=""

   if (myref.indexOf("?")>-1)
   {  refsplit=myref.split("?")
      postline=refsplit[1]
      postline=unescape(postline)
   }
   if (postline.length<50)
   {  history.back(1)
   }
}

function goterms()
{ window.open("terms.html",'','toolbar=no, location=no, scrollbars=yes, resizeable=yes, height=500 width=400')
}

function makeyear()
{  var now=new Date()
   var nowyy=now.getYear()
   var nowyys=nowyy-18
   var nowstop=nowyys-100
   var ymsg=""
   for (i=nowyys; i>nowstop; i--)
   {   ymsg+="<option value=\""
       ymsg+=i
       ymsg+="\">"
       ymsg+=i
   }
  return ymsg
}

function ckemail(inEm)
{ var testEm = inEm
  var AtSym    = testEm.indexOf('@')
  var Period   = testEm.lastIndexOf('.')
  var Space    = testEm.indexOf(' ')
  var Length   = testEm.length - 1   // Array is from 0 to length-1
  
  if  ((AtSym < 1) ||                     // '@' cannot be in first position
      (Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
      (Period == Length ) ||             // Must be atleast one valid char after '.'
      (Space  != -1))                     // No empty spaces permitted
  { return 0
  }
  return 1
}


function checkap()
{  var test=document.form1.myemail.value
   if (!ckemail(test))
   {  alert("Please enter a valid email address.")
      document.form1.myemail.focus()
      return
   }   
   var test=document.form1.mycamt.value
   var testb=""
   var allnum="0123456789"
   for (i=0; i<test.length; i++)
   {   var achar=test.substr(i,1)
       if (allnum.indexOf(achar)>-1)
       {  testb+=achar
       }
   }
   var testn=parseInt(testb)
   if (!testn || testn<1000)
   {  alert("Please enter a finance amount ($1000.00 minimum)")
      document.form1.mycamt.focus()
      return
   }

   var test=document.form1.myname.value
   if (test=="")
   {  alert("Please enter your full first and last name.")
      document.form1.myname.focus()
      return
   }

   var test=document.form1.myfirm.value
   if (test=="")
   {  alert("Please enter your employer.\n\nIf you are self-employed, enter the name of your company. This must be a registered dba in your county.")
      document.form1.myfirm.focus()
      return
   }

   var test=document.form1.myincome.value
   var testn=parseInt(test)
   if (!testn || testn<10000)
   {  alert("Please enter your income.\n\n$10,000 USD minimum.")
      document.form1.myincome.focus()
      return
   }

   var test=document.form1.myhphone.value
   if (test=="")
   {  alert("Please enter your home telephone number")
      document.form1.myhphone.focus()
      return
   }

   var test=document.form1.mydobmm.value
   if (test=="0")
   {  alert("Please enter a valid birthday")
      document.form1.mydobmm.focus()
      return
   }
   var test=document.form1.mydobdd.value
   if (test=="0")
   {  alert("Please enter a valid birthday")
      document.form1.mydobdd.focus()
      return
   }
   var test=document.form1.mydobyy.value
   if (test=="0")
   {  alert("Please enter a valid birthday")
      document.form1.mydobyy.focus()
      return
   }

   var test=document.form1.myssno.value
   if (test=="")
   {  alert("Please enter your social security number or National ID (credit checks)")
      document.form1.myssno.focus()
      return
   }

   var test=document.form1.mystreet.value
   if (test=="")
   {  alert("Please enter your residence street address.")
      document.form1.mystreet.focus()
      return
   }
   var test=document.form1.mycity.value
   if (test=="")
   {  alert("Please enter your residence city.")
      document.form1.mycity.focus()
      return
   }

   var test=document.form1.mystate.value
   if (test=="0")
   {  var test=document.form1.myprovince.value
      if (test=="")
      {  alert("Please enter your residence State or province.")
         document.form1.mystate.focus()
         return
      }
   }

   var test=document.form1.myzip.value
   if (test=="")
   {  alert("Please enter your residence zipcode/postal code.")
      document.form1.myzip.focus()
      return
   }

   var test=document.form1.mycountry.value
   if (test=="0")
   {  alert("Please enter your residence country.")
      document.form1.mycountry.focus()
      return
   }
   var test=document.form1.myres.value
   if (test=="0")
   {  alert("Please select the type of residence you own.")
      document.form1.myres.focus()
      return
   }

   var test=document.form1.myfamily.value
   if (test=="0")
   {  alert("Please select the number people in your home.")
      document.form1.myfamily.focus()
      return
   }

   var test=document.form1.mylot.value
   if (test=="")
   {  alert("Please enter the size of the property (lot) in square feet.\n\nIf you use square meters, please indicate this.")
      document.form1.mylot.focus()
      return
   }

   var test=document.form1.mysqft.value
   if (test=="")
   {  alert("Please enter the size of the home interior in square feet.\n\nIf you use square meters, please indicate this.")
      document.form1.mysqft.focus()
      return
   }

   var test=document.form1.mybedrooms.value
   if (test=="0")
   {  alert("Please enter the number of bedrooms in the home.")
      document.form1.mybedrooms.focus()
      return
   }

   var test=document.form1.mybaths.value
   if (test=="0")
   {  alert("Please enter the number of bathrooms in the home.")
      document.form1.mybaths.focus()
      return
   }

   var test=document.form1.mysstreet.value
   var test2=document.form1.myscity.value=document.form1.mycity.value
   var test3=document.form1.mysstate.value=document.form1.mystate.value
   var test4=document.form1.myszip.value=document.form1.myzip.value
   if (test=="" || test2=="" || test3=="" || test4=="")
   {  document.form1.mysstreet.value=document.form1.mystreet.value
      document.form1.myscity.value=document.form1.mycity.value
      document.form1.mysstate.value=document.form1.mystate.value
      document.form1.myszip.value=document.form1.myzip.value
   }  else
   {  if (test2=="")
      {  alert("Please enter your shipping city.")
         document.form1.myscity.focus()
         return
      }
      if (test3=="0")
      {  var test=document.form1.mysprovince.value
         if (test=="")
         {  alert("Please enter your shipping State or province.")
            document.form1.mysstate.focus()
            return
         }
      }
      if (test4=="")
      {  alert("Please enter your shipping zipcode/postal code.")
         document.form1.myszip.focus()
         return
      }
   }
   
   var test=document.form1.my1td.value
   var kick=false
   if (test=="no mortgage - I own")
   {  kick=true
      test=""
   }
   if (test=="" || test.length<3)
   {  if (!kick)
      {  document.form1.my1td.value="no mortgage - I own"
         alert("Please enter your 1st TD/Mortgage information.\n\nIf you have no mortgage and own your property outright, leave this as 'no mortgage - I own'")
         document.form1.my1td.focus()
         return
      }
   }  else
   {  var test=document.form1.my1bank.value
      if (test=="")
      {  alert("Please enter the name of the Bank or lending institution.")
         document.form1.my1bank.focus()
         return
      }
      var test=document.form1.my1name.value
      if (test=="")
      {  alert("Please enter the full name of the contact at the Bank or lending institution.")
         document.form1.my1name.focus()
         return
      }
      var test=document.form1.my1street.value
      if (test=="")
      {  alert("Please enter your Bank or lending institution street address.")
         document.form1.my1street.focus()
         return
      }
      var test=document.form1.my1city.value
      if (test=="")
      {  alert("Please enter your Bank or lending institution city.")
         document.form1.my1city.focus()
         return
      }
    
      var test=document.form1.my1state.value
      if (test=="0")
      {  var test=document.form1.my1province.value
         if (test=="")
         {  alert("Please enter your Bank or lending institution State or province.")
            document.form1.my1state.focus()
            return
         }
      }
    
      var test=document.form1.my1zip.value
      if (test=="")
      {  alert("Please enter your Bank or lending institution zipcode/postal code.")
         document.form1.my1zip.focus()
         return
      } 
      var test=document.form1.my2bank.value
      var testn=parseInt(test)
      if (testn>0)
      {  var test=document.form1.my2bank.value
         if (test=="")
         {  alert("Please enter the name of the 2nd TD Bank or lending institution.")
            document.form1.my2bank.focus()
            return
         }
    
         var test=document.form1.my2name.value
         if (test=="")
         {  alert("Please enter the full name of the contact at the 2nd TD Bank or lending institution.")
            document.form1.my2name.focus()
            return
         }
         var test=document.form1.my2street.value
         if (test=="")
         {  alert("Please enter your 2nd TD Bank or lending institution street address.")
            document.form1.my2street.focus()
            return
         }
    
         var test=document.form1.my2city.value
         if (test=="")
         {  alert("Please enter your 2nd TD Bank or lending institution city.")
            document.form1.my2city.focus()
            return
         }
       
         var test=document.form1.my2state.value
         if (test=="0")
         {  var test=document.form1.my2province.value
            if (test=="")
            {  alert("Please enter your 2nd TD Bank or lending institution State or province.")
               document.form1.my2state.focus()
               return
            }
         }
       
         var test=document.form1.my2zip.value
         if (test=="")
         {  alert("Please enter your 2nd TD Bank or lending institution zipcode/postal code.")
            document.form1.my2zip.focus()
            return
         }
 
         var test=document.form1.my3bank.value
         var testn=parseInt(test)
         if (testn>0)
         {  var test=document.form1.my3bank.value
            if (test=="")
            {  alert("Please enter the name of the 3rd TD Bank or lending institution.")
               document.form1.my3bank.focus()
               return
            }
       
            var test=document.form1.my3name.value
            if (test=="")
            {  alert("Please enter the full name of the contact at the 3rd TD Bank or lending institution.")
               document.form1.my3name.focus()
               return
            }
            var test=document.form1.my3street.value
            if (test=="")
            {  alert("Please enter your 3rd TD Bank or lending institution street address.")
               document.form1.my3street.focus()
               return
            }
       
            var test=document.form1.my3city.value
            if (test=="")
            {  alert("Please enter your 3rd TD Bank or lending institution city.")
               document.form1.my3city.focus()
               return
            }
          
            var test=document.form1.my3state.value
            if (test=="0")
            {  var test=document.form1.my3province.value
               if (test=="")
               {  alert("Please enter your 3rd TD Bank or lending institution State or province.")
                  document.form1.my3state.focus()
                  return
               }
            }
          
            var test=document.form1.my3zip.value
            if (test=="")
            {  alert("Please enter your 3rd TD Bank or lending institution zipcode/postal code.")
               document.form1.my3zip.focus()
               return
            }
    
            var test=document.form1.my4bank.value
            var testn=parseInt(test)
            if (testn>0)
            {  var test=document.form1.my4bank.value
               if (test=="")
               {  alert("Please enter the name of the 4th TD Bank or lending institution.")
                  document.form1.my4bank.focus()
                  return
               }
          
               var test=document.form1.my4name.value
               if (test=="")
               {  alert("Please enter the full name of the contact at the 4th TD Bank or lending institution.")
                  document.form1.my4name.focus()
                  return
               }
               var test=document.form1.my4street.value
               if (test=="")
               {  alert("Please enter your 4th TD Bank or lending institution street address.")
                  document.form1.my4street.focus()
                  return
               }
          
               var test=document.form1.my4city.value
               if (test=="")
               {  alert("Please enter your 4th TD Bank or lending institution city.")
                  document.form1.my4city.focus()
                  return
               }
             
               var test=document.form1.my4state.value
               if (test=="0")
               {  var test=document.form1.my4province.value
                  if (test=="")
                  {  alert("Please enter your 4th TD Bank or lending institution State or province.")
                     document.form1.my4state.focus()
                     return
                  }
               }
             
               var test=document.form1.my4zip.value
               if (test=="")
               {  alert("Please enter your 4th TD Bank or lending institution zipcode/postal code.")
                  document.form1.my4zip.focus()
                  return
               }
            }
         }
      }
   }
   var el=document.form1.elements.length
   for (i=0; i<el; i++)
   {   var myelnam=document.form1.elements[i].name
       var mystuff=document.form1.elements[i].value
       if (mystuff.length>0)
       {  var msg=myelnam+" "+mystuff
postline+="&"
postline+=myelnam
postline+="="
postline+=mystuff
       }
   }
   var gothere="creditck.html?"+postline
   window.location=gothere
}

function ckme(pass)
{ var key=pass+"="
  allpost=postline.split(key)
  var rside=allpost[1]
  var ckmsg=""
  if (rside && rside.length>0)
  {  sidesplit=rside.split("&")
     ckmsg=sidesplit[0]
  }
  if (!ckmsg)
  {  var ckmsg=""
  }
  return ckmsg
}

function ckagree()
{ var iagree=document.form1.agreed.checked
  if (!iagree)
  {  alert("Please read and agree to the TERMS AND CONDITIONS by checking the box before continuing or printing this credit application.")
     document.form1.agreed.focus()
     return
  }
}

