//*********************************************************************
// APInstruments 
// Helper functions
//*********************************************************************


  //******************
  // search
  function search() 
  {
      openNewWindow("http://www.google.com/search?q="+document.form1.input1.value+"+site%3Awww.apinstruments.com");
     
  }
	

  function openNewWindow(newURL) 
  {     
     var MyWindowOptions = 'width=850,height=600,status=yes,toolbar=no,scrollbars=yes,resizable=yes';
     window.open(newURL, '', MyWindowOptions);
  }


  function downloadSoftware(software)
  {
    // Display download form and when next is clicked, set page to software 
    //window.location.href = "downloadForm.html?" + software;  
    window.open("downloadForm.php?package=" + software);
  }

  function goToURL(manual)
  {
     window.location = manual; 
  }
  	
  
  //function sendMsg(form)
  //{
  //   document.downloadform.Message.value = (
  //      '  ' + newline +       
  //      '-----Automated Download EMail --------- ' + newline       
  //   );	 		  
  //}

  //**********************************
  // Old download (not using php).  This is not used, but may come in handy if php is an issue.
  function downloadit()
  {
    if (validate())
    {
       // Get the download file from the url 
       var arg=location.href.split("?");
       var softwareFile = arg[1];
       // Send an email with info from form	
       document.downloadform.Message.value = (
          '  ' + newline +       
           '-----Automated Download EMail --------- ' + newline     
       );	
       window.location.href = softwareFile;
       window.focus();		
       return true;
    }	
  }


  function getValidated()
  {
    return validated;
  }

  function validate()
  {
     validated=false;
     if (document.downloadform.name.value.length == 0) {
	   alert("Please enter your name");
 	   return false;
     }
    
     if (document.downloadform.email.value.length == 0) {
	 alert("Please enter your email address");
	 return false;
     } 

     		 
     // Validate email address
     if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.downloadform.email.value))
     {
        //email format is good; do nothing
     }
     else
     {
         alert("Invalid email Address! Please re-enter.")
         return false;
     }
		
     
     validated = true; 
     return true;
  }




