function MM_findObj(n, d) { //v4.0

  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 && document.getElementById) x=document.getElementById(n); return x;

}



function showHideLayers() { //v3.0

  var i,p,v,obj,args=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) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }

    obj.visibility=v; }

}

function MM_swapImage() {
  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];}
}

var openState = "none"

function currentOpenL(openL) {
openState = openL
}

function closeMenu(openL) {
showHideLayers(openState,'','hide');
}


function controlLayers(openL) {
showHideLayers(openState,'','hide',openL,'','show');
}

//function timeClose() {
//closeMenu();
// or  showHideLayers('layer1','','hide');
//}

var timer;
function Pause() {
timer = setTimeout("closeMenu()",1000); // 1 secs
return false;
}

function stopPause() {
clearTimeout(timer)
}


function toggle(link, el_id, tx)
// Greg Addess the argument tx
// which passes the third argument in the link
// in this case is the name of the link text

{
	var el;
	if (el = document.getElementById(el_id))
	{
		bWhich = (/block/.test(el.style.display));
        	el.style.display = (bWhich) ? 'none' : 'block';
		link.innerHTML = (bWhich) ? ''+ tx : ''+ tx;
	}
	return false;
}

function toggleNone(link, el_id, tx)
// Greg Addess the argument tx
// which passes the third argument in the link
// in this case is the name of the link text

{
	var el;
	if (el = document.getElementById(el_id))
	{
		bWhich = (/block/.test(el.style.display));
        	el.style.display = (bWhich) ? 'none' : 'none';
		link.innerHTML = (bWhich) ? ''+ tx : ''+ tx;
	}
	return false;
}



// Start the Form Validation /////////////////////
// I Believe you can't have numbers in the fiedl name for this script
//
//global variable for error flag
var errfound = false;
//function to validate by length
function ValidLength(item, len) {
   return (item.length >= len);
}
//function to validate an email address
function ValidEmail(item) {
   if (!ValidLength(item, 1)) return false;
   if (item.indexOf ('@', 0) == -1) return false;
   return true;
}
// display an error alert
function error(elem, text) {
// abort if we already found an error
   if (errfound) return;
   window.alert(text);
   elem.select();
   elem.focus();
   errfound = true;
}

// Start Phone Number Validation Part 1 /////////////
//
//
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}
//
//
// End Phone Number Validation Part 1 /////////////

// Main validation function
// Change the Form and Field Name  document.FORM_NAME.FIELD_NAME.value
function Validate() {
	// pNum is for the Radio Button check
	var pNum
   errfound = false;

  	var Name=document.onlineSupp.name

	if ((Name.value==null)||(Name.value=="")){
		alert("Please Enter your Name")
		Name.value=""
		Name.focus()
		pNum = false;
		return (false);
         }

if(errfound == false) {

  	var Company=document.onlineSupp.company

	if ((Company.value==null)||(Company.value=="")){
		alert("Please Enter your Company")
		Company.value=""
		Company.focus()
		pNum = false;
		return false
	}

}

if(errfound == false) {

		newString = new String(document.onlineSupp.email.value);
		if(newString.search(/[\w_\.-]+@[\w-_\.]+\.\w{2,3}/gi) != 0)
		{
			alert("You must enter a valid Email Address");
			document.onlineSupp.email.focus();
			document.onlineSupp.email.select();
			pNum = false;
			return (false);
		}

   		if (!ValidLength(document.onlineSupp.email.value,6))
      	error(document.entryForm.email,"Invalid Email Address ");
		pNum = false;

}

if(errfound == false) {

	var PhoneNum=document.onlineSupp.phone

	if ((PhoneNum.value==null)||(PhoneNum.value=="")){
		alert("Please Enter your Phone Number")
		PhoneNum.focus()
		pNum = false;
		return (false);
	}
	if (checkInternationalPhone(PhoneNum.value)==false){
		alert("Please Enter a Valid Phone Number")
		PhoneNum.value=""
		PhoneNum.focus()
		pNum = false;
		return (false);
	}


}

if(errfound == false) {


  	var Subject=document.onlineSupp.subject

	if ((Subject.value==null)||(Subject.value=="")){
		alert("Please Enter Subject")
		Subject.value=""
		Subject.focus()
		pNum = false;
		return (false);
	}
}

	 // return true
     return !errfound; /* true if there are no errors */
}
