var isNS = (navigator.appName.indexOf("Netscape") != -1);


var isIE = false;
var ue = navigator.userAgent;
if (ue.indexOf("MSIE") > -1) {
    isIE = true;
}
else {
    isIE = false;
}


// n: id of object(string)
// d: document which will be searched for
// Examples:
// 1. FindObject('txtName');
// 2. FindObject('txtName',window.opener.document);

function FindObject(n, d) {
    var p, i, x; if (!d) d = document;
    if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document;
        n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n];
    for (i = 0; !x && i < d.forms.length; i++)
        x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++)
        x = FindObject(n, d.layers[i].document);
    if (!x && document.getElementById)
        x = document.getElementById(n);
    return x;
}

(function () { /*Use Object Detection to detect IE6*/
    var m = document.uniqueID /*IE*/
&& document.compatMode /*>=IE6*/
&& !window.XMLHttpRequest /*<=IE6*/
&& document.execCommand;
    try {
        if (!!m) { m("BackgroundImageCache", false, true) /* = IE6 only */ }
    }

    catch (oh) { };

})();

function checkHtmlTags(control) {
    var invalidControls = "";

    if (control.value.indexOf('<') > -1) {
        invalidControls = "< ";
        control.value = control.value.replace("<", '')
    }
    else if (control.value.indexOf('/>') > -1) {
        invalidControls += "/> "
        control.value = control.value.replace("/>", '')
    }
    else if (control.value.indexOf('>') > -1) {
        invalidControls += "> "
        control.value = control.value.replace(">", '')
    }

    if (invalidControls.length != 0) {
        //alert("Please dont use characters like " + invalidControls);
        return;
    }
}

function Trim(s) {
    // Remove leading spaces and carriage returns
    while ((s.substring(0, 1) == ' ') || (s.substring(0, 1) == '\n') || (s.substring(0, 1) == '\r'))
    { s = s.substring(1, s.length); }

    // Remove trailing spaces and carriage returns
    while ((s.substring(s.length - 1, s.length) == ' ') || (s.substring(s.length - 1, s.length) == '\n') || (s.substring(s.length - 1, s.length) == '\r'))
    { s = s.substring(0, s.length - 1); }

    return s;
}



function IsAlphanumeric(alphane) {
    var numaric = alphane;
    for (var j = 0; j < numaric.length; j++) {
        var alphaa = numaric.charAt(j);
        var hh = alphaa.charCodeAt(0);
        if ((hh > 47 && hh < 59) || (hh > 64 && hh < 91) || (hh > 96 && hh < 123) || (hh == 32)) {
        }
        else {
            return false;
        }
    }
    return true;
}

function AutoRedirectToFrame() {
    var url = top.location.href.substring(top.location.href.toLowerCase().indexOf('admin/') + 6);

    if (top.location.href.toLowerCase().lastIndexOf("frames.aspx") < 0) {
        if (top.location.href.toLowerCase().lastIndexOf("mediamanagement") < 0)
            top.location.href = "Frames.aspx?ReturnUrl=" + url;
        else
            top.location.href = url;
    }
}


function leapYear(Year) {
    return (((Year % 4) == 0) && ((Year % 100) != 0) || ((Year % 400) == 0)) ? 1 : 0;
}

function getDaysInMonth(month, year) {
    var days;
    if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
        days = 31;
    else if (month == 4 || month == 6 || month == 9 || month == 11)
        days = 30;
    else if (month == 2) {
        if (leapYear(year) == 1)
            days = 29;
        else
            days = 28;
    }
    return (days);
}

function validateDate(d, m, y, errorMsg, changedOne) {
    var day = FindObject(d);
    var month = FindObject(m);
    var year = FindObject(y);
    var changed = FindObject(changedOne);

    var myDate = day.value;
    var myMonth = month.selectedIndex + 1;
    var myYear = year.value;

    if (parseInt(myDate) > getDaysInMonth(myMonth, myYear)) {
        alert(errorMsg);
        changed.selectedIndex = 0;
        return false;
    }
    return true;
}


