MouseMoveTaskArray = new Array();
MouseUpTaskArray = new Array();


var IE = navigator.appName.indexOf('Microsoft')>-1?true:false
if(!IE){document.addEventListener("mousemove", function(event) { trackMouse(event); }, false);}
else{document.onmousemove = trackMouse;}  
document.onmouseup=DoMouseupTasks

//_________________________________________________________________
function DetectFlash(){
    FlashInstalled = true
    try{obj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");     }
    catch(e){
        try{obj = navigator.mimeTypes["ShockwaveFlash.ShockwaveFlash"]}
        catch(e){FlashInstalled = false}
    }
}
DetectFlash();
//FlashInstalled = false//forces image to be the GIF image
if(FlashInstalled){PleaseWaitObj = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="50" height="50" id="pleasewait" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="images/pleasewait.swf" /><PARAM NAME="WMode" VALUE="Transparent"/><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="images/pleasewait.swf" quality="high" wmode="transparent" width="50" height="50" name="pleasewait" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>'}
else{
    WaitImage = new Image()
    WaitImage.src = 'images/pleasewait.gif';
    PleaseWaitObj = '<img src="images/pleasewait.gif" name="PleaseWaitImage">'
}



document.write('<div ID="MessageLayer"      style="z-index:101;position:absolute;visibility:hidden;border:solid white 1px;background:url(js/bg_messagediv.png);color:#FFFFFF;"></div>')
document.write('<div ID="MessageShadowDiv"  style="z-index:100;position:absolute;visibility:hidden;color:#FFFFFF;"><img src="js/bg_shadow_whole.png" name="MessageShadowImage"></div>')
document.write('<div ID="echoDiv"           style="z-index:103;padding:5px;position:absolute;border:solid white 1px;background:url(js/bg_overlaydiv.png);visibility:hidden;z-index:1000;color:#000000;" onclick="CloseEcho();"></div>')
document.write('<div ID="EchoShadowDiv"     style="z-index:102;position:absolute;visibility:hidden;"><img src="js/bg_shadow_whole.png" name="EchoShadowImage"></div>')
document.write('<div ID="PageOverlay"       style="z-index:200;position:absolute;visibility:hidden;border:solid black 1px;background:url(js/bg_overlaydiv.png);color:#FFFFFF;"></div>')


function DoMouseupTasks(){
    for(ArrayTask in MouseUpTaskArray){eval(MouseUpTaskArray[ArrayTask])}

}

//_________________________________________________________________
function trackMouse(e){
	if(document.body){
		if (IE) {MouseYPos = event.clientY; MouseXPos = event.clientX;} 
		else    {MouseYPos = e.pageY;       MouseXPos = e.pageX;}
		RealMouseYPos = MouseYPos + parseInt(document.body.scrollTop)
            
		RealMouseXPos = MouseXPos + parseInt(document.body.scrollLeft)
	}
    for(ArrayTask in MouseMoveTaskArray){eval(MouseMoveTaskArray[ArrayTask])}
}


//
function CheckMaxLength(fieldObj,paramMaxLen){
	if(fieldObj.value.length>paramMaxLen){fieldObj.value = fieldObj.value.substring(0,paramMaxLen);}
}

//_________________________________________________________________
function msover(CallingImage){
	CallingImage.src = CallingImage.src.indexOf('_2.')==-1 ? CallingImage.src.replace('_1.','_2.') : CallingImage.src.replace('_2.','_1.');
	CallingImage.src = CallingImage.src.indexOf('_ON.')==-1 ? CallingImage.src.replace('_OFF.','_ON.') : CallingImage.src.replace('_ON.','_OFF.');
}

function msoff(CallingImage){
	CallingImage.src = CallingImage.src.indexOf('_1.')==-1 ? CallingImage.src.replace('_2.','_1.') : CallingImage.src
	CallingImage.src = CallingImage.src.indexOf('_OFF.')==-1 ? CallingImage.src.replace('_ON.','_OFF.') : CallingImage.src
}

//_________________________________________________________________
function ShowMessage(MessageHTML){
	document.getElementById('MessageLayer').innerHTML = MessageHTML  + '<br><br><div style="text-align:center;"><a href="javascript:CloseMessage();">Close</a></div>';
	document.getElementById('MessageLayer').style.top = screen.height/2  - (document.getElementById('MessageLayer').offsetHeight/2) + parseInt(document.body.scrollTop) + 'px' //RealMouseYPos - (document.getElementById('MessageLayer').offsetHeight/2) + 'px';
	document.getElementById('MessageLayer').style.left = screen.width/2 -  (document.getElementById('MessageLayer').offsetWidth/2) + parseInt(document.body.scrollLeft) + 'px'    //RealMouseXPos - (document.getElementById('MessageLayer').offsetWidth/2) + 'px';
	document.getElementById('MessageLayer').style.visibility='visible';
    
	document.getElementById('MessageShadowDiv').style.top = parseInt(document.getElementById('MessageLayer').style.top) + 10 + 'px'
	document.getElementById('MessageShadowDiv').style.left = parseInt(document.getElementById('MessageLayer').style.left)  + 10 + 'px'
    document.getElementById('MessageShadowDiv').style.zIndex = document.getElementById('MessageLayer').style.zIndex - 1
    document.images['MessageShadowImage'].style.width = parseInt(document.getElementById('MessageLayer').offsetWidth) + 20 + 'px'
    document.images['MessageShadowImage'].style.height = parseInt(document.getElementById('MessageLayer').offsetHeight) + 20 + 'px'
	document.getElementById('MessageShadowDiv').style.visibility='visible';

}

//_________________________________________________________________
function CloseMessage(){
	document.getElementById('MessageLayer').style.visibility='hidden';
	document.getElementById('MessageShadowDiv').style.visibility='hidden';

}

//_________________________________________________________________
function FormatCurrency(TargetNumber){
	TargetNumber = TargetNumber * 100;
	TargetNumber = Math.round(TargetNumber).toString();
	ThisPriceCash = TargetNumber.substring(0,TargetNumber.length-2)
	ThisPriceChange = TargetNumber.substring(TargetNumber.length-2,TargetNumber.length)
	return('$' + ThisPriceCash + '.' + ThisPriceChange);
}

//_________________________________________________________________
function echo(ResponseString){
    if (ResponseString==''){ResponseString = 'Note: An unkown script has attempted to display a message to you, but the message is empty.'}
    document.getElementById('echoDiv').innerHTML = ResponseString + "<br><span style=\"font-size:.7em;\">(Click to close)</span>";
    document.getElementById('echoDiv').style.top = (parseInt(screen.availHeight)/2) - (parseInt(document.getElementById('echoDiv').offsetHeight)/2);
    document.getElementById('echoDiv').style.left = (parseInt(screen.availWidth)/2) - (parseInt(document.getElementById('echoDiv').offsetWidth)/2);
    document.getElementById('echoDiv').style.visibility = 'visible';
	
    document.getElementById('EchoShadowDiv').style.top = parseInt(document.getElementById('echoDiv').style.top) + 10 + 'px'
	document.getElementById('EchoShadowDiv').style.left = parseInt(document.getElementById('echoDiv').style.left)  + 10 + 'px'
    document.getElementById('EchoShadowDiv').style.zIndex = document.getElementById('echoDiv').style.zIndex - 1
    document.images['EchoShadowImage'].style.width = parseInt(document.getElementById('echoDiv').offsetWidth) + 20 + 'px'
    document.images['EchoShadowImage'].style.height = parseInt(document.getElementById('echoDiv').offsetHeight) + 20 + 'px'
	document.getElementById('EchoShadowDiv').style.visibility='visible';

}

function CloseEcho(){
    document.getElementById('echoDiv').style.visibility = 'hidden';	
    document.getElementById('EchoShadowDiv').style.visibility='hidden';
}

function ShowOverlay(OverlayMessage){
    PageOverlay
    document.getElementById('PageOverlay').innerHTML = OverlayMessage
    document.getElementById('PageOverlay').style.top = '0px';
    document.getElementById('PageOverlay').style.left = '0px';
    document.getElementById('PageOverlay').style.height = parseInt(screen.availHeight) + parseInt(document.body.scrollTop) + 'px';
    document.getElementById('PageOverlay').style.width = parseInt(screen.availWidth) + parseInt(document.body.scrollLeft) + 'px';
    document.getElementById('PageOverlay').style.visibility = 'visible';

}

function HideOverlay(){
    document.getElementById('PageOverlay').style.visibility = 'hidden';
}
//_________________________________________________________________
function XMLRequest(TargetURL,PostValue,MultipartBoundary){
	if(MultipartBoundary==null){MultipartBoundary = "";}
	if (window.XMLHttpRequest) {
		if(PostValue==undefined){PostValue=null;}
		xmlhttp = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		if(PostValue==undefined){PostValue=null;}
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}

	if(PostValue!=null && PostValue!=0){
		xmlhttp.open("POST", TargetURL, false);
		if(MultipartBoundary.length>0){xmlhttp.setRequestHeader("Content-Type","multipart/form-data, boundary="+MultipartBoundary);}
		else{xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");}
		xmlhttp.setRequestHeader("Content-Length", PostValue.length);
		xmlhttp.setRequestHeader("Connection", "close");
	}
	else{
		xmlhttp.open("GET", TargetURL, false);
		xmlhttp.setRequestHeader("Content-Length", '0');
	}


	xmlhttp.send(PostValue);
	if(xmlhttp.ResponseText){ ReturnText = xmlhttp.ResponseText.toString(); }
	else{ReturnText = xmlhttp.responseText.toString();}

	if(ReturnText.indexOf('The system cannot find the file specified.') > -1){
		while(ReturnText.indexOf('The system cannot find the file specified.') > -1){
			xmlhttp.send(PostValue);
			if(xmlhttp.ResponseText){ ReturnText = xmlhttp.ResponseText.toString(); }
			else{ReturnText = xmlhttp.responseText.toString();}
		}
	}

	return ReturnText
}

//_________________________________________________________________
function findPosX(obj)
{
    var curleft = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x){curleft += obj.x;}
    return curleft;
}

//_________________________________________________________________
function findPosY(obj)
{
    var curtop = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y){curtop += obj.y;}
    return curtop;
}

//_________________________________________________________________
function GetLocation(TargetLocation,IsNewWindow){
    if(IsNewWindow==1){window.open(TargetLocation,'window2','width=700,height=580');}
    else{document.location.href=TargetLocation}
}

function ClearMessage(){
	document.getElementById('MessageDiv').innerHTML = "";
}

//_________________________________________________________________
function ShowHelp(){
	CurrentContent = document.getElementById('HelpDiv').innerHTML
	if (CurrentContent==''){document.getElementById('HelpDiv').style.width=360;	document.getElementById('HelpDiv').innerHTML = HelpText;}
	else{document.getElementById('HelpDiv').innerHTML = ''; document.getElementById('HelpDiv').style.width=1;}
}

function CheckNumeric(CallingField){
	if(isNaN(CallingField.value) || CallingField.value.indexOf('.')!=-1){
		alert('Please enter only numbers into this field')
		while((isNaN(CallingField.value) || CallingField.value.indexOf('.')!=-1) && CallingField.value!=''){
			CallingField.value = CallingField.value.substring(0,CallingField.value.length-1)
		}
	}
}

function ShowFullImage(ImagePath){
    ShowOverlay('<table style="width:100%;height:100%;"><tr><td  style="width:100%;height:100%;vertical-align:center;text-align:center;"><img src="images/' + ImagePath + '"><br><a href="javascript:HideOverlay();">[Close]</a></td></tr></table>');
}

function GetObj(TargetObj){
    if(!ObjExist(TargetObj)){return false;}
    try{
        TmpObj = document.getElementById(TargetObj);
    }
    catch(e){return false;}
    return TmpObj;
}

function ObjExist(TargetObj){
    if(document.getElementById(TargetObj)){return true;}
    else{return false;}
}

function ShowAllDivs(){
    DivList = document.getElementsByTagName('div')
    for(j=0;j<DivList.length;++j){
        DivList[j].innerHTML = DivList[j].className + '<br>' + DivList[j].innerHTML
        DivList[j].style.borderWidth='1px';
        DivList[j].style.borderStyle='solid';
        DivList[j].style.borderColor='black';
        DivList[j].style.visibility='visible';
    }
}