﻿if (typeof Namespace == 'undefined') { var Namespace = {}; } if (!Namespace.Manager) { Namespace.Manager = {}; } Namespace.Manager = { Register: function(ns) { ns = ns.split('.'); if (!window[ns[0]]) { window[ns[0]] = {}; } var fns = ns[0]; for (var i = 1; i < ns.length; i++) { fns += "." + ns[i]; eval("if(!window." + fns + ")window." + fns + "={};"); } } }

Namespace.Manager.Register('DD.Net.Page.Request');
DD.Net.Page.Request.Uri = document.URL;
function Depreciated(msg) {var m = msg ? msg : ''; alert('This object has been depreciated.\n\n' +m); }

/* Image Utility */
function newImage(arg) {
    if (document.images) {
        rslt = new Image();
        rslt.src = arg;
        return rslt;
    }
}

function changeImages() {
    if (document.images) {
        for (var i = 0; i < changeImages.arguments.length; i += 2) {
            document[changeImages.arguments[i]].src = changeImages.arguments[i + 1];
        }
    }
}
// pop up image in window
function imgPreview(imageURL) {
    if (document.getElementById && navigator.userAgent.toLowerCase().indexOf('opera') == -1) {

        var imgWin = openWin("", 'imgWin', 'width=300, height=250, left=100, top=100');

        with (imgWin.document) {
            writeln('<html><head><title>Loading...</title>');
            writeln('<style type="text/css"><!-- body { margin: 0px; } --></style></head>');
            //writeln('<body onload="self.focus();"><img id="pic" style="display:none" /></body></html>');
            writeln('<body><img id="pic" style="display:none"></body></html>');
            close();
        }

        var img = new Image();
        img.onload = function() { sizeImgWin(imgWin, img); };
        img.src = imageURL;
    }
    else
        openWin(imageURL, 'imagePreview');
}

function sizeImgWin(win, img) {
    var new_w = img.width;
    var new_h = img.height;
    var old_w = win.innerWidth || win.document.body.offsetWidth;
    var old_h = win.innerHeight || win.document.body.offsetHeight;

    if (!new_w) { new_w = old_w; }
    if (!new_h) { new_h = old_h; }

    new_w -= old_w; new_h -= old_h;
    win.resizeBy(new_w, new_h);
    //win.document.title = img.src.substring(img.src.lastIndexOf("/")+1);
    win.document.title = 'Preview Image';
    var pic = win.document.getElementById('pic');
    pic.src = img.src;
    pic.style.display = 'block';
    sw = screen.width;
    sh = screen.height;
    var leftPos = ((sw - new_w) / 2) - 100; // Exactly centered.
    var topPos = ((sh - new_h) / 2) - (100 + (((sh - new_h) / 2) * 0.1)); // Centered, then moved up 10%
    win.moveTo(leftPos, topPos);
}

/*******************************/

// open a new window
function openWin(url, name, options) {
    var w = window.open(url, name, options);
    return w;
}

// resizeing a window
function resizeWin(startSize, targetSize, moveX, finalX, finalY) {
    var x;
    if (startSize < targetSize) {
        for (x = startSize; x <= targetSize; x = x + moveX)
            window.resizeBy(moveX, 0);
    } else {
        for (x = startSize; x > targetSize; x = x - moveX)
            window.resizeBy(moveX, 0);
    }
    // finish this
    if (typeof (finalX) != "undefined")
        window.resizeTo(finalX, 450);
    if (typeof (finalY) != "undefined")
        window.resizeTo(finalX, finalY);
} // end of resize	

// Mouse Over Utilty functions
function mouseOverBg(obj, overcolor) { obj.style.background = overcolor; }
function mouseOutBg(obj, outcolor) { obj.style.background = outcolor; }
function mouseOverClass(obj, cssClass) { obj.className = cssClass; }
function mouseOutClass(obj, cssClass) { obj.className = cssClass; }
// end of Mouse over

