
// for date
function displayDate() {

	dList = new Array('Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag');
	mList = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'Oktober', 'November', 'December');
	var now = new Date();
	var d = now.getDay();
	var m = now.getMonth();
	var n = now.getDate();
	var y = now.getYear();
	if (y==100) {y +=1900}
	
	var df = dList[d];
	var mf = mList[m];
//	document.write(df + ', ' + mf + ' ' + n + ', ' + y + ' ');
	document.write('<span class="date1">' + df + '&#160;</span>' + '<span class="date1">' + n + '&#160;</span>' + '<span class="date2">' + mf + '&#160; &#160;</span>');
}



// For drop-down menu system

     NS4 = (document.layers);
     IE4 = (document.all);
    ver4 = (NS4 || IE4);
     IE5 = (IE4 && navigator.appVersion.indexOf("5.")!=-1);
   isMac = (navigator.appVersion.indexOf("Mac") != -1);
  isMenu = (NS4 || (IE4 && !isMac) || (IE5 && isMac));

function popUp(){return};
function popDown(){return};

if (!ver4) event = null;



// For pop-up window launch
 function popWindow(page)
   {
                popUp = window.open(page, "info", "top=150,left=200,menubar=no,scrollbars=yes,resizable=no,status=no,width=360,height=350")
                popUp.focus()               
   }





//check for empty fields
function empty(string)
{
	for(var i=0; i < string.length; i++)
		{
			var loc = string.charAt(i);
			if ((loc != ' ') && (loc != '\n') && (loc != '\t'))
			return(false);
		}
	return(true);
}


//  verify phone number fields
function isPhone(n)
{
  	if (n == "")
	{
		return(false);
	}
  var valid = "1234567890()- .";
  var temp;
  for (i=0; i<n.length; i++)
  	{
		temp = "" + n.substring(i, i+1);
		if (valid.indexOf(temp) == "-1")
		{
			return(false);
		}
  	}
	return(true);
}


//	check for valid email address	
function checkEmail(address)
{
	var invalidChars = " /:,;"
	for (i=0; i<invalidChars.length; ++i)
		{
 		badChar = invalidChars.charAt(i);
 		if (address.indexOf(badChar,0) != -1)
  			{
   				return(false);
  			}
		}
	atPos = address.indexOf("@",1);
	if (atPos == -1)
		{
			return(false);
		}
	if (address.indexOf("@",atPos+1) != -1)
		{
			return(false);
		}
	periodPos = address.indexOf(".",atPos);
	if (periodPos == -1)
		{
			return(false);
		}

	if (periodPos+3 > address.length)
		{
			return(false);
		}
	return(true);
}


//Validate a non-numeric field
function validate(field) 
{
var valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' "
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";
	}
return ok;
}

//Validate Alpha field
function checkAlpha(field)
{
		var valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'- ";
		var check = field.length;
 		var allValid = true;
 		for (var i=0;  i < check;  i++)
 			{
    		temp = "" + field.substring(i, i+1);
			if (valid.indexOf(temp) == "-1"); 
			allValid = false;
			}
}


//Validate that a radio selection has been made
function radioChecked(radio) {
   var checkedButton = false;
   for (var i=0; i<radio.length; i++) {
    if (radio[i].checked) {
      checkedButton = true;
    }
   }
   return(checkedButton);
}


//Validate the zip code fields
function validZip(zip)
{
  	if (zip == "")
	{
		return(false);
	}
  var valid = "1234567890- ";
  var temp;
  for (i=0; i<zip.length; i++)
  	{
		temp = "" + zip.substring(i, i+1);
		if (valid.indexOf(temp) == "-1")
		{
			return(false);
		}
  	}
	return(true);
}



