////////////////////////////////////////////////////////////
////////////////MOUSE MOVEMENT DETECTION/////////////////////
////////////////////////////////////////////////////////////////
var w3c=(document.getElementById)? true: false;
var ie5=(w3c && document.all)? true : false;
var ns6=(w3c && (navigator.appName=="Netscape"))? true: false;

var trackcommands = new Array();
function tc(name, afunction){
	this.commandID = name
	this.afunction = new Function(afunction);
	trackcommands[trackcommands.length] = this;
}
var mouser_mx=0;
var mouser_my=0;
function mouseMoveHandler(evt){

	if (trackcommands)
	{
		mouser_mx=(ie5)?event.clientX:evt.pageX;
		mouser_my=(ie5)?event.clientY:evt.pageY;
		for (var i = 0; i < trackcommands.length; i++){
			trackcommands[i].afunction();
		}
	}
	return true;
}
document.onmousemove=mouseMoveHandler;
///////////////////////////////////////////////////////////////



function DisplayElement() {
	//vislayer( show/hide, [wait X ms before running], layer1, layer2, layer3...)
	var args = DisplayElement.arguments,vismode=args[0]
	if (vismode == "stoptimer")
	{
		clearTimeout(capTimeout);
	}
	else
	{
	
		if (isInt(args[1]))
		{
			var strT = "";
			for (i=2; i<args.length; i++)
				strT = strT + ",'"+args[i]+"'";
			capTimeout = setTimeout("visLayer('"+args[0]+"'"+strT+")", args[1]);
		}
		else
		{
			//alert("1");
			for (i=1; i<args.length; i++){
				if (document.getElementById(args[i])){
					aLayer = document.getElementById(args[i]);
					if (vismode == "show")
						aLayer.style.display = "block";
					else
						aLayer.style.display = "none";
				}
			}
		}
	}
}

function isInt(num){
	str = num.toString()
	for (var i = 0; i < str.length; i++){
		var aChar = str.charAt(i);
		if (aChar < "0" || aChar > "9"){
			return false;
		}
		return true;
	}
}
function DL_GetElementLeft(eElement)
{
    if (!eElement && this)                       // if argument is invalid
    {                                            // (not specified, is null or is 0)
        eElement = this;                         // and function is a method
    }                                            // identify the element as the method owner
    
    var nLeftPos = eElement.offsetLeft;          // initialize var to store calculations
    var eParElement = eElement.offsetParent;     // identify first offset parent element  
    while (eParElement != null)
    {                                            // move up through element hierarchy
        nLeftPos += eParElement.offsetLeft;      // appending left offset of each parent
        eParElement = eParElement.offsetParent;  // until no more offset parents exist
    }
    return nLeftPos;                             // return the number calculated
}


function DL_GetElementTop(eElement)
{
    if (!eElement && this)
    {
        eElement = this;
    }

    var nTopPos = eElement.offsetTop;
    var eParElement = eElement.offsetParent;
    while (eParElement != null)
    {
        nTopPos += eParElement.offsetTop;
        eParElement = eParElement.offsetParent;
    }
    return nTopPos;
}


//Menu Code
var MenuHideTimeout, CaptionHideTimeout;
function MV(menu, anc){
	ShowMenu(menu, anc);
}
function MU(menu){
	DisplayElement('hide','MenuCaption');
	HideMenu(menu);
}
function ShowMenu(MenuName, anc){
	HideAll()
	clearTimeout(MenuHideTimeout);
	//clearTimeout(CaptionHideTimeout);
	DisplayElement('show', MenuName);
	if (anc){
		var mPopup = document.getElementById(MenuName);
		mPopup.style.left = DL_GetElementLeft(anc) -5
		mPopup.style.top = DL_GetElementTop(anc)+20
	}

}
function HideMenu(MenuName){
	MenuHideTimeout = setTimeout("DisplayElement('hide', '" + MenuName + "');", 1000);
//	CaptionHideTimeout = setTimeout("HideCaption();", 1000);
	//CaptionHideTimeout = setTimeout("DisplayElement('hide','MenuCaption');", 1000);
}

function HideAll(){
	DisplayElement('hide', 'mSetup');
	DisplayElement('hide', 'mNew');
	DisplayElement('hide', 'mManage');
	DisplayElement('hide', 'mReports');
}

var capy = 15;
function Caption(text){
	var cap = document.getElementById("MenuCaption")
	cap.style.display = "block";
	if (text){
		cap.innerHTML = text
	}

	capy--;
	cap.style.top = capy;
	if (capy <= 1) {
		clearTimeout(capTimeout)
		capy = 15;
	} else {
		capTimeout = setTimeout("Caption()", 30)
	}

}

///////////////////////////////////////////////////
////////////////TOOL TIP//////////////////
///////////////////////////////////////////////////
var xoffset=0;
var yoffset=0;
function ToolTip(text, x, y){
	var ToolTip = document.getElementById('ToolTip');
	if (!ToolTip)
	{
		ToolTip=document.createElement('div');
		ToolTip.setAttribute('id','ToolTip'); 
		ToolTip.style.position='absolute';
		ToolTip.style.backgroundColor='#7194b2';
		ToolTip.style.padding='2px 2px 2px 2px';
		ToolTip.style.borderColor='#000000';
		ToolTip.style.color='#FFFFFF';
		ToolTip.style.borderStyle="inset";
		ToolTip.style.borderWidth="1px";
		//ToolTip.style.filter="alpha(opacity=90)";
		ToolTip.style.zIndex = 100;
		document.body.appendChild(ToolTip);
		ToolTip.mousetracker = new tc('ToolTipMove', 'ToolTipMove()');
	}
	if (x)
	{
		xoffset = x;
	}
	if (y)
	{
		yoffset = y;
	}
	ToolTip.innerHTML = text;
	ToolTip.style.display='block';
}
function ToolTipMove(){
	var yScrollOffset = 0;
	if (ie5)
		yScrollOffset = document.body.scrollTop;
	var ToolTip = document.getElementById('ToolTip');
	if (ToolTip){
		ToolTip.style.left = mouser_mx+15+xoffset;
		ToolTip.style.top = mouser_my-30 + yScrollOffset + yoffset;
	}
}
function HideToolTip(){
	v = document.getElementById('ToolTip');
	v.style.display='none';
}
//////////////////////////////////////////

function changeImg(imgName, targetFile){
	theImage = document.images[imgName];
	theImage.src = targetFile;
}





function tt(min, max, avail, seasonname, visible, privacy){

	var ts = "";

	if (seasonname.length > 0)
	{
		ts = ts + tRow("Season", seasonname);
	}

	if (min.length > 0)
		ts = ts + tRow("Min", min);

	if (max.length > 0)
		ts = ts + tRow("Max", max);

	if (avail.length > 0)
		ts = ts + tRow("Available", avail);
	
	if (visible.length > 0)
		ts = ts + tRow("Visible", visible);

	if (privacy.length > 0)
		ts = ts + tRow("Status", privacy);

	if (ts.length > 0){
		ts = "<table>" + ts + "</table>";
		ToolTip(ts);
	}
}

function tRow(label, value){
	return "<tr><td style=\"color:#FFFF00\" align=right>" + label + ":</td><td style=\"color:#FFFFFF\">" + value + "</td></tr>";
}



function ev(num, lnkButtonID){
	document.Form1.evid.value = num;
	__doPostBack(lnkButtonID, '');
}

			
			
			
			
