﻿function forceEnter(ID, event) {
    if (event && event.keyCode == 13) {
        document.getElementById(ID).click();
        event.returnValue = false;
        return false;
    }
    return true;
}


jQuery(window).load(function() {
    if (!(jQuery.browser.msie && jQuery.browser.version == "6.0")) {
        jQuery(".CD_Content img, .CD_RightColumn img, #ND_MainNavigationHolder img, #Struct_FP_SpotsHolder img, .CD_FrontpageText img, .CD_FrontpageImage img, .LB_lightbox img").each(function(i) {
            var align = jQuery(this).attr('align');
            this.id = 'CorneredImage' + i;
            //pyr_cornerlib.add(this, { radius: 10 });
            pyr_corners.add(this, { xradius: "10", yradius: "10", corners: "1111" });
            if (align == 'right')
                jQuery('#CorneredImage' + i).css({ float: "right", padding: "3px 0 10px 10px" });
            else if (align == 'left')
                jQuery('#CorneredImage' + i).css({ float: "left", padding: "3px 10px 10px 0" });
        });
        jQuery('#ND_MainNavigationHolder ul li ul').css({ visibility: 'visible', display: 'none', zIndex: 5000 });
        
    }
    else {
        jQuery("#Struct_Page img[align='right']").css({ float: "right", padding: "3px 0 10px 10px" });
        jQuery("#Struct_Page img[align='left']").css({ float: "left", padding: "3px 10px 10px 0" });
    }
});

var timeout;
jQuery(document).ready(function() {
    if (jQuery.browser.msie && jQuery.browser.version == "6.0") {
        jQuery('#ND_MainNavigationHolder ul li ul').css({ visibility: 'visible', display: 'none', zIndex: 5000 });
    }
    jQuery('li.TopItem').hover(function() {
        if (jQuery(this).hasClass('Hover'))
            clearTimeout(timeout);
        else {
            clearTimeout(timeout);
            hideContext();
            jQuery(this).addClass('Hover');
        }
    }, function() {
        timeout = setTimeout('hideContext()', 100);
    });

    jQuery('li.Hover ul').mouseenter(function() {
        clearTimeout(timeout);
    });
    jQuery('li.Hover ul').mouseleave(function() {
        timeout = setTimeout('hideContext()', 100);
    });
    hideContext = function() {
        jQuery('li.Hover').removeClass('Hover');
    }
});







/**
* Synchronously load the XML document at the specified URL and
* return it as a Document object
*/
//XML.load = function(url) 
function loadDoc(url) {
    // Create a new document with the previously defined function
    var xmldoc = new newDocument(url);
    return xmldoc;         // Return the document
};

/**
* Create a new Document object. If no arguments are specified,
* the document will be empty. If a root tag is specified, the document
* will contain that single root tag. If the root tag has a namespace
* prefix, the second argument must specify the URL that identifies the
*namespace.
*/
//XML.newDocument = function(rootTagName, namespaceURL) 
function newDocument(url) {
    try {

        if (window.ActiveXObject) {
            var errorHappendHere = "Check Browser and security settings";
            xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
            xmlDoc.async = false;
            xmlDoc.load(url);
            return xmlDoc
        }
        else if (window.XMLHttpRequest) {
            var errorHappendHere = "Error handling XMLHttpRequest request";
            var d = new XMLHttpRequest();
            d.open("GET", url, false);
            d.send(null);
            xmlDoc = d.responseXML;
            return xmlDoc;
        }
        else (document.implementation && document.implementation.createDocument)
        {
            // This is the W3C standard way to do it
            var errorHappendHere = "Error.";
            xmlDoc = document.implementation.createDocument("", "", null);
            xmlDoc.async = false;
            xmlDoc.load(url);

        }
    }
    catch (e) {
        alert(errorHappendHere);
    }
};