// w: dialog width
// h: dialogheight
// rs:1/0 resizable
// sc:1/0 scrollable
// mn:1/0 menuvisible
// Examples:
// <a href="myUrl" onclick="return Popup(this.href,400,300,0,0,0);">click to popup</a>
function Popup(url, w, h, rs, sc, mn, wn) {
    if (wn == undefined) {
        wn = 'bsh';
    }


    t = (screen.height / 2) - (h / 2);
    l = (screen.width / 2) - (w / 2);
    newwindow = window.open(url, wn, 'toolbar=0, status=1, menubar=' + mn + ', location=0, resizable=' + rs + ', scrollbars=' + sc + ', width=' + w + ', height=' + h + ', top=' + t + ', left=' + l);
    if (window.focus) { newwindow.focus() }
    return false;
}

function Popup1(url, rs, sc, mn) {
    // return Popup(url,600,400,rs,sc,mn);
    w = 600;
    h = 400;
    t = (screen.height / 2) - (h / 2);
    l = (screen.width / 2) - (w / 2);
    newwindow = window.open(url, 'bsh', 'toolbar=0, status=1, menubar=' + mn + ', location=0, resizable=' + rs + ', scrollbars=' + sc + ', width=' + w + ', height=' + h + ', top=' + t + ', left=' + l);
    if (window.focus) { newwindow.focus() }
    return false;
}


function Popup2(url, target, properties) {
    if (target == '_self') {
        window.open(url, '_self');
    }
    else if (target == '_blank_') {
        window.open(url, '_blank');
    }
    else {
        var strwidth = 'width';
        var strheight = 'height';
        var strStatus = 'status';
        var startIndex;
        var endIndex;
        var width;
        var height;


        startIndex = properties.indexOf(strheight);
        strheight = strheight + '=';
        startIndex = startIndex + strheight.length;
        endIndex = properties.indexOf(strwidth);
        height = properties.substring(startIndex, endIndex - 1);


        startIndex = properties.indexOf(strwidth);
        strwidth = strwidth + '=';
        startIndex = startIndex + strwidth.length;
        endIndex = properties.indexOf(strStatus);
        width = properties.substring(startIndex, endIndex - 1);

        var leftDim = (screen.width - width) / 2;
        var topDim = (screen.height - height) / 2;
        var hwString = 'left=' + leftDim + ',top=' + topDim + ',' + properties;
        window.open(url, '_blank', hwString);
    }
    return false;
}

function Popup3(w, h, url, rs, sc, mn) {
    t = (screen.height / 2) - (h / 2);
    l = (screen.width / 2) - (w / 2);
    newwindow = window.open(url, 'bsh', 'toolbar=0, status=1, menubar=' + mn + ', location=0, resizable=' + rs + ', scrollbars=' + sc + ', width=' + w + ', height=' + h + ', top=' + t + ', left=' + l);
    if (window.focus) { newwindow.focus() }
    return false;
}


// base page function for Admin
function AvoidHistoryBack__() {
    if (window.history.length > 0)
        window.history.forward();
}

function emailCheck(emailStr) {
    var checkTLD = 1;
    var knownDomsPat = /^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
    var emailPat = /^(.+)@(.+)$/;
    var specialChars = "\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
    var validChars = "\[^\\s" + specialChars + "\]";
    var quotedUser = "(\"[^\"]*\")";
    var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
    var atom = validChars + '+';
    var word = "(" + atom + "|" + quotedUser + ")";
    var userPat = new RegExp("^" + word + "(\\." + word + ")*$");
    var domainPat = new RegExp("^" + atom + "(\\." + atom + ")*$");
    var matchArray = emailStr.match(emailPat);

    if (matchArray == null) {
        return false;
    }

    var user = matchArray[1];
    var domain = matchArray[2];

    for (i = 0; i < user.length; i++) {
        if (user.charCodeAt(i) > 127) {
            return false;
        }
    }

    for (i = 0; i < domain.length; i++) {
        if (domain.charCodeAt(i) > 127) {
            return false;
        }
    }

    if (user.match(userPat) == null) {
        return false;
    }

    var IPArray = domain.match(ipDomainPat);

    if (IPArray != null) {
        for (var i = 1; i <= 4; i++) {
            if (IPArray[i] > 255) {
                return false;
            }
        }
        return true;
    }

    var atomPat = new RegExp("^" + atom + "$");
    var domArr = domain.split(".");
    var len = domArr.length;

    for (i = 0; i < len; i++) {
        if (domArr[i].search(atomPat) == -1) {
            return false;
        }
    }

    if (checkTLD && domArr[domArr.length - 1].length != 2 &&
	domArr[domArr.length - 1].search(knownDomsPat) == -1) {
        return false;
    }

    if (len < 2) {
        return false;
    }

    return true;
}

