/*

 * Newsletter form validation
 
 */
 
 function validateForm(x) {
	
	var msg = "The following error(s) have occurred:\n\n",errorcount=0,blankfields=[];
	
	for(i=0; i < x.elements.length; i++) {
	
		var f = x.elements[i];
		
		if(f.value == "") {
		
			blankfields.push(f.id);
			errorcount++;
			
		}
		
		if(f.id == "Email" && f.value != "") {
		
			if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,8})+$/.test(f.value)) {
																	  
				var invalidEmail = true;
				
				errorcount++;
			
			}
		
		}
		
	}
	
	if(errorcount > 0) {
		
		if(blankfields.length > 0) {
			msg += "- " + blankfields.join(", ");
			msg += (blankfields.length > 1) ? " are " : " is ";
			msg += "missing.";
		}
		
		msg += "\n";
		
		if(invalidEmail) msg += "- Please enter a valid email.\n";
		
		msg += "\n";
	
		alert(msg);
		
		return false;
		
	} else {
	
		return true;
		
	}
	
 }
 
 
 
  /*
  * Open flash video in a pop up.
  * Must pass through the video file name w/o extension,
  * desired video height & width, auto play (true/false)
  * can also pass across an escaped short description of the video.
  */
  
  function openVideo(){
	  
	  var a = openVideo.arguments;
	  
	  var vidURL = a[0];
	  var winParams = a[1];
	  
	  var videoWin = window.open(vidURL,'videoWin',winParams + ",location=no,toolbar=no");
	  
	  videoWin.focus();
	  
  }
  
   /*
  * JS popup for vids.
  */ 
function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=638,height=410,left = 340,top = 312');");
}

function popUpSmall(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=638,height=190,left = 340,top = 312');");
}

function delayer(){
				window.location = "../home/index.php"
			}