//document.execCommand('BackgroundImageCache', false, true);

if(typeof(Menu_HideItems) != "undefined")
{
var oldMenu_HideItems = Menu_HideItems;
	
if(oldMenu_HideItems)
{
	Menu_HideItems = function(items){
	if (!items || ((typeof(items.tagName) == "undefined") && (items instanceof Event))) { items = __rootMenuItem; }
	if(items && items.rows && items.rows.length == 0){ items.insertRow(0); }
		return oldMenu_HideItems(items);
	} 
}
}

//used for the admin menu left 
var type = "IE";	//Variable used to hold the browser name

//detects the capabilities of the browser
function BrowserSniffer() {
	if (navigator.userAgent.indexOf("Opera")!=-1 && document.getElementById) type="OP";		//Opera
	else if (document.all) type="IE";														//Internet Explorer e.g. IE4 upwards
	else if (document.layers) type="NN";													//Netscape Communicator 4
	else if (!document.all && document.getElementById) type="MO";							//Mozila e.g. Netscape 6 upwards
	else type = "IE";		//I assume it will not get here
}

//Show and hide a layer
//id is the name of the layer
//action is either hidden or visible
//Seems to work with all versions NN4 plus other browsers
var visibleElementId;
function ShowLayer(id, action){
//alert(id)
    if(action=='visible')
    {
        if(visibleElementId && id!=visibleElementId)
        {
            ShowLayer(visibleElementId,'hidden');
        }
        visibleElementId=id;
    }
    else if(action=='hidden')
    {
        if(visibleElementId && id==visibleElementId)
        {
            visibleElementId=null;
        }
    }

//	if (type=="IE") eval("document.all." + id + ".style.visibility='" + action + "'");
//	if (type=="NN") eval("document." + id + ".visibility='" + action + "'");
//	if (type=="MO" || type=="OP") eval("document.getElementById('" + id + "').style.visibility='" + action + "'");
    
//    eval("document.getElementById('" + id + "').style.visibility='" + action + "'");
//alert($get(id))
//alert($get(id).style.visibility)
    if($get(id)!=null)
        $get(id).style.visibility=action;
}
function ShowLayerDelay(id, action, delaySeconds){
//alert(id)
    if(action=='visible')
    {
        if(visibleElementId && id!=visibleElementId)
        {
            ShowLayer(visibleElementId,'hidden');
        }
        visibleElementId=id;
    }
    else if(action=='hidden')
    {
        if(visibleElementId && id==visibleElementId)
        {
            visibleElementId=null;
        }
    }

//	if (type=="IE") eval("document.all." + id + ".style.visibility='" + action + "'");
//	if (type=="NN") eval("document." + id + ".visibility='" + action + "'");
//	if (type=="MO" || type=="OP") eval("document.getElementById('" + id + "').style.visibility='" + action + "'");
    
//    eval("document.getElementById('" + id + "').style.visibility='" + action + "'");
//alert($get(id))
//alert($get(id).style.visibility)
    window.setTimeout("SetVisibility('"+id+"','"+action+"');",delaySeconds);
}
function SetVisibility(id,action)
{
    if($get(id)!=null)
        $get(id).style.visibility=action;
}

//scroller
function findPosition( oElement ) {
  if( typeof( oElement.offsetParent ) != 'undefined' ) {
    for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {
      posX += oElement.offsetLeft;
      posY += oElement.offsetTop;
    }
    return [ posX, posY ];
  } else {
    return [ oElement.x, oElement.y ];
  }
}

