/*************************************************************************
  This code is from Dynamic Web Coding at http://www.dyn-web.com/
  Copyright 2001-3 by Sharon Paine 
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

// resize fix for ns4
var origWidth, origHeight;
if (document.layers) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

// link style change
var cur_link;
function doLinkClass(lnk) {
  if (lnk && lnk.blur) lnk.blur();	// remove marquee
  if (!lnk || cur_link == lnk) return;
  if (cur_link) cur_link.className = "done";
  lnk.className = "on";
  cur_link = lnk;
}

var cur_leg;	// holds id of currently visible layer
function swapLayers(lnk,id) {
  doLinkClass(lnk);
  if (cur_leg) hideLayer(cur_leg);
  showLayer(id);
  cur_leg = id;
}

function showLayer(id) {
  var leg = getElemRefs(id);
  if (leg && leg.css) leg.css.visibility = "visible";
}

function hideLayer(id) {
  var leg = getElemRefs(id);
  if (leg && leg.css) leg.css.visibility = "hidden";
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? getlegRef(id,document): null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

// get reference to nested layer for ns4
// from old dhtmllib.js by Mike Hall of www.brainjar.com
function getlegRef(leg,doc) {
	if (document.layers) {
		var theleg;
		for (var i=0; i<doc.layers.length; i++) {
	  	theleg = doc.layers[i];
			if (theleg.name == leg) return theleg;
			else if (theleg.document.layers.length > 0) 
	    	if ((theleg = getlegRef(leg,theleg.document)) != null)
					return theleg;
	  }
		return null;
  }
}

function init(id,leg) {
  var lnk = getElemRefs(id);
  swapLayers(lnk,leg);
}

/*090711-----------shadowbox*/
function openShadowbox(content, player, title){
    Shadowbox.open({
        content:    content,
        player:     player,
        title:      title
    });
}

