/* =Load Functions
-----------------------------------------------------------------------------*/
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent(startList);
addLoadEvent(doNewWin);
addLoadEvent(vid);


/* =Open a new window
-----------------------------------------------------------------------------*/
function doNewWin() {
  if (!document.getElementsByTagName) return false;
  var links=document.getElementsByTagName("a");
  for (var i=0; i < links.length; i++) {
    if (links[i].className.match("newwin")) {
      links[i].onclick=function() {window.open(this.href);return false;
      }
    }
  }
}

/* =IE Menu dropdown support
-----------------------------------------------------------------------------*/
function startList() {
	if(document.all && document.getElementById &&  document.getElementsByTagName){
		var navRoot = document.getElementById("nav");
		var li = navRoot.getElementsByTagName("LI");
		for (i=0; i<li.length; i++) {
			node = li[i];
			node.onmouseover=function(){this.className=" over";}
			node.onmouseout=function(){this.className=this.className.replace(" over", "");}
		}
	}
}

/* =Validate Email
-----------------------------------------------------------------------------*/
// Match Emails
function sameMail(){
	if(!document.getElementById && !document.getElementById("rmailError") && !rmailError.innerHTML) return false;
	var email = document.application.Email;
	var rmail = document.application.rEmail;
	var e = email.value;
	var r = rmail.value;
	var rmailError = document.getElementById("rmailError");
	
	if(e!=r){
		rmailError.innerHTML="<h3 class='topspace orange'>Emails Do not match</h3>";
		email.focus();
	}else{
		rmailError.innerHTML="";
	}
}
function valMail() {
	var email = document.application.Email;
	var e = email.value;
	var emailError = document.getElementById("emailError");
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(e)){
		emailError.innerHTML="";
	}else{
		emailError.innerHTML="<h3 class='topspace orange'>Invalid Email Address</h3>";
		email.focus();
	}
}


/* =Write flash
-----------------------------------------------------------------------------*/
var firstTime = true;
var onOff = 0;
function vid(){
	if(document.getElementById("expo")){
		if(firstTime == true){
			document.getElementById("script").innerHTML="Click here to Play";
			firstTime = false;
		}			
		var cont = document.getElementById("expo");
		var image = '<img alt="" src="photos/expo.jpg" width="297" height="250" />'+
					 '<p>Click here to Play</p>';
		var flash = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="297" height="250" title="Explosion">'+
		'<param name="movie" value="vid/expo.swf" />'+
		'<param name="quality" value="high" />'+
		'<param name="wmode" value="transparent" />'+
		'<embed src="vid/expo.swf" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="297" height="250"></embed>'+
		'</object>'+
		'<p>Click here to Stop</p>';
		
		cont.onclick=function() {
			if(onOff == 0){
				onOff = 1;
				cont.innerHTML=flash;
			}
			else if(onOff == 1){
				onOff = 0;
				cont.innerHTML=image;
			}			
		}
	}
}








