﻿window.onload = rolloverInit;

	var panes = new Array();
	var newWindow
	
	var videownd = {
	    x:0, y:0, w:550, h:350,  // Window position and size
	    win: null,                // The window we will create
	
	    // Start the animation
	    start: function( ) {
	         // Start with the window in the center of the screen
	         videownd.x = (screen.width - bounce.w)/2;
	         videownd.y = (screen.height - bounce.h)/2;
	
	         // Create the window that we're going to move around
	         // The javascript: URL is simply a way to display a short document
	         // The final argument specifies the window size
	         //bounce.win = window.open('javascript:"<h1>BOUNCE!</h1>"', "",
	         videownd.win = window.open('http://safari.oreilly.com', "",
	                                  "left=" + videownd.x + ",top=" + videownd.y +
	                                  ",width=" + videownd.w + ",height=" +videownd.h+
	                                  ",status=yes,toolbar=no");
	
	    },
	
	    // Stop the animation
	    stop: function( ) {
	         if (!video.win.closed) videownd.win.close( ); // Close window
	    }
	}
	function makeNewWindow(url,height) {
	    //newWindow = window.open(url,"window","toolbar=0,scrollbars=0,resizable=0,unadorned=yes,height=350,width=550")
		//showModelessDialog(url, "center:yes; resizable:no; dialogHeight:270px; dialoWidth:480px; unadorned:yes");
		var attribs="toolbar=no,scrollbars=no, resizable=yes,WIDTH=540,HEIGHT=";
		attribs += height;
	    newWindow = window.open(url,"",attribs);
	    return false;
	}
	
	function makeNewWindowXY(url,width,height) {
	    //newWindow = window.open(url,"window","toolbar=0,scrollbars=0,resizable=0,unadorned=yes,height=350,width=550")
		//showModelessDialog(url, "center:yes; resizable:no; dialogHeight:270px; dialoWidth:480px; unadorned:yes");
		var attribs="toolbar=no,scrollbars=no, resizable=yes,";// WIDTH=,HEIGHT=";
		attribs += "WIDTH=";
		attribs += width;
		attribs += ",HEIGHT=";
		attribs += height;
	    newWindow = window.open(url,"",attribs);
	    return false;
	}
	
	function setupPanes(containerId, defaultTabId) {
	  // go through the DOM, find each tab-container
	  // set up the panes array with named panes
	  // find the max height, set tab-panes to that height
	  panes[containerId] = new Array();
	  var maxHeight = 0; var maxWidth = 0;
	  var container = document.getElementById(containerId);
	  var paneContainer = container.getElementsByTagName("div")[0];
	  var paneList = paneContainer.childNodes;
	  for (var i=0; i < paneList.length; i++ ) {
	    var pane = paneList[i];
	    if (pane.nodeType != 1) continue;
	    if (pane.offsetHeight > maxHeight) maxHeight = pane.offsetHeight;
	    if (pane.offsetWidth  > maxWidth ) maxWidth  = pane.offsetWidth;
	    pane.style.visibility = "hidden";
	    panes[containerId][pane.id] = pane;
	    pane.style.display = "none";

	  }
	    paneContainer.style.height = maxHeight + "px";
	    paneContainer.style.width  = maxWidth + "px";
	    document.getElementById(defaultTabId).onclick();
	}
	
	function showPane(paneId, activeTab) {
	  // make tab active class
	  // hide other panes (siblings)
	  // make pane visible
	    for (var con in panes) {
	    activeTab.blur();
	    activeTab.className = "tab-active";
	    if (panes[con][paneId] != null) { // tab and pane are members of this container
	      var pane = document.getElementById(paneId);
	      pane.style.display = "block";
	      pane.style.visibility = "visible";
	      var container = document.getElementById(con);
	      var tabs = container.getElementsByTagName("ul")[0];
	      var tabList = tabs.getElementsByTagName("a")
	      for (var i=0; i<tabList.length; i++ ) {
	        var tab = tabList[i];
	        if (tab != activeTab) tab.className = "tab-disabled";
	      }
	      for (var i in panes[con]) {
	        var pane = panes[con][i];
	        if (pane == undefined) continue;
	        if (pane.id == paneId) continue;
	        pane.style.display = "none"
	      }
	    }
	  }
	  return false;    
	}
	
	function rolloverInit() {
		var pageContent = document.getElementById("content");
		pageContent.style.visibility="visible";
		for (var i=0; i<document.links.length; i++) {
			var linkObj=document.links[i];
			if (linkObj.id) {
				var imgObj=document.getElementById(linkObj.id+"_img");
				if (imgObj) {
					setupRollover(linkObj, imgObj);
				}
			}
		}	
	}
	
	function setupRollover(thisLink, thisImage) {
		thisLink.imgToChange=thisImage;
		thisLink.onmouseout=rollOut;
		thisLink.onmouseover=rollOver;
		
		thisLink.outImage = new Image();
		thisLink.outImage.src = thisImage.src;
		
		thisLink.overImage = new Image();
		thisLink.overImage.src = "../images/"+thisImage.id+"_in.jpg";
	}
	
	function rollOver() {
		this.imgToChange.src=this.overImage.src;
	}
	
	function rollOut() {
		this.imgToChange.src=this.outImage.src;
	}


