﻿//Pop out box
var theObj="";
var newObj="";
function toolTip(text,me,box) {
  theObj=me;
  newObj=box;
  theObj.onmousemove=updatePos;
  document.getElementById(newObj).innerHTML=text;
  document.getElementById(newObj).style.display="block";
  //window.onscroll=updatePos;
}

function updatePos() {
  var ev=arguments[0]?arguments[0]:event;
  var x=ev.clientX;
  var y=ev.clientY;
  diffX=-150;
  diffY=-100;
  document.getElementById(newObj).style.top  = y+diffY+f_scrollTop()+"px";
  document.getElementById(newObj).style.left = x+diffX+f_scrollLeft()+"px";
  theObj.onmouseout=hideMe;
   //alert(f_scrollTop());
}
function hideMe() {
  document.getElementById(newObj).style.display="none";
}

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}



//End pop out box

//Tab management stuff
function highlight(showMe, tabsNum) 
{
  var up = "tabUp";
  var down = "tabDown";

    // Update Tabs to show the one selected
  document.getElementById('' + showMe).className=up;
    
  for(i=1; i<=tabsNum; i++) 
  {
        if(showMe!=i) 
        {
            document.getElementById(''+i).className=down;
        }
  }


  var hideTab = "";
  var divTab = "tab"+showMe;
  document.getElementById(divTab).style.display = "block";

  for(i=1; i<=tabsNum; i++) 
  {
    hideTab = "tab" + i;
    if (divTab != hideTab) 
    {
        document.getElementById(hideTab).style.display = "none";
    }
  }
}

//Used for css menu on admin site
startList = function()
{
    if(document.all&&document.getElementById)
    {
        navRoot = document.getElementById("nav");
        for(i=0; i < navRoot.childNodes.length; i++)
        {
            node = navRoot.childNodes[i];
            if(node.nodeName == "li")
            {
                node.onmouseover=function()
                {
                    this.className+=" over";
                }
                node.onmouseout=function()
                {
                    this.className=this.className.replace(" over", "");
                }
            }
        }
    }
    window.onload=startList;
    
    
}

//Show - Hide function
function showHide(control)
    {
        var c = document.getElementById(control);
        
        if(c.style.display == "none")
            c.style.display = "block";
        else
            c.style.display = "none";    
    }

//Pop up window
function popItScroll(theLink)
{ 
	window.open(theLink,null,'height=800,width=700,scrollbars=yes,resizable=yes'); 
	}
	

function printPartOfPage(elementId)
{
 var printContent = document.getElementById(elementId);
 var windowUrl = 'about:blank';
 var uniqueName = new Date();
 var windowName = 'Print' + uniqueName.getTime();
 var printWindow = window.open(windowUrl, windowName, 'left=50000,top=50000,width=0,height=0');

 printWindow.document.write(printContent.innerHTML);
 printWindow.document.close();
 printWindow.focus();
 printWindow.print();
 printWindow.close();
}

