//start text area character counter
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
countfield.value = maxlimit - field.value.length;
}

// **************************************
function deleteNews(which) {

	var agree=confirm("Are you sure you want to delete this news item?\n\nThis action cannot be undone!");
	if (agree)
		return true ;
	else
		return false ;
}

// **************************************
function showNotSelectable(which) {

	var agree=confirm("This class is not orderable based on your membership type.");
	if (agree)
		return true ;
	else
		return false ;
}

// **************************************
function deleteAsset(which) {

	var agree=confirm("Are you sure you want to delete this asset?\n\nThis action cannot be undone.");
	if (agree)
		return true ;
	else
		return false ;
}

// **************************************
function addToCart(which) {

	var agree=confirm("Are you sure you want to add this program to your shopping cart?\n");
	if (agree)
		return true ;
	else
		return false ;
}

// **************************************
function removeFromCart(which) {

	var agree=confirm("Are you sure you want to remove this program from your shopping cart?\n");
	if (agree)
		return true ;
	else
		return false ;
}


// **************************************
function checkrequiredSelectClasses(whichForm,whichCheckBoxArray,myMax,myMin,whichQuestion)
/*
  This function takes 5 paramaters:
  whichForm -- the NAME of the form to be validated, a string
  whichCheckBoxArray -- the NAME of the checkbox to be checked, a string
  myMax -- the most you want the user to be able to check, an integer
  myMin -- the least you want the user to be able to check, an integer
  whichQuestion -- a short description of the question, a string
  
  example use:
  howManyChecked('myform','cb_industry',6,1,'Industry');
*/
{

    var _countChecked = 0;
    var err = 0;

    var numCheckboxes = document[whichForm][whichCheckBoxArray].length;
    if (numCheckboxes>1) {
    } else {
        numCheckboxes = 1;
    }    
    /* iterate through all the elements in the checkbox array */
    if (numCheckboxes==1) {
        if (document.form99.selectedLineitems.checked) {
            _countChecked++;
        } else {
        }    
    } else {  
        for(i=0;i<numCheckboxes;i++)
        {
	        /* and check to see if each is checked */
	        if(document.form99.selectedLineitems[i].checked==true)
		        /* if it is, increment a counter */
		        { _countChecked++; }
        }
    }
    /* is the count too high? */
    if(_countChecked > myMax) { 
        alert('Too many classes selected.');
        return false; 
    }
    /* of is the count too low */
    else if(_countChecked < myMin) { 
	    alert('You must choose at least one Class.');
        return false; 
    }

}


// **************************************
function validateContactForm(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#ffee99';
  var bgGood = "white";

if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="name" && tempobj.value=='') {
			fieldlist = "Name";
			pass=false;
			break;
		}
		if (tempobj.name=="email" && tempobj.value=='') {
			fieldlist = "Email";
			pass=false;
			break;
		}
		if (tempobj.name=="state" && tempobj.value=='') {
			fieldlist = "State";
			pass=false;
			break;
		}
		if (tempobj.name=="comments" && tempobj.value=='') {
			fieldlist = "Comments";
			pass=false;
			break;
		}
	}
}

if (!pass) {
	setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
//	tempobj.blur();
	return false;
}
else
return true;
}


// **************************************
function validateInquiryForm(which) {

var pass=true;
fieldlist = "";

  var bgBad = '#ffee99';
  var bgGood = "white";

if (document.images) {
	for (i=0;i<which.length;i++) {
		var tempobj=which.elements[i];
		if (tempobj.name=="name" && tempobj.value=='') {
			fieldlist = "Name";
			pass=false;
			break;
		}
		if (tempobj.name=="email" && tempobj.value=='') {
			fieldlist = "Email";
			pass=false;
			break;
		}
		if (tempobj.name=="phone" && tempobj.value=='') {
			fieldlist = "Phone";
			pass=false;
			break;
		}
		if (tempobj.name=="comments" && tempobj.value=='') {
			fieldlist = "Comments";
			pass=false;
			break;
		}
	}
}

if (!pass) {
	setColor(tempobj, bgBad);
	alert(""+fieldlist+" is required.");
	tempobj.focus();
//	tempobj.blur();
	return false;
}
else
return true;
}



