var goodToGo = false;

nav0 = new Image(); nav0.src = "images/nav/SL_nav_home.gif";
nav0_roll = new Image(); nav0_roll.src = "images/nav/SL_nav_home_roll.gif";

nav1 = new Image(); nav1.src = "images/nav/SL_nav_research.gif";
nav1_roll = new Image(); nav1_roll.src = "images/nav/SL_nav_research_roll.gif";
nav1_hi = new Image(); nav1_hi.src = "images/nav/SL_nav_research_hi.gif";

nav2 = new Image(); nav2.src = "images/nav/SL_nav_people.gif";
nav2_roll = new Image(); nav2_roll.src = "images/nav/SL_nav_people_roll.gif";
nav2_hi = new Image(); nav2_hi.src = "images/nav/SL_nav_people_hi.gif";

nav3 = new Image(); nav3.src = "images/nav/SL_nav_publications.gif";
nav3_roll = new Image(); nav3_roll.src = "images/nav/SL_nav_publications_roll.gif";
nav3_hi = new Image(); nav3_hi.src = "images/nav/SL_nav_publications_hi.gif";

nav4 = new Image(); nav4.src = "images/nav/SL_nav_protocols.gif";
nav4_roll = new Image(); nav4_roll.src = "images/nav/SL_nav_protocols_roll.gif";
nav4_hi = new Image(); nav4_hi.src = "images/nav/SL_nav_protocols_hi.gif";

nav5 = new Image(); nav5.src = "images/nav/SL_nav_links.gif";
nav5_roll = new Image(); nav5_roll.src = "images/nav/SL_nav_links_roll.gif";
nav5_hi = new Image(); nav5_hi.src = "images/nav/SL_nav_links_hi.gif";

nav6 = new Image(); nav6.src = "images/nav/SL_nav_contact.gif";
nav6_roll = new Image(); nav6_roll.src = "images/nav/SL_nav_contact_roll.gif";
nav6_hi = new Image(); nav6_hi.src = "images/nav/SL_nav_contact_hi.gif";


btn_video = new Image(); btn_video.src = "images/SL_btn_video.gif";
btn_video_roll = new Image(); btn_video_roll.src = "images/SL_btn_video_roll.gif";


// STYLE CHANGING
function changeStyle(id, newClass) {
	identity=document.getElementById(id);	
	if (identity) identity.className=newClass;	
}	

// Open and Closing
function stretchIt(prefix) {
	closedID = document.getElementById(prefix + "_closed");
	openID = document.getElementById(prefix + "_open");
	//alert("CLOSED IS: " + closedID.className );
	if (closedID && openID) {
		if (closedID.className == "hide") {
			openID.className = "hide";
			closedID.className = "show";
		} else {
			closedID.className = "hide";
			openID.className = "show";
		}
	}
}


// IMAGE ROLLOVER FUNCTION 

function flash(img1, img2) {
	// alert(img1 + " to " + img2);
	if (document.images) eval('document.images[img1].src = '+img2+'.src');
}


// CSS COMPLIANT EXTERNAL LINK FUNCTION (OPEN NEW POP-UP) 

function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank";
 }
}


// POP UP WINDOW
function popIt(url,name,height,width,resize,scrolling) {
	// alert("Pop Recipe: " + url);
	
	features = "menubar=0, tollbar=0, scrollbars=" + scrolling + ", resizable=" + resize + ", width=" + width + ", height=" + height + ",dependent=yes";
	
	if (window.thePopper && !window.thePopper.closed) {
		
		thePopper.resizeTo(width,height);
		thePopper.innerwidth=width;
		thePopper.height=height;
		thePopper.location.href = url;
		thePopper.focus();
		
	} else {

		var winl = Math.floor((screen.width - width) / 2);
		var wint = Math.floor((screen.height - height) / 2);
					
		thePopper = window.open(url,name,'top='+wint+',left='+winl+','+features);
		thePopper.innerwidth=width;
		thePopper.height=height;
	
	}
	 
}



// FOR CSS MENU
	startList = function() {
	alert('START LIST');
	if (document.all&&document.getElementById) {
	navRoot = document.getElementById("nav");
	for (i=0; i<navRoot.childNodes.length; i++) {
	node = navRoot.childNodes[i];
	if (node.nodeName=="LI") {
	node.onmouseover=function() {
	this.className+=" over";
	  }
	  node.onmouseout=function() {
	  this.className=this.className.replace
			(" over", "");
	   }
	   }
	  }
	 }
	}
	// window.onload=startList;
	


var stretcher;

// Kicks everything off.  --  first number = distance, 2nd time
function loaded (theHeight) {
	stretcher = new Stretcher(document.getElementById('front'), theHeight, 250, changeText);
}

// Callback for when the stretcher finishes a stretch/shrink
// Based on the state of the widget, display the right status text
function changeText () {
	/* document.getElementById('ctrTitle').firstChild.nodeValue = stretcher.isStretched() ? "Click to Shrink" : "Click to Stretch"; */
	if (stretcher.isStretched()) {
		changeStyle('topEdge', 'open');
		changeStyle('bottomEdge', 'open');
	} else {
		changeStyle('topEdge', 'closed');
		changeStyle('bottomEdge', 'closed');
	}
}


		
function init() {
	externalLinks();
	startList;
}

window.onload=init;
