////////////////////////////////////////////////////////////
////////////////MOUSE MOVEMENT DETECTION/////////////////////
////////////////////////////////////////////////////////////////
var SelectedRow;


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);
	this.active = true;
	trackcommands[trackcommands.length] = this;
}
mouser_mx=0; mouser_my=0;
function mouseMoveHandler(evt){
	mouser_mx=(ie5)?event.clientX:evt.pageX;
	mouser_my=(ie5)?event.clientY:evt.pageY;
	for (var i = 0; i < trackcommands.length; i++){
		if (trackcommands[i].active){
			trackcommands[i].afunction();
		}
	}
	return true;
}
document.onmousemove=mouseMoveHandler;
///////////////////////////////////////////////////////////////

function ToggleDisplay(obj){
	obj1 = document.getElementById(obj);
	if (obj1.style.display == "none")
		obj1.style.display = "";
	else
		obj1.style.display = "none";
}
var capTimeout;
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("DisplayElement('"+args[0]+"'"+strT+")", args[1]);
		}
		else
		{
			for (i=1; i<args.length; i++){
				if (document.getElementById(args[i])){
					aLayer = document.getElementById(args[i]);
					if (vismode == "show")
						aLayer.style.display = "";
					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 changeImg(imgName, targetFile){
	theImage = document.images[imgName];
	theImage.src = targetFile;
}

function OpenWindow(url, parms)
{
	window.open(url, '', parms);
}
function OpenWindow2(url, title, parms)
{
	window.open(url, title, parms);
}

function AlertFeatDisabled(chk){
	alert("This feature is not enabled. To ask about it, contact Chriscom at 905-470-0970 x 11)");
	chk.checked = false;
}

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;
function MV(menu, anc){
	ShowMenu(menu, anc);
}
function MU(menu){
	HideMenu(menu);
}
function ShowMenu(MenuName, anc){
	HideAllMenu()
	clearTimeout(MenuHideTimeout);
	DisplayElement('show', MenuName);
	if (anc){
		var mPopup = document.getElementById(MenuName);
		mPopup.style.left = DL_GetElementLeft(anc)-12;
		mPopup.style.top = DL_GetElementTop(anc)+17;
	}

}
function HideMenu(MenuName){
	MenuHideTimeout = setTimeout("DisplayElement('hide', '" + MenuName + "');", 1000);
}

function HideAllMenu(){
	DisplayElement('hide', 'mSetup');
	DisplayElement('hide', 'mJobs');
	DisplayElement('hide', 'mReports');
	DisplayElement('hide', 'mFind');
	DisplayElement('hide', 'mItems');
	DisplayElement('hide', 'mClients');
	DisplayElement('hide', 'mOrders');
	DisplayElement('hide', 'mOrdering');
	DisplayElement('hide', 'mContacts');
}



///////////////////////////////////////////////////
////////////////TOOL TIP//////////////////
///////////////////////////////////////////////////
var xoffset=0;
var yoffset=0;
var ToolTipOutTimer;
function ToolTip(obj, text, x, y){
	var ToolTip = document.getElementById('ToolTip');
	if (!ToolTip)
	{
		ToolTip=document.createElement('div');
		ToolTip.setAttribute('id','ToolTip'); 
		ToolTip.style.position='absolute';
		ToolTip.className = 'TT';
		ToolTip.style.zIndex = 100;
		document.body.appendChild(ToolTip);
		ToolTip.mousetracker = new tc('ToolTipMove', 'ToolTipMove()');
	}
	if (x)
	{
		xoffset = x;
	}
	else
	{
		xoffset = 0;
	}
	if (y)
	{
		yoffset = y;
	}
	else
	{
		yoffset = 0;
	}
	ToolTip.innerHTML = text;
	ToolTip.style.display='';
	if (ToolTipOutTimer != null)
	{
		clearTimeout(ToolTipOutTimer);
	}
	obj.onmouseout = HideToolTipTimer
}

function ToolTipMove(){
	var yScrollOffset = 0;
	if (ie5)
		yScrollOffset = document.body.scrollTop;
	var ToolTip = document.getElementById('ToolTip');
	ToolTip.style.left = mouser_mx+15+xoffset;
	ToolTip.style.top = mouser_my-30 + yScrollOffset + yoffset;
}
function HideToolTipTimer(){
	ToolTipOutTimer = setTimeout("HideToolTip();", 300);
}
function HideToolTip(){
	v = document.getElementById('ToolTip');
	v.style.display='none';
}
function ChangeToolTipText(text){
	v = document.getElementById('ToolTip');
	v.innerHTML = text;
}


function ToolTip2(obj, TitleBlock, BodyBlock, x, y)
{
	text = '<div class=TTSEP style="font-size:10px"><B>' + TitleBlock + '</b></div>' + BodyBlock;
	ToolTip(obj, text, x, y);
}
//////////////////////////////////////////
function OpenImageWindow(url, args){
	var b = window.open(url, 'PopupWindow', args);
	b.document.write('<html><body style=\"padding-right:0px;padding-left:0px;padding-bottom:0px;padding-top:0px;margin:0px;\"><img src=\"' + url + '\"></body></html>');
}










			function DGSelectAll(CheckBoxControl,DGName) 
			{

				if (CheckBoxControl.checked == true) 
				{
			        
					var i;
			        
					for (i=0; i < document.forms[0].elements.length; i++) 
					{
						if ((document.forms[0].elements[i].type == 'checkbox') && (document.forms[0].elements[i].name.indexOf(DGName) > -1)) 
						{
							document.forms[0].elements[i].checked = true;
						}
					}
				} 
			    
				else
				{
					var i;
					for (i=0; i < document.forms[0].elements.length; i++) 
					{
						if ((document.forms[0].elements[i].type == 'checkbox') && (document.forms[0].elements[i].name.indexOf(DGName) > -1)) 
						{
							document.forms[0].elements[i].checked = false;
						}
					}
				}
			}
			
			
			