var loadingAsMobile = false;

try {
    loadingAsMobile = (getCookie("LoadingAsMobile") == "true");
} catch (e) {
}

var sitePath = "";

try {
    sitePath = (getCookie("_SitePath"));
} catch (e) {
}

Date.now = Date.now || function () { return +new Date; };

$j(document).ready(function () {
    if (!window.JSON) $j.getScript("A_Master/library/js/json2.js");
    prependSploaders(); moveSwaps(); crm_Init();
    try { if (document.location.href.indexOf("autoLaunchBL=true") > 0) LaunchbuddyListiframe(); } catch (e) { }
    initBackToMobile();

    if ($j(".formDatePicker").length !== 0) {
        $j(".formDatePicker").datepicker({
            minDate: "1/1/1900",
            maxDate: "1/1/2100"
        });
        $j("#ui-datepicker-div").hide();
    }

    if ($j(".formControlCell .maskTextbox").length !== 0) {

        $j(".formControlCell .maskDisplayTextbox").hide();

        $j(".formControlCell .maskTextbox").focus(function () {
            $j("#" + $j(this).attr("id").replace("_mask", "")).show().select();
            $j(this).hide();
        });

        $j(".formControlCell .maskDisplayTextbox").blur(function () {
            $j(this).hide();
            $j("#" + $j(this).attr("id") + "_mask").show();

            if ($j(this).val() !== "") {
                $j("#" + $j(this).attr("id") + "_mask").val("00000000");
            } else {
                $j("#" + $j(this).attr("id") + "_mask").val("");
            }
        });

    }

    if ($j(".formMaskedInput").length !== 0) {
        $j(".formMaskedInput").hover(
            function () { $j(this).html($j(this).attr("value")); },
            function () { $j(this).html("********"); }
        );
    }

    if ($j(".dialogToolbar").length !== 0) {
        $j("<div/>").addClass("dialogToolbarPad").appendTo("body");
        /* toolbars disappear in safari, this fixes it */
        $j(".dialogToolbar").css("position", "absolute");
        window.setTimeout("$j(\".dialogToolbar\").css(\"position\", \"fixed\");", 100);
    }

    if (getCookie("clearSessionStorage") == "true") {
        clearSessionStorage();
        setCookie("clearSessionStorage", "false", 1)
    }

    window.setTimeout(function () { $j(".dialogToolbar .dialogToolbarMessage").fadeOut(); }, 2500);
}); 

function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

function clearSessionStorage() {
    if (useSessionStorage()) {
        try {
            window.opener.sessionStorage.clear();
        } catch (e) { }
        try {
            window.sessionStorage.clear();
        } catch (e) { }
    }
}
function initBackToMobile() {
    var btm = $j("#returnToMobileVersion").html("View Mobile Site<div></div>").click(function () {
        document.location.href = 'default8026.html?p=membersdefault&amp;setAsMobile=true';
    });
    if (btm) {
        btm.find("div").click(function (event) {
            $j("#returnToMobileVersion").hide("slide", { direction: "down" });
            $j(window).unbind("resize");
            if (useSessionStorage()) sessionStorage.setItem("hideMobile", true);
            event.stopPropagation();
        });
        if (useSessionStorage() && sessionStorage.getItem("hideMobile")) {
            btm.detach();
        } else if (window.location.href.toLowerCase().indexOf('=crm_') > 0) {
            btm.detach();
        } else {
            $j(window).resize(function () {
                if ((document.documentElement.clientWidth / window.innerWidth) <= 1.25) {
                    $j("#returnToMobileVersion").show();
                } else {
                    $j("#returnToMobileVersion").hide();
                }
            });
        }
    }
}
function useSessionStorage() {
    try {
        if (sessionStorage) {
            try {
                sessionStorage.setItem("testKey", 1);
                sessionStorage.removeItem("testKey");
                return true;
            } catch (error) {
                if (error.code === DOMException.QUOTA_EXCEEDED_ERR && sessionStorage.length === 0) return false;
            }
        }
    } catch (error) {
        return false;
    }
    return false;
}

function isCheckboxChecked(cb) {
    if (cb.attr("checked") == "checked") return true;
    if (cb.attr("checked")) return true;
    return false;
}
function dataFix(d) {
    try {
        return (d.d) ? d.d : d;
    } catch (e) {
        return d;
    }
}
function prependSploaders() {
    var Sploders = $j("body").find(".sploder");

    for (i = 0; i < Sploders.length; i++) {
        $j(Sploders[i]).css('display', 'none');
        var iframeSrc = GetIFrameSource($j(Sploders[i]).find('iframe').get(0));
        var MoveDiv = $j(Sploders[i]).detach();
        $j("#defaultnetform").prepend(MoveDiv);
        $j("#BillPayForm").prepend(MoveDiv);
        $j("#frmAdminConsole").prepend(MoveDiv);
        if (iframeSrc.toLowerCase().indexOf('http') >= 0) { SetIFrameSource($j(MoveDiv).find('iframe').get(0), iframeSrc); }
    }
}
function moveSwaps() {
    var Swaps = $j("body").find(".swap");

    for (i = 0; i < Swaps.length; i++) {
        var moveTo = $j(Swaps[i]).attr('moveTo');
        var MoveDiv = $j(Swaps[i]).detach();
        $j("#" + moveTo).append(MoveDiv);
    }
}
function GetIFrameSource(myframe) {
    try {
        if (myframe !== null) {
            if (myframe.src) {
                return myframe.src;
            }
            else if (myframe.contentWindow !== null && myframe.contentWindow.location !== null) {
                return myframe.contentWindow.location.href;
            }
            else { return myframe.getAttribute('src'); }
        }
    } catch (e) { return ''; }
}
function SetIFrameSource(myframe, src) {
    if (myframe !== null) {
        if (myframe.src) {
            myframe.src = src;
        }
        else if (myframe.contentWindow !== null && myframe.contentWindow.location !== null) {
            myframe.contentWindow.location.href = src;
        }
        else { return myframe.setAttribute('src', src); }
    }
}
function urlWithoutHash() {
    var url = window.location.href;
    var hash = window.location.hash;
    var index_of_hash = url.indexOf(hash) || url.length;
    var hashless_url = url.substr(0, index_of_hash);
    return hashless_url;
}
function doSpell(frm, fld) {
    //window.open("spellchecker/window.asp?jsvar=document."+frm+"."+fld+".value", null, "height=230,width=450,status=no,toolbar=no,menubar=no,location=no"); 
    window.open("spellchecker/defaultf8e9.html?jsvar=document." + frm + "." + fld + ".value", null, "height=230,width=450,status=no,toolbar=no,menubar=no,location=no");
}
function KeepAlive() {
    var urlpath = document.location.href;
    urlpath = urlpath.substring(7, urlpath.length - 7);
    var i
    if (urlpath.indexOf('ceclients') >= 0) {
        i = urlpath.indexOf('/d');
        if (i < 0) {
            i = urlpath.indexOf('/D');
        }

    }
    else {
        i = urlpath.indexOf('index.html');
    }

    urlpath = 'http://' + urlpath.substring(0, i + 1);
    if (urlpath.length <= 7) {
        urlpath = document.location.href + '';
    }
    KeepAliveDiv.innerHTML = "<img src='" + urlpath + "/A_master/NET/RadEditor/getImage.aspx?ID=522142' alt=''>";
    setTimeout('KeepAlive()', 600000);
}
function sessionExpire() {
    // The URL for the facility detail
    var url = 'default.aspx?p=home&logout=true';
    var urlpath = document.location.href;
    urlpath = urlpath.substring(7, urlpath.length - 7);
    var i
    if (urlpath.indexOf('ceclients') >= 0) {
        i = urlpath.indexOf('/d');
        if (i < 0) {
            i = urlpath.indexOf('/D');
        }

    }
    else {
        i = urlpath.indexOf('index.html');
    }

    urlpath = 'http://' + urlpath.substring(0, i + 1);
    if (urlpath.length <= 7) {
        urlpath = document.location.href + '';
    }

    url = urlpath + url;
    if (window.parent == null) {
        document.location.href = url;
    }
    else {
        window.parent.location.href = url;
    }
    alert("Your Session Has Expired.\nPlease Log Back in to Continue.");
}

function OpenNewWindow(url, name, options) {
    var temp = window.open(url, name, options);
    if (temp) {
        temp.focus();
    } else {
        alert('Please Enable popups for this site to continue'); return false;
    }
    return temp;
}
function OpenModule(WName, PageName, Width, Height, Parameters) {
    var temp = OpenModule2(WName, PageName, Width, Height, Parameters, 0, 0, 0, 1, 0, 1);
}
function OpenModule2(WName, PageName, Width, Height, Parameters, Menubar, ToolBar, Location, ScrollBar, StatusBar, Resize) {
    // The URL for the facility detail
    var url = 'default.aspx?p=' + PageName + '&NoModResize=1&NoNav=1&ShowFooter=False&' + Parameters;
    var urlpath = document.location.href;

    var isHTTPS = (urlpath.indexOf("https:///") != -1) ? true : false;

    urlpath = (isHTTPS) ? urlpath.substring(8, urlpath.length - 8) : urlpath.substring(7, urlpath.length - 7);

    var i;


    if (urlpath.indexOf('ceclients') >= 0) {
        i = urlpath.indexOf('/d');
        if (i < 0) {
            i = urlpath.indexOf('/D');
        }

    }
    else {
        i = urlpath.indexOf('index.html');
    }

    var directive = (isHTTPS) ? "https://" : "http://";

    urlpath = directive + urlpath.substring(0, i + 1);

    if (urlpath.length <= 7) {
        urlpath = document.location.href + '';
    }

    url = urlpath + url;
    // Open the window
    var temp = OpenURL(url, WName, Width, Height, Menubar, ToolBar, Location, ScrollBar, StatusBar, Resize);
}