// **************************************
function checkAll(field) 
{
for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}

// **************************************
function uncheckAll(field) 
{
for (i = 0; i < field.length; i++)
	field[i].checked = false ;
}

// **************************************
function setColor(el, bg) {
  if (el.style) el.style.backgroundColor = bg;
}

// **************************************
function validate(field) {
var valid = "0123456789"
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Invalid entry!  Only numbers are accepted!");
field.focus();
field.select();
   }
}

// **************************************
function validate2(field) {
var valid = "0123456789."
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Invalid entry!  Only numbers are accepted!");
field.focus();
field.select();
   }
}

// **************************************
function validatePhone(str) {
var valid = "0123456789-"
var ok1 = "yes";
var ok2 = "yes";
var temp;
if (str.length == 0) {               // no phone entered
} else {
	for (var i=0; i<str.length; i++) {
	    temp = "" + str.substring(i, i+1);
	    if (valid.indexOf(temp) == "-1") ok1 = "no";
	    if ((i==3 || i==7) && str.substring(i,i+1)!="-") {
	        alert("Invalid entry!  Format must be: nnn-nnn-nnnn");
	        return false;
	    }  
	}
	if (str.length == 12) {             // must be xxx-xxx-xxxx
	} else {
	      ok2 = "no";
	}
	if (ok1 == "no") {
	    alert("Invalid entry!  Only numbers are accepted!");
        return false;
   }
	if (ok2 == "no") {
        alert("Phone number field must use be entered in xxx-xxx-xxxx format");
        return false;
   }
	}
}


// **************************************
function validateChars(field,chars) {
	if (field.value.length < chars) {
		alert("Entry must be at least "+chars+" characters");
		field.focus();
		field.select();
   }
}

// **************************************
function check_date(field){
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = "/";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField.value;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 19xx */
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '19' + DateValue.substr(4,2); }
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(0,2);
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(2,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
      DateField.value = month + seperator + day + seperator + year;
   }
   /* Error-message if err != 0 */
   else {
      alert("Date is incorrect!\n\nMust use format: mm/dd/yyyy");
      DateField.select();
	  DateField.focus();
   }
}

// **************************************
function check_date2(field){
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = "/";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField.value;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(0,2);
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(2,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
      DateField.value = month + seperator + day + seperator + year;
   }
   /* Error-message if err != 0 */
   else {
      alert("Date is incorrect!\n\nMust use format: mm/dd/yyyy");
      DateField.select();
	  DateField.focus();
   }
}

// **************************************
function gtpage(url,frname,height,width) {

        var p1 = 'toolbar=no,'
        var p2 = 'location=no,'
        var p3 = 'directories=no,'
        var p4 = 'status=no,'
        var p5 = 'menubar=no,'
        var p6 = 'resizable=no,'
        var p7 = 'scrollbars=no,'
        var p8=  'copyhistory=no,'
        var p9 = 'width='+width+',';
        var p10 = 'height='+height
        var props = p1+p2+p3+p4+p5+p6+p7+p8+p9+p10;

        themainwindow = window.open(url,frname,props);
        themainwindow.focus();

     }

// **************************************
function gtpage2(url,frname,height,width) {

        var p1 = 'toolbar=no,'
        var p2 = 'location=no,'
        var p3 = 'directories=no,'
        var p4 = 'status=no,'
        var p5 = 'menubar=no,'
        var p6 = 'resizable=yes,'
        var p7 = 'scrollbars=yes,'
        var p8=  'copyhistory=no,'
        var p9 = 'width='+width+',';
        var p10 = 'height='+height
        var props = p1+p2+p3+p4+p5+p6+p7+p8+p9+p10;

        themainwindow = window.open(url,frname,props);
        themainwindow.focus();

     }

// **************************************
	function printpage() {
	window.print();
	}
	
// **************************************
function echeck(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert("Invalid e-mail address entered")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Invalid e-mail address entered")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    alert("Invalid e-mail address entered")
	    return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    alert("Invalid e-mail address entered")
	    return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    alert("Invalid e-mail address entered")
	    return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    alert("Invalid e-mail address entered")
	    return false
	 }
		
	 if (str.indexOf(" ")!=-1){
	    alert("Invalid e-mail address entered")
	    return false
	 }

	 return true					
}


	
// **************************************
// Hide / Show text with 'Learn More'...	
// **************************************

