function showHelpText(txt, e) {
  hd = document.getElementById('helpdiv');
  if (self.innerHeight) { // all except Explorer
    windowWidth = self.innerWidth;
    windowHeight = self.innerHeight;
    addly = self.pageYOffset;
  }
  else if (document.documentElement && document.documentElement.clientHeight) {
 // Explorer 6 Strict Mode
    windowWidth = document.documentElement.clientWidth;
    windowHeight = document.documentElement.clientHeight;
    addly = document.documentElement.scrollTop;
  }
  else if (document.body) { // other Explorers
    windowWidth = document.body.clientWidth;
    windowHeight = document.body.clientHeight;
    addly = document.body.scrollTop;
  }

  cursoroff = 12;

  x = (window.event ? window.event.clientX : e.pageX) + cursoroff;
  max_x = windowWidth - (310 + cursoroff);
  if (max_x < x) x = max_x;

  y = (window.event ? window.event.clientY + addly : e.pageY) + cursoroff;


  hd.style.visibility='visible';
  hd.style.top = y+'px';
  hd.style.left = x+'px';
  hd.innerHTML = txt;
}

//!!!!! IMPORTANT -- DO NOT DELETE THE FUNCTION BELOW
function confirmDelete(URL) {
	if(confirm("Are you sure you want to delete this?")){
	window.location.href=URL;}

}

function confirmSubmit()
{
var agree=confirm("Are you sure you want to delete this?");
if (agree)
	return true ;
else
	return false ;
}
function confirmPassed(PassedString)
{
var statement = 'Are you sure you want to delete ' + PassedString + '?';
var agree=confirm(statement);
if (agree)
	return true ;
else
	return false ;
}


function specificDelete(WhatToDelete, F_Element)
{
var append1 = eval("document.NewEquipmentForm." + F_Element + ".selectedIndex");
appends = eval("document.NewEquipmentForm." + F_Element + ".options[append1].text");
var final_statement = 'Are You sure you would like to delete '+ appends + '?';
var agree=confirm(final_statement);
if (agree)
	return true ;
else
	return false ;
}


function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w)  / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function ModifyEx(url, myname, w, h, scroll, selectbox) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
var appends = eval("document.NewEquipmentForm." + selectbox + ".value");
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
var url2 = url + appends;
win = window.open(url2, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function CheckCoefficient(Type){
	if(document.EquipmentForm.IsGeneric.checked != true){
		if(document.EquipmentForm.EquipmentType.value == 'isDual'){
			document.EquipmentForm.Coefficient.value = 1.5;
		}else{
			document.EquipmentForm.Coefficient.value = 1;
		}
	}else{
			document.EquipmentForm.Coefficient.value = 'Not Applicable';
	}
}


// Begin auto tab code
var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
	var keyCode = (isNN) ? e.which : e.keyCode;
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsElement(filter,keyCode)) {
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+1) % input.form.length].focus();
	}
	function containsElement(arr, ele) {
		var found = false, index = 0;
		while(!found && index < arr.length)
			if(arr[index] == ele)
				found = true;
			else
				index++;
		return found;
	}
	function getIndex(input) {
		var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1)
			if (input.form[i] == input)index = i;
			else i++;
		return index;
	}
	return true;
}

function loadImages() {
  if (document.getElementById) {  // DOM3 = IE5, NS6
    document.getElementById('hidepage').style.visibility = 'hidden';
  }
  else {
    if (document.layers) {  // Netscape 4
      document.hidepage.visibility = 'hidden';
    }
    else {  // IE 4
      document.all.hidepage.style.visibility = 'hidden';
    }
  }
}

// move items between two multiselect lists
function moveSelected(from, to) {
  for (var i = from.options.length-1; i >= 0; i--) {
    if (from.options[i].selected) {
      to.options[to.options.length] = new Option(from.options[i].text, from.options[i].value, false, false);
      from.options[i] = null;
    }
  }
}


function getElementsByClassName(cn) {
  var rx = new RegExp("(?:^|\\s)" + cn+ "(?:$|\\s)");
  var allT = document.getElementsByTagName("*"), allCN = [], ac="", i = 0, a;
    while (a = allT[i=i+1]) {
      ac=a.className;
      if ( ac && ac.indexOf(cn) !==-1) {
        if(ac===cn){ allCN[allCN.length] = a; continue;   }
        rx.test(ac) ? (allCN[allCN.length] = a) : 0;
      }
    }
  return allCN;
}

function sethtml(div,content)
{
    var search = content;
    var script;
         
    document.getElementById(div).innerHTML=content;

    while( script = search.match(/(<script[^>]+javascript[^>]+>\s*(<!--)?)/i))
    {
      search = search.substr(search.indexOf(RegExp.$1) + RegExp.$1.length);
      
      if (!(endscript = search.match(/((-->)?\s*<\/script>)/))) break;
      
      block = search.substr(0, search.indexOf(RegExp.$1));
      search = search.substring(block.length + RegExp.$1.length);
      
      var oScript = document.createElement('script');
      oScript.text = block;
      document.getElementsByTagName("head").item(0).appendChild(oScript);
    }
   
} 

function displayWaitNotice(txt, id) {
  if ('' == txt) {
    txt = 'Updating information<br />Please wait';
  }
  $(id).innerHTML = '<div style="text-align: center; margin: 25px 10px">' + txt + '<br /><img src="images/pockdole.gif" />';
}


function workoutMarkPrinted(woid, mem) {
  var url = 'DashboardFiles/dashboard_remote_markprinted.php';
  var params = 'woid=' + woid + '&mem=' + mem;
  var ajax = new Ajax.Request(
              url,
              {method: 'post', parameters: params }
  );
}
