// JavaScript for Laura Foley's final project

// Code for fly-out menus (needed for IE browsers) begins here. Credit: http://www.alistapart.com/articles/horizdropdowns/


startList = function() {
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;

// Code for fly-out menus ends here

// Code for button rollovers begins here. Credit: Laura Lemay, Teach Yourself Web Publishing with HTML and XHTML in 21 Days (fourth edition) 

if (document.images) {

homeRoll = new Image();
homeRoll.src = "images/home_roll.gif";
home = new Image();
home.src = "images/home.gif";

causesRoll = new Image();
causesRoll.src = "images/causes_roll.gif";
causes = new Image();
causes.src = "images/causes.gif";

pressuresRoll = new Image();
pressuresRoll.src = "images/pressures_roll.gif";
pressures = new Image();
pressures.src = "images/pressures.gif";

groupsRoll = new Image();
groupsRoll.src = "images/groups_roll.gif";
groups = new Image();
groups.src = "images/groups.gif";

dietsRoll = new Image();
dietsRoll.src = "images/diets_roll.gif";
diets = new Image();
diets.src = "images/diets.gif";

resourcesRoll = new Image();
resourcesRoll.src = "images/resources_roll.gif";
resources = new Image();
resources.src = "images/resources.gif";

aboutRoll = new Image();
aboutRoll.src = "images/about_roll.gif";
about = new Image();
about.src = "images/about.gif";

}

function activate (image_name) {
	if (document.images) {
	document[image_name].src = eval(image_name + "Roll.src");
	
	}
}

function deactivate(image_name) {
	if (document.images) {
	document[image_name].src = eval(image_name + ".src");
	}
}


// Code for button rollovers ends here

// Code for pop-up windows begins here. Credit: http://accessify.com/tools-and-wizards/accessibility-tools/pop-up-window-generator/default.php


var newWindow = null;

function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}

function popUpWin(url, type, strWidth, strHeight){
	
	closeWin();
	
	if (type == "fullScreen"){
		strWidth = screen.availWidth - 100;
		strHeight = screen.availHeight - 200;
	}
	
	var tools="";
	if (type == "standard" || type == "fullScreen") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
	if (type == "console") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+",left=0,top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}

// end pop-up window script