function debugIt(obj, subobj, lev) {
    var str = new String();
    for (var item in obj) {
        str += item + ' == ' + escape(obj[item]) + ' <br>\n\r';
        if (subobj && (typeof (obj[item]) == 'object') && (lev < 4)) {
            str += '<blockquote>' + debugIt(obj[item], subobj, (lev + 1)) + '</blockquote>';
        }
    }
    return str;
}
function DebugObject(obj, debugPropObjects) { PrintPreview(debugIt(obj, debugPropObjects, 1)); }

// absorb the text and print it to the window
function PrintPreview(txt, print) {
    var html = new String();
    html = '<html><head>\n';
    //html += '<link href="'+ g_AppPath +'UI/css/print.css" media="print" rel="stylesheet" type="text/css" />'
    html = html.concat('<style>\n ');
    html = html.concat(' body{ font-family: verdana, arial; font-size: .9em; } \n');
    html = html.concat(' a { color:#000066; font-size: .7em; } \n ');
    html = html.concat(' .hidefromprinter{ display:none; visibility:hidden; } \n ');
    html = html.concat('</style>\n</head>\n');
    html = html.concat('<body>');
    html = html.concat('<div align="right">');
    html = html.concat('<a href="javascript:window.print();">');
    //html = html.concat( '<img src="' + IconPath + 'print.gif" border="0" alt="" title="Print" align="absmiddle" hspace="2"/>';
    html = html.concat('Send to Printer</a>');
    html = html.concat(' | '); // seperator
    html = html.concat('<a href="#" onclick="window.close();">');
    //html = html.concat( '<img src="' + IconPath + 'close.gif" border="0" alt="" title="Close Print Preview" align="absmiddle" hspace="2"/>';
    html = html.concat('Close Print Preview</a></div>');
    html = html.concat('<div>' + txt + '</div></body></html>');


    // open window and display the text from debugging the object
    var w = window.open('', 'Debugger', 'width=770,height=450,resizable=yes,scrollbars=yes,location=0,status=yes,menubar=0,toolbar=0');
    w.document.write(html);
    w.document.close();
}


/**********************  COOKIES **************************************** */
function Cookie() {
    this.Enabled = true;
    this.Message = "Cookies are accepted."
    // check cookies
    this.Test = function() {
        if (document.cookie != null) {
            document.cookie = "cookiettest=ok";  // cookies enabled?
            var CookieTest = document.cookie;
            if (CookieTest == "" || CookieTest.indexOf("cookietest") == -1) {
                this.Enabled = false;
                this.Message = "Please turn on cookies.";
            }
        }
        return this.Message;
    } // end of cookie checker

    /* Cookie tools */
    this.Add = function(name, value, days) {
        var expires = "";
        if (days) {
            var date = new Date();
            date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
            expires = "; expires=" + date.toGMTString();
        }
        // set the cookie up
        document.cookie = name + "=" + value + expires + "; path=/";
    }
    // gets the value from a Cookie
    this.Get = function(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') c = c.substring(1, c.length);
            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
        }
        return null;
    }
    // removes the cookies
    this.Delete = function(name) {
        this.Add(name, "", -1);
    }
} // end of Cookie object

var Cookies = new Cookie();

/* cookie tools */

/********************** END COOKIES **************************************** */


