//General Show fide function

function ShowHide(ItemID){
GetImagePos=document.getElementById(ItemID).style.display=='none' ? '' : 'none';
document.getElementById(ItemID).style.display=GetImagePos;
}

// This Changes the display state of multiple elements
// pass over a list of the ids of the elements to display or hide
//based on the current elements state
// ChangeMultiState('Item1','Item2','Item3')

function ChangeMultiState(){
for (var i = 0; i < arguments.length; i++) {
GetImagePos=document.getElementById(arguments[i]).style.display=='none' ? '' : 'none';
		document.getElementById(arguments[i]).style.display=GetImagePos;;
		}
}

// specify a check box and then hide or show related elements
// The first argument passed to the function is the id of the check box
// then loop throught all other arguments and set thier dispalys
function CheckBoxShowHide(){

	if (document.getElementById(arguments[0]).checked){
		for (var i = 1; i < arguments.length; i++) {
		document.getElementById(arguments[i]).style.display='';
		}
	}

	else{
		for (var i = 1; i < arguments.length; i++) {
		document.getElementById(arguments[i]).style.display='none';
		}
	
	}

}


///remove an oject from the page
 function NukeObject(Nuke){
 TheItem = document.getElementById(Nuke);
 document.body.removeChild(TheItem);
 }
 
 
 ///// Get position of an Element x or y pass only the id of the element 
 // findPosX(TableID);[ oLink.x,[ posX, 
 // returns an integer in pixels



  function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
  
// Fade out
function fadeOut(objId,opacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity >= 0) {
		  setOpacity(obj, opacity);
		  opacity -= 15;
		  window.setTimeout("fadeOut('"+objId+"',"+opacity+")", 200);
		} else {
			ShowHide(objId);
		}
	}
}

// Fade in
function fadeIn(objId,opacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		ShowHide(objId);
		if (opacity <= 100) {
		  setOpacity(obj, opacity);
		  opacity += 10;
		  window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 80);
		}
	}
}

// Set appropriate opacity depending on browser
function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
	
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
	
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}


function BallonInfo(AttachTo,BalloonMessage){

TheXPlace = (findPosX(document.getElementById(AttachTo))+40)+"px";
TheYPlace = (findPosY(document.getElementById(AttachTo))-100)+"px";

	var Balloon = null;	
if (document.getElementById("BalloonWindow") == null ){

			Balloon = document.createElement("iframe");
			Balloon.name = "BalloonWindow";
			Balloon.id = "BalloonWindow";
			Balloon.allowTransparency = true;
			//Balloon.style.backgroundColor="transparent";
			Balloon.scrollbars="no";
			Balloon.scrolling="no";
			Balloon.style.height = "115px";
			Balloon.style.width = "188px";
			Balloon.style.display = "";
			Balloon.style.position = "absolute";
			Balloon.style.zIndex = 100;
			Balloon.style.border = 0;
			Balloon.style.top=TheYPlace;
			Balloon.style.left=TheXPlace;
			document.body.appendChild(Balloon);
	}

var thelocal="http://" + location.host +"/help/balloon_help.html";
	 setTimeout(function (){
	  document.getElementById("BalloonWindow").src = thelocal;
	  }, 10);	

	


///what is the width of the object we want to place
//subtracting the width of the object allows us to place it 
//on the right hand side of the place that was click

		//this places the window at the specified top of the 
		//parent window based on the scroll position
//Framed.style.top=(parseInt(TheYPlace))+"px";
//Framed.style.left=parseInt(TheXPlace)+"px";


//document.getElementById(AttachTo).focus();
//fadeIn(Framed,'100');


}
 function closeballoon(BalloonName){
 if (document.getElementById(BalloonName) != null){ 
	Needle = document.getElementById(BalloonName);
	document.body.removeChild(Needle);
	}
 }
function inspect(elm){
  var str = "";
  for (var i in elm){
    str += i + ": " + elm.getAttribute(i) + "\n";
  }
  alert(str);
}


// returns any highlited text(selected)
// http://www.quirksmode.org/js/
function getSel()
{
	var txt = '';
	var foundIn = '';
	if (window.getSelection)
	{
		txt = window.getSelection();
		foundIn = 'window.getSelection()';
	}
	else if (document.getSelection)
	{
		txt = document.getSelection();
		foundIn = 'document.getSelection()';
	}
	else if (document.selection)
	{
		txt = document.selection.createRange().text;
		foundIn = 'document.selection.createRange()';
	}
	else return;
	document.forms[0].selectedtext.value = 'Found in: ' + foundIn + '\n' + txt;
}


//returns a random number for use in urls to prevent caching
function RandomSeed(){

return Math.floor(Math.random()*11000000);
}