﻿$(document).ready(
        function() {
            var path = location.pathname.substring(1);
            if (!path) path = "default.aspx";
            if (path) {

                $('#leftsidebar a[href$="' + path + '"]')
                    .prepend('<img tag="" src="images/pp_icon4-sb.png" width="25" height="25" class="navlogosidebar" />')
                    .parents()
                    .addClass('current');
                $('#footer a[href$="' + path + '"]')
                    .addClass('current')
                    .prepend('<img tag="" src="images/pp_icon4-f.png" width="15" height="15" class="navlogofooter" />');
            }
        });


//function extractPageName(hrefString) {

//    var arr = hrefString.split('/');
//    if (arr[3] == "") arr[3] = "default.aspx"; 
//    return (arr.length < 2) ? hrefString : arr[arr.length - 2].toLowerCase() + arr[arr.length - 1].toLowerCase();
//    
//}

//function setActiveMenu(arr, crtPage) {

//    for (var i = 0; i < arr.length; i++) {
//        if (extractPageName(arr[i].href) == crtPage) {
//                arr[i].className = "current";
//                arr[i].parentNode.className = "current";
//        }
//    }
//}

//function setPage() {
//    hrefString = document.location.href ? document.location.href : document.location;
//    if (document.getElementById("leftsidebar") != null)
//        setActiveMenu(document.getElementById("leftsidebar").getElementsByTagName("a"), extractPageName(hrefString));
//    if (document.getElementById("footer") != null)
//        setActiveMenu(document.getElementById("footernav").getElementsByTagName("a"), extractPageName(hrefString));        
//}


        // --------------Silverlight-------------------------
        function onSilverlightError(sender, args) {

            var appSource = "";
            if (sender != null && sender != 0) {
                appSource = sender.getHost().Source;
            }
            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;

            var errMsg = "Unhandled Error in Silverlight Application " + appSource + "\n";

            errMsg += "Code: " + iErrorCode + "    \n";
            errMsg += "Category: " + errorType + "       \n";
            errMsg += "Message: " + args.ErrorMessage + "     \n";

            if (errorType == "ParserError") {
                errMsg += "File: " + args.xamlFile + "     \n";
                errMsg += "Line: " + args.lineNumber + "     \n";
                errMsg += "Position: " + args.charPosition + "     \n";
            }
            else if (errorType == "RuntimeError") {
                if (args.lineNumber != 0) {
                    errMsg += "Line: " + args.lineNumber + "     \n";
                    errMsg += "Position: " + args.charPosition + "     \n";
                }
                errMsg += "MethodName: " + args.methodName + "     \n";
            }

            throw new Error(errMsg);
        }

        function highlightDownloadArea(fOn) {
            document.getElementById("overlay").className = (fOn) ? "fadeSome" : "fadeLots";
        }

        function CloseWindow() {
            window.close();
        }


        // --------------End Silverlight-------------------------
