<!-- hide script from older browsers
/*
// go to error handler in the event any js error appears on the page
// The onError event handler for windows cannot be expressed in HTML. 
// Therefore, you must spell it all lowercase and set it in a SCRIPT tag. 
// http://docs.sun.com/source/816-6408-10/handlers.htm#1120097

window.onerror= showError ;

var tmpStringError ;

function showError(msg,url,l)
	{
//	tmpStringError="There was an error on this page.\n\n" ;
//	tmpStringError+="Error: " + msg + "\n" ;
//	tmpStringError+="URL: " + url + "\n" ;
//	tmpStringError+="Line: " + l + "\n\n" ;
//	tmpStringError+="Click OK to continue.\n\n" ;
	alert('tmpStringError') ;
	return true ;
	}
*/

// used in the checkForm function below for form validation
// need to have one variable for each family of radio buttons
	var radio_selection = "" ;
	var image_selection = "" ;

// used in the checkForm function below for form validation
// need to have one variable for each family of check buttons
	var check_selection = "" ;





function hideError(tmpErrName) {
	document.getElementById(tmpErrName).style.display = "none" ;
	return true;
}

function hideErrorBackground(tmpName) {
	document.getElementById(tmpName).style.background='#FFFFFF' ; 
	return true;
}

function showError(tmpErrName) {
	document.getElementById(tmpErrName).style.display = "inline" ;
	return true;
}

function showErrorBackground(tmpElement) {
	tmpElement.style.background='#FFFF80'; 
//	tmpElement.focus();   // this line throws an error in Firefox
	return true;
}


function checkForm(cform)  // cform is the name of the form passed during the onSubmit
	{

//	var strMatchEmail = "" ; // names of req'd email fields go here eg "cemail"
//	var strMatchEmailField = "cemail" ; // names of any email fields go here eg "cemail"
		// if data exists in this field, than validate as e-mail address
//	var strMatchRadio = "radio image" ; // names of req'd radio button fields go here eg "cname comments"
//	var strMatchDropDown = "dropdown" ; // names of req'd dropdown fields go here eg "cname comments"
//	var strMatchCheck = "check1 check2 check3" ; // names of req'd checkbox fields go here eg "cname comments"
	var strMatchCheckFamily1 = "chkCheck1 chkCheck2 chkCheck3" ; // names of req'd checkbox fields go here eg "cname comments"	

	var item=cform ;
	var tmpCount ; // variable for counting through all the elements
	var tmpDropDownIndex ;
	var tmpEmailField ;
	var tmpElement ;
	var tmpErrName  ;
	var tmpName ;
	var tmpNameType ;
 	var tmpPassed = true ;
	var tmpRadioField= "" ;
	var tmpString = "" ; // temp variable used for debugging
	
//	alert('item.elements.length= ' + item.elements.length);	
	tmpCount = item.elements.length ;
	
	for (var i=0; i < tmpCount; i++) 
 	{  

		tmpName = item.elements[i].name ;
		tmpNameType = tmpName.substring(0,3) ;
		
// check to see if the form element is one of the fields to which we should
// pay attention
	if ((tmpNameType == "txt")
//		|| (strMatchText.match(tmpName))
//		|| (strMatchEmail.match(tmpName))
//		|| (strMatchEmailField.match(tmpName))
//		|| (strMatchRadio.match(tmpName))
//		|| (strMatchDropDown.match(tmpName))
//		|| (strMatchCheck.match(tmpName))
		|| (tmpNameType == "ema")
		|| (tmpNameType == "oem")
		|| (tmpNameType == "drp")
		|| (tmpNameType == "rad")
		|| (tmpNameType == "chk")
		) 
		{
			
			tmpErrName = 'err_' + tmpName ; 
			tmpElement = item.elements[i] ;

			// needs to be manually input for each family of check 
			// boxes to be validated 
			if (strMatchCheckFamily1.match(tmpName))
				{
				tmpErrName = "err_chkCheck" ;
				}

			
			// clear previous errors
//			tmpString = tmpString + ", " + tmpErrName;
			hideError(tmpErrName) ;

			// hide error highlighting
			if ((tmpNameType == "txt")
//				|| (strMatchText.match(tmpName))
//				|| (strMatchEmail.match(tmpName))
//				|| (strMatchEmailField.match(tmpName))
//				|| (strMatchDropDown.match(tmpName))
				|| (tmpNameType == "ema")
				|| (tmpNameType == "oem")
				|| (tmpNameType == "drp")
				) 
				{
				hideErrorBackground(tmpName);
				}


			
			// check to see if field is an e-mail field
			// if an e-mail field, then assign value to be used for validating field
			if ((tmpNameType == "ema")  ||
					(tmpNameType == "oem"))
					{
					tmpEmailField=tmpElement.value;
					}

			// check validity of required text boxes	
				if ((tmpNameType == "txt") 
					&& (tmpElement.value == ""))
					{
					showError(tmpErrName) ;
					showErrorBackground(tmpElement) ;
					tmpPassed = false ;
					}
			
			// check validity of required email addresses
				if ((tmpNameType == "ema")  
					&& (tmpEmailField.indexOf(' ')!=-1 
			      || 0 >= tmpEmailField.indexOf('@')
			      || tmpEmailField.indexOf('@')+1 >= tmpEmailField.length
				   || 0 >= tmpEmailField.indexOf('.')
			      || tmpEmailField.indexOf('.')+1 >= tmpEmailField.length
					)) 
					{ 
					showError(tmpErrName) ;
					showErrorBackground(tmpElement) ;
					tmpPassed = false ;
					}	
			
			// check validity of email addresses fields with data in them
			
				if ((tmpNameType == "oem") 
						&& (tmpEmailField.length > 0)
						&& (tmpEmailField.indexOf(' ')!=-1 
				      || 0 >= tmpEmailField.indexOf('@')
				      || tmpEmailField.indexOf('@')+1 >= tmpEmailField.length
					   || 0 >= tmpEmailField.indexOf('.')
				      || tmpEmailField.indexOf('.')+1 >= tmpEmailField.length
						)) 
						{ 
						showError(tmpErrName) ;
						showErrorBackground(tmpElement) ;						tmpPassed = false ;
						}	

		// check validity of required drop down lists
			if (tmpNameType == "drp")
				{
				tmpDropDownIndex = tmpElement.selectedIndex ;
				if (tmpDropDownIndex==0)
					{
					showError(tmpErrName) ;
					showErrorBackground(tmpElement) ;
					tmpPassed = false ;
					}

				}

					

		// check validity of required radio buttons
		// need to manually input loop for each category of radio buttons
			if (tmpNameType == "rad")
				{
/*				alert(tmpName);
				var myOption = -1;
				for (i=tmpElement.length-1; i > -1; i--) 
					{
					if (tmpElement[i].checked) 
						{
						myOption = i;
						}
					}
				if (myOption == -1) 
					{
					showError(tmpErrName) ;
					tmpPassed = false ;
					alert("You must select a radio button");
					return false;
					
					}
					*/
				
				if (tmpName.match('radRadio'))
					{ 
					if (radio_selection =="")
						{
						showError(tmpErrName) ;
						tmpPassed = false ;
						}
					}
				if (tmpName.match('radImage'))
					{ 
					if (image_selection=="")
						{
						showError(tmpErrName) ;
						tmpPassed = false ;
						}
					}
				}
				

		// check validity of required check boxes
		// need to manually input loop for each category of check boxes
			if (tmpNameType == "chk")
				{
				if (check_selection=="")
					{
					showError(tmpErrName) ;
					tmpPassed = false ;
					}

				}

		}

		
	}
//	alert('tmpString = ' + tmpString);
	return tmpPassed;

}




