function doTitle(newTitle){
	iconTitle.innerHTML=newTitle;
}

function show(element){
	if (document.getElementById){
		document.getElementById("placeholder").style.display="none";
		document.getElementById(element).style.display="block";
	}
}

function hide(element){
	if (document.getElementById){
		document.getElementById(element).style.display="none";
		document.getElementById("placeholder").style.display="block";
	}
}

function showHoffman(element){
	if (document.getElementById){
		a=new Array('baker','besner','brown','fairbridge','lai','lehmann','middleton','ritter','romero','schroeder','shem','shier','wertschek');
		for (i=0;i<a.length;i++){
			document.getElementById(a[i]).style.display="none";
		}
		document.getElementById(element).style.display="block";
	}
}

function popWindow(url,w,h){
	hp=window.open(url,"Homemade_Parachute","width="+w+",height="+h+",status=0,toolbar=0,menubar=0,resizable=0,scrollbars=0");
	hp.focus()
}

function changeImage() {
	newImage++;
	if (newImage>=newImages.length){
		newImage=0;
	}
	document.images.changeme.src=imagePath+newImages[newImage];
}

function flashWin(){
	x=screen.height
	if (x==480) {
		y = 350
	} else if (x==600) {
		y = 470
	} else if (x==624) {
		y = 470
	} else if (x==768) {
		y = 630
	} else if (x<=870) {
		y = 740
	} else if (x<=960) {
		y = 830
	} else if (x<=1024) {
		y = 870
	} else if (x > 1024) {
		y = x - 130
	}
	
	x = y
	l=(screen.width-x) / 2;
	t=(screen.height-y) / 2;
	
	popWin=window.open("flash.html","HomemadeParachute","width="+x+",height="+y+",left="+l+",top="+t+",screenX="+l+",screenY="+t+",status=no,toolbar=no,menubar=no,resizable=no,scrollbars=no");
	popWin.focus();
}

function mailto(add,name){
	alpha="12wCAxGDPJHSIOKnELhM@pUtQvRbqVaWdXsYiZcfNgjBlmrkoFuTy.ze34";
	ad="";
	for (i=0;i<add.length;i++){
		ad=ad+alpha.charAt(alpha.indexOf(add.charAt(i))-2);
	}
	e="";
	for (i=0;i<name.length;i++){
		e=e+alpha.charAt(alpha.indexOf(name.charAt(i))-2);
	}
	document.write('<a href="mailto:'+ad+'">'+e+'</a>');
}

function fixMail(){
	alpha="12wCAxGDPJHSIOKnELhM@pUtQvRbqVaWdXsYiZcfNgjBlmrkoFuTy.ze34";
	for(i=0;i<document.links.length;i++){
		if (document.links[i].href.indexOf("mailto") >=0){
			ad="";
			x=document.links[i].href;
			for (n=6;n<x.length;n++){
				ad=ad+alpha.charAt(alpha.indexOf(x.charAt(n))-2);
			}
			at="U@uk4kds4tdodN@yv4eNuk";
			atd="";
			for (n=0;n<at.length;n++){
				atd=atd+alpha.charAt(alpha.indexOf(at.charAt(n))-2);
			}

			document.links[i].href="mailto:"+ad+atd;
		}
	}
}

function decrypt(input){
	alpha="12wCAxGDPJHSIOKnELhM@pUtQvRbqVaWdXsYiZcfNgjBlmrkoFuTy.ze34";
	d="";
	for (i=0;i<input.length;i++){
		d=d+alpha.charAt(alpha.indexOf(input.charAt(i))-2);
	}
	document.write(d);
}

function sortTable(col){
	tbl=document.getElementById("jsbx");
	if (tbl.reverseSort==null){
		tbl.reverseSort=new Array();
	}
	if (col==tbl.lastColumn){
		tbl.reverseSort[col] = !tbl.reverseSort[col];
	}
	tbl.lastColumn=col;
	tblrs=tbl.rows.length;
  	oldDsply = tbl.style.display;
	tbl.style.display = "none";
	
	for (i=0;i<tblrs;i++){
		minIdx=i;
		minVal=getTextValue(tbl.rows[i].cells[col]);
		
		for (j=i+1;j<tblrs;j++){
			testVal=getTextValue(tbl.rows[j].cells[col]);
			cmp=compareValues(minVal,testVal);
			if (tbl.reverseSort[col]){
				cmp = -cmp;
			}
			if (cmp>0){
				minIdx=j;
				minVal=testVal;
			}
		}
		if (minIdx>i){
			tmp=tbl.removeChild(tbl.rows[minIdx]);
			tbl.insertBefore(tmp,tbl.rows[i]);
		}
	}
	tbl.style.display = oldDsply;
}

//-----------------------------------------------------------------------------
// Functions to get and compare values during a sort.
//-----------------------------------------------------------------------------

// This code is necessary for browsers that don't reflect the DOM constants
// (like IE).
if (document.ELEMENT_NODE == null) {
  document.ELEMENT_NODE = 1;
  document.TEXT_NODE = 3;
}

function getTextValue(el) {

  var i;
  var s;

  // Find and concatenate the values of all text nodes contained within the
  // element.
  s = "";
  for (i = 0; i < el.childNodes.length; i++)
    if (el.childNodes[i].nodeType == document.TEXT_NODE)
      s += el.childNodes[i].nodeValue;
    else if (el.childNodes[i].nodeType == document.ELEMENT_NODE &&
             el.childNodes[i].tagName == "BR")
      s += " ";
    else
      // Use recursion to get text within sub-elements.
      s += getTextValue(el.childNodes[i]);

  return normalizeString(s);
}

function compareValues(v1, v2) {

  var f1, f2;

  // If the values are numeric, convert them to floats.

  f1 = parseFloat(v1);
  f2 = parseFloat(v2);
  if (!isNaN(f1) && !isNaN(f2)) {
    v1 = f1;
    v2 = f2;
  }

  // Compare the two values.
  if (v1 == v2)
    return 0;
  if (v1 > v2)
    return 1
  return -1;
}

// Regular expressions for normalizing white space.
var whtSpEnds = new RegExp("^\\s*|\\s*$", "g");
var whtSpMult = new RegExp("\\s\\s+", "g");

function normalizeString(s) {

  s = s.replace(whtSpMult, " ");  // Collapse any multiple whites space.
  s = s.replace(whtSpEnds, "");   // Remove leading or trailing white space.

  return s;
}