// detects the OS Version
function ClientOS() {
    var agt = navigator.userAgent.toLowerCase();
    var win = (agt.indexOf("win") != -1);

    this.Version = "";
    this.IsWin = true;
    this.IsMac = false;

    // windows 95 OS
    this.win95 = ((agt.indexOf("win95") != -1) || (agt.indexOf("windows 95") != -1));
    if (this.win95) this.Version = "Windows 95";

    // windows 98 OS
    this.win98 = ((agt.indexOf("win98") != -1) || (agt.indexOf("windows 98") != -1));
    if (this.win98) this.Version = "Windows 98";

    // windows NT
    this.winNT = ((agt.indexOf("winnt") != -1) || (agt.indexOf("windows nt") != -1));
    if (this.winNT) this.Version = "Windows NT/XP";

    // windows 2000
    this.win2000 = ((agt.indexOf("windows nt 5.0") != -1));
    if (this.win2000) this.Version = "Windows 2000";
    this.win32 = (this.win95 || this.winnt || this.win98 || this.win2000 || ((this.major >= 4) && (navigator.platform == "Win32")) || (agt.indexOf("win32") != -1) || (agt.indexOf("32bit") != -1));

    // macintosh
    this.mac = ((agt.indexOf("mac") != -1) || (agt.indexOf("Mac") != -1));
    //alert(this.mac);
    if (this.mac) { this.Version = "Macintosh"; this.IsMac = true; };
    return this.Version;
}
// end of OS Detection

// Determine browser and version.
function Browser() {
    var ua, s, i;
    this.isIE = false;
    this.isNS = false;
    this.version = null;

    ua = navigator.userAgent;

    s = "MSIE";
    if ((i = ua.indexOf(s)) >= 0) {
        this.isIE = true;
        this.version = parseFloat(ua.substr(i + s.length));
        return;
    }

    s = "Netscape6/";
    if ((i = ua.indexOf(s)) >= 0) {
        this.isNS = true;
        this.version = parseFloat(ua.substr(i + s.length));
        return;
    }

    // Treat any other "Gecko" browser as NS 6.1.
    s = "Gecko";
    if ((i = ua.indexOf(s)) >= 0) {
        this.isNS = true;
        this.version = 6.1;
        return;
    }
}

var browser = new Browser();

/*****************************************************************************************************/

var SHOW = (document.layers) ? 'show' : 'visible';
var HIDE = (document.layers) ? 'hide' : 'hidden';

// ******************** Objects for the Window **************************** //
function PreloadImage(src) {
    var img = new Image();
    img.src = src;
    return img;
}

function el(id) {
    if (document.getElementById) {
        // send back object
        return document.getElementById(id);
    } else if (document.layers) {
        // send back object
        return document.layers[id];
    } else if (document.all)
        return document.all(id);
}

// gets a reference to the style object
function elStyle(id) {
    var dom = el(id);

    if (document.layers)
        return dom;
    else
        return dom.style;
}

// displays the div on the page
function showEl(id) {
    var dom = elStyle(id);
    if (dom) {
        dom.visibility = SHOW;
        dom.display = '';
    }
    return false;
}

// hides the Element
function hideEl(id) {
    var dom = elStyle(id);
    if (dom) {
        dom.visibility = HIDE;
        dom.display = 'none';
    }
    return false;
}
// toggles the element
function toggleEl(id) {
    var dom = elStyle(id);
    if (dom) {
        var currentMode = dom.display;
        if (currentMode == 'none')
            showEl(id);
        else
            hideEl(id);
    }
    return false;
}

function toggleDivs(containerdiv) {
    var containerDiv = el(containerdiv);
    for (var x = 0; x < containerDiv.childNodes.length; x++) {
        if (containerDiv.childNodes[x].nodeType == 1)
            hideEl(containerDiv.childNodes[x].id);
    }

    if (toggleDivs.arguments.length > 1) {
        for (var s = 1; s < toggleDivs.arguments.length; s++) {
            showEl(toggleDivs.arguments[s]);
        }
    }
    
    return false;
}

function setHtml(id, html) {
    var obj = el(id);
    if (obj)
        try { obj.innerHTML = html; } catch (e) { alert('This HTML [' + id + '] element does not support innerHTML property'); }
}
// toggles the div
function toggleDiv(id) {
    return toggleEl(id);
}
// updates the innerHTML of a Div
function updateDiv(id, html) {
    setHtml(id, html);
}
// sets the value of the input
function setInputValue(id, v) {
    var input = el(id);
    if (input)
        try { input.value = v; } catch (e) { alert('This HTML [' + id + '] element does not support value property'); }
    }