//PROGRESS LAYER CODES START
///////////////////////////////////////////////////////////////////////////////////////
function ActivateProgressArea() {
    if (gloDisplayProgress) {
        //		for(i = 0; i < document.forms[0].elements.length; i++) 
        //		{
        //			elm = document.forms[0].elements[i];
        //			if(elm.type == 'select-one' || elm.type == 'select-multiple')
        //			{
        //				elm.style.visibility = "HIDDEN";
        //			}
        //		}
        //		
        //		var progressBar = 'progressBar';
        //		var progressBarUnSeen = 'progressBarUnSeen';
        //		
        //		if (document.getElementById(progressBar) == null) return;
        //		document.getElementById(progressBar).style.visibility = '';
        //		document.getElementById(progressBar).style.zIndex = 1001;
        //		document.getElementById(progressBarUnSeen).style.visibility = '';
        //		document.getElementById(progressBarUnSeen).style.zIndex = 1000;
        //		document.getElementById(progressBarUnSeen).style.height = document.body.scrollHeight;
        //		document.getElementById(progressBarUnSeen).style.width = document.body.scrollWidth;
        JQ.loading();
    }
    gloDisplayProgress = true;
}

function getPageScrollTop() {
    var yScrolltop;
    if (self.pageYOffset) {
        yScrolltop = self.pageYOffset;
    }
    else if (document.documentElement && document.documentElement.scrollTop) {
        yScrolltop = document.documentElement.scrollTop;
    }
    else if (document.body) {
        yScrolltop = document.body.scrollTop;
    }
    arrayPageScroll = new Array('', yScrolltop)
    return arrayPageScroll;
}

function getPageSize() {
    var de = document.documentElement;
    var w = window.innerWidth || self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
    var h = window.innerHeight || self.innerHeight || (de && de.clientHeight) || document.body.clientHeight;

    arrayPageSize = new Array(w, h)
    return arrayPageSize;
}
///////////////////////////////////////////////////////////////////////////////////////
//PROGRESS LAYER CODES END


//Copyrights Management Crosscut, used in news
function linkClick(width, height, pageId) {
    x = (640 - width) / 2, y = (480 - height) / 2;

    if (screen) {
        y = (screen.availHeight - height) / 2;
        x = (screen.availWidth - width) / 2;
    }

    window.open('ExpiredPage.aspx?pageId=' + pageId, 'newWin', 'width=' + width + ',height=' + height + ',screenX=' + x + ',screenY=' + y + ',top=' + y + ',left=' + x);
}
///Copyrights Management Crosscut, used in news

var BrowserDetect = {
    init: function () {
        this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
        this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
        this.OS = this.searchString(this.dataOS) || "an unknown OS";
    },
    searchString: function (data) {
        for (var i = 0; i < data.length; i++) {
            var dataString = data[i].string;
            var dataProp = data[i].prop;
            this.versionSearchString = data[i].versionSearch || data[i].identity;
            if (dataString) {
                if (dataString.indexOf(data[i].subString) != -1)
                    return data[i].identity;
            }
            else if (dataProp)
                return data[i].identity;
        }
    },
    searchVersion: function (dataString) {
        var index = dataString.indexOf(this.versionSearchString);
        if (index == -1) return;
        return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
    },
    dataBrowser: [
		{
		    string: navigator.vendor,
		    subString: "Apple",
		    identity: "Safari"
		},
		{
		    prop: window.opera,
		    identity: "Opera"
		},
		{
		    string: navigator.vendor,
		    subString: "iCab",
		    identity: "iCab"
		},
		{
		    string: navigator.vendor,
		    subString: "KDE",
		    identity: "Konqueror"
		},
		{
		    string: navigator.userAgent,
		    subString: "Firefox",
		    identity: "Firefox"
		},
		{		// for newer Netscapes (6+)
		    string: navigator.userAgent,
		    subString: "Netscape",
		    identity: "Netscape"
		},
		{
		    string: navigator.userAgent,
		    subString: "MSIE",
		    identity: "Explorer",
		    versionSearch: "MSIE"
		},
		{
		    string: navigator.userAgent,
		    subString: "Gecko",
		    identity: "Mozilla",
		    versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
		    string: navigator.userAgent,
		    subString: "Mozilla",
		    identity: "Netscape",
		    versionSearch: "Mozilla"
		}
	],
    dataOS: [
		{
		    string: navigator.platform,
		    subString: "Win",
		    identity: "Windows"
		},
		{
		    string: navigator.platform,
		    subString: "Mac",
		    identity: "Mac"
		},
		{
		    string: navigator.platform,
		    subString: "Linux",
		    identity: "Linux"
		}
	]

};

