function hideDiv1(ht) { 
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('hideShow1').style.visibility = 'hidden'; 
		document.getElementById('hideShow1').style.height = "40px";
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.hideShow1.visibility = 'hidden'; 
			document.hideShow1.height = "0px";
		} 
		else { // IE 4 
			document.all.hideShow1.style.visibility = 'hidden'; 
			document.all.hideShow1.style.height = '40px'; 
		} 
	} 
	// Now show the other element.
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('hideShow_1').style.visibility = 'visible'; 
		document.getElementById('hideShow_1').style.overflow = 'visible';
		document.getElementById('hideShow_1').style.height = ht + "px";
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.hideShow_1.visibility = 'visible'; 
			document.hideShow_1.style.overflow = 'visible';
//			document.hideShow_1.style.height = ht + "px";
		} 
		else { // IE 4 
			document.all.hideShow_1.style.visibility = 'visible'; 
			document.hideShow_1.style.overflow = 'visible';
//			document.hideShow_1.style.height = ht + "px";
		} 
	} 
} 

function showDiv1(ht) { 
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('hideShow1').style.visibility = 'visible'; 
		document.getElementById('hideShow1').style.height = ht + "px";
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.hideShow1.visibility = 'visible'; 
			document.hideShow1.height = ht + "px";
		} 
		else { // IE 4 
			document.all.hideShow1.style.visibility = 'visible'; 
			document.all.hideShow1.style.height = ht + "px";
		} 
	} 
	// Now, hide the other element.
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('hideShow_1').style.visibility = 'hidden'; 
		document.getElementById('hideShow_1').style.overflow = 'hidden';
		document.getElementById('hideShow_1').style.height = ht + "px";
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.hideShow_1.visibility = 'hidden'; 
			document.hideShow_1.overflow = 'hidden';
			document.hideShow_1.height = ht + "px";
		} 
		else { // IE 4 
			document.all.hideShow_1.style.visibility = 'hidden'; 
			document.all.hideShow_1.style.overflow = 'hidden';
			document.all.hideShow_1.style.height = ht + "px";
		} 
	} 
} 


function hideDiv2(ht) { 
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('hideShow2').style.visibility = 'hidden'; 
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.hideShow2.visibility = 'hidden'; 
		} 
		else { // IE 4 
			document.all.hideShow2.style.visibility = 'hidden'; 
		} 
	} 
	// Now show the other element.
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('hideShow_2').style.visibility = 'visible'; 
		document.getElementById('hideShow_2').style.overflow = 'visible';
		document.getElementById('hideShow_2').style.height = ht + "px";
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.hideShow_2.visibility = 'visible'; 
			document.hideShow_2.style.overflow = 'visible';
//			document.hideShow_2.style.height = ht + "px";
		} 
		else { // IE 4 
			document.all.hideShow_2.style.visibility = 'visible'; 
			document.hideShow_2.style.overflow = 'visible';
//			document.hideShow_2.style.height = ht + "px";
		} 
	} 
} 

function showDiv2(ht) { 
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('hideShow2').style.visibility = 'visible'; 
		document.getElementById('hideShow2').style.height = ht + "px";
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.hideShow2.visibility = 'visible'; 
			document.hideShow2.height = ht + "px";
		} 
		else { // IE 4 
			document.all.hideShow2.style.visibility = 'visible'; 
			document.all.hideShow2.style.height = ht + "px"; 
		} 
	} 
	// Now, hide the other element.
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('hideShow_2').style.visibility = 'hidden'; 
		document.getElementById('hideShow_2').style.overflow = 'hidden';
		document.getElementById('hideShow_2').style.height = ht + "px";
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.hideShow_2.visibility = 'hidden'; 
			document.hideShow_2.overflow = 'hidden';
			document.hideShow_2.height = ht + "px"; 
		} 
		else { // IE 4 
			document.all.hideShow_2.style.visibility = 'hidden'; 
			document.all.hideShow_2.style.overflow = 'hidden';
			document.all.hideShow_2.style.height = ht + "px";
		} 
	} 
} 


