﻿function printContent(strid) {
    var prtContent = document.getElementById(strid);
    var WinPrint =
        window.open('', '', 'left=0,top=0,width=1,height=1,t oolbar=0,scrollbars=0,status=0');
    WinPrint.document.write("<html><head><link rel='stylesheet' type='text/css' href='GeneralStyleSheet.css' /></head><body>" + prtContent.innerHTML + "</body></html>");

    WinPrint.document.close();
    WinPrint.focus();
    WinPrint.print();
    WinPrint.close();
}
function SetTextValue(obj, TextToSet) {
    if (obj.value == "") {
        obj.value = TextToSet;
    }
}

function RemoveTextValue(obj, TextToCompare) {
    if (obj.value == TextToCompare) {
        obj.value = "";
    }
}


/******************** Document Types Control *************************/

function onDocTypeCBoxClick(cBoxObj) {
    selectAllCBoxes(cBoxObj.parentNode.parentNode, cBoxObj.checked, cBoxObj);
    if (cBoxObj.checked) {
        
        selectParents(cBoxObj);
    } else {
        deselectParents(cBoxObj);
     }
    
}
function selectAllCBoxes(obj, checked, rootObj) {
    for (var i = 0; i < obj.childNodes.length; i++) {
        if (obj.childNodes[i] != rootObj && obj.childNodes[i].checked != null) {
            //obj.childNodes[i].disabled = !checked;
            obj.childNodes[i].checked = checked;
        }
        selectAllCBoxes(obj.childNodes[i], checked, rootObj);
    }
}
function selectParents(cBoxObj) {
    if (cBoxObj.parentNode.parentNode.parentNode.getAttribute("id") == "docTypeFilterContainer")
        return
    
    var parent = getParentCBox(cBoxObj);
    parent.checked = true;
    selectParents(parent);

}
function deselectParents(cBoxObj) {
    if (cBoxObj.parentNode.parentNode.parentNode.getAttribute("id") == "docTypeFilterContainer")
        return
    if(allDeselected(cBoxObj.parentNode.parentNode.parentNode)){
        var parentCBox = getParentCBox(cBoxObj);
        parentCBox.checked = false;
        deselectParents(parentCBox);
    }
    
}
function allDeselected(obj) {
    if (obj.tagName != null && obj.tagName.toLowerCase() == "input" && obj.getAttribute("type").toLowerCase() == "checkbox") {
        if (obj.checked)
            return false;
    }
    for (var i = 0; i < obj.childNodes.length; i++) {
        if (!allDeselected(obj.childNodes[i])) {
            return false;
        }
    }
    return true;
}
function getParentCBox(child){
    return child.parentNode.parentNode.parentNode.parentNode.firstChild.firstChild;
}
/******************** End of Document Types Control ******************/

/************************** Navigation Tabs **************************/
var curObjectID;
var ddfocus_Array = new Array();

function setBlur(obj) {
    ddfocus_Array.push(obj);
}

document.onclick = function(e) {
for (var i = 0; i < ddfocus_Array.length; i++) {
        if (clickedOutsideElement(ddfocus_Array[i].id, e)) ddLostFocus(ddfocus_Array[i]);
    }
}

function clickedOutsideElement(elemId, e) {
    evt = e || window.event
    var theElem = getEventTarget(evt);

    while (theElem != null) {
        if (theElem.id == elemId)
            return false;
        theElem = theElem.offsetParent;
    }
    return true;
}

function getEventTarget(evt) {
    var targ = (evt.target) ? evt.target : evt.srcElement;

    if (targ != null) {
        if (targ.nodeType == 3)
            targ = targ.parentNode;
    }
    return targ;
}

function ddLostFocus(obj) {
    obj.style.display = "none"
    obj.style.visibility = "hidden"
    try {
        hideElementByID(curObjectID);
    }
    catch (Error)
    { }
    updateFocusArray(obj);
}

function updateFocusArray(obj) {
    for (var i = 0; i < ddfocus_Array.length; i++) {
        if (ddfocus_Array[i] == obj) {
            ddfocus_Array.splice(i, 1);
        }
    }
}

function callNavigation(tabID) {
    curObjectID = tabID;
    setTimeout('openPullDown()', 100)
}

    function openPullDown() {
        setBlur(document.getElementById('divPullDown' + curObjectID));
        showElementByID('divPullDown' + curObjectID);
        curObjectID = 'divPullDown' + curObjectID;
     }

     function showElementByID(element_id) {
    if (document.getElementById && document.getElementById(element_id) && document.getElementById(element_id).style) {
        document.getElementById(element_id).style.visibility = "visible";
        document.getElementById(element_id).style.display = "";
        //document.getElementById(element_id).style.left = "10px";
        setNavPullDownValue("1");
        
    }
}

function hideElementByID(element_id) {
    if (document.getElementById && document.getElementById(element_id) && document.getElementById(element_id).style) {
        document.getElementById(element_id).style.visibility = "hidden";
        document.getElementById(element_id).style.display = "none";
        setNavPullDownValue("0");
    }

}
/********************* End of Navigation Tabs ************************/
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

function trackClick(AdName, PageID, AdURL) {
    try {
        pageTracker._trackEvent('AdClick', '' + AdName + '', '' + PageID + '');
        window.location = AdURL;
    } catch (e) { }
}