// Main validation of the form fields
function ValidateCore(form)
{
var msg;
var blankField = "";
var errors = "";
var form = document.contact;
	for(var i=0; i<form.length; i++)
		{
		var field = form.elements[i];
		if (empty(field.value))
			{
			blankField += "\n         " + field.name;
			continue;
			}

    if ((form.catid.value =="registration_training") || (form.catid.value =="registration_event"))
      {
        if (!radioChecked(form.Interest1))
          {
    		  errors += " - Please choose an event to register for. \n";
    		  }
    	}

    if (form.catid.value =="registration_seminar")
      {
        if (form.Interest1.value =="")
          {
    		  errors += " - Please choose an event to register for. \n";
    		  }
    	}

//    	
//    if (form.catid.value =="download")
//      {
//        if ((!form.Interest1.checked) && (!form.Interest2.checked))
//          {
//    		  errors += " - Please choose a product to download. \n";
//    		  }
//    	}

    	
    if (form.catid.value =="apply")
      {
        if (!radioChecked(form.Interest1))
          {
    		  errors += " - Please choose a position to apply for. \n";
    		  }
    	}
 

  	if (form.FirstName.value =="")
  		{
    		errors += " - Please enter your first name.\n";
  	  }
		if (form.LastName.value =="")
  		{
    		errors += " - Please enter your last name.\n";
  	  }
		if (form.Company.value =="")
			{
			errors += " - Please enter your company name. \n";
		  }
		if (form.Title.value =="")
			{
			errors += " - Please enter your title. \n";
		  }
		if (!checkEmail(form.Email.value))
			{
				errors += " - The email address is invalid. Please use the format 'name@isp.com'\n";
		  }


    if ((form.catid.value =="demonstration") || (form.catid.value =="apply"))
      {
        if (form.FileUpload.value =="")
          {
    		  errors += " - Please choose a file to send. \n";
    		  }
    	}
    	
   

		
	if (!blankField && !errors)	return(true);
	
	msg = "__________________________________________________\n\n"
	msg += "This form was not sent for the following reason(s).\n";
	
	if (blankField)
		{
		msg += "__________________________________________________\n\n";
		msg += " - The following field(s) are required:" + blankField; "\n";
		if (errors) msg += "\n";
		}
	msg += errors;
	alert(msg);
	return(false);
	}
}

 






// Main validation of the form fields

function ValidateBilling(form)
{
var msg;
var blankField = "";
var errors = "";
var form = document.contact;


	if (!form.PaymentType)	return(true);
	
	for(var i=0; i<form.length; i++)
		{
		var field = document.contact.elements[i];
		if (empty(field.value))
			{
			blankField += "\n         " + field.name;
			continue;
			}


		if (form.BillingAddress1.value =="")
			{
			errors += " - Please enter a billing address. \n";
			}
		if (form.BillingCity.value =="")
			{
			errors += " - Please enter a city for the billing address. \n";
			}
		if (form.BillingProvince.value == "")
			{
			errors += " - Please select a state/province for the billing address. \n";
			}
		if (form.BillingPostalCode.value =="")
			{
			errors += " - Please enter a valid zip/postal code for the billing address. \n";
			}
		if (form.BillingCountry.value == "")
			{
			errors += " - Please select a country for the billing address. \n";
			}


    if (!radioChecked(form.PaymentType))
    	{
    		errors += " - Please select a payment method. \n";
    	}
    else 
      {

      if (form.PaymentType[0].checked)
        {
  
      		if (form.CardType.selectedIndex == 0)
      			{
      			errors += " - Please select a credit card type. \n";
      			}
      		if (form.CardNumber.value == "")
      			{
      			errors += " - Please enter a credit card number. \n";
      			}
      		if (form.ExpirationMonth.selectedIndex == 0)
      			{
      			errors += " - Please select an expiration month. \n";
      			}
      		if (form.ExpirationYear.selectedIndex == 0)
      			{
      			errors += " - Please select an expiration year. \n";
      			}
      			
      		if (form.CardHolder.value == "")
      			{
      				errors += " - Please enter a valid cardholder name. \n";
      			}
      	}

     	else
     	  {
      		if (form.BillingPONumber.value == "")
      			{
      			errors += " - Please enter a PO number. \n";
      			}
      	}
      }

		

	if (!blankField && !errors)	return(true);
	
	msg = "__________________________________________________\n\n"
	msg += "This form was not sent for the following reason(s).\n";
	
	if (blankField)
		{
		msg += "__________________________________________________\n\n";
		msg += " - The following field(s) are required:" + blankField; "\n";
		if (errors) msg += "\n";
		}
	msg += errors;
	alert(msg);
	return(false);
	}
}

	
	





// function to copy registration address to billing address
function CopyAddress() 
{
  var form = document.contact;
	if (form.BillingSame.checked) 
	{
    Fname = document.contact.FirstName.value; 
		Lname = document.contact.LastName.value;
	  CardHolder = Fname + " " + Lname;
		form.CardHolder.value = CardHolder;
		form.BillingAddress1.value = form.Address1.value;
		form.BillingAddress2.value = form.Address2.value;
		form.BillingCity.value = form.City.value;
		form.BillingProvince.value = form.Province.value;
		form.BillingPostalCode.value = form.PostalCode.value;
		form.BillingCountry.value = form.Country.value;
   }
}



// Validate Course selection
function ValidateCourse()
{
  		if (!radioChecked(document.contact.Course))
  			{
    			errors += " - You have not selected a course.\n";
  			}
  
  		if (document.contact.Course.value =="")
			{
			errors += " - Please select a course to attend. \n";
			}

}


