/* 
 * Main javascript for JDPS site
 * @author Chirstopher V Lapa \m/ <chris.lapa@gmail.com> 
 * @date 20 June 2007
 */
 
 // menu stuff
 /* GENERAL FUNCS */
function popUpWindow(URLStr, myWidth, myHeight){
	day = new Date();
	id = day.getTime();
	//alert(URLStr+" || "+myWidth+" || "+myHeight);
	window.open(URLStr,"popUpWin"+id,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbar=0,resizable=1,copyhistory=1,width="+myWidth+",height="+myHeight);
}

 // get the el cross browser
function getEl(elID){
    if (document.getElementById)
        var returnEl = document.getElementById(elID);
    else if (document.all)
        var returnEl = document.all[elID];
    else if (document.layers)
        var returnEl = document.layers[elID];
    return returnEl;
}
 
 //var for last link clicked
 var lastLink = "";
 
 // func to control menu highlighting
 function activateLink(linkID){
	 
	 var thisLink = getEl(linkID);
	 if(linkID !== lastLink && lastLink == ""){
	 	thisLink.className = "activeMenuLink";
		lastLink = linkID;
	 }else if(linkID == lastLink){
		thisLink.className = "activeMenuLink";
		lastLink = linkID;
	 }else if(linkID !== lastLink){
		 thisLink.className = "activeMenuLink";
		 var oldLink = getEl(lastLink);
		 oldLink.className = "menuLink";
		 lastLink = linkID;
	 }
 }
 
 // Example:
// simplePreload( '01.gif', '02.gif' ); 
function simplePreload()
{ 
  var args = simplePreload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

function validateForm(){
	// check user has entered details into the form that we need
	var emailFilter=/^.+@.+\..{2,3}$/;
	if(document.jdpsSubscribe.subName.value == ""){
		alert("Please enter your name");
		document.jdpsSubscribe.subName.focus();
		return false;
	}else if(document.jdpsSubscribe.subEmail.value == ""){
		alert("Please enter your email");
		document.jdpsSubscribe.subEmail.focus();
		return false;
	}else if (!(emailFilter.test(document.jdpsSubscribe.subEmail.value))) { 
		alert("Please enter a valid Email address");
		document.jdpsSubscribe.subEmail.focus();
		return false;
	}else{
		document.jdpsSubscribe.submit();
	}
}