//-----------------------------------------------------------------------------------------------------
// COPYRIGHT
//  Copyright (c) 1997-2007 LinkTek Corporation.
// 
// WARNING
//  This software is copyrighted! Any use of this software or other software
//  whose copyright is held by David Greenbaum or LinkTek Corporation
//  or any software derived from such software without the prior written
//  consent of the copyright holder is a violation of federal law punishable
//  by imprisonment, fine or both. LinkTek Corporation will pay a
//  reward of three thousand dollars ($3000) for information leading to
//  successful civil litigation or criminal conviction of anyone violating
//  a copyright held by David Greenbaum or LinkTek Corporation. */
// 
// PURPOSE
//   Add client side processing to the LinkTek web site that will be used with
//   server side PHP code to capture available search keywords, make them available
//   to all site pages that include this script and write the keywords to a cookie.
//
// NOTES
//   This Javascript file is to be included into every html file with the line:
//	 <SCRIPT TYPE="text/javascript" SRC="global.js"></SCRIPT>.
// WRITTEN
//  10 May 2007 (DougF)
// MODIFIED
// 
var keywordsFormName = 'keywordsForm';

function submitForm() {
// PURPOSE
//   Use client side load event to submit form.
// RETURNS
//   Nothing
// ARGUMENTS
//   formName [optional] -- INPUT -- name of form to be submitted
//   NOTE: This argument is accessed by the global variable 
//   iWhichFile As Integer -- INPUT -- GI_PROCESS_PARENT or GI_PROCESS_CHILD
// MODIFIED
//   30 Jan 2002 (BVS) -- Removed added space from backup prefix.
//   28 Feb 2002 (BVS) -- Added handling of moving backup files to backup folder.
//   03 Apr 2003 (BVS) -- Added handling of extraneous .PPT extension when rewriting
//                        PowerPoint temp file using the PPT OLE server based DLL.
//   15 Aug 2003 (BVS) -- Added exit function call to return correct error code if rewrite error.
//   07 Jul 2004 (BVS) -- Added use of new error code for links pointing to missing worksheets.

  var formName = null;
  var nodeList = null;
  var node = null;
  var formNode = null;
  
  // This function takes an optional argument, the name
  // of the form to submit can be passed in as an argument
  // Test for presence of this form name if absent, set 
  // the default value to a constant.
  if (arguments.length > 0) {
    formName = arguments[0];
  }
  else {
    formName = keywordsFormName;
  }
  
  // look for form with defined name
  nodeList = getElementsByTagName("form");
  for (node in nodeList) {
    if (node.name == formName) {
	  formNode = node;
    }
  }
  
  // if found, submit it
  if (formNode) {
    formNode.submit();
  }
}

function checkWhitePaper(theForm) {
	var address=theForm.email.value;
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if (theForm.email.value == "" || reg.test(address) == false){
		alert ("Please enter your e-mail address after clicking the {OK} button.");
		theForm.email.focus();
		return (false);
	}
	return (true);
}


function checkNews(theForm) {
	if (theForm.name.value == ""){
		alert ("Please enter your name after clicking the {OK} button.");
		theForm.name.focus();
		return (false);
	}
	if (theForm.phone.value == ""){
		alert ("Please enter your phone after clicking the {OK} button.");
		theForm.phone.focus();
		return (false);
	}
	if (theForm.email.value == ""){
		alert ("Please enter your e-mail address after clicking the {OK} button.");
		theForm.email.focus();
		return (false);
	}
	return (true);
}

function checkWhite(theForm) {
	if (theForm.name.value == ""){
		alert ("Please enter your name after clicking the {OK} button.");
		theForm.name.focus();
		return (false);
	}
	if (theForm.phone.value == ""){
		alert ("Please enter your phone after clicking the {OK} button.");
		theForm.phone.focus();
		return (false);
	}
	if (theForm.email.value == ""){
		alert ("Please enter your e-mail address after clicking the {OK} button.");
		theForm.email.focus();
		return (false);
	}
	return (true);
}


