window.onload=function(){//wait for page to load
preLoad();
navSwap();
}

function preLoad(){
  var myimages = new Array();
  function preloading(){
  for (x=0; x<preloading.arguments.length; x++){
  myimages[x] = new Image();
  myimages[x].src = preloading.arguments[x];
  }
  }
  preloading("images/overstate/home.jpg","images/overstate/media.jpg","images/overstate/about.jpg","images/overstate/schedule.jpg","images/overstate/faq.jpg","images/overstate/contact.jpg");
}

function navSwap(){
  var images = document.getElementById("nav").getElementsByTagName("img");
    for(i=0;i<images.length;i++){ // for all images in nav
    
      if(images[i].name != "girl"){ //if all images are NOT the girl
        images[i].onmouseover=function(){//on mousover
          this.src = this.src.replace(/images/,"images/overstate");//switch dir to 'overstate'
          //the image has been changed
        }
        images[i].onmouseout=function(){
        this.src = this.src.replace("images/overstate","images");//switch dir to normal
        //the image src change has been 'undone'
        } 
      }
    }
}

function newWindow(windowName, URL, width, height, scrolling) {

	width = width || 400;
	height = height || 360;
	scrolling = scrolling || 0;
	
	var topX = (window.screen.width / 2) - ( width / 2);
	var topY = (window.screen.height / 2) - ( height / 2);
	
	window.open(URL, windowName, 'width=' + width + ',height=' + height +
 ',location=no,resizable=yes,scrollbars=' + scrolling + 
',screenX=' + topX + ',screenY=' + topY);
}
//usage : newWindow('class','http://wds.com',400,400,'no');


function flash(id){
setTimeout("document.getElementById('formholder').style.display='none'",0);
setTimeout("document.getElementById('formholder').style.display='inline'",500);
setTimeout("document.getElementById('formholder').style.display='none'",1000);
setTimeout("document.getElementById('formholder').style.display='inline'",1500);
setTimeout("document.getElementById('formholder').style.display='none'",2000);
setTimeout("document.getElementById('formholder').style.display='inline'",2500);
}

function obscureEmail(){
  var emailaddr = document.getElementById("emailaddr");
  var decimals = [105,110,102,111,64,116,104,101,104,111,111,112,119,111,114,107,111,117,116,46,99,111,109];
  var converted = [];
  
  for(i=0;i<decimals.length;i++){    
    converted += String.fromCharCode(decimals[i]);
  }
  
  //create an email link
  var email = converted.link("mailto:"+converted);
  emailaddr.innerHTML = email;
}

function PopupCenter(pageURL, name,w,h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, name, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}