function trapEnter(e, enterFunction){
     if (!e) e = window.event;
     if (e.keyCode == 13){
          e.cancelBubble = true;
          if (e.returnValue) e.returnValue = false;
          if (e.stopPropagation) e.stopPropagation();
          if (enterFunction) eval(enterFunction);
          return false;
     } else {
          return true;
     }     
}

function toggleDiv(id){

	var lay = getElemRefs(id); 
	
	vStyle = lay.style.display;
	
	if(vStyle=='none'){
		lay.style.display = "block";
	}else{
		lay.style.display = "none";
	}


}

/*********
code from prodosys, function for showing layers centered
**********/

function showCentered(id,w,h){
	//id = id of element
	//w = width
	//h = height
	
	var ns=(document.layers);
	var ie=(document.all);
	var w3=(document.getElementById && !ie);
	var calunit=ns? "" : "px" ;
	
	var docWidth;
	var docHeight;
	if (ie){
	docWidth=doctruebody().offsetWidth/2+doctruebody().scrollLeft-20;
	docHeight=doctruebody().offsetHeight/2+doctruebody().scrollTop-20;
	}	
	else if (ns){
	docWidth=window.innerWidth/2+window.pageXOffset-20;
	docHeight=window.innerHeight/2+window.pageYOffset-20;
	} 
	else if (w3){
	docWidth=self.innerWidth/2+window.pageXOffset-20;
	docHeight=self.innerHeight/2+window.pageYOffset-20;
	} 
		
	var lay = document.getElementById(id);
	
	var docleft = Math.round(docWidth-w/2)+calunit;
	var doctop = Math.round(docHeight-h/2)+calunit;
	
	
	lay.style.width = w;
	lay.style.height = h;
	lay.style.left = docleft;
	lay.style.top = doctop;
	
	//alert(docleft);
	//alert(doctop);
	
showDivPro(id);
	
	//showLayerDisplay(id);
	//toggleLayer(id);	
     }
     
function doctruebody(){
		return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}	


function showDivPro(whichLayer)
{
//Copied from http://www.netlobo.com/div_hiding.html
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  vis.display = 'block';
}


/*************************************************************************
  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_lyr;	// holds id of currently visible layer
function swapLayers(lnk,id) {
  doLinkClass(lnk);
  if (cur_lyr) hideLayer(cur_lyr);
  showLayer(id);
  cur_lyr = id;
}

function showLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "visible";
}

function hideLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "hidden";
}

function showLayerDisplay(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.display = "";
}

function hideLayerDisplay(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.display = "none";
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? getLyrRef(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 getLyrRef(lyr,doc) {
	if (document.layers) {
		var theLyr;
		for (var i=0; i<doc.layers.length; i++) {
	  	theLyr = doc.layers[i];
			if (theLyr.name == lyr) return theLyr;
			else if (theLyr.document.layers.length > 0) 
	    	if ((theLyr = getLyrRef(lyr,theLyr.document)) != null)
					return theLyr;
	  }
		return null;
  }
}

function init(id,lyr) {
  var lnk = getElemRefs(id);
  swapLayers(lnk,lyr);
}

function writeDiv(id,content){
	var d = getElemRefs(id);
	d.innerHTML = content;
}

function appendDiv(id,content){
	var d = getElemRefs(id);
	d.innerHTML = d.innerHTML + ' ' + content;
}

function writeSpan(id,content){
	var d = getElemRefs(id);
	d.innerText = content;
}

var hide= true;

function toggleRows(tableId, tag){

	tbl = document.getElementById(tableId);
	var len = tbl.rows.length;
	var vStyle = (hide)? "none":"";

	for(i=1 ; i< len; i++){
		 tbl.rows[i].style.display = vStyle;
	 }

	if(hide)
		tag.innerHTML = "Click here to show rows";
	else
		tag.innerHTML = "Click here to hide rows";
	hide= !hide;
}

function toggleLayer(id){
	//alert(id);

	var lay = getElemRefs(id); 
	//document.getElementById(id);
	//alert(lay.style.display);
	
	vStyle = lay.style.display;
	
	//var vStyle = (hide)? "none":"";

	//for(i=1 ; i< len; i++){
	//	 tbl.rows[i].style.display = vStyle;
	// }
	
	if(vStyle=='none'){
		lay.style.display = "";
	}else{
		lay.style.display = "none";
	}
	
	//lay.style.display = vStyle;
	//hide= !hide;
	
	//show(id);

}

function toggleLayerPro(whichLayer)
{
//Copied from http://www.netlobo.com/div_hiding.html
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

/*  
Made by Martial Boissonneault © 2002-2003 http://getElementById.com/
May be used and changed freely as long as this msg is intact
Visit http://getElementById.com/ for more free scripts and tutorials.
*/
var ns4 = (document.layers);
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);

function show(id){
	// Netscape 4
	if(ns4){
		document.layers[id].visibility = "show";
	}
	// Explorer 4
	else if(ie4){
		document.all[id].style.visibility = "visible";
	}
	// W3C - Explorer 5+ and Netscape 6+
	else if(ie5 || ns6){
		document.getElementById(id).style.visibility = "visible";
	}
}

function hide(id){
	// Netscape 4
	if(ns4){
		document.layers[id].visibility = "hide";
	}
	// Explorer 4
	else if(ie4){
		document.all[id].style.visibility = "hidden";
	}
	// W3C - Explorer 5+ and Netscape 6+
	else if(ie5 || ns6){
		document.getElementById(id).style.visibility = "hidden";
	}
}