function OpenURL(url, WName, Width, Height, Menubar, ToolBar, Location, ScrollBar, StatusBar, Resize) {

    // Get the window settings, set defaults if no settings are provided
    if (ToolBar == 1) { showToolBar = 'toolbar=yes'; } else { showToolBar = 'toolbar=no'; }
    if (Menubar == 1) { showMenuBar = 'menubar=yes'; } else { showMenuBar = 'menubar=no'; }
    if (Location == 1) { showLocation = 'location=yes'; } else { showLocation = 'location=no'; }
    if (ScrollBar == 1) { showScrollBar = 'scrollbars=yes'; } else { showScrollBar = 'scrollbars=no'; }
    if (StatusBar == 1) { showStatusBar = 'status=yes'; } else { showStatusBar = 'status=no'; }
    if (Resize == 1) { showResize = 'resizable=yes'; } else { showResize = 'resizable=no'; }

    // Get this window's position
    var x = 0;
    var y = 0;
    var w = 0;
    var h = 0;
    w = screen.AvailWidth;
    h = screen.AvailHeight;

    // Modify the position - CENTER THE NEW WINDOW
    x = (w - Width) / 2;
    y = (h - Height) / 2;

    // Open the window
    var temp = OpenNewWindow(url, WName, 'width=' + Width + ',height=' + Height + ',' + showStatusBar + ',' + showToolBar + ',' + showMenuBar + ',' + showLocation + ',' + showScrollBar + ',' + showResize + ',screenX=' + x + ',screenY=' + y + ',left=' + x + ',top=' + y);
    if (WName == 'billing') { setTimeout('try{parent.navmenu.location.href = parent.navmenu.location.href;}catch(e){} window.location.href=window.location.href;', 5000); }
}


function underconstruction() {
    alert('This feature is under construction');
}

function rowon(row) {
    row.className = 'rowhighlight';
}

function rowoff(row) {
    row.className = 'tnavTabContent';
}

function rowHoverOn(row) {
    row.className = 'rowHover';
}

function rowHoverOff(row) {
    row.className = 'rowNormal';
}


function Left(str, n) {
    if (n <= 0)							// Invalid bound, return blank string
        return '';
    else if (n > String(str).length)	// Invalid bound, return
        return str; 				// entire string
    else								// Valid bound, return appropriate substring
        return String(str).substring(0, n);
}

function Right(str, n) {
    if (n <= 0)							// Invalid bound, return blank string
        return "";
    else if (n > String(str).length)	// Invalid bound, return
        return str; 					// entire string
    else {								// Valid bound, return appropriate substring
        var iLen = String(str).length;
        return String(str).substring(iLen, iLen - n);
    }
}








/**
* DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
**/

// Declaring valid date character, minimum year and maximum year
var dtCh = "index.html";
var minYear = 1900;
var maxYear = 2100;

function isInteger(s) {
    var i;
    for (i = 0; i < s.length; i++) {
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag) {
    var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary(year) {
    // February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28);
}
function DaysArray(n) {
    for (var i = 1; i <= n; i++) {
        this[i] = 31
        if (i == 4 || i == 6 || i == 9 || i == 11) { this[i] = 30 }
        if (i == 2) { this[i] = 29 }
    }
    return this
}

function isDate(dtStr) {
    var daysInMonth = DaysArray(12)
    var pos1 = dtStr.indexOf(dtCh)
    var pos2 = dtStr.indexOf(dtCh, pos1 + 1)
    var strMonth = dtStr.substring(0, pos1)
    var strDay = dtStr.substring(pos1 + 1, pos2)
    var strYear = dtStr.substring(pos2 + 1)
    strYr = strYear
    if (strDay.charAt(0) == "0" && strDay.length > 1) strDay = strDay.substring(1)
    if (strMonth.charAt(0) == "0" && strMonth.length > 1) strMonth = strMonth.substring(1)
    for (var i = 1; i <= 3; i++) {
        if (strYr.charAt(0) == "0" && strYr.length > 1) strYr = strYr.substring(1)
    }
    month = parseInt(strMonth)
    day = parseInt(strDay)
    year = parseInt(strYr)
    if (pos1 == -1 || pos2 == -1) {
        alert("The date format should be : mm/dd/yyyy")
        return false
    }
    if (strMonth.length < 1 || month < 1 || month > 12) {
        alert("Please enter a valid month")
        return false
    }
    if (strDay.length < 1 || day < 1 || day > 31 || (month == 2 && day > daysInFebruary(year)) || day > daysInMonth[month]) {
        alert("Please enter a valid day")
        return false
    }
    if (strYear.length != 4 || year == 0 || year < minYear || year > maxYear) {
        alert("Please enter a valid 4 digit year between " + minYear + " and " + maxYear)
        return false
    }
    if (dtStr.indexOf(dtCh, pos2 + 1) != -1 || isInteger(stripCharsInBag(dtStr, dtCh)) == false) {
        alert("Please enter a valid date")
        return false
    }
    return true
}



function dateDiff(psDateVal1, psDateVal2) {
    date1 = new Date();
    date2 = new Date();
    diff = new Date();

    var psTimeVal1 = '01:00:00';
    var psTimeVal2 = '01:00:00';

    if (isDate(psDateVal1)) { // Validates first date 
        date1temp = new Date(psDateVal1 + " " + psTimeVal1);
        date1.setTime(date1temp.getTime());
    }
    else return false; // otherwise exits


    if (isDate(psDateVal2)) { // Validates second date 
        date2temp = new Date(psDateVal2 + " " + psTimeVal2);
        date2.setTime(date2temp.getTime());
    }
    else return false; // otherwise exits

    // sets difference date to difference of first date and second date

    diff.setTime(date2.getTime() - date1.getTime());

    timediff = diff.getTime();

    if (timediff >= 0) {
        return true;
    } else {
        return false;
    }

}


function checkadate(chkMonth, chkDay, chkYear) {
    /*Validate Date DropDown Selection fields (Dropdown Month, Dropdown Day, text field Year)*/
    var checkOK = "0123456789";
    var checkStr = chkYear.value;
    var allValid = true;
    var decPoints = 0;
    var allNum = "";
    for (i = 0; i < checkStr.length; i++) {
        ch = checkStr.charAt(i);
        for (j = 0; j < checkOK.length; j++)
            if (ch == checkOK.charAt(j))
                break;
        if (j == checkOK.length) {
            allValid = false;
            break;
        }
        allNum += ch;
    }

    if (!allValid) {
        alert("Please enter only numbers in the \"chkYear\" field.");
        chkYear.focus();
        return (false);
    }

    var chkVal = allNum;
    var prsVal = parseInt(allNum);
    if (chkVal != "" && !(prsVal >= "1900" && prsVal <= "2100")) {
        alert("Please enter a value greater than or equal to \"1900\" and less than or equal to \"2100\" in the Year field.");
        chkYear.focus();
        return (false);
    }

    var piSumDate = 0;
    if (chkMonth.selectedIndex != 0) { piSumDate = 1; }
    if (chkDay.selectedIndex != 0) { piSumDate = piSumDate + 1; }
    if (chkYear.value != "") { piSumDate = piSumDate + 1; }

    if (piSumDate == 0) {
        //no field values entered... no checking required
    } else if (piSumDate == 3) {
        var usrBirthDate = chkMonth.value + '/' + chkDay.value + '/' + chkYear.value;
        if (isDate(usrBirthDate) == false) {
            chkDay.focus();
            return (false);
        }
    } else {
        alert('Please enter the Month, Day and Year for the date');
        chkYear.focus();
        return (false);
    }

    return (true);
}

function checkanumber(chkNumber) {
    var checkOK = "0123456789";
    var checkStr = chkNumber.value;
    var allValid = true;
    var decPoints = 0;
    var allNum = "";
    for (i = 0; i < checkStr.length; i++) {
        ch = checkStr.charAt(i);
        for (j = 0; j < checkOK.length; j++)
            if (ch == checkOK.charAt(j))
                break;
        if (j == checkOK.length) {
            allValid = false;
            break;
        }
        allNum += ch;
    }
    if (!allValid) {
        alert("Please enter only numbers in the field.");
        chkNumber.focus();
        return (false);
    }

}

function ScrollIt() {
    //if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1)
    //{
    //	theform = document.defaultnetform;
    //} else {
    //	theform = document.forms["defaultnetform"];
    // 	 }
    //alert(document.getElementById("PageX").value);
    //	window.scrollTo(theform.PageX.value, theform.PageY.value);
    window.scrollTo(document.getElementById("PageX").value, document.getElementById("PageY").value);
}
function setcoords() {
    var myPageX;
    var myPageY;
    try {
        if (typeof (window.pageYOffset) == 'number') {
            //Netscape compliant
            myPageY = window.pageYOffset;
            myPageX = window.pageXOffset;
        } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
            //DOM compliant
            myPageY = document.body.scrollTop;
            myPageX = document.body.scrollLeft;
        } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
            //IE6 standards compliant mode
            myPageY = document.documentElement.scrollTop;
            myPageX = document.documentElement.scrollLeft;
        }
        //if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) 
        //     {
        //		    theform = document.defaultnetform;
        //	     } else {
        //		    theform = document.forms["defaultnetform"];
        //	     }
        document.getElementById("PageX").value = myPageX;
        document.getElementById("PageY").value = myPageY;
    } catch (ex) { }
    var AdminBarDiv = document.getElementById('SlidingAdminDiv');
    try {
        setAdminBarPosition();
    }
    catch (err) { }
    try {
        if (AdminBarDiv != null) {
            AdminBarDiv.style.top = myPageY;
        }
    }
    catch (err) {
        if (AdminBarDiv != null) {
            AdminBarDiv.style.top = 0;
        }
    }
    try {
        ScrollTheDiv();
    }
    catch (err) {
    }

}