function setCheckedValue(id, checked) { var chk = el(id); if (chk) { chk.checked = checked; } }
 
/*********************** Fading functions *************************************/
var FadeStateEnum = { 'Opaque': 2, 'Transparent': -2, 'FadingIn': 1, 'FadingOut': -1 };
var FadeTimeout = 5;

function fadeIn(id) {
    var o = el(id);
    if (o == null) { return; }
    if (o.style.display == 'none') { fadeEl(id); }
}


function fadeEl(id, to) {
    var element = el(id);
    if (element == null) { return; }
    if (element.style.display == 'none') { updateOpacity(element, 5); showEl(id); }
    if (element.FadeState == null) {
        element.FadeState = (element.style.opacity == null || element.style.opacity == '' || element.style.opacity == '1') ? FadeStateEnum.Opaque : FadeStateEnum.Transparent;
    }
    if (element.FadeState == FadeStateEnum.FadingIn || element.FadeState == FadeStateEnum.FadingOut) { return; }

    element.FadeState = (element.FadeState == FadeStateEnum.Opaque) ? FadeStateEnum.FadingOut : FadeStateEnum.FadingIn;
    element.Timer = (to) ? to : FadeTimeout;
    element.Timeouts = new Array();
    element.ClearTimeouts = function() { for (var i = 0; i < this.Timeouts.length; i++) { clearTimeout(element.Timeouts[i]); } }
    element.Timeouts.push(setTimeout('fader("' + id + '");', element.Timer));
}
function fader(id) {
    var element = el(id);
    // get the current value
    var opactity = element.OpacityValue;
    if (opactity == null || opactity == 0) {
        // we have no value, based on state select value
        opactity = (element.FadState == FadeStateEnum.FadingOut) ? 100 : 0.5;
    }
    var newOpactity = (element.FadeState == FadeStateEnum.FadingIn) ? opactity + 1 : opactity - 1;
    updateOpacity(element, newOpactity);
    if (newOpactity > 5 && newOpactity < 100) {
        element.Timeouts.push(setTimeout('fader("' + id + '");', element.Timer));
    } else {
        element.FadeState = (element.FadeState == FadeStateEnum.FadingIn) ? FadeStateEnum.Opaque : FadeStateEnum.Transparent;
        if (element.FadeState == FadeStateEnum.Transparent) { hideEl(element.id) }
        element.ClearTimeouts();
    }
}
function updateOpacity(obj, opacity) {
    opacity = (opacity == 100) ? 99.999 : opacity;
    // IE/Win
    obj.style.filter = "alpha(opacity:" + opacity + ")";
    var opacityValue = opacity / 100;
    // Safari<1.2, Konqueror
    obj.style.KHTMLOpacity = opacityValue;
    // Older Mozilla and Firefox
    obj.style.MozOpacity = opacityValue;
    // Safari 1.2, newer Firefox and Mozilla, CSS3
    obj.style.opacity = opacityValue;
    //set value in Object
    obj.OpacityValue = opacity;
}


/******************* Edn Fading Functions *****************************************/

function DropDownUtility() { }
DropDownUtility.prototype.SelectedItem = function(id) {
    var dd = el(id);
    return (dd) ? dd.options[dd.selectedIndex] : null;
}
DropDownUtility.prototype.SelectedValue = function(id) {
    var item = this.SelectedItem(id);
    return (item) ? item.value : null;
}
DropDownUtility.prototype.SelectedText = function(id) {
    var item = this.SelectedItem(id);
    return (item) ? item.text : null;
}
DropDownUtility.prototype.SetValue = function(id, value) {
    var dd = el(id);
    if (dd) {
        for (var i = 0; i < dd.options.length; i++) {
            if (dd.options[i].value == value) {
                dd.options[i].selected = true;
                return true;
            }
        }
    } // end of if
    return false;
}
// Setup Global object to work with DropDowns
var DropDowns = new DropDownUtility();

