// JavaScript Document
var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;
var offsetX = 10;
var offsetY = 20;
var toolTipSTYLE="";

function ieFix(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function initToolTips() {
	if(ns4||ns6||ie4) {
		if(ns4) 	 toolTipSTYLE = document.toolTipLayer;
		else if(ns6) toolTipSTYLE = document.getElementById("toolTipLayer").style;
		else if(ie4) toolTipSTYLE = document.all.toolTipLayer.style;
		
		if(ns4) document.captureEvents(Event.MOUSEMOVE);
		else {
		  toolTipSTYLE.visibility = "visible";
		  toolTipSTYLE.display = "none";
		}
		document.onmousemove = moveToMouseLoc;
	}
}

function toolTip(msg) {
	if(toolTip.arguments.length < 1) { // hide
		if(ns4) toolTipSTYLE.visibility = "hidden";
		else toolTipSTYLE.display = "none";
	}
	else { // show
		if(ns4) {
			toolTipSTYLE.document.write( msg );
			toolTipSTYLE.document.close();
			toolTipSTYLE.visibility = "visible";
		}
		if(ns6) document.getElementById("toolTipLayer").innerHTML = msg;
		if(ie4) document.all("toolTipLayer").innerHTML = msg;
		if(ns6||ie4) toolTipSTYLE.display='block';
	}
}

function moveToMouseLoc(e) {
	x = (ns4||ns6) ? e.pageX : event.x + ieFix().scrollLeft;
	y = (ns4||ns6) ? e.pageY : event.y + ieFix().scrollTop;
	toolTipSTYLE.left = x + offsetX+"px";
	toolTipSTYLE.top = y + offsetY+"px";
	return true;
}

function writeDate()
{
  today = new Date();
  caDay = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
  caMon = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");

  iDate = today.getDate();
  iDay  = today.getDay();
  iMon  = today.getMonth();
  iYear = today.getFullYear();

  document.write( caDay[iDay] + '  ' + caMon[iMon] + ' ' + iDate + ', ' + iYear );
}

function writeBanner()
{
	document.write("<MAP name=\"map1\">\n");
	document.write("<AREA shape=RECT alt=\"Organization Chart of the Utah Department of Health\" coords=573,3,662,14 href=\"http://health.utah.gov/html/div_offices.html\">\n");
	document.write("<AREA shape=RECT alt=\"General information about the Utah Department of Health\" coords=482,3,561,14 href=\"http://health.utah.gov/html/utah_doh.html\">\n");
	document.write("<AREA shape=RECT alt=\"List of important contacts in the Utah Department of Health\" coords=379,3,471,14 href=\"http://health.utah.gov/html/contact_us.html\">\n");
	document.write("<AREA shape=RECT alt=\"Alphabetical list of services, programs, and related links\" coords=283,3,372,15 href=\"http://health.utah.gov/alphalist.html\">\n");
	document.write("<AREA shape=RECT alt=\"Links to public health data sites\" coords=192,3,269,15 href=\"http://health.utah.gov/html/health_data.html\">\n");
	document.write("<AREA shape=RECT alt=\"News releases, media, marketing and public information\" coords=141,2,182,15 href=\"http://health.utah.gov/html/press_releases.html\">\n");
	document.write("<AREA shape=RECT alt=\"Utah Department of Health Internet site Home page\" coords=2,3,130,33 href=\"http://health.utah.gov/\">\n");
	document.write("<AREA shape=RECT alt=\"General Mailing Address: PO Box 141010, Salt Lake City, Utah, 84114-1010\" coords=148,22,466,31>\n");
	document.write("<AREA shape=RECT alt=\"General Phone Number: 801/538/6101\" coords=493,22,661,31>\n");
	document.write("</MAP>\n");
	document.write("<IMG src=\"http://health.utah.gov/UDOHbanner.gif\" alt=\"Internet Site navigation banner\" width=755 height=35 border=0 useMap=../Admin/include/%22#map1/%22>\n");
}

function writeModified()
{
	date = document.lastModified;
	//iDay = date.getDay();
	document.write("<br>Page last modified:"+date+" \n");
}

function writeFooter()
{
  now = new Date();
  iYear = now.getFullYear();
  document.write( '<strong>© Copyright '+ iYear + ', Utah Department of Health</strong>. All rights reserved.<br>\n');
}

function writeFooter2(comp, email)
{
  now = new Date();
  iYear = now.getFullYear();

  //document.write( '<strong>© Copyright '+ iYear + ', '+comp+'</strong>. All material found on this site are copyrighted.<BR>No material may be reproduced or reused without explicit permission from <strong>'+comp+'</strong>.');
  document.write( '<strong>© Copyright '+ iYear + ', '+comp+'</strong>. All rights reserved.<br>\n');
  if(email != undefined)
  	document.write( '<a href='+email+' onMouseOut=\"window.status=\' \';return true\" onMouseOver=\"window.status=\'Comments or Questions?!! Send me an E-mail\'; return true\">'+email+'</a>' );
}

function OpenImg(pic)                                                       
{                    
	var pics = true;                                      
    pics=window.open( '', 'pics', "width=384,height=288,toolbar=no,location=no,menubar=no,scrollbars=no,resizable=no,maximize=no,titlebar=no");
    pics.moveTo(0,0);
	pics.document.write("<html><head><title>SonicFuzion</title></head>\n");
    pics.document.write("<body bgcolor='#FFFFFF' text=#FFFFFF link=#FFCC33 vlink=#CCCCCC vspace=0 hspace=0 marginheight=0 marginwidth=0 leftmargin=0 topmargin=0 onLoad=\"setTimeout('window.close()',10000)\">\n");
    pics.document.write("<script language=JavaScript>setTimeout('document.close()',1000)</script>\n");
    pics.document.write("<center><img src='../Admin/include/images/%22%2Bpic%2B%22' alt='Expanded View' border='0' width='384' height='288'></center>\n");
    pics.document.write("</body></html>");
}

function openWin(content)
{
	wins=window.open('','wins',"width=320,height=240,toolbar=no,location=no,menubar=no,scrollbars=auto,resizable=no,maximize=no,titlebar=no");
	wins.document.write("<html><head><style>body{font-size:12px; font-family: arial,verdana,helvetica,geneva; color:#000000; background: white;}</style></head><body>");
	wins.document.write(content);
	wins.document.write("</body></html>");
}

function openPage(url)
{
	wins=window.open(url,'wins',"width=600,height=800,toolbar=no,location=no,menubar=no,scrollbars=auto,resizable=no,maximize=no,titlebar=no");
}


function ClearAll()
{
	var ml = document.form1;
	var len = ml.elements.length;
	for (var i = 0; i < len; i++) {
	    var e = ml.elements[i];
	    if (e.name == "delItem") {
		e.checked = false;
	    }
	}
	ml.toggleAll.checked = false;
}

function Delete()
{        
	ml = document.form1;
	len = ml.elements.length;

	x = 0;
	for(var i = 0 ; i < len ; i++) {
	    if (ml.elements[i].name == "delItem" && ml.elements[i].checked) {
		x++;
	    }
	}
	if (x) {
	    if (!confirm("Are you sure you want to delete "+x+" rows?")) {
		ClearAll();
		return;
	    }
	}
	var ml=document.form1;
	ml.submit();
}

function showMenu(layerName) {
	var newsLayer = document.getElementById(layerName).style;
	var img = document.getElementById('plus');
	
	if( newsLayer.visibility == "hidden") {
		newsLayer.visibility = "visible";
		//newsLayer.display = "inherit";
		newsLayer.display = "inline";
	}
	else {
		newsLayer.visibility = "hidden";
		newsLayer.display = "none";
	}
	
	//alert(img.src);
	srv = img.src.substr(0,img.src.indexOf("images/icons/"));
	//alert(srv);
	if( img.src.indexOf("plus.gif") >= 0 ){ 
		img.src = srv+"images/icons/mins.gif";
	}
	else{
		img.src = srv+"images/icons/plus.gif";
	}
}

function showMsg() {
	args = showMsg.arguments;
	argv = args.length;
	
	layerName = args[0];
	newsLayer = document.getElementById(layerName).style;

	
	if( newsLayer.visibility == "hidden") {
		newsLayer.visibility = "visible";
		newsLayer.display = "block";
	}
	else {
		newsLayer.visibility = "hidden";
		newsLayer.display = "none";
	}
	
	return true;
}

function showMsg2() {
	args = showMsg2.arguments;
	layer = new Array();
	
	layer[0] = document.getElementById(args[0]).style;
	for(i=1; i<args.length; i++) {
		layer[i] = document.getElementById(args[i]).style;	
		
		if( layer[0].visibility == "hidden") {
			layer[0].visibility = "visible";
			layer[0].display = "block";
		}
		/*else {
			layer[0].visibility = "hidden";
			layer[0].display = "none";
		}*/
		
		layer[i].visibility = "hidden";
		layer[i].display = "none";
	}
		
	return true;
}

function preloadImages()
{
  if(document.images)
  {
    if(!document.imageArray) document.imageArray = new Array();
    var i,j = document.imageArray.length, args = preloadImages.arguments;
    
    for(i=0; i<args.length; i++)
    {
      if (args[i].indexOf("#")!=0)
      {
        document.imageArray[j] = new Image;
        document.imageArray[j++].src = args[i];
      }
    }
  }
}

/************************************************************************/
//
// Roatating Pics
// 
/************************************************************************/

var arImgs = new Array();
var num = Math.floor(Math.random()*(arImgs.length)); // Random number from 0 - 15

function preloadImg() {
	for(i=0; i<arguments.length; i++) {
		arImgs[i] = new Image();
		arImgs[i].src = arguments[i];
	}
}

function showPic(num) {
	document.write('<img name="rndImg" src="'+arImgs[num].src+'" width="115" height="80" border="0" />');
	setInterval("randomImg()",delay);
}

function randomImg() {
if( num == ( tempindex=Math.floor(Math.random()*(arImgs.length)) ) ) {
	num=num==0? 1 : num-1
}
else
	num=tempindex

	document.images.rndImg.src=arImgs[num].src
}