var datePickerDivID = "datepicker";
var iFrameDivID = "datepickeriframe";
var updateDateFunctionName = "updateDateField";
var dateSeparator;
var dateFormat;

var dayArray = new Array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
var monthArray = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');

function displayDatePicker(dateFieldName, displayBelowThisObject) {
    var targetDateField;
    targetDateField = document.getElementById(dateFieldName);
    if (!displayBelowThisObject) displayBelowThisObject = targetDateField;
    dateSeparator = "index.html";
    dateFormat = "mdy"
    var x = displayBelowThisObject.offsetLeft;
    var y = displayBelowThisObject.offsetTop + displayBelowThisObject.offsetHeight;
    // deal with elements inside tables and such
    var parent = displayBelowThisObject;
    while (parent.offsetParent) {
        parent = parent.offsetParent;
        x += parent.offsetLeft;
        y += parent.offsetTop;
    }
    drawDatePicker(targetDateField, x, y);
}

function drawDatePicker(targetDateField, x, y) {
    var dt = getFieldDate(targetDateField.value);
    if (!document.getElementById(datePickerDivID)) {
        var newNode = document.createElement("div");
        newNode.setAttribute("id", datePickerDivID);
        newNode.setAttribute("class", "dpDiv");
        newNode.setAttribute("style", "visibility: hidden;");
        document.body.appendChild(newNode);
    }
    var pickerDiv = document.getElementById(datePickerDivID);
    pickerDiv.style.position = "absolute";
    pickerDiv.style.left = x + "px";
    pickerDiv.style.top = y + "px";
    pickerDiv.style.visibility = (pickerDiv.style.visibility == "visible" ? "hidden" : "visible");
    pickerDiv.style.display = (pickerDiv.style.display == "block" ? "none" : "block");
    pickerDiv.style.zIndex = 99998;
    refreshDatePicker(targetDateField.name, dt.getFullYear(), dt.getMonth(), dt.getDate());
}
function drawStaticDatePicker(customDatePickerDivID, dateFieldName) {
    var targetDateField;
    dateSeparator = "index.html";
    dateFormat = "mdy"
    targetDateField = document.getElementById(dateFieldName);
    var dt = getFieldDate(targetDateField.value);
    datePickerDivID = customDatePickerDivID;
    var pickerDiv = document.getElementById(datePickerDivID);
    pickerDiv.style.visibility = "visible"
    pickerDiv.style.display = "block"
    pickerDiv.style.zIndex = 99998;
    updateDateFunctionName = "updateDateFieldStatic";
    refreshDatePicker(targetDateField.name, dt.getFullYear(), dt.getMonth(), dt.getDate());
}
function refreshDatePicker(dateFieldName, year, month, day) {
    var thisDay = new Date();
    if ((month >= 0) && (year > 0)) {
        thisDay = new Date(year, month, 1);
    } else {
        day = thisDay.getDate();
        thisDay.setDate(1);
    }
    var crlf = "\r\n";
    var TABLE = "<table cellpadding=0 cellspacing=0 width=210 cols=7 class='page'>" + crlf;
    var xTABLE = "</table>" + crlf;
    var TR = "<tr class='plgHeaderBar'>";
    var TR_title = "<tr height=25 class='plgCalendarHeader'>";
    var TR_days = "<tr align=center class='plgCalendarHeader'>";
    var TR_todaybutton = "<tr height=18 class='plgCalendarHeader'>";
    var xTR = "</tr>" + crlf;
    var TD = "<td align=center width=14% height=10 valign=middle class='plgCalendarWeekday' onMouseOut='this.className=\"plgCalendarWeekday\";' style='text-decoration:none;cursor:hand;border:1px solid #FFFFFF;' onMouseOver='this.className=\"plgCalendarDayOn\";' ";    // leave this tag open, because we'll be adding an onClick event
    var TD_title = "<td align=center colspan=5 class='plgHeaderBar'>";
    var TD_buttons = "<td align=center class='plgHeaderBar'>";
    var TD_todaybutton = "<td align=center colspan=7 class='plgHeaderBar'>";
    var TD_days = "<td width=14% align=center class='plgCalendarHeader'>";
    var TD_selected = "<td align=center width=14% height=10 valign=middle class='plgCalendarWeekday' onMouseOut='this.className=\"plgCalendarWeekday\";' style='text-decoration:none;cursor:hand;border:1px solid #FF0000;'  onMouseOver='this.className=\"plgCalendarDayOn\";' ";    // leave this tag open, because we'll be adding an onClick event
    var xTD = "</td>" + crlf;
    var DIV_title = "<div class='plgHeaderBar'>";
    var DIV_selected = "<div>";
    var xDIV = "</div>";
    var html = TABLE;
    html += TR_title;
    html += TD_buttons + getButtonCode(dateFieldName, thisDay, -1, "<font size=2>&laquo;</font>") + xTD;
    html += TD_title + DIV_title + monthArray[thisDay.getMonth()] + " " + thisDay.getFullYear() + xDIV + xTD;
    html += TD_buttons + getButtonCode(dateFieldName, thisDay, 1, "<font size=2>&raquo;</font>") + xTD;
    html += xTR;
    html += TR_days;
    for (i = 0; i < dayArray.length; i++)
        html += TD_days + dayArray[i] + xTD;
    html += xTR;
    html += TR;
    for (i = 0; i < thisDay.getDay(); i++)
        html += "<td class=page>" + "&nbsp;" + "</td>";
    do {
        dayNum = thisDay.getDate();
        TD_onclick = " onclick=\"" + updateDateFunctionName + "('" + dateFieldName + "', '" + getDateString(thisDay) + "');\">";
        if (dayNum == day)
            html += TD_selected + TD_onclick + DIV_selected + dayNum + xDIV + xTD;
        else
            html += TD + TD_onclick + dayNum + xTD;
        if (thisDay.getDay() == 6)
            html += xTR + TR;
        thisDay.setDate(thisDay.getDate() + 1);
    } while (thisDay.getDate() > 1)
    if (thisDay.getDay() > 0) {
        for (i = 6; i > thisDay.getDay(); i--)
            html += "<td class=page>" + "&nbsp;" + "</td>";
    }
    html += xTR;
    var today = new Date();
    var todayString = "Today is " + dayArray[today.getDay()] + ", " + monthArray[today.getMonth()] + " " + today.getDate();
    html += TR_todaybutton;
    html += "<td align=left colspan=4 class='plgHeaderBar'><a class='plgHeaderBarAction' style='cursor:hand;' onClick='refreshDatePicker(\"" + dateFieldName + "\");'>Jump To Today</a></td>";
    html += "<td align=right colspan=3 class='plgHeaderBar'><a class='plgHeaderBarAction' style='cursor:hand;' onClick='" + updateDateFunctionName + "(\"" + dateFieldName + "\");'>Close&nbsp;X</a></td>";
    html += xTR;
    html += xTABLE;

    document.getElementById(datePickerDivID).innerHTML = html;
    adjustiFrame();
}
function getButtonCode(dateFieldName, dateVal, adjust, label) {
    var newMonth = (dateVal.getMonth() + adjust) % 12;
    var newYear = dateVal.getFullYear() + parseInt((dateVal.getMonth() + adjust) / 12);
    if (newMonth < 0) {
        newMonth += 12;
        newYear += -1;
    }
    return "<a class='plgHeaderBarAction' style='cursor:hand;' onClick='refreshDatePicker(\"" + dateFieldName + "\", " + newYear + ", " + newMonth + ");'>" + label + "</a>";
}
function getDateString(dateVal) {
    var dayString = "00" + dateVal.getDate();
    var monthString = "00" + (dateVal.getMonth() + 1);
    dayString = dayString.substring(dayString.length - 2);
    monthString = monthString.substring(monthString.length - 2);
    switch (dateFormat) {
        case "dmy":
            return dayString + dateSeparator + monthString + dateSeparator + dateVal.getFullYear();
        case "ymd":
            return dateVal.getFullYear() + dateSeparator + monthString + dateSeparator + dayString;
        case "mdy":
        default:
            return monthString + dateSeparator + dayString + dateSeparator + dateVal.getFullYear();
    }
}
function getFieldDate(dateString) {
    var dateVal;
    var dArray;
    var d, m, y;
    try {
        dArray = splitDateString(dateString);
        if (dArray) {
            switch (dateFormat) {
                case "dmy":
                    d = parseInt(dArray[0], 10);
                    m = parseInt(dArray[1], 10) - 1;
                    y = parseInt(dArray[2], 10);
                    break;
                case "ymd":
                    d = parseInt(dArray[2], 10);
                    m = parseInt(dArray[1], 10) - 1;
                    y = parseInt(dArray[0], 10);
                    break;
                case "mdy":
                default:
                    d = parseInt(dArray[1], 10);
                    m = parseInt(dArray[0], 10) - 1;
                    y = parseInt(dArray[2], 10);
                    break;
            }
            dateVal = new Date(y, m, d);
        } else if (dateString) {
            dateVal = new Date(dateString);
        } else {
            dateVal = new Date();
        }
    } catch (e) {
        dateVal = new Date();
    }
    return dateVal;
}
function splitDateString(dateString) {
    var dArray;
    if (dateString.indexOf("index.html") >= 0)
        dArray = dateString.split("index.html");
    else if (dateString.indexOf(".") >= 0)
        dArray = dateString.split(".");
    else if (dateString.indexOf("-") >= 0)
        dArray = dateString.split("-");
    else if (dateString.indexOf("\\") >= 0)
        dArray = dateString.split("\\");
    else
        dArray = false;
    return dArray;
}
function updateDateFieldStatic(dateFieldName, dateString) {
    var targetDateField = document.getElementsByName(dateFieldName).item(0);
    if (dateString)
        targetDateField.value = dateString;
    var pickerDiv = document.getElementById(datePickerDivID);
    adjustiFrame();
    var dt = getFieldDate(targetDateField.value);
    refreshDatePicker(targetDateField.name, dt.getFullYear(), dt.getMonth(), dt.getDate());
    try { targetDateField.focus(); } catch (e) { }
    if ((dateString) && (typeof (datePickerClosed) == "function"))
        datePickerClosed(targetDateField);
}
function updateDateField(dateFieldName, dateString) {
    var targetDateField = document.getElementsByName(dateFieldName).item(0);
    if (dateString)
        targetDateField.value = dateString;
    var pickerDiv = document.getElementById(datePickerDivID);
    pickerDiv.style.visibility = "hidden";
    pickerDiv.style.display = "none";
    adjustiFrame();
    try { targetDateField.focus(); } catch (e) { }
		try {$j(targetDateField).change(); } catch(e) { }
    if ((dateString) && (typeof (datePickerClosed) == "function"))
        datePickerClosed(targetDateField);
}
function adjustiFrame(pickerDiv, iFrameDiv) {
    var is_opera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1);
    if (is_opera)
        return;
    try {
        if (!document.getElementById(iFrameDivID)) {
            var newNode = document.createElement("iFrame");
            newNode.setAttribute("id", iFrameDivID);
            newNode.setAttribute("src", "javascript:false;");
            newNode.setAttribute("scrolling", "no");
            newNode.setAttribute("frameborder", "0");
            document.body.appendChild(newNode);
        }
        if (!pickerDiv)
            pickerDiv = document.getElementById(datePickerDivID);
        if (!iFrameDiv)
            iFrameDiv = document.getElementById(iFrameDivID);
        try {
            iFrameDiv.style.position = "absolute";
            iFrameDiv.style.width = pickerDiv.offsetWidth;
            iFrameDiv.style.height = pickerDiv.offsetHeight;
            iFrameDiv.style.top = pickerDiv.style.top;
            iFrameDiv.style.left = pickerDiv.style.left;
            iFrameDiv.style.zIndex = pickerDiv.style.zIndex - 1;
            iFrameDiv.style.visibility = pickerDiv.style.visibility;
            iFrameDiv.style.display = pickerDiv.style.display;
        } catch (e) {
        }
    } catch (ee) {
    }
}