/* END functions to help with form elements */

// all common function for strings
if (!String.compare) {
    String.compare = function(s1, s2) {
        if (s1 == s2)
            return 0;

        if (s1 > s2)
            return 1;

        return -1;
    };
}

if (!String.isNullorEmpty) {
    String.isNullorEmpty = function(str) {
        return (str == null || str == "" || str.length == 0);
    }
}

if (!String.format) {
    String.format = function(text) {
        //check if there are two arguments in the arguments list
        if (arguments.length <= 1) { return text; }
        //decrement to move to the second argument in the array
        var tokenCount = arguments.length - 2;
        for (var token = 0; token <= tokenCount; token++) {
            //iterate through the tokens and replace their placeholders from the original text in order
            text = text.replace(new RegExp('\\{' + token + '\\}', 'gi'), arguments[token + 1]);
        }
        return text;
    };
}

function ReplaceVB(strSource, strFind, strReplace) {
    if (!(strSource))
        return strSource;

    var regExp = eval('/' + strFind + '/gi');
    var strReturn = strSource.replace(regExp, strReplace);
    return strReturn;
}

function updateTextBox(txtbox, message) {
    if (String.compare(txtbox.value, message) == 0) {
        element.value = '';
    } else if (element.value.length == 0) {
        element.value = message;
    }
}

// checks to see if the object exists in the array
Array.prototype.Contains = function(obj) {
    for (var i = 0; i < this.length; i++) {
        if (this[i] == obj)
            return true;
    }
    return false;
}
Array.prototype.Remove = function(obj) {
    var newArray = new Array();
    for (var i = 0; i < this.length; i++) {
        if (this[i] != obj)
            newArray.push(this[i]);
    }
    return newArray;
}

// *********************************************************************** //
// attachEvents to Objects
// *********************************************************************** //

// help function to add a window event
function addEventToElement(obj, eventName, func) {
    // check params
    if (!(obj && func && eventName))
        return null;
    // check the nameing of the event
    if (typeof window.attachEvent != "undefined") {
        eventName = 'on' + eventName;
    }
    // attach the event      
    if (typeof obj.addEventListener != "undefined") {
        obj.addEventListener(eventName, func, false);
    } else if (typeof obj.attachEvent != "undefined") {
        obj.attachEvent(eventName, func);
    } else { return null; }
    // everythign ok  
    return true;
}


// help function to add a window event
function addWindowEvent(eventName, func) {
    // ok add it
    return addEventToElement(window, eventName, func);
}