var Url = {

    // public method for url encoding
    encode: function (string) {
        return escape(this._utf8_encode(string));
    },

    // public method for url decoding
    decode: function (string) {
        return this._utf8_decode(unescape(string));
    },

    // private method for UTF-8 encoding
    _utf8_encode: function (string) {
        string = string.replace(/\r\n/g, "\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if ((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode: function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while (i < utftext.length) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if ((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i + 1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i + 1);
                c3 = utftext.charCodeAt(i + 2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }
}

// For country selection dropdownlist
function RedirectToCountry(elem) {
    if (document.forms[0].elements['myCountries_ddCountry']) {
        var strSelection;
        strSelection = document.forms[0].elements['myCountries_ddCountry'].options[document.forms[0].elements['myCountries_ddCountry'].selectedIndex].value;
        if (strSelection != "") {
            document.location.href = strSelection;
        }
    }
}
//For Ajax
function GetXmlHttpObject() {
    var xmlHttp = null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}
// remove special characters like "$" and "," etc...
function filterSpecialChars(str) {
    /* HTML Replaces */
    str = str.replace('&amp;', " "); // html -> &
    str = str.replace('&lt;', " ");  // html -> <
    str = str.replace('&gt;', " ");  // html -> >

    /* Unicode Character Replace */
    var newStr = '';
    for (var i = 0; i <= str.length - 1; i++)
        if (escape(str.charAt(i)) != '%AE' /* ® */
				&& escape(str.charAt(i)) != '%A9' /* © */
				&& escape(str.charAt(i)) != '%BD' /* ½ */) {
            //DEBUG ::: alert('in : ' + str.charAt(i) + ' --> ' + escape(str.charAt(i)));
            newStr += str.charAt(i);
        }
    /* Ascii Character Replace */
    re = /\$|,|\/|@|#|~|`|\%|\*|\^|\&|\(|\)|\+|\=|\[|\-|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|\./g;
    newStr = newStr.replace(re, " ");
    return newStr.replace("  ", " ").replace("  ", " ").replace("  ", " ").replace("  ", " ");
}

//moved from BasicSearch.ascx
function GenerateSearch(url, msg) {
    var expressionString = "";
    var q = FindObject('txtConditionText').value;
    q = Trim(q);

    q = filterSpecialChars(q);

    if (q != "") {
        if (q == "A++") {
            q = "APlusPlus";
        }
        if (q == "a++") {
            q = "APlusPlus";
        }
        searchText = q.split(" ");
        for (i = 0; i < searchText.length; i++) {
            if (Trim(searchText[i]) != "") {
                if (i < searchText.length - 1)
                    expressionString += "0|2|" + searchText[i].replace("'", "''") + "|0|1|";
                else
                    expressionString += "0|2|" + searchText[i].replace("'", "''") + "|0|";
            }
        }
        top.location.href = url + expressionString;
    }
    else {
        alert(msg);
    }

    return false;
}
function Del(Word) {
    a = Word.indexOf("<");
    b = Word.indexOf(">");
    len = Word.length;
    c = Word.substring(0, a);
    if (b == -1)
        b = a;
    d = Word.substring((b + 1), len);
    Word = c + d;
    tagCheck = Word.indexOf("<");
    if (tagCheck != -1)
        Word = Del(Word);
    return Word;
}


var FTS = {
    SiteMapId: jsbase + '/',
    Q: jsbq,
    S: jsbs,
    P: "",
    ExternalFrameName: '',
    ArticleCategoryKey: 'category',
    ArticleCategoryId: function () { return ''; },
    ProductNavigationAlert: '',
    Search: function (e, func) {
        if (e == 1) {
            func(keywords); return false;
        }
        var keyCode = e.keyCode ? e.keyCode : e.which;

        if (keyCode == 13) {
            eval(func);
            return false;
            // func(keywords);return false;
        }
        return true;
    },
    Article: function (keywords) {
        top.location.href = FTS.SiteMapId + FTS.P + FTS.Q + '=' + Url.encode(FTS.Escape(keywords)) + "&" + FTS.ArticleCategoryKey + "=" + FTS.ArticleCategoryId();
    },
    Site: function (keywords) {

        if (FTS.ExternalFrameName != '') {
            top.frames[FTS.ExternalFrameName].location.href = FTS.SiteMapId + FTS.P + FTS.Q + '=' + Url.encode(FTS.Escape(keywords));
        } else {
            top.location.href = FTS.SiteMapId + FTS.P + FTS.Q + '=' + Url.encode(FTS.Escape(keywords));
        }
        return false;
    },
    Site2: function (and, exact, any, none, near) {
        top.location.href = FTS.SiteMapId + FTS.P + (and == '' ? '' : (FTS.Q + '=' + Url.encode(FTS.Escape(and)))) + (exact == '' ? '' : ('&95=' + Url.encode(FTS.Escape(exact)))) + (any == '' ? '' : ('&97=' + Url.encode(FTS.Escape(any)))) + (none == '' ? '' : ('&98=' + Url.encode(FTS.Escape(none)))) + (near == '' ? '' : ('&99=' + Url.encode(FTS.Escape(near))));
        return false;
    },
    Site3: function (keywords, query) {
        top.location.href = FTS.SiteMapId + FTS.P + FTS.Q + '=' + Url.encode(FTS.Escape(keywords)) + query;
        return false;
    },
    Product: function (keywords) {
        top.location.href = jsbase + '/' + FTS.S + FTS.P + FTS.Q + '=' + Url.encode(FTS.Escape(keywords));
    },
    Product2: function (keywords, catalogue, category, family) {
        top.location.href = FTS.SiteMapId + FTS.P + FTS.Q + '=' + Url.encode(FTS.Escape(keywords)) + (catalogue == '' ? '' : '&' + catalogue) + (category == '' ? '' : '&' + category) + (family == '' ? '' : '&' + family);
    },
    ProductNavigation: function (optionValue) {
        if (optionValue == "") {
            if (FTS.ProductNavigationAlert != '') alert(FTS.ProductNavigationAlert);
        } else
            top.location.href = optionValue;

    },
    Feature: function (keywords) {
        top.location.href = jsbase + '/' + FTS.S + FTS.P + '95=' + Url.encode(FTS.Escape(keywords));
    },
    Escape: function (word) {
        if (word == "A++") word = "APlusPlus";
        if (word == "a++") word = "APlusPlus";

        word = word.replace(/<strong>/g, "__l__").replace(/<\/strong>/g, "__r__");
        word = word.replace(/<b>/g, "__bl__").replace(/<\/b>/g, "__br__");
        word = word.replace(/,/g, "+");
        word = word.replace(/&amp;/g, "+");
        word = word.replace(/&/g, "+");
        word = word.replace(/ /g, "+");
        word = word.replace(/</g, "+");
        word = word.replace(/>/g, "+");

        return word;
    }
}
FTS.P = typeof (window["jsbp"]) == "undefined" ? "" : jsbp;

function ProductSearchFor(q) {
    if (q == "A++") {
        q = "APlusPlus";
    }
    if (q == "a++") {
        q = "APlusPlus";
    }
    FTS.Feature(q);
}


function BaseGenerateProductSearch(i, exactSearch, urlForRedirect, alertEnterConditionText, ddlClientId, alertlblSelectAProductCategory, redirectForItem1, redirectForItem2, redirectForItem3, isJSActiveLocaleIsNull) {
    expressionString = "";

    var q = FindObject('txtProductQuery').value;
    q = Trim(q);
    q = Del(q);
    if (exactSearch == false)
        q = filterSpecialChars(q);

    if (i == 1) {
        if (q != "") {
            if (exactSearch) {
                expressionString += "0|2|" + q + "|0|";
            }
            else {
                searchText = q.split(" ");
                for (i = 0; i < searchText.length; i++) {
                    if (Trim(searchText[i]) != "") {
                        if (i < searchText.length - 1)
                            expressionString += "0|2|" + searchText[i].replace("'", "''") + "|0|2|";
                        else
                            expressionString += "0|2|" + searchText[i].replace("'", "''") + "|0|";
                    }
                }
            }
            top.location.href = urlForRedirect + expressionString;
        }
        else {
            alert(alertEnterConditionText);
        }
    }
    else {
        if (!isJSActiveLocaleIsNull) {
            itemId = FindObject(ddlClientId).value.split("~");
            if (itemId[0] == 0)
                alert(alertlblSelectAProductCategory);
            if (itemId[0] == 1)
                top.location.href = redirectForItem1 + itemId[1];
            else if (itemId[0] == 2)
                top.location.href = redirectForItem2 + itemId[1];
            else if (itemId[0] == 3)
                top.location.href = redirectForItem3 + itemId[1];
        }
    }

    return false;
}



function clearColumnDiv(pID, sVisible) {
    var el = window.document.getElementById(pID);
    if (el) if (sVisible == '') el.style.display = 'none';
}

// Only Use Bosch Style
function fixColumnDiv(pID, sVisible) {
    var el = window.document.getElementById(pID);
    if (el) if (sVisible == '') el.className = 'HeaderFixDiv';
}

function makeTableOrderable(objCell) {
    if (objCell.onclick.toString().indexOf("makeTableOrderable") > -1) {
        var objTable = objCell
        while (objTable.tagName.toLowerCase() != "table") {
            objTable = objTable.parentNode;
        }
        var sortType = 0;
        var tableId = "#" + objTable.id;
        if (objTable.id == 'tblMediaFiles') {
            JQ(tableId).tablesorter(
			{
			    headers:
				{
				    0: { sorter: false },
				    4: { sorter: false }
				},
			    sortList: [[objCell.cellIndex, sortType]]
			});
        }
        else if (objTable.id == 'tblDefaultPageSettings') {
            JQ(tableId).tablesorter(
			{
			    headers:
				{
				    1: { sorter: false },
				    2: { sorter: false }
				},
			    sortList: [[objCell.cellIndex, sortType]]
			});
        }
        else if (objTable.id == 'tblProductCodes') {
            JQ(tableId).tablesorter({
                sortList: [[objCell.cellIndex, sortType]]
            });
        }
        else {
            JQ(tableId).tablesorter(
						{
						    headers:
							{
							    4: { sorter: false },
							    5: { sorter: false },
							    6: { sorter: false }
							},
						    sortList: [[objCell.cellIndex, sortType]]
						});
        }
        objCell.click();
    }
}

function ExpandNode(NodeId) {

    var objDiv = document.getElementById("Exp" + NodeId);

    var objChild = document.getElementById("Child" + NodeId);

    if (objChild != null & objDiv != null) {
        if (objChild.style.display == 'none') {
            objChild.style.display = 'block';
            objDiv.innerHTML = "<span>-</span>";
        }
        else {
            objChild.style.display = 'none';
            objDiv.innerHTML = "<span>+</span>";
        }
    }

}

function linkCode(RSID, obj, linkName) {
    var s = s_gi(RSID);
    s.tl(obj, 'o', linkName);
}



String.prototype.trim = function () {
    return this.replace(/^\s+|\s+$/g, "");
}
String.prototype.ltrim = function () {
    return this.replace(/^\s+/, "");
}
String.prototype.rtrim = function () {
    return this.replace(/\s+$/, "");
}


