﻿// JScript File

function selectAll() {
     
    var theForm = document.forms[0], z = 0;
    
    for(z=0; z<theForm.length;z++){
        if(theForm[z].type == 'checkbox' &&( !theForm[z].disabled)){
            theForm[z].checked = true ;
        }
    }
    
    return false;
}

function clearAll() {
 
    var theForm = document.forms[0], z = 0;
    
    for(z=0; z<theForm.length;z++)
    {
        if(theForm[z].type == 'checkbox' &&( !theForm[z].disabled)){
            theForm[z].checked = false;
        }
    }
    
    return false;
}
    
    
    
    
//////////////////////////////////////////////////////////  
// Search result popup/tooltip code
//////////////////////////////////////////////////////////     
var nOffsetX=10;
var nOffsetY=20;
var objPopupWindowDiv;

//Detect browser type
var ns4=document.layers
var ns6=document.getElementById&&!document.all
var ie=document.all

//Set objPopupWindowDiv depending on browser type
if (ns4) 
    objPopupWindowDiv=document.popupWindowDiv
else if (ns6) 
    objPopupWindowDiv=document.getElementById("popupWindowDiv").style
else if (ie) 
    objPopupWindowDiv=document.all.popupWindowDiv.style

//Initialise display    
if (ns4) 
    document.captureEvents(Event.MOUSEMOVE);
else {
    objPopupWindowDiv.visibility="visible"
    objPopupWindowDiv.display="none"        
}

//Set mouse move handler
document.onmousemove = getMousePos;

function showPopupWindow(strText, strUniqueID){
    var content = "<div class=PopupWindow>" + strText + "</div>";
    var bWindowChanged = true;
    
    if (ns4) {
        objPopupWindowDiv.document.write(content);
        objPopupWindowDiv.document.close();
        objPopupWindowDiv.visibility = "visible"
    }
    else if (ns6) {
        document.getElementById("popupWindowDiv").innerHTML = content;
        objPopupWindowDiv.display = ''
        
        bWindowChanged = (document.getElementById("popupWindowDiv").getAttribute("ActivePopup") != strUniqueID);
        document.getElementById("popupWindowDiv").setAttribute("ActivePopup", strUniqueID);
    }
    else {
        document.all("popupWindowDiv").innerHTML = content;
        objPopupWindowDiv.display = '';   
        
        bWindowChanged = (objPopupWindowDiv.getAttribute("ActivePopup") != strUniqueID);
        objPopupWindowDiv.setAttribute("ActivePopup", strUniqueID);
    }
    
    if (bWindowChanged)
        window.setTimeout('hidePopupWindowNow(\'' + strUniqueID + '\')', 10000);  
}

function hidePopupWindow(strUniqueID){

    var strCurrentWindow = '';
    
    if (ns4) {
        strCurrentWindow = strUniqueID;
    }
    else if (ns6) {
        strCurrentWindow = document.getElementById("popupWindowDiv").getAttribute("ActivePopup");
    }
    else {
        strCurrentWindow = objPopupWindowDiv.getAttribute("ActivePopup");
    }
    
    if (strCurrentWindow == strUniqueID)
    { 
        window.setTimeout('hidePopupWindowNow(\'' + strUniqueID + '\')', 1000);    
    }
}

function hidePopupWindowNow(strUniqueID){

    //Get current window again as may have changed since timer was started
    var strCurrentWindow = '';
    
    if (ns4) {
        strCurrentWindow = strUniqueID;
    }
    else if (ns6) {
        strCurrentWindow = document.getElementById("popupWindowDiv").getAttribute("ActivePopup");
    }
    else {
        strCurrentWindow = objPopupWindowDiv.getAttribute("ActivePopup");
    }

    if (strCurrentWindow == strUniqueID)
    { 
        if (ns4) {
            objPopupWindowDiv.visibility = "hidden";
        }
        else if (ns6) {    
            document.getElementById("popupWindowDiv").setAttribute("ActivePopup", '');
            objPopupWindowDiv.display="none";
        }
        else {
            objPopupWindowDiv.setAttribute("ActivePopup", '');
            objPopupWindowDiv.display="none";
        }
    }
}

function getMousePos(e){
    var x, y
    
    if (ns4 || ns6) {
        x = e.pageX
        y = e.pageY
    }
    else {
        x = event.x+document.body.scrollLeft;
        y = event.y+document.body.scrollTop
    }
    
    objPopupWindowDiv.left = (x + nOffsetX + 'px');
    objPopupWindowDiv.top = (y + nOffsetY + 'px');
}