// helper function from: http://www.tek-tips.com/faqs.cfm?fid=4862
function addOnloadEvent(fnc) {
    var ret = addWindowEvent("load", fnc);
    if (!ret) {
        if (window.onload != null) {
            var oldOnload = window.onload;
            window.onload = function(e) {
                oldOnload(e);
                if (window[fnc])
                    window[fnc]();
            };
        } else {
            window.onload = fnc;
        }
    }
}
// put this on a text box to trigger form submit when enter key is hit
function EnterKeyDownEvent(e, fn) {
    e = (e) ? e : event;
    if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
        if (fn) {
            document.forms[0].onsubmit = function() { return false; }
            return fn(e);
        } else { document.forms[0].submit(); }
        return false;
    } else
        return true;
}
function toggleCheckBoxValue(chk) {
    if (chk) {
        chk.value = (chk.value == 'on') ? 'checked' : 'on';
    }
}
function GetClientInfo() {
    var w = 0;
    var h = 0;
    //IE
    if (!window.innerWidth) {
        //strict mode
        if (!(document.documentElement.clientWidth == 0)) {
            w = document.documentElement.clientWidth;
            h = document.documentElement.clientHeight;
        } else { //quirks mode
            w = document.body.clientWidth;
            h = document.body.clientHeight;
        }
    }
    //w3c
    else {
        w = window.innerWidth;
        h = window.innerHeight;
    }
    return { 'Width': w, 'Height': h };
}
function GetScrollInfo() {
    var offsetX = 0;
    var offsetY = 0;
    //IE
    if (!window.pageYOffset) {
        //strict mode
        if (!(document.documentElement.scrollTop == 0)) {
            offsetY = document.documentElement.scrollTop;
            offsetX = document.documentElement.scrollLeft;
        }
        //quirks mode
        else {
            offsetY = document.body.scrollTop;
            offsetX = document.body.scrollLeft;
        }
    } else { //w3c
        offsetX = window.pageXOffset;
        offsetY = window.pageYOffset;
    }
    return { Left: offsetX, Top: offsetY };
}
function GetClientCenter() {
    var args = (arguments[0] != null) ? arguments[0] : { Width: 0, Height: 0 };
    var _x = 0;
    var _y = 0;
    var _top = 0;
    var _left = 0;
    var scrollInfo = GetScrollInfo();
    var clientSize = GetClientInfo();
    
    var offsetX = scrollInfo.Left; 
    var offsetY = scrollInfo.Top;
        
    _x = ((clientSize.Width - args.Width) / 2) + offsetX;
    _y = ((clientSize.Height - args.Height) / 2) + offsetY;
    _top = _y + 'px';
    _left = _x + 'px';
    return { 'X': _x, 'Y': _y, 'Left': _left, 'Top': _top };
}
function centerEl(elem, isModal) {
    var xy = GetClientCenter({ 'Width': elem.offsetWidth, 'Height': elem.offsetHeight });
    elem.style.top = xy.Top;
    elem.style.left = xy.Left;
    if (isModal) {
        ModalDimmer.Show(elem);
    }
}
function parsePx(v) { var s = v; try { s = v.toString().toLowerCase(); } catch (e) { } return (s.indexOf('px') != -1 || s == 'auto') ? s : s + 'px'; }

function ShowLoader(divid, msg) {
    updateDiv(divid, AjaxLoaderImageTag + '&nbsp;' + msg);
}
function HideLoader(divid, msg) {
    var txt = (msg) ? msg : '';
    updateDiv(divid, txt);
}
// global Ajax Library for any page
var AjaxLoaderImageSrc = 'WebResource.axd?d=Qgz1aw91_Lbg5Mc1q7aGF7Eqp5uQ_dKcGNjG8VkrbvaJkpvgzLs7HnYDwMmkS9Js0&t=634159264760000000';
var AjaxLoaderImageTag = '<img src="' + AjaxLoaderImageSrc + '" alt="Loading..." Border="0" />';
//preload here
newImage(AjaxLoaderImageSrc);

// function, builds a parameter to be sent via post
function Param(name, value) {
    var val = (encodeURIComponent) ? encodeURIComponent(value) : escape(value);
    return name + "=" + val;
}
// addparameters to send, send name, val, name1, val1, name2, value2
// returns name=val&name1=val1&name2=value2
function Params() {
    var params = '';
    var len = Params.arguments.length;
    for (var i = 0; i < Params.arguments.length; i += 2) {
        params += Param(Params.arguments[i], Params.arguments[i + 1]);
        params += (len > i) ? '&' : '';
    }
    return params;
}

function GetHTTPObject() {
    var xhr = false;
    // Mozilla, Safari, IE 7...
    if (window.XMLHttpRequest) { xhr = new XMLHttpRequest(); }
    // IE 6
    else if (window.ActiveXObject) { try { xhr = new ActiveXObject("MSXml2.XMLHttp"); } catch (e) { try { xhr = new ActiveXObject("Microsoft.XMLHttp"); } catch (e) { } } }
    if (!xhr) return true;
    // send back the object
    return xhr;
} // end of GetAjaxObject