function hideDiv3(ht) { 
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('hideShow3').style.visibility = 'hidden'; 
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.hideShow3.visibility = 'hidden'; 
		} 
		else { // IE 4 
			document.all.hideShow3.style.visibility = 'hidden'; 
		} 
	} 
	// Now show the other element.
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('hideShow_3').style.visibility = 'visible'; 
		document.getElementById('hideShow_3').style.overflow = 'visible';
		document.getElementById('hideShow_3').style.height = ht + "px";  //'40px';
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.hideShow_3.visibility = 'visible'; 
			document.hideShow_3.style.overflow = 'visible';
//			document.hideShow_3.style.height = ht + "px";  //'40px';
		} 
		else { // IE 4 
			document.all.hideShow_3.style.visibility = 'visible'; 
			document.hideShow_3.style.overflow = 'visible';
//			document.hideShow_3.style.height = ht + "px"; //'40px';
		} 
	} 
} 

function showDiv3(ht) { 
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('hideShow3').style.visibility = 'visible'; 
		document.getElementById('hideShow3').style.height = ht + "px";
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.hideShow3.visibility = 'visible'; 
			document.hideShow3.height = ht + "px";
		} 
		else { // IE 4 
			document.all.hideShow3.style.visibility = 'visible'; 
			document.all.hideShow3.style.height = ht + "px"; 
		} 
	} 
	// Now, hide the other element.
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('hideShow_3').style.visibility = 'hidden'; 
		document.getElementById('hideShow_3').style.overflow = 'hidden';
		document.getElementById('hideShow_3').style.height = ht + "px";
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.hideShow_3.visibility = 'hidden'; 
			document.hideShow_3.overflow = 'hidden';
			document.hideShow_3.height = ht + "px"; 
		} 
		else { // IE 4 
			document.all.hideShow_3.style.visibility = 'hidden'; 
			document.all.hideShow_3.style.overflow = 'hidden';
			document.all.hideShow_3.style.height = ht + "px";
		} 
	} 
} 



function hideDiv4(ht) { 
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('hideShow4').style.visibility = 'hidden'; 
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.hideShow4.visibility = 'hidden'; 
		} 
		else { // IE 4 
			document.all.hideShow4.style.visibility = 'hidden'; 
		} 
	} 
	// Now show the other element.
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('hideShow_4').style.visibility = 'visible'; 
		document.getElementById('hideShow_4').style.overflow = 'visible';
		document.getElementById('hideShow_4').style.height = ht + "px";  //'40px';
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.hideShow_4.visibility = 'visible'; 
			document.hideShow_4.style.overflow = 'visible';
//			document.hideShow_4.style.height = ht + "px";  //'40px';
		} 
		else { // IE 4 
			document.all.hideShow_4.style.visibility = 'visible'; 
			document.hideShow_4.style.overflow = 'visible';
//			document.hideShow_4.style.height = ht + "px"; //'40px';
		} 
	} 
} 

function showDiv4(ht) { 
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('hideShow4').style.visibility = 'visible'; 
		document.getElementById('hideShow4').style.height = ht + "px";
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.hideShow4.visibility = 'visible'; 
			document.hideShow4.height = ht + "px";
		} 
		else { // IE 4 
			document.all.hideShow4.style.visibility = 'visible'; 
			document.all.hideShow4.style.height = ht + "px"; 
		} 
	} 
	// Now, hide the other element.
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('hideShow_4').style.visibility = 'hidden'; 
		document.getElementById('hideShow_4').style.overflow = 'hidden';
		document.getElementById('hideShow_4').style.height = ht + "px";
	} 
	else { 
		if (document.layers) { // Netscape 4 
			document.hideShow_4.visibility = 'hidden'; 
			document.hideShow_4.overflow = 'hidden';
			document.hideShow_4.height = ht + "px"; 
		} 
		else { // IE 4 
			document.all.hideShow_4.style.visibility = 'hidden'; 
			document.all.hideShow_4.style.overflow = 'hidden';
			document.all.hideShow_4.style.height = ht + "px";
		} 
	} 
} 