// script for dynamic html forms
// http://developer.apple.com/internet/webcontent/dynamicforms.html
// http://developer.apple.com/internet/webcontent/examples/choose_form_source.html


// function switchDiv()
//  this function takes the id of a div
//  and calls the other functions required
//  to show that div
//
function switchDiv(div_id)
{
  var style_sheet = getStyleObject(div_id);
  if (style_sheet)
  {
//    hideAll();
    changeObjectVisibility(div_id,"visible");
  }
  else 
  {
    alert("sorry, this only works in browsers that do Dynamic HTML");
  }
}

function hideDiv(div_id)
{
   changeObjectVisibility(div_id,"hidden");
}


/*
// function hideAll()
//  hides a bunch of divs
//
function hideAll()
{
   changeObjectVisibility("ez","hidden");
   changeObjectVisibility("full","hidden");
   changeObjectVisibility("superduper","hidden");
}
*/

// function getStyleObject(string) -> returns style object
//  given a string containing the id of an object
//  the function returns the stylesheet of that object
//  or false if it can't find a stylesheet.  Handles
//  cross-browser compatibility issues.
//
function getStyleObject(objectId) {
  // checkW3C DOM, then MSIE 4, then NN 4.
  //
  if(document.getElementById && document.getElementById(objectId)) {
	return document.getElementById(objectId).style;
   }
   else if (document.all && document.all(objectId)) {  
	return document.all(objectId).style;
   } 
   else if (document.layers && document.layers[objectId]) { 
	return document.layers[objectId];
   } else {
	return false;
   }
}

function changeObjectVisibility(objectId, newVisibility) {
    // first get a reference to the cross-browser style object 
    // and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else {
	// we couldn't find the object, so we can't change its visibility
	return false;
    }
}









// hiding e-mail addresses using hex and javascript
// with thanks to Philip of http://NikitaTheSpider.com
// http://www.csgnetwork.com/asciiset.html
function WriteContactLink(anchorId) {
    var s = "mailto:";
    var a = [0x69, 0x6e, 0x66, 0x6f, 0x40, 0x4e, 0x53, 0x43, 0x63,  
0x61, 0x72, 0x64, 0x73, 0x2e, 0x63, 0x61];

    for (var i = 0; i < a.length; i++)
       s += String.fromCharCode(a[i]);

    e = document.getElementById(anchorId);
    e.setAttribute("href", s);
}

//-->