// Make a request to get some data
function SendAjax(method, url, args, callback) {
    var xmlHttp = GetHTTPObject();
    // init the request
    if (xmlHttp.preserveWhitespace)
        xmlHttp.preserveWhitespace = true;

    xmlHttp.open(method, url, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Connection", "close");
    if (args)
        xmlHttp.setRequestHeader("Content-length", args.length);
    // set call back method
    if (callback)
        xmlHttp.onreadystatechange = function() {
            if (callback) { callback(xmlHttp); }
        };
    // sends the request to the server
    if (args)
        xmlHttp.send(args);
    else
        xmlHttp.send(null);
    return xmlHttp;
}
// send Error to the Audit Log 
function LogScriptException(scriptException) {
    try {
        LogException(scriptException.message, scriptException.fileName, scriptException.lineNumber);
    }
    catch (e) {
        alert('Fatal error ' + e.message);
    }
}
var ClientScriptErrorHandler = 'Net2Lib.ClientScriptError.aspx';
// Send a some details with the Script
function LogException(msg, url, line) {
    var qs = (window.location.search) ? window.location.search : "";
    // build parameters
    var args = Params('msg', msg, 'url', url, 'line', line, 'stacktrace', GetStackTrace());
    if (qs)
        args += Param('qs', qs);
    // send to Server to Audit Error
    SendAjax('POST', ClientScriptErrorHandler, args, null);
    //  handle the error here
    return true;
}
function GetStackTrace() {
    var callstack = [];
    var lines = null;
    var isCallstackPopulated = false;
    try {
        i.dont.exist += 0; //does not exist - that's the point
    } catch (e) {
        if (e.stack) { //Firefox
            lines = e.stack.split("\n");
            for (var j = 0; j < lines.length; j++) {
                if (lines[j].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
                    callstack.push(lines[j]);
                }
            }
            //Remove call to printStackTrace()
            callstack.shift();
            isCallstackPopulated = true;
        }
        else if (window.opera && e.message) { //Opera
            lines = e.message.split("\n");
            for (var x = 0; x < lines.length; x++) {
                if (lines[x].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
                    var entry = lines[x];
                    //Append next line also since it has the file info
                    if (lines[x + 1]) {
                        entry += " at " + lines[x + 1];
                        x++;
                    }
                    callstack.push(entry);
                }
            }
            //Remove call to printStackTrace()
            callstack.shift();
            isCallstackPopulated = true;
        }
    }
    if (!isCallstackPopulated) { //IE and Safari
        var currentFunction = arguments.callee.caller;
        while (currentFunction) {
            var fn = currentFunction.toString();
            //If we can't get the function name set to "anonymous"
            var fname = fn.substring(fn.indexOf("function") + 8, fn.indexOf("(")) || "anonymous";
            callstack.push(fname);
            currentFunction = currentFunction.caller;
        }
    }
    return callstack.join("\n\n");
}

var Resources = {};
function GetResourceText(key, className) {
    if (typeof Resources == 'undefined') { alert('ClientScript Resources are not defined.  Please check to make the sure the handler is included.'); }
    if (typeof className == 'undefined') {
        for (c in Resources) {
            if (typeof className == 'undefined' && typeof(eval('Resources.'+c)) != 'function') { className = c; break; }
        }
    }
    var resourceKey = 'Resources.' + className + '.' + key;
    var resx = eval(resourceKey);
    if (typeof (resx) == 'undefined') { LogException(resourceKey + 'is not defined.', document.URL, -1); }
    return resx;    
}

Resources.SetLanguagePreference = function(key, name) {
    function SetLanguagePreference_Complete(xhr) {
        if (xhr.readyState != 4) { return; }
        // reload the page with the language setting
        location.replace(document.URL);        
    }

    SendAjax('POST', DD.Net.Page.Request.Uri, Param(key, name), SetLanguagePreference_Complete);
    return false;
}