function activateFlashPlugins() {
    try {
        objects = document.getElementsByTagName("object");
        for (var i = 0; i < objects.length; i++) {
            try {
                objects[i].outerHTML = objects[i].outerHTML;
            } catch (err2) { }
        }
    } catch (err1) { }
}



var dragObj = new Object();

function dragStart(event, id) {
    var el;
    var x, y;
    dragObj.elNode = window.document.getElementById(id);
    if (navigator.appVersion.indexOf("MSIE") != -1) {
        x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
        y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
    } else {
        x = event.clientX + window.scrollX;
        y = event.clientY + window.scrollY;
    }
    dragObj.cursorStartX = x;
    dragObj.cursorStartY = y;
    dragObj.elStartLeft = parseInt(dragObj.elNode.style.left, 10);
    dragObj.elStartTop = parseInt(dragObj.elNode.style.top, 10);
    if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
    if (isNaN(dragObj.elStartTop)) dragObj.elStartTop = 0;
    if (navigator.appVersion.indexOf("MSIE") != -1) {
        document.attachEvent("onmousemove", dragGo);
        document.attachEvent("onmouseup", dragStop);
        window.event.cancelBubble = true;
        window.event.returnValue = false;
    } else {
        document.addEventListener("mousemove", dragGo, true);
        document.addEventListener("mouseup", dragStop, true);
        event.preventDefault();
    }
}
function dragGo(event) {
    var x, y;
    if (navigator.appVersion.indexOf("MSIE") != -1) {
        x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
        y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
    } else {
        x = event.clientX + window.scrollX;
        y = event.clientY + window.scrollY;
    }
    dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
    dragObj.elNode.style.top = (dragObj.elStartTop + y - dragObj.cursorStartY) + "px";
    if (navigator.appVersion.indexOf("MSIE") != -1) {
        window.event.cancelBubble = true;
        window.event.returnValue = false;
    } else {
        event.preventDefault();
    }
}
function dragStop(event) {
    if (navigator.appVersion.indexOf("MSIE") != -1) {
        document.detachEvent("onmousemove", dragGo);
        document.detachEvent("onmouseup", dragStop);
    } else {
        document.removeEventListener("mousemove", dragGo, true);
        document.removeEventListener("mouseup", dragStop, true);
    }
}