//THIS FUNCTION IS NOT USED COUSE IT IS WRITTEN AS A STARTUP SCRIPT IN THE LOAD EVENT ON THE MENU USER CONTROL.
//function PrepareScrollingMenu(menuId,btnLeftId,btnRightId,rectWidth)
//{
////    if(action == 'start')
//  //  {
//  alert("inside");
//    var menu, btnLeft, btnRight;
//    if (type=="IE"){
//        menu = eval("document.all." + menuId);
//        btnLeft = eval("document.all." + btnLeftId);
//        btnRight = eval("document.all." + btnRightId);
//    }
//    if (type=="NN"){
//        menu = eval("document." + menuId);
//        btnLeft = eval("document." + btnLeftId);    
//        btnRight = eval("document." + btnRightId);    
//    }
//    if (type=="MO" || type=="OP"){
//        menu = eval("document.getElementById('" + menuId + "')");
//        btnLeft = eval("document.getElementById('" + btnLeftId + "')");
//        btnRight = eval("document.getElementById('" + btnRightId + "')");
//    }
//    
//    if((menu == null) || (btnLeft == null) || (btnRight == null)) return;
//    
//    var locationXY, menuX = 0, menuY = 0;
//    var locationbtnLeft, btnLeftX = 0, btnLeftY = 0;
//    var locationbtnRight, btnRightX = 0, btnRightY = 0;
//    locationXY = findPosition(menu);
//    locationbtnLeft = findPosition(btnLeft);
//    locationbtnRight = findPosition(btnRight);

//    if(locationXY != null)
//    {
//        menuX = locationXY[0];
//        menuY = locationXY[1];
//    }
//    if(locationbtnLeft != null)
//    {
//        btnLeftX = locationbtnLeft[0];
//        btnLeftY = locationbtnLeft[1];
//    }
//    if(locationbtnRight != null)
//    {
//        btnRightX = locationbtnRight[0];
//        btnRightY = locationbtnRight[1];
//    }
//    
//    //clip: rect([top] [right] [bottom] [left])

//    btnLeft.style.position = 'absolute';
//    btnLeft.style.top = btnLeftY;
//    btnLeft.style.left = btnLeftX;
//    
//    btnRight.style.position = 'absolute';
//    btnRight.style.top = btnRightY;
//    btnRight.style.left = menuX*1 + rectWidth*1 + 3;        //multiply by 1 to make the strings numbers so we can add them.

////    alert(menu.length);
//    menu.style.position = 'absolute';
//    menu.style.top = menuY;
//    menu.style.left = menuX;
//    menu.style.clip = 'rect(0 ' + rectWidth + ' ' + '20' + ' 0)';
//}


////    s = window.setInterval("StartScroll()", interval);   
////    }
////    else if(action == 'stop')
////    {
////    window.clearInterval(s);
////    }

    //scrolling interval handler [s]
    var s;
function StartScroll(menuId, direction, interval, clipWidth)
{
    if (type=="IE"){
        menu = eval("document.all." + menuId);
    }
    if (type=="NN"){
        menu = eval("document." + menuId);
    }
    if (type=="MO" || type=="OP"){
        menu = eval("document.getElementById('" + menuId + "')");
    }
 
    if(menu == null || direction == null || interval == null) return;
    
    s = window.setInterval("Scroll('" + menuId + "','" + direction + "','" + clipWidth + "')", interval);
    
}
var disp = 0;
function Scroll(menuId,direction,clipWidth)
{
    if (type=="IE"){
        menu = eval("document.all." + menuId);
    }
    if (type=="NN"){
        menu = eval("document." + menuId);
    }
    if (type=="MO" || type=="OP"){
        menu = eval("document.getElementById('" + menuId + "')");
    }
    var locationXY = findPosition(menu);

    if(menu == null || direction == null) 
    {
        window.clearInterval(s);
    }
    else
    {
        var leftPX = locationXY[0];
        if(direction == 'left')
        {
            if(disp > 0)
            {    
               leftPX =  locationXY[0]*1 + 1;
                disp--;
            }
        }
        else if(direction == 'right')
        {
            if((menu.offsetWidth) && (menu.offsetWidth > (disp + clipWidth*1)))
            {
                leftPX =  locationXY[0]*1 - 1;
                disp++;
            }
        }
        else
        { 
            window.clearInterval(s);
            return;
        }
            
        menu.style.left = leftPX + "px";
        var newRight = disp*1 + clipWidth*1;
        var newLeft = disp*1 + 3;

        if(menu.offsetHeight)
            menu.style.clip = "rect(0 " + newRight + " " + menu.offsetHeight + " " + newLeft + ")";
        else
            menu.style.clip = "rect(0 " + newRight + " 20 " + newLeft + ")";
    }
}
//function resize(){  
//var frame = document.getElementById("chatTable");  
//var htmlheight = document.body.parentNode.scrollHeight;  
//var windowheight = (typeof window.innerHeight != 'undefined' ? window.innerHeight : document.body.offsetHeight);
//if ( htmlheight < windowheight ) { document.body.style.height = windowheight + "px"; frame.style.height = windowheight + "px"; }  
//else { document.body.style.height = htmlheight + "px"; frame.style.height = htmlheight + "px"; }  
//} 
function postbackOnCheck(e) 
{ 
    var isNav = (window.navigator.appName.toLowerCase().indexOf("netscape")>=0); 
    var o; 
    if (isNav && e != null) 
        o = e.target; 
    else 
        o = window.event.srcElement; 
    if (o.tagName == 'INPUT' && o.type == 'checkbox' && o.name != null && o.name.indexOf('CheckBox') > -1) 
        __doPostBack("",""); 
}
//var PullForChatRequestsTimer = "";
//function startTimers()
//{
//    PullForChatRequestsTimer = window.setInterval("JSPullForChatRequests()",3000);
//}
//function JSPullForChatRequests()
//{
//    PageMethods.PullForChatRequests(PopUpChatWindow, errorCallback);
//}
//function PopUpChatWindow(result)
//{
//    if(result!=null)
//    {   
//        window.open(result);
//    }
//}
//function onload()
//{
//    startTimers();
//}
//function errorCallback(result)
//{
//    alert("An error occurred while invoking the remote method: " + result);
//}
function PositionHelpPanel(HelpPanelId,ReferenceElementId)
{
    var HP = document.getElementById(HelpPanelId);
//    var RE = document.getElementById(ReferenceElementId);
////    if(HP!="undefined" && RE!="undefined")
//    {
    HP.style.left="100px";
//    }
////HP.style.width="500px";
//HP.align="left";
////alert(HP.innerHTML.length);
//HP.style.width = screen.availWidth/2;//-document.body.clientWidth;
//HP.style.left = screen.availWidth/3;
////    if(screen.availWidth<HP.style.left+HP.style.width)
////        HP.style.left=screen.width-HP.style.width;
////alert(document.documentElement.clientWidth);
////alert(screen.availWidth-document.documentElement.clientWidth);
}
function getPosition(e) {
    e = e || window.event;
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } 
    else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
    return cursor;
}
var BlinkInterval = 30000;
var BlinkTimer = window.setInterval("UserOnLineBlink()",BlinkInterval);

//Blink
function UserOnLineBlink()
{
    try
    {
        PageMethods.UserOnLineBlink(SetTimerInterval, errorCallback);
    }
    catch(err)
    {
    }
}
function SetTimerInterval(result)
{
    var newValue = parseInt(result);
    if(newValue <= 0)
    {
        clearInterval(BlinkTimer);
    }
    else if(BlinkInterval != newValue)
    {
        BlinkInterval = newValue;
        clearInterval(BlinkTimer);
        BlinkTimer = window.setInterval("UserOnLineBlink()",BlinkInterval);
    }
}
function errorCallback(result)
{
//    alert("An error occurred while invoking the remote method: " + result);
}

////for dropdown selection while typing
////add the following to the dropdown tag:
//// onKeyup="TrapKey(this, this.event)"
//function clearWord()
//{
//userWord = "";
//document.forms[0].result.value = ""; 
//}
//var userWord = "";
//function TrapKey(obj, e)
//{
//thekey = String.fromCharCode(event.keyCode);
//userWord += thekey;
//for (var i = 0; i < obj.options.length; i++) {
//var txt = obj.options[i].text.toUpperCase();
//document.forms[0].result.value = userWord; 
//if (txt.indexOf(userWord) == 0) {
//obj.options[i].selected = true;
//obj.options[i].focus();
//break;
//}
//}
//setTimeout("clearWord()", 3000)
//}

function CallPrint(strid)
{
var prtContent = document.getElementById(strid);
var WinPrint = window.open('','','letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
WinPrint.document.write(strid.innerHTML);
//WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
//WinPrint.close();
// prtContent.innerHTML = strOldOne;
}

////clean MSWord tags from the RichText Editor
//function CleanWordHTML( str )
//{
//str = str.replace(/<o:p>\s*<\/o:p>/g, "") ;
//str = str.replace(/<o:p>.*?<\/o:p>/g, "&nbsp;") ;
//str = str.replace( /\s*mso-[^:]+:[^;"]+;?/gi, "" ) ;
//str = str.replace( /\s*MARGIN: 0cm 0cm 0pt\s*;/gi, "" ) ;
//str = str.replace( /\s*MARGIN: 0cm 0cm 0pt\s*"/gi, "\"" ) ;
//str = str.replace( /\s*TEXT-INDENT: 0cm\s*;/gi, "" ) ;
//str = str.replace( /\s*TEXT-INDENT: 0cm\s*"/gi, "\"" ) ;
//str = str.replace( /\s*TEXT-ALIGN: [^\s;]+;?"/gi, "\"" ) ;
//str = str.replace( /\s*PAGE-BREAK-BEFORE: [^\s;]+;?"/gi, "\"" ) ;
//str = str.replace( /\s*FONT-VARIANT: [^\s;]+;?"/gi, "\"" ) ;
//str = str.replace( /\s*tab-stops:[^;"]*;?/gi, "" ) ;
//str = str.replace( /\s*tab-stops:[^"]*/gi, "" ) ;
//str = str.replace( /\s*face="[^"]*"/gi, "" ) ;
//str = str.replace( /\s*face=[^ >]*/gi, "" ) ;
//str = str.replace( /\s*FONT-FAMILY:[^;"]*;?/gi, "" ) ;
//str = str.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
//str = str.replace( /<(\w[^>]*) style="([^\"]*)"([^>]*)/gi, "<$1$3" ) ;
//str = str.replace( /\s*style="\s*"/gi, '' ) ;
//str = str.replace( /<SPAN\s*[^>]*>\s*&nbsp;\s*<\/SPAN>/gi, '&nbsp;' ) ;
//str = str.replace( /<SPAN\s*[^>]*><\/SPAN>/gi, '' ) ;
//str = str.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
//str = str.replace( /<SPAN\s*>(.*?)<\/SPAN>/gi, '$1' ) ;
//str = str.replace( /<FONT\s*>(.*?)<\/FONT>/gi, '$1' ) ;
//str = str.replace(/<\\?\?xml[^>]*>/gi, "") ;
//str = str.replace(/<\/?\w+:[^>]*>/gi, "") ;
//str = str.replace( /<H\d>\s*<\/H\d>/gi, '' ) ;
//str = str.replace( /<H1([^>]*)>/gi, '' ) ;
//str = str.replace( /<H2([^>]*)>/gi, '' ) ;
//str = str.replace( /<H3([^>]*)>/gi, '' ) ;
//str = str.replace( /<H4([^>]*)>/gi, '' ) ;
//str = str.replace( /<H5([^>]*)>/gi, '' ) ;
//str = str.replace( /<H6([^>]*)>/gi, '' ) ;
//str = str.replace( /<\/H\d>/gi, '<br>' ) ; //remove this to take out breaks where Heading tags were
//str = str.replace( /<(U|I|STRIKE)>&nbsp;<\/\1>/g, '&nbsp;' ) ;
//str = str.replace( /<(B|b)>&nbsp;<\/\b|B>/g, '' ) ;
//str = str.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
//str = str.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
//str = str.replace( /<([^\s>]+)[^>]*>\s*<\/\1>/g, '' ) ;
////some RegEx code for the picky browsers
//var re = new RegExp("(<P)([^>]*>.*?)(<\/P>)","gi") ;
//str = str.replace( re, "<div$2</div>" ) ;
//var re2 = new RegExp("(<font|<FONT)([^*>]*>.*?)(<\/FONT>|<\/font>)","gi") ;
//str = str.replace( re2, "<div$2</div>") ;
//str = str.replace( /size|SIZE = ([\d]{1})/g, '' ) ;

//return str ;
//}

function UpdateDislayInSeconds(ControlClientID, NewDisplayState, Seconds)
{
    alert(ControlClientID+" - "+NewDisplayState+" - "+ Seconds)
    window.setTimeout("UpdateDislay(" + ControlClientID + ", " + NewDisplayState + ")",0);

}
function UpdateDislay(ControlClientID, NewDisplayState)
{
alert(ControlClientID+" - "+NewDisplayState)
    document.getElementById(ControlClientID).style.visibility=NewDisplayState;
}