var DivTop = null;
var DivLeft = null;
var ScrollDivID = null;
var DivHeight = null;
var DivWidth = null;
var GrayedOut = false;
var Centered = false;
var divUnPinned = false;
var autoResize = true;
var oversizedWindow = false;
function toggleDiv(id, height, width, centerme, grayOut) {
    ScrollDivID = null;
    DivHeight = height;
    DivWidth = width;
    var divObj = document.getElementById(id);
    var grayOutDivObj = document.getElementById('grayOutDiv');
    if (divObj.style.visibility == 'hidden') {


        try {
            document.getElementById(id.replace("Div", "") + "LoadingDiv").style.display = 'block';
            document.getElementById(id.replace("Div", "") + "iframe").style.display = 'none';
        } catch (e) { }

        divObj.style.visibility = 'visible';
        divObj.style.display = 'block';
        var winW = 0, winH = 0;


        if (parseInt(navigator.appVersion) > 3) {
            if (navigator.appName == "Netscape") {
                winW = window.innerWidth;
                winH = window.innerHeight;
            }
            if (navigator.appName.indexOf("Microsoft") != -1) {
                if (navigator.userAgent.indexOf("MSIE 10") != -1) {
                    winW = window.innerWidth;
                    winH = window.innerHeight;
                } else {
                    winW = document.body.offsetWidth;
                    winH = document.body.offsetHeight;
                }
            }
        }
        if (centerme == 'true') {
            divObj.style.top = (winH - height) / 2 + "px";
            divObj.style.left = (winW - width) / 2 + "px";
            Centered = true;
        }
        if (id != "socialItemsLightboxDiv" && height > winH) {
            divObj.style.top = 0;
            height = winH - 10;
        }
        divObj.style.height = height + 'px';
        if (id != "socialItemsLightboxDiv" && width > winW) {
            divObj.style.left = 0;
            width = winW - 10;
        }
        divObj.style.width = width + 'px';
        if (grayOut == 'true') {

            try {
                var pageWidth = $j(document).width() + "px";
                var pageHeight = $j(document).height() + "px";
            }
            catch (e) {
                if (document.body && (document.body.scrollWidth || document.body.scrollHeight)) {
                    var pageWidth = document.body.scrollWidth + 'px';
                    var pageHeight = document.body.scrollHeight + 'px';
                } else if (document.body.offsetWidth) {
                    var pageWidth = document.body.offsetWidth + 'px';
                    var pageHeight = document.body.offsetHeight + 'px';
                } else {
                    var pageWidth = '100%';
                    var pageHeight = '100%';
                }
            }
            if (grayOutDivObj != null) {
                grayOutDivObj.style.display = 'block';
                grayOutDivObj.style.height = pageHeight;
                grayOutDivObj.style.width = pageWidth;
                GrayedOut = true;
            }
            ScrollDivID = id;
            ScrollTheDiv();
        }
    } else {
        divObj.style.visibility = 'hidden';
        divObj.style.display = 'none';
        try {
            grayOutDivObj.style.display = 'none';
            GrayedOut = false;
            Centered = false;
            DivTop = null;
            DivLeft = null;
            grayOutDivObj.style.height = '1px';
            grayOutDivObj.style.width = '1px';
        } catch (err2) {
        }
    }
    if (id == "socialItemsLightboxDiv")
        window.scrollTo(0, 0);
}
function resizeEnabledDiv(height, width) {
    var axisDialogBoxes = $j(".axisDialogBox").length;
    if (axisDialogBoxes == 1) {
        $j(".axisDialogBox").trigger("setSize", { height: height, width: width });
        return;
    } else if (axisDialogBoxes > 1) {

    }


    if (!ScrollDivID) return;
    id = ScrollDivID;
    DivHeight = height;
    DivWidth = width;
    var divObj = document.getElementById(id);
    var winW = 0, winH = 0;
    if (!height) height = 0;
    if (!width) width = 0;
    if (parseInt(navigator.appVersion) > 3) {
        if (navigator.appName == "Netscape") {
            winW = window.innerWidth;
            winH = window.innerHeight;
        }
        if (navigator.appName.indexOf("Microsoft") != -1) {
            if (navigator.userAgent.indexOf("MSIE 10") != -1) {
                winW = window.innerWidth;
                winH = window.innerHeight;
            } else {
                winW = document.body.offsetWidth;
                winH = document.body.offsetHeight;
            }
        }
    }
    if (Centered) {
        if (height > 0) { divObj.style.top = (winH - height) / 2 + "px"; DivTop = (winH - height) / 2; }
        if (width > 0) { divObj.style.left = (winW - width) / 2 + "px"; DivLeft = (winW - width) / 2; }
        Centered = true;
    }
    if (id != "socialItemsLightboxDiv" && height > winH) {
        divObj.style.top = 0;
        if (autoResize) { height = winH - 10; } else { divObj.style.position = "absolute"; document.body.scrollTop = 0; oversizedWindow = true; }
    }
    if (height > 0) divObj.style.height = height + 'px';
    if (id != "socialItemsLightboxDiv" && width > winW) {
        divObj.style.left = 0;
        if (autoResize) { width = winW - 10; } else { divObj.style.position = "absolute"; document.body.scrollLeft = 0; oversizedWindow = true; }
    }
    if (width > 0) divObj.style.width = width + 'px';
    MoveSocialItemsLightbox();
    ScrollTheDiv();
}
function setEnabledDivTitle(title) {
    var axisDialogBoxes = $j(".axisDialogBox").length;
    if (axisDialogBoxes == 1) {
        $j(".axisDialogBox").trigger("setTitleBar", title);
        return;
    } else if (axisDialogBoxes > 1) {

    }

    if (!ScrollDivID) return;
    id = ScrollDivID;
    id = Left(id, id.length - 3) + "Span";
    var titleObj = document.getElementById(id);
    if (titleObj) titleObj.innerHTML = title;
}
function closeAllAxisDialogs() {
    $j(".axisDialogBox").trigger("closeDialog");
}
function closeDialog() {
    var axisDialogBoxes = $j(".axisDialogBox").length;
    if (axisDialogBoxes == 1) {
	if($j(".axisDialogBox").parent().css("display")!=="none") {
	        $j(".axisDialogBox").trigger("closeDialog");
        	return;
	}
    } else if (axisDialogBoxes > 1) {

    }

    if (!ScrollDivID && parent) closeThisAxisDialog();
    if (!ScrollDivID) return;
    disableDiv(ScrollDivID);
}
function closeThisAxisDialog() {
    parent.setTimeout("closeDialog();", 100);
} 
function enableDiv(id, height, width, centerme, grayOut) {
    autoResize = true;
    oversizedWindow = false;
    enableDiv2(id, height, width, centerme, grayOut);
}
function enableDivNoResize(id, height, width, centerme, grayOut) {
    autoResize = false;
    oversizedWindow = false;
    enableDiv2(id, height, width, centerme, grayOut);
}
function enableDiv2(id, height, width, centerme, grayOut) {
    ScrollDivID = null;
    DivHeight = height;
    DivWidth = width;
    var divObj = document.getElementById(id);
    var grayOutDivObj = document.getElementById('grayOutDiv');
    divObj.style.visibility = 'visible';
    divObj.style.display = 'block';
    var winW = 0, winH = 0;
    if (!height) height = 0;
    if (!width) width = 0;
    if (parseInt(navigator.appVersion) > 3) {
        if (navigator.appName == "Netscape") {
            winW = window.innerWidth;
            winH = window.innerHeight;
        }
        if (navigator.appName.indexOf("Microsoft") != -1) {
            if (navigator.userAgent.indexOf("MSIE 10") != -1) {
                winW = window.innerWidth;
                winH = window.innerHeight;
            } else {
                winW = document.body.offsetWidth;
                winH = document.body.offsetHeight;
            }
        }
    }
    if (centerme == 'true') {
        if (height > 0) divObj.style.top = (winH - height) / 2 + "px";
        if (width > 0) divObj.style.left = (winW - width) / 2 + "px";
        Centered = true;
    }
    if (height > winH) {
        divObj.style.top = 0;
        if (autoResize) { height = winH - 10; } else { divObj.style.position = "absolute"; document.body.scrollTop = 0; oversizedWindow = true; }
    }
    if (height > 0) divObj.style.height = height + 'px';
    if (width > winW) {
        divObj.style.left = 0;
        if (autoResize) { width = winW - 10; } else { divObj.style.position = "absolute"; document.body.scrollLeft = 0; oversizedWindow = true; }
    }
    if (width > 0) divObj.style.width = width + 'px';
    if ($j.browser.msie && parseInt($j.browser.version) >= 10) {
        // size iframe for ie 10 standard mode
        var idRoot = id.replace('Div', '');
        var iframeH = $j('#' + idRoot + 'ContentCell').height();
        $j('#' + idRoot + 'iframe').height(iframeH);
    }

    if (grayOut == 'true') {
        try {
            var pageWidth = $j(document).width() + "px";
            var pageHeight = $j(document).height() + "px";
        }
        catch (e) {
            if (document.body && (document.body.scrollWidth || document.body.scrollHeight)) {
                var pageWidth = document.body.scrollWidth + 'px';
                var pageHeight = document.body.scrollHeight + 'px';
            } else if (document.body.offsetWidth) {
                var pageWidth = document.body.offsetWidth + 'px';
                var pageHeight = document.body.offsetHeight + 'px';
            } else {
                var pageWidth = '100%';
                var pageHeight = '100%';
            }
        }
        if (grayOutDivObj != null) {
            grayOutDivObj.style.display = 'block';
            grayOutDivObj.style.height = pageHeight;
            grayOutDivObj.style.width = pageWidth;
            GrayedOut = true;
        }
        ScrollDivID = id;
        ScrollTheDiv();
    }

}
function disableDiv(id, height, width, centerme, grayOut) {
    ScrollDivID = null;
    var divObj = document.getElementById(id);

    if (!divObj) {
        $j("#" + id.replace("Div", "")).trigger("closeDialog");
        return;
    }

    var grayOutDivObj = document.getElementById('grayOutDiv');
    divObj.style.visibility = 'hidden';
    divObj.style.display = 'none';
    DivTop = null;
    DivLeft = null;
    Centered = false;
    try {
        grayOutDivObj.style.height = '1px';
        grayOutDivObj.style.width = '1px';
        grayOutDivObj.style.display = 'none';
        GrayedOut = false;
    }
    catch (err2) {
    }
}
function minMaxDiv(id, minImageID, maxImageID, height, minHeight) {
    var myDiv = document.getElementById(id);
    var minImg = document.getElementById(minImageID);
    var maxImg = document.getElementById(maxImageID);
    if (minImg.style.position == 'absolute') {
        minImg.style.position = 'static';
        minImg.style.margin = '0';
        maxImg.style.position = 'absolute';
        maxImg.style.margin = '-9999';
        myDiv.style.height = height + 'px';
        myDiv.style.overflow = 'auto';
    } else {
        maxImg.style.position = 'static';
        maxImg.style.margin = '0';
        minImg.style.position = 'absolute';
        minImg.style.margin = '-9999';
        myDiv.style.height = minHeight + 'px';
        myDiv.style.overflow = 'hidden';
    }

}
function SploderLoaded(id) {
    var iFrame = document.getElementById(id + "iframe");
    if (iFrame) iFrame.style.display = 'block';
    var loadDiv = document.getElementById(id + "LoadingDiv");
    if (loadDiv) loadDiv.style.display = 'none';
}
function unPinDiv(id, pinID) {
    GrayedOut = false;
    Centered = false;
    divUnPinned = true;
    var pin = document.getElementById(pinID);
    pin.style.position = 'static';
    pin.style.margin = '0';
    var grayOutDivObj = document.getElementById('grayOutDiv');
    try {
        grayOutDivObj.style.height = '1px';
        grayOutDivObj.style.width = '1px';
        grayOutDivObj.style.display = 'none';
        GrayedOut = false;
    }
    catch (err2) {
    }
}
function pinDiv(id, pinID) {
    var pin = document.getElementById(pinID);
    divUnPinned = false;
    pin.style.position = 'absolute';
    pin.style.margin = '-9999';
    GrayedOut = true;
    Centered = true;
    var grayOutDivObj = document.getElementById('grayOutDiv');
    try {
        grayOutDivObj.style.height = '1px';
        grayOutDivObj.style.width = '1px';
        grayOutDivObj.style.display = 'block';
    }
    catch (err2) {
    }
    OnPageResize()
}
function OnPageResize() {
    var grayOutDivObj = document.getElementById('grayOutDiv');
    if (Centered && ScrollDivID != null) {
        var divObj = document.getElementById(ScrollDivID);
        var winW = 0, winH = 0;
        if (parseInt(navigator.appVersion) > 3) {
            if (navigator.appName == "Netscape") {
                winW = window.innerWidth;
                winH = window.innerHeight;
            }
            if (navigator.appName.indexOf("Microsoft") != -1) {
                if (navigator.userAgent.indexOf("MSIE 10") != -1) {
                    winW = window.innerWidth;
                    winH = window.innerHeight;
                } else {
                    winW = document.body.offsetWidth;
                    winH = document.body.offsetHeight;
                }
            }
        }
        DivTop = (winH - DivHeight) / 2;
        DivLeft = (winW - DivWidth) / 2;
        divObj.style.top = DivTop;
        divObj.style.left = DivLeft;
        if (DivHeight > winH) {
            divObj.style.top = 0;
            if (autoResize) { divObj.style.height = winH - 10 + 'px'; } else { divObj.style.position = "absolute"; document.body.scrollTop = 0; oversizedWindow = true; }
            DivTop = 0;
        } else {
            divObj.style.height = DivHeight + 'px';
        }
        if (DivWidth > winW) {
            divObj.style.left = 0;
            if (autoResize) { divObj.style.width = winW - 10 + 'px'; } else { divObj.style.position = "absolute"; document.body.scrollLeft = 0; oversizedWindow = true; }
            DivLeft = 0;
        } else {
            divObj.style.width = DivWidth + 'px';
        }
        if ($j.browser.msie && parseInt($j.browser.version) >= 10) {
            // size iframe for ie 10 standard mode
            var idRoot = id.replace('Div', '');
            var iframeH = $j('#' + idRoot + 'ContentCell').height();
            $j('#' + idRoot + 'iframe').height(iframeH);
        }
        ScrollTheDiv();
    }
    if (GrayedOut) {
        grayOutDivObj.style.height = "1px";
        grayOutDivObj.style.width = "1px";
        try {
            var pageWidth = $j(document).width() + "px";
            var pageHeight = $j(document).height() + "px";
        }
        catch (e) {
            if (document.body && (document.body.scrollWidth || document.body.scrollHeight)) {
                var pageWidth = document.body.scrollWidth + 'px';
                var pageHeight = document.body.scrollHeight + 'px';
            } else if (document.body.offsetWidth) {
                var pageWidth = document.body.offsetWidth + 'px';
                var pageHeight = document.body.offsetHeight + 'px';
            } else {
                var pageWidth = '100%';
                var pageHeight = '100%';
            }
        }
        grayOutDivObj.style.height = pageHeight;
        grayOutDivObj.style.width = pageWidth;
    }
}
function AdminDashShown() {
    var Dash = document.getElementById("adminDashboard");
    if (Dash) {
        //if(Dash.style.display=="none") return false;
        return true;
    }
    else {
        return false;
    }
}
function ScrollTheDiv() {
    var PageX = 0; var PageY = 0;
    if (typeof (window.pageYOffset) == 'number') {
        PageY = window.pageYOffset;
        PageX = window.pageXOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        PageY = document.body.scrollTop;
        PageX = document.body.scrollLeft;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        PageY = document.documentElement.scrollTop;
        PageX = document.documentElement.scrollLeft;
    }
    try {
        var buddyListDivObj = document.getElementById("buddyListDiv");
        buddyListDivObj.style.top = parseFloat(PageY) + 51;
    } catch (e) {
    }
    try {
        var buddyListDivObj = document.getElementById("buddyListDiv_opener");
        if (AdminDashShown() && PageY < 52) {
            buddyListDivObj.style.top = "52px";
        } else {
            buddyListDivObj.style.top = parseFloat(PageY) + 4 + "px";
        }
    } catch (e) {
    }
    try {
        var Props = document.getElementById("rdpPagePropsOpener");
        if (AdminDashShown() && PageY < 52) {
            Props.style.top = 52;
        } else {
            Props.style.top = parseFloat(PageY) + 4;
        }
    }
    catch (err) {
    }
    var divSubModalObj = document.getElementById(ScrollDivID);
    if (!divSubModalObj) return;
    if (MoveSocialItemsLightbox()) return;
    if (divSubModalObj.style.visibility != null && divUnPinned == false && oversizedWindow == false) {
        if (divSubModalObj.style.position == "fixed") return;
        if (DivTop == null && DivLeft == null) {
            DivTop = parseFloat(divSubModalObj.style.top.replace(/px/, ''));
            DivLeft = parseFloat(divSubModalObj.style.left.replace(/px/, ''));
        }
        var Top = DivTop + parseFloat(PageY);
        var Left = DivLeft + parseFloat(PageX);
        divSubModalObj.style.top = Top + "px";
        divSubModalObj.style.left = Left + "px";
    } else if (divUnPinned == true || oversizedWindow == true) {
        // its fiiiiiine
    } else {
        DivTop = null;
        DivLeft = null;
    }
}
function MoveSocialItemsLightbox() {
    if (ScrollDivID == "socialItemsLightboxDiv") {
        $j("#socialItemsLightboxDiv").css("position", "absolute");
        $j("#socialItemsLightboxDiv").css("top", "25");
        return true;
    }
    return false;
}
function MiniPageMouseover(id) {
    try {
        var MPDiv = document.getElementById("mpDiv" + id);
        MPDiv.style.zIndex = 100000;
        MPDiv.style.position = 'relative';
        MPDiv.style.background = "#ffffff";
    } catch (e) {
    }
    try {
        var CTEDiv = document.getElementById("clickToEditDiv" + id);
        CTEDiv.style.zIndex = 100000;
        CTEDiv.style.position = 'relative';
        CTEDiv.style.background = "#ffffff";
    } catch (e) {
    }
    var grayOutDivObj = document.getElementById('grayOutDiv');
    if (document.body && (document.body.scrollWidth || document.body.scrollHeight)) {
        var pageWidth = document.body.scrollWidth + 'px';
        var pageHeight = document.body.scrollHeight + 'px';
    } else if (document.body.offsetWidth) {
        var pageWidth = document.body.offsetWidth + 'px';
        var pageHeight = document.body.offsetHeight + 'px';
    } else {
        var pageWidth = '100%';
        var pageHeight = '100%';
    }
    grayOutDivObj.style.display = 'block';
    grayOutDivObj.style.height = pageHeight;
    grayOutDivObj.style.width = pageWidth;
}
function MiniPageMouseout(id) {
    try {
        var MPDiv = document.getElementById("mpDiv" + id);
        MPDiv.style.background = "none";
        MPDiv.style.zIndex = 0;
    } catch (e) {
    }
    try {
        var MPDiv = document.getElementById("clickToEditDiv" + id);
        MPDiv.style.background = "none";
        MPDiv.style.zIndex = 0;
    } catch (e) {
    }
    var grayOutDivObj = document.getElementById('grayOutDiv');
    try {
        grayOutDivObj.style.display = 'none';
    } catch (err2) {
    }
}
function GreyOutMouseOver(id) {
    var MPDiv = document.getElementById(id);
    MPDiv.style.zIndex = 100000;
    MPDiv.style.position = 'relative';
    MPDiv.style.background = "#ffffff";
    var grayOutDivObj = document.getElementById('grayOutDiv');
    if (document.body && (document.body.scrollWidth || document.body.scrollHeight)) {
        var pageWidth = document.body.scrollWidth + 'px';
        var pageHeight = document.body.scrollHeight + 'px';
    } else if (document.body.offsetWidth) {
        var pageWidth = document.body.offsetWidth + 'px';
        var pageHeight = document.body.offsetHeight + 'px';
    } else {
        var pageWidth = '100%';
        var pageHeight = '100%';
    }
    grayOutDivObj.style.display = 'block';
    grayOutDivObj.style.height = pageHeight;
    grayOutDivObj.style.width = pageWidth;
}
function GreyOutMouseout(id) {
    var MPDiv = document.getElementById(id);
    MPDiv.style.background = "none";
    MPDiv.style.zIndex = 0;
    var grayOutDivObj = document.getElementById('grayOutDiv');
    try {
        grayOutDivObj.style.display = 'none';
    } catch (err2) {
    }
}
function scrollElement(id, direction, distance) {
    var ele = document.getElementById(id);
    if (direction == 'left') {
        try { ele.scrollLeft = ele.scrollLeft - distance; } catch (e) { ele.scrollLeft = 0; }
    }
    if (direction == 'right') {
        try { ele.scrollLeft = ele.scrollLeft + distance; } catch (e) { ele.scrollLeft = ele.scrollWidth; }
    }
    if (direction == 'up') {
        try { ele.scrollTop = ele.scrollTop - distance; } catch (e) { ele.scrollTop = 0; }
    }
    if (direction == 'down') {
        try { ele.scrollTop = ele.scrollTop + distance; } catch (e) { ele.scrollTop = ele.scrollHeight; }
    }
}
function FormatCurrency(tb) {
    var num = tb.value;
    tb.value = formatCurrency(num);
}
function formatCurrency(num, noCents) {
    num = num.toString().replace(/\$|\,/g, '');
    if (isNaN(num)) num = "0";
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num * 100 + 0.50000000001);
    cents = num % 100;
    num = Math.floor(num / 100).toString();
    if (cents < 10)
        cents = "0" + cents;
    for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++)
        num = num.substring(0, num.length - (4 * i + 3)) + ',' +
        num.substring(num.length - (4 * i + 3));
    if (noCents) {
        return ((sign) ? '' : '-') + '$' + num;
    } else {
        return ((sign) ? '' : '-') + '$' + num + '.' + cents;
    }
}
function formatNumberCommas(x) {
    var parts = x.toString().split(".");
    parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
    return parts.join(".");
}
function UnformatCurrency(tb) {
    var num = tb.value;
    num = num.toString().replace(/\$|\,/g, '');
    tb.value = num;
}
function getXMLHttpObj() {
    if (typeof (XMLHttpRequest) != 'undefined')
        return new XMLHttpRequest();

    var axO = ['Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.4.0',
		'Msxml2.XMLHTTP.3.0', 'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'], i;
    for (i = 0; i < axO.length; i++)
        try {
            return new ActiveXObject(axO[i]);
        } catch (e) { }
    return null;
}
function EnableKeepAlive() {
    CreateKeepAliveCookie();
    window.setInterval("CreateKeepAliveCookie();", 60000);
}
function CreateKeepAliveCookie() {
    var exdate = new Date();
    var minutes = exdate.getMinutes();
    minutes += 2;
    exdate.setMinutes(minutes);
    document.cookie = "keepAlive_" + escape(document.location.href) + "=open;expires=" + exdate.toGMTString() + ";path=/";
}
function SelectMyTab(sender, eventArgs) {
    var multiPageID = sender.get_multiPageID();
    var tab = eventArgs.get_tab();
    sender.set_multiPageID(null);
    tab.select();
}
function UnSelectMyTab(e, ctrl) {
    var tabStrip = $find(ctrl.id);
    if (!tabStrip) return;
    //Find the element which the mouse is over  
    var destElement = e.relatedTarget || e.toElement;
    if ($telerik.isDescendant(tabStrip.get_element(), destElement))
        return;
    var initialTab = tabStrip.findTabByText(tabStrip.get_attributes().getAttribute("InitialTab"));
    initialTab.unselect();
    initialTab.selectParents();
}
function getSessionUID() {
    var c_name = "ceSessionUID";
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}
function autoResizeIframe(id) {
    var newheight;
    var newwidth;
    if (document.getElementById) {
        newheight = document.getElementById(id).contentWindow.document.body.scrollHeight;
        newwidth = document.getElementById(id).contentWindow.document.body.scrollWidth;
    }
    document.getElementById(id).height = (newheight) + "px";
    document.getElementById(id).width = "100%"; //(newwidth) + "px";
}
function resizeSlideMenu(menuID) {
    var totalAdjust = 0;
    var m = $j('#' + menuID);
    totalAdjust += ($j(m).find('ul').outerWidth(true) - $j(m).find('ul').width());
    totalAdjust += ($j(m).outerWidth(true) - $j(m).width());
    if ($j.browser.msie) {
        $j(m).find('ul.rmRootGroup > li').each(function () { if (parseInt($j(this).css("margin-left").replace("px", ""))) { totalAdjust += parseInt($j(this).css("margin-left").replace("px", "")) }; if (parseInt($j(this).css("margin-right").replace("px", ""))) { totalAdjust += parseInt($j(this).css("margin-right").replace("px", "")) }; });
        while (totalAdjust > 0) {
            $j(m).find('ul.rmRootGroup > li').each(function () { if ($j(this).width() > 0 && totalAdjust > 0) { $j(this).width(($j(this).width() - 1) + ((parseInt($j(this).css("padding-left").replace("px", ""))) ? parseInt($j(this).css("padding-left").replace("px", "")) : 0) + ((parseInt($j(this).css("padding-right").replace("px", ""))) ? parseInt($j(this).css("padding-right").replace("px", "")) : 0) + ((parseInt($j(this).css("border-left-width").replace("px", ""))) ? parseInt($j(this).css("border-left-width").replace("px", "")) : 0) + ((parseInt($j(this).css("border-right-width").replace("px", ""))) ? parseInt($j(this).css("border-right-width").replace("px", "")) : 0)); totalAdjust -= 1; } });
        }
    } else {
        $j(m).find('ul.rmRootGroup > li').each(function () { totalAdjust += ($j(this).outerWidth(true) - $j(this).width()); });
        while (totalAdjust > 0) {
            $j(m).find('ul.rmRootGroup > li').each(function () { if ($j(this).width() > 0 && totalAdjust > 0) { $j(this).width(($j(this).width() - 1)); totalAdjust -= 1; } });
        }
    }
}
function getCookie(c_name) {
    if (document.cookie.length > 0) {
        var c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            var c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}
function setCookie(c_name, value, expiredays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" + escape(value) +
    ((expiredays == null) ? "" : ";expires=" + exdate.toUTCString());
}
var escapeable = /["\\\x00-\x1f\x7f-\x9f]/g,

		meta = {

		    '\b': '\\b',

		    '\t': '\\t',

		    '\n': '\\n',

		    '\f': '\\f',

		    '\r': '\\r',

		    '"': '\\"',

		    '\\': '\\\\'

		};
function JSONescape(string) {
    if (string.match(escapeable)) {

        return string.replace(escapeable, function (a) {

            var c = meta[a];

            if (typeof c === 'string') {

                return c;

            }

            c = a.charCodeAt();

            return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);

        });

    }

    return string;
}
function hasTouchSupport() {
    var support = {},
            events = ['touchstart', 'touchmove', 'touchend'],
            el = document.createElement('div'), i;

    try {
        for (i = 0; i < events.length; i++) {
            var eventName = events[i];
            eventName = 'on' + eventName;
            var isSupported = (eventName in el);
            if (!isSupported) {
                el.setAttribute(eventName, 'return;');
                isSupported = typeof el[eventName] == 'function';
            }
            support[events[i]] = isSupported;
        }
        return support.touchstart && support.touchend && support.touchmove;
    }
    catch (err) {
        return false;
    }
}
function axisShareThis(sender) {
    var senderOffset = $j(sender).offset();
    var left = senderOffset.left;
    var top = senderOffset.top + $j(sender).height();
    if (($j(window).width() / 2) < left) {
        $j("#shareBar").css("left", left - ($j("#shareBar").width() - $j(sender).width()));
    } else {
        $j("#shareBar").css("left", left);
    }
    $j("#shareBar").css("top", top);
    $j("#shareBar").fadeIn();
}
function CloseAxisShareThisBox() {
    $j("#shareBar").hide();
}
axisBrowser = function () {
    if (jQuery.parseJSON(getCookie("CEBrowser"))) {
        return jQuery.parseJSON(getCookie("CEBrowser"));
    } else {
        var obj = {};
        return obj;
    }
}

function setRadUL(menuID, r) {
    var u = $j('#' + menuID).find('.rmRootGroup');
    var totalWidth = 1;
    if ($j.browser.mozilla) { totalWidth = 2; }
    $j('#' + menuID).find('.rmRootGroup.rmHorizontal .rmItem').each(function () { totalWidth += $j(this).width(); });
    $j(u).css('width', totalWidth);
    if (r == 1) { var ww = $j(window).width(); if (totalWidth > ww) { $j(u).css('width', 'auto'); } }
}
function AttachCredentialValidation(UserID, Credential, TextboxID, ConfirmTextboxID, OutputDivID) {
    var Textbox;
    if (TextboxID !== "") Textbox = $j("#" + TextboxID);
    var ConfirmTextbox;
    if (ConfirmTextboxID !== "") ConfirmTextbox = $j("#" + ConfirmTextboxID);
    var OutputDiv;
    if (OutputDivID !== "") OutputDiv = $j("#" + OutputDivID);
    if (Textbox.length !== 1) return;
    var PathToASMX = sitePath + "/A_Master/NET/Login/Credentials.asmx";
    $j.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: PathToASMX + "/GetValidateLoginCredentialJSON",
        data: "{\"UserID\": \"" + UserID + "\",\"Credential\": \"" + Credential + "\"}",
        dataType: "json",
        success: function (data) {
            var criteria = data.d;
            //alert(criteria);
            outputValidationCriteria(Textbox, ConfirmTextbox, OutputDiv, criteria);
            Textbox.focus(function () { if ($j(this).val().trim() === "********") $j(this).val(""); outputValidationCriteria(Textbox, ConfirmTextbox, OutputDiv, criteria); });
            Textbox.blur(function () { if ($j(this).val().trim() === "" && $j(this).attr("isdefault") === "true") $j(this).val("********"); outputValidationCriteria(Textbox, ConfirmTextbox, OutputDiv, criteria); });
            Textbox.keyup(function () { outputValidationCriteria(Textbox, ConfirmTextbox, OutputDiv, criteria); });
            if (ConfirmTextbox && ConfirmTextbox.length === 1) {
                ConfirmTextbox.after($j("<span/>").addClass("credentialInputValidator").attr("id", ConfirmTextboxID + "_validator"));
                ConfirmTextbox.keyup(function () { checkValidationIsEqual(Textbox, ConfirmTextbox); });
            }
            Textbox.after($j("<span/>").addClass("credentialInputValidator").attr("id", TextboxID + "_validator"));
        },
        error: function (xhr, status, error) { alert(xhr.responseText); }
    });
}
function checkValidationIsEqual(Textbox, ConfirmTextbox) {
    var inputValidator = $j("#" + ConfirmTextbox.attr("id") + "_validator");
    inputValidator.removeClass("isValid");
    inputValidator.removeClass("notValid");
    if (Textbox.val() === "" || ConfirmTextbox.val() === "") return;
    if (Textbox.val() === ConfirmTextbox.val()) {
        inputValidator.addClass("isValid");
    } else {
        inputValidator.addClass("notValid");
    }
}
function outputValidationCriteria(Textbox, ConfirmTextbox, OutputDiv, Criteria) {
    var evaled = eval("(" + Criteria + ")");
    OutputDiv.html("");
    OutputDiv.removeClass("criteriaValidationWrapper");
    OutputDiv.addClass("criteriaValidationWrapper");
    OutputDiv.hide();
    var input = Textbox.val().trim();
    var ul = $j("<ul/>").appendTo(OutputDiv);
    var inputIsValid = true;
    $j.each(evaled, function (key, Criteria) {
        var isValid = false;
        if (input !== "") { //do the validation
            switch (Criteria.Type) {
                case "AllowedChars":
                    if (Criteria.Value.indexOf(":") !== -1) {
                        var split = Criteria.Value.split(":");
                        if (split.length === 2) {
                            if (input.length >= split[0] && input.length <= split[1]) isValid = true;
                            break;
                        }
                    }
                case "MinChars":
                    if (input.length >= Criteria.Value) isValid = true;
                    break;
                case "MaxChars":
                    if (input.length < Criteria.Value) isValid = true;
                    break;
                case "LCaseChars":
                    var LCaseCount = 0;
                    for (var i = 0; i < input.length; i++) {
                        if (input.charCodeAt(i) >= 97 && input.charCodeAt(i) <= 122) LCaseCount++;
                    }
                    if (LCaseCount >= Criteria.Value) isValid = true;
                    break;
                case "UCaseChars":
                    var UCaseCount = 0;
                    for (var i = 0; i < input.length; i++) {
                        if (input.charCodeAt(i) >= 65 && input.charCodeAt(i) <= 90) UCaseCount++;
                    }
                    if (UCaseCount >= Criteria.Value) isValid = true;
                    break;
                case "NumericChars":
                    var NumericCount = 0;
                    for (var i = 0; i < input.length; i++) {
                        if (input.charCodeAt(i) >= 48 && input.charCodeAt(i) <= 57) NumericCount++;
                    }
                    if (NumericCount >= Criteria.Value) isValid = true;
                    break;
                case "SpecialChars":
                    var SpecialCount = 0;
                    for (var i = 0; i < input.length; i++) {
                        if (input.charCodeAt(i) >= 33 && input.charCodeAt(i) <= 47) SpecialCount++;
                        if (input.charCodeAt(i) >= 58 && input.charCodeAt(i) <= 64) SpecialCount++;
                        if (input.charCodeAt(i) >= 91 && input.charCodeAt(i) <= 96) SpecialCount++;
                        if (input.charCodeAt(i) >= 123 && input.charCodeAt(i) <= 126) SpecialCount++;
                    }
                    if (SpecialCount >= Criteria.Value) isValid = true;
                    break;
                case "NoFirstName":
                    if (input.toLowerCase().indexOf(Criteria.Value) === -1) isValid = true;
                    break;
                case "NoLastName":
                    if (input.toLowerCase().indexOf(Criteria.Value) === -1) isValid = true;
                    break;
                case "NotOppositeReversed":
                    if (input.toLowerCase() !== Criteria.Value) isValid = true;
                    break;
                case "NotOpposite":
                    if (input.toLowerCase() !== Criteria.Value) isValid = true;
                    break;
                case "NoContainOpposite":
                    if (input.toLowerCase().indexOf(Criteria.Value) === -1) isValid = true;
                    break;
                case "AllowedPasswords":
                    isValid = true
                    break;
                default:
                    isValid = true;
            }
            if (!isValid) inputIsValid = false;
        }
        var li = $j("<li/>").appendTo(ul);
        if (Criteria.Type === "AllowedPasswords" || Criteria.Type === "NotInUseByAnotherAccount") {
        } else {
            li.addClass((isValid) ? "isValid" : "notValid");
        }
        var div = $j("<div/>").appendTo(li);
        $j("<span/>").addClass("validateImage").addClass().appendTo(div);
        $j("<span/>").addClass("validateText").html(Criteria.DisplayString).appendTo(div);
    });
    var inputValidator = $j("#" + Textbox.attr("id") + "_validator");
    inputValidator.removeClass("isValid");
    inputValidator.removeClass("notValid");
    if (input !== "") inputValidator.addClass((inputIsValid) ? "isValid" : "notValid");
    if (!inputIsValid || Textbox.is(":focus") || input === "") OutputDiv.show();
    if (ConfirmTextbox) checkValidationIsEqual(Textbox, ConfirmTextbox);
    if (evaled.length === 0) {
        OutputDiv.hide();
        inputValidator.hide();
    }
    if (input === "********") {
        OutputDiv.hide();
        inputValidator.removeClass("isValid");
        inputValidator.removeClass("notValid");
    }
}
jQuery.expr[':'].focus = function (elem) {
    return elem === document.activeElement && (elem.type || elem.href);
};
function FloatHeader(tableId) {

    if ($j("#" + tableId + "_floatedHeader").length !== 0) $j("#" + tableId + "_floatedHeader").remove();

    var $originalTable = $j("#" + tableId);

    var $floatedHeader = $j("<div/>").attr("id", tableId + "_floatedHeader").attr("originaltableid", tableId).addClass("floatedTableHeader").hide();
    $floatedHeader.offset({ left: $originalTable.offset().left });

    try {
        var browser = axisBrowser();
        if (browser.Browser === "IE") {
            $floatedHeader.css("position", "absolute").css("top", $j(window).scrollTop());
        } else {
            $floatedHeader.css("position", "fixed").css("top", "0");
        }
    } catch (e) {
        $floatedHeader.css("position", "fixed").css("top", "0");
    }

    $originalTable.parent().append($floatedHeader);

    var $table = $originalTable.clone().html("").attr("id", "");
    var $originalRow = $originalTable.find("tr:first");
    var $row = $originalRow.clone();

    $originalRow.children("td").each(function (index) {
        $j($row.children("td")[index]).width($j(this).width());
    });

    $table.append($row);

    $floatedHeader.append($table);

    if ($j(window).scrollTop() > $originalTable.offset().top) {
        $floatedHeader.show();
    }

    if ($j(window).scrollTop() > $originalTable.offset().top + $originalTable.height()) {
        $floatedHeader.hide();
    }

    $j(document).scroll(function () {
        if ($j(window).scrollTop() > $originalTable.offset().top) {
            if ($floatedHeader.css("position") === "absolute") {
                $floatedHeader.css("top", $j(window).scrollTop());
            }
            $floatedHeader.show();
        } else {
            $floatedHeader.hide();
        }
        if ($j(window).scrollTop() > $originalTable.offset().top + $originalTable.height()) {
            $floatedHeader.hide();
        }
    });

}
        String.prototype.replaceAll = function(target, replacement) {
          return this.split(target).join(replacement);
        };


      // #### CRM Integration
        function crm_Init() {
            $j('[data-crm-init="load"]').each(function () {
                crm_ReplaceContent(this);
            });
        }
        function crm_ReplaceContent(obj) {
            if ($j(obj).attr("data-crm-init") != 'complete') {
                $j(obj).attr("data-crm-init", 'complete');
                var postData = JSON.parse($j(obj).attr("data-crm-filters"));
                postData["prefix"] = $j(obj).attr("data-crm-prefix");
                postData["content"] = $j(obj).html();
                $j(obj).html('Loading ...');

                var jsonContent = JSON.stringify(postData);
                $j.ajax({
                    type: "POST",
                    url: $j(obj).attr('data-crm-path') + "/content/replace",
                    data: jsonContent,
                    dataType: 'json',
                    success: function (data, status, xhr) {
                        $j(obj).html(data);
                    },
                    error: function (xhr, status, error) { alert(xhr.responseText); }
                });
            }
      }


      // #### End CRM Integration
