/* ----------------------------------------------------------- */
// Browser Sniff
/* ----------------------------------------------------------- */

var InstantASP_UserAgent = navigator.userAgent.toLowerCase();
var InstantASP_Opera = (InstantASP_UserAgent.indexOf('opera') != -1); // is opera
var InstantASP_Opera8 = ((InstantASP_UserAgent.indexOf('opera 8') != -1 || InstantASP_UserAgent.indexOf('opera/8') != -1) ? 1 : 0); // is opera8
var InstantASP_NS4 = (document.layers) ? true : false; // is netscape 4
var InstantASP_IE4 = (document.all && !document.getElementById) ? true : false; // is IE 4
var InstantASP_IE5 = (document.all && document.getElementById) ? true : false; // is IE 5+
var InstantASP_NS6 = (!document.all && document.getElementById) ? true : false; // is netscape 6
var InstantASP_FireFox = (InstantASP_UserAgent.indexOf("firefox/") != -1); // is firefox
var InstantASP_Transitions = (InstantASP_IE5 || InstantASP_IE4) ? true : false // do we support transitions

/* ----------------------------------------------------------- */
// Get a reference to an object on the client-side                   
/* ----------------------------------------------------------- */

var Drag = {

    obj: null,

    init: function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper) {
        o.onmousedown = Drag.start;

        o.hmode = bSwapHorzRef ? false : true;
        o.vmode = bSwapVertRef ? false : true;

        o.root = oRoot && oRoot != null ? oRoot : o;

        if (o.hmode && isNaN(parseInt(o.root.style.left))) o.root.style.left = "0px";
        if (o.vmode && isNaN(parseInt(o.root.style.top))) o.root.style.top = "0px";
        if (!o.hmode && isNaN(parseInt(o.root.style.right))) o.root.style.right = "0px";
        if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

        o.minX = typeof minX != 'undefined' ? minX : null;
        o.minY = typeof minY != 'undefined' ? minY : null;
        o.maxX = typeof maxX != 'undefined' ? maxX : null;
        o.maxY = typeof maxY != 'undefined' ? maxY : null;

        o.xMapper = fXMapper ? fXMapper : null;
        o.yMapper = fYMapper ? fYMapper : null;

        o.root.onDragStart = new Function();
        o.root.onDragEnd = new Function();
        o.root.onDrag = new Function();
    },

    start: function(e) {
        var o = Drag.obj = this;
        e = Drag.fixE(e);
        var y = parseInt(o.vmode ? o.root.style.top : o.root.style.bottom);
        var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right);
        o.root.onDragStart(x, y);

        o.lastMouseX = e.clientX;
        o.lastMouseY = e.clientY;

        if (o.hmode) {
            if (o.minX != null) o.minMouseX = e.clientX - x + o.minX;
            if (o.maxX != null) o.maxMouseX = o.minMouseX + o.maxX - o.minX;
        } else {
            if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
            if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
        }

        if (o.vmode) {
            if (o.minY != null) o.minMouseY = e.clientY - y + o.minY;
            if (o.maxY != null) o.maxMouseY = o.minMouseY + o.maxY - o.minY;
        } else {
            if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
            if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
        }

        document.onmousemove = Drag.drag;
        document.onmouseup = Drag.end;

        return false;
    },

    drag: function(e) {
        e = Drag.fixE(e);
        var o = Drag.obj;

        var ey = e.clientY;
        var ex = e.clientX;
        var y = parseInt(o.vmode ? o.root.style.top : o.root.style.bottom);
        var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right);
        var nx, ny;

        if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
        if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
        if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
        if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

        nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
        ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

        if (o.xMapper) nx = o.xMapper(y)
        else if (o.yMapper) ny = o.yMapper(x)

        Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
        Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
        Drag.obj.lastMouseX = ex;
        Drag.obj.lastMouseY = ey;

        Drag.obj.root.onDrag(nx, ny);
        return false;
    },

    end: function() {
        document.onmousemove = null;
        document.onmouseup = null;
        Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]),
									parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
        Drag.obj = null;
    },

    fixE: function(e) {
        if (typeof e == 'undefined') e = window.event;
        if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
        if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
        return e;
    }
};

function InstantASP_FindControl(strControlName) {

    var objReturn = '';
    if (InstantASP_IE5 || InstantASP_NS6 || InstantASP_Opera || InstantASP_Opera8) {
        objReturn = document.getElementById(strControlName);
    }
    else if (InstantASP_IE4) {
        objReturn = document.all[strControlName];
    }
    else if (InstantASP_NS4) {
        objReturn = document.layers[strControlName];
    }

    return objReturn

}


/* ----------------------------------------------------------- */
// Get top offset for object
/* ----------------------------------------------------------- */

function InstantASP_GetOffsetTop(objControl) {

    var top = objControl.offsetTop;
    var parent = objControl.offsetParent;
    while (parent != document.body) {
        top += parent.offsetTop;
        parent = parent.offsetParent;
    }
    return top;

}

/* ----------------------------------------------------------- */
// Get left offset for object
/* ----------------------------------------------------------- */

function InstantASP_GetOffsetLeft(objControl) {

    var left = objControl.offsetLeft;
    var parent = objControl.offsetParent;
    while (parent != document.body) {
        left += parent.offsetLeft;
        parent = parent.offsetParent;
    }
    return left;

}

/* ----------------------------------------------------------- */
// Starting with the given node, find the nearest contained element             
/* ----------------------------------------------------------- */

function InstantASP_GetContainer(node, tagName) {

    while (node != null) {
        if (node.tagName != null && node.tagName == tagName)
            return node; node = node.parentNode;
    }
    return node;
}

/* ----------------------------------------------------------- */
// Removes px and percentage markers from css style properties and returns an integer      
/* ----------------------------------------------------------- */

function InstantASP_StyleWidthToInt(strInput) {

    var strOutput = 0;
    if (strInput.toLowerCase().indexOf("px") >= 0) {
        strOutput = strInput.substr(0, strInput.toLowerCase().indexOf("px"));
    } else if (strInput.indexOf("%") >= 0) {
        strOutput = strInput.substr(0, strInput.indexOf("%"));
    }
    return parseInt(strOutput);

}

/* ----------------------------------------------------------- */
// XmlHttpRequest    
/* ----------------------------------------------------------- */

function InstantASP_XmlHttpRequest() {
    var XmlHttp, bComplete = false;
    try { XmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); }
    catch (e) {
        try { XmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
        catch (e) {
            try { XmlHttp = new XMLHttpRequest(); }
            catch (e) { XmlHttp = false; } 
        } 
    }
    if (!XmlHttp) return null;
    this.Connect = function(sURL, sMethod, sVars, oEvent) {
        if (!XmlHttp) return false;
        bComplete = false;
        sMethod = sMethod.toUpperCase();

        try {
            if (sMethod == "GET") {
                XmlHttp.open(sMethod, sURL + "?" + sVars, true);
                sVars = "";
            }
            else {
                XmlHttp.open(sMethod, sURL, true);
                XmlHttp.setRequestHeader("Method", "POST " + sURL + " HTTP/1.1");
                XmlHttp.setRequestHeader("Content-Type",
          "application/x-www-form-urlencoded");
            }
            XmlHttp.onreadystatechange = function() {
                if (XmlHttp.readyState == 4 && !bComplete) {
                    bComplete = true;
                    oEvent(XmlHttp);
                } 
            };
            XmlHttp.send(sVars);
        }
        catch (e) { return false; }
        return true;
    };
    return this;
}

/* ----------------------------------------------------------- */
// Encode a string for including within a URL      
/* ----------------------------------------------------------- */

function InstantASP_EncodeString(strInput) {

    if (!strInput) { return ''; }
    strInput = strInput.replace(/^\s*/, '');
    strInput = strInput.replace(/\s+/, ' ');
    strInput = strInput.replace(/\+/g, '%2B');
    strInput = strInput.replace(/\"/g, '%22').replace(/\'/g, '%27');
    return escape(strInput);

}

/* ----------------------------------------------------------- */
// Opens a new window
/* ----------------------------------------------------------- */

function InstantASP_OpenWindow(Url, Width, Height, Scroll, ToolBar, Location, Status, MenuBar, Resizeable, Unique) {
    var String;
    var winName = Width.toString() + Height.toString()
    String = "toolbar=" + ToolBar + ",location=" + Location
    String += ", directories=0,status=" + Status + ",menubar=" + MenuBar + ","
    String += "scrollbars=" + Scroll + ",resizable=" + Resizeable + ",copyhistory=0,";
    String += ",width=";
    String += Width;
    String += ",height=";
    String += Height;

    // should we center popup window
    if (InstantASP_IE4 || InstantASP_IE5 || InstantASP_Opera || InstantASP_NS6) {
        WndTop = (screen.height - Height) / 2;
        WndLeft = (screen.width - Width) / 2;
        String += ",top=";
        String += WndTop;
        String += ",left=";
        String += WndLeft;
    }

    // should we display single popup or allow multiple
    try {
        if (Unique == true) { WinPic = window.open(Url, WinNum++, String); }
        else { WinPic = window.open(Url, winName, String); WinPic.focus(); } 
    }
    catch (e) { };
}


/* ----------------------------------------------------------- */
// This funtion removes any trialing anchor points within a string
/* ----------------------------------------------------------- */

function InstantASP_RemoveBookMark(strInput) {
    var uri = new String(strInput)
    var strOutput; var intPos = uri.indexOf('#');
    if (intPos > 0) { strOutput = uri.substring(0, intPos); }
    else { strOutput = uri; } return strOutput;
}

/* ----------------------------------------------------------- */
// This funtion removes any querystring from a string
/* ----------------------------------------------------------- */

function InstantASP_RemoveQueryString(strInput) {
    var uri = new String(strInput)
    var strOutput; var intPos = uri.indexOf('?');
    if (intPos > 0) { strOutput = uri.substring(0, intPos); }
    else { strOutput = uri; } return strOutput;
}

/* ----------------------------------------------------------- */
// Get the height of an object.
/* ----------------------------------------------------------- */

function InstantASP_GetObjHeight(obj) {
    var height = 0;
    if (InstantASP_NS4) { var height = obj.clip.height; }
    else { var height = obj.offsetHeight; }
    return height;
}

/* ----------------------------------------------------------- */
// Start simple menu client side script
/* ----------------------------------------------------------- */

var InstantASP_MenusActive = false; // determines if a menu is active
var InstantASP_MenuItems = new Array(); // holds a collection of current active menus
var InstantASP_MenuLeft = 0;
var InstantASP_MenuRight = 0;
var InstantASP_MenuTop = 0;
var InstantASP_MenuBottom = 0;

/* ----------------------------------------------------------- */
// Set-up document event handlers	
/* ----------------------------------------------------------- */

if (InstantASP_IE4 || InstantASP_IE5 || InstantASP_Opera) {
    document.onclick = InstantASP_HideAllMenusOnClick;
    document.onscroll = InstantASP_HideAllMenusOnClick;
    window.onresize = InstantASP_HideAllMenus;
}
else if (InstantASP_NS6) {
    document.addEventListener("mousedown", InstantASP_HideAllMenusOnClick, true);
    window.addEventListener("onresize", InstantASP_HideAllMenus, true);
}
else if (InstantASP_NS4) {
    document.onmousedown = InstantASP_HideAllMenusOnClick;
    window.captureEvents(Event.MOUSEMOVE);
}

/* ----------------------------------------------------------- */
// Open Menu on MouseOver Event
/* ----------------------------------------------------------- */

function InstantASP_OpenMenuMouseOver(Caller, DivLayer, InnerHTML, Width) {

    if (InstantASP_MenusActive) { InstantASP_OpenMenu(Caller, DivLayer, InnerHTML, Width); }
}

/* ----------------------------------------------------------- */
// Open Menu on MouseClick Event
/* ----------------------------------------------------------- */

function InstantASP_OpenMenu(Caller, DivLayer, InnerHTML, Width) {
    //alert("Test");
    // create unique identity for generated div layer
    DivLayer = DivLayer + "_" + Caller

    // create iframe to hold menu, this ensures we render over dropdownlists
    var Iframe = DivLayer + "_Iframe"

    // determine if we can create elements dynamically
    if (!document.createElement) { return false; }

    // check to see if item is already within active menu array if so just quit and return false
    for (count = 0; count < InstantASP_MenuItems.length; count++) {
        if (InstantASP_MenuItems[count] == DivLayer) {
            return false;
        }
    }

    // hide any menus that maybe open
    InstantASP_HideAllMenus();

    // add active menu to array and set active state to true
    InstantASP_MenuItems[InstantASP_MenuItems.length] = DivLayer;
    InstantASP_MenusActive = true;

    // create the div layer container for this menu
    InstantASP_CreateLayer(InnerHTML, DivLayer, Iframe, Width);

    // get object references to div layer and div_layer that called this function    
    var div_layer = InstantASP_FindControl(DivLayer);
    div_layer.className = "Menu_SmallTxt";
    var div_layerIframe = InstantASP_FindControl(Iframe);
    var div_layer_caller = InstantASP_FindControl(Caller);

    // set default offset for div layer from the caller div
    var offsetTopDefault; offsetTopDefault = div_layer_caller.offsetHeight + 4;

    // position div layer relative to the opening link  
    var top = InstantASP_GetOffsetTop(div_layer_caller) + offsetTopDefault;
    var left = InstantASP_GetOffsetLeft(div_layer_caller);

    // set position of controls
    div_layer.style.top = top;
    div_layer.style.left = left;
    div_layerIframe.style.top = top;
    div_layerIframe.style.left = left;

    //  calculate left and top positions of current div layer
    if (InstantASP_IE4 || InstantASP_IE5 || InstantASP_Opera) {
        InstantASP_MenuLeft = div_layer.style.posLeft;
        InstantASP_MenuTop = div_layer.style.posTop - offsetTopDefault;
    } else if (InstantASP_NS6) {
        InstantASP_MenuLeft = InstantASP_StyleWidthToInt(div_layer.style.left);
        InstantASP_MenuTop = InstantASP_StyleWidthToInt(div_layer.style.top);
    }

    // calculate right and bottom positions of current div layer
    InstantASP_MenuRight = parseInt(InstantASP_MenuLeft) + parseInt(mnu_extent.x);
    InstantASP_MenuBottom = parseInt(InstantASP_MenuTop) + parseInt(mnu_extent.y);

    // now ensure Iframe sits tidy behind Div
    div_layerIframe.style.height = (InstantASP_MenuBottom - InstantASP_MenuTop);

    // ensure width is tidy
    Width = InstantASP_StyleWidthToInt(Width)

    // attempt to keep menu on screen			
    if (InstantASP_IE4 || InstantASP_IE5 || InstantASP_Opera || InstantASP_NS6) {
        win_width = document.body.clientWidth;
        if (InstantASP_MenuRight > win_width) {
            div_layer.style.left = win_width - Width - 10;
            div_layerIframe.style.left = win_width - Width - 10;
        }
    }

    // finally display the menu		
    // if this is not IE we don't need to display the Iframe
    if ((InstantASP_IE4 || InstantASP_IE5 && !InstantASP_Opera)) { div_layerIframe.style.display = ""; }
    div_layer.style.display = "";


}

function noError() { return true; }
window.onerror = noError;
/* ----------------------------------------------------------- */
// Create div layer to hold menu
/* ----------------------------------------------------------- */

function InstantASP_CreateLayer(InnerHTML, DivLayer, Iframe, mnu_width) {
    if (DivLayer == "ctl02_ctl00_smSearch_SimpleMenuDivLayer_ctl02_ctl00_smSearch" && navigator.appName == "Microsoft Internet Explorer") {
        InnerHTML = InnerHTML.replace("FormButtonBig", "'FormButtonBig1'");
    }
    if (InnerHTML.indexOf("Rate This Topic") >= 0) {
        InnerHTML = InnerHTML.replace("FormButtonBig", "'FormButtonBig2'");
        InnerHTML = InnerHTML.replace("Rate This Topic", "Rate this topic");
    }
    if (InnerHTML.indexOf("Jump To Page") >= 0 && navigator.appName == "Microsoft Internet Explorer") {
        InnerHTML = InnerHTML.replace("FormButtonBig", "'FormButtonBigIE'");
    }
    var frameDiv = document.createElement('iframe');
    frameDiv.id = Iframe;
    frameDiv.setAttribute('class', '');
    frameDiv.setAttribute('src', 'blank.htm');
    frameDiv.style.position = 'absolute';
    frameDiv.style.zindex = 1;
    frameDiv.style.width = mnu_width;

    // create div layer container to holder table
    var elemDiv = document.createElement('div');
    elemDiv.id = DivLayer;
    elemDiv.setAttribute('class', '');
    elemDiv.style.position = 'absolute';
    elemDiv.style.zindex = 50;
    elemDiv.style.width = mnu_width;

    // deteremine what table to apply as the innerHTML of the div layer container
    elemDiv.innerHTML = InnerHTML;

    // add elements to document
    document.body.appendChild(frameDiv);
    document.body.appendChild(elemDiv);

    // get layer height now content has been added
    var mnu_height;

    if ((InstantASP_IE4 || InstantASP_IE5) || InstantASP_NS6)
    { mnu_height = elemDiv.offsetHeight; }
    else if (InstantASP_NS4)
    { mnu_height = elemDiv.clip.height; }

    mnu_extent = {
        x: mnu_width,
        y: mnu_height
    };

    // finally hide the layer 
    frameDiv.style.display = "none";
    elemDiv.style.display = "none";

}

/* ----------------------------------------------------------- */
// Hide all menus on click event of document
/* ----------------------------------------------------------- */

function InstantASP_HideAllMenusOnClick(event) {

    // are menus active
    if (InstantASP_MenusActive) {
        // find the element that was clicked
        if (InstantASP_IE4 || InstantASP_IE5 || InstantASP_Opera) {
            el = window.event.srcElement;
        }
        else {
            el = (event.target.tagName ? event.target : event.target.parentNode);
        }

        // did we find a parent div layer
        if (InstantASP_GetContainer(el, "DIV") != null) {
            // if we have click anywhere outside our menu
            if (InstantASP_GetContainer(el, "DIV").id.indexOf("_SimpleMenuDivLayer") == -1) {
                // hide all menus
                InstantASP_HideAllMenus();
            }
        } else {
            // hide all menus
            InstantASP_HideAllMenus();
        }
    }
}

/* ----------------------------------------------------------- */
// Hide all active menus 
/* ----------------------------------------------------------- */

function InstantASP_HideAllMenus() {

    if (InstantASP_MenusActive) {
        for (count = 0; count < InstantASP_MenuItems.length; count++) {
            var div_layer = InstantASP_FindControl(InstantASP_MenuItems[count]);
            var iframe_layer = InstantASP_FindControl(InstantASP_MenuItems[count] + "_Iframe");
            if (div_layer != null && iframe_layer != null) {
                iframe_layer.style.display = 'none';
                div_layer.style.display = 'none';
                InstantASP_MenuItems[count] = '';
                InstantASP_MenusActive = false;
            }
        }
    }
}
/* ----------------------------------------------------------- */
// Toggles and objects visibliity
/* ----------------------------------------------------------- */

function InstantASP_ToggleVisability(obj, visible) {

    obj = InstantASP_FindControl(obj);
    if (visible) { obj.style.display = ""; }
    else { obj.style.display = "none"; }

}
//-->

//Start->After everypage this event fires
window.onload = function() {

    FillCategory();

    var objRateTopic = document.getElementById("ctl02_ctlTopic_ctlPanelBar_ctl14");
    var objDisplayMode = document.getElementById("ctl02_ctlTopic_ctlPanelBar_ctl16");
    var objTopicOptions = document.getElementById("ctl02_ctlTopic_ctlPanelBar_ctl18");
    var objPageHTML = document.body.innerHTML;
    var objdivContent2 = document.getElementById("divContent2");
    var objtdFormInputDropDown_150 = document.getElementById("ctl02_ctlSearchOptions_ctlSearch_ctlKeywordsRoundedTable_tdFormInputDropDown_150");
    var objctlDateNavigation_month = document.getElementById("ctl02_ctlDateNavigation_month");
    var objctlDateNavigation_year = document.getElementById("ctl02_ctlDateNavigation_year");
    var objctlTextEditor = document.getElementById("txtNotes");
    var objctlSignatureEditor = document.getElementById("txtSignature");
    var objtxtPost_Editor = document.getElementById("txtPost");

    if (objRateTopic != null)
        objRateTopic.className = "pink12";
    if (objDisplayMode != null)
        objDisplayMode.className = "pink12";
    if (objTopicOptions != null)
        objTopicOptions.className = "pink12";

    if (navigator.appName == "Microsoft Internet Explorer") {

        if (objdivContent2 != null && objdivContent2.className != "content2IE") {
            objdivContent2.className = "content2IE";
        }
    }

    var sPath = window.location.pathname;
    var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
    if (sPage == "Search1-1-1.aspx") {
        if (objtdFormInputDropDown_150 != null) {
            objtdFormInputDropDown_150.style.visibility = "hidden";
        }
    }
    if (objctlDateNavigation_month != null) {
        objctlDateNavigation_month.style.width = "90px";
        if (navigator.appName == "Netscape") {
            objctlDateNavigation_month.className = "selectfield_3";
        }
    }

    if (objctlDateNavigation_year != null) {
        objctlDateNavigation_year.style.width = "50px";
    }

    if (sPage == "ControlPanel.aspx") {
        if (objctlTextEditor != null) {
            objctlTextEditor.className = "";
        }
    }
    if (sPage == "Post.aspx") {
        if (objtxtPost_Editor != null) {
            objtxtPost_Editor.className = "";
        }
        var objctlEventStart_day = document.getElementById("ctl02_ctlPostControl_ctlPanelBar_ctlEventDateRoundedTable_ctlEventStart_day");
        var objctlEventStart_year = document.getElementById("ctl02_ctlPostControl_ctlPanelBar_ctlEventDateRoundedTable_ctlEventStart_year");
        var objctlEventEnd_day = document.getElementById("ctl02_ctlPostControl_ctlPanelBar_ctlEventDateRoundedTable_ctlEventEnd_day");
        var objctlEventEnd_year = document.getElementById("ctl02_ctlPostControl_ctlPanelBar_ctlEventDateRoundedTable_ctlEventEnd_year");
        var objtdddlBackGroundColor = document.getElementById("tdddlBackGroundColor");
        var objtdddlFontColor = document.getElementById("tdddlFontColor");
        var objctlEventStart = document.getElementById("ctl02_ctlPostControl_ctlPanelBar_ctlEventDateRoundedTable_ctlEventStart");
        var objdivctlEventStart = document.getElementById("divctlEventStart");
        var objctlEventStart_month = document.getElementById("ctl02_ctlPostControl_ctlPanelBar_ctlEventDateRoundedTable_ctlEventStart_month");
        var objdivctlEventEnd = document.getElementById("divctlEventEnd");
        var objctlEventEnd = document.getElementById("ctl02_ctlPostControl_ctlPanelBar_ctlEventDateRoundedTable_ctlEventEnd");
        var objctlEventEnd_month = document.getElementById("ctl02_ctlPostControl_ctlPanelBar_ctlEventDateRoundedTable_ctlEventEnd_month");
        if (navigator.appName == "Microsoft Internet Explorer") {
            if (objctlEventStart != null)
                objctlEventStart.style.width = "0";

            if (objdivctlEventStart != null)
                objdivctlEventStart.className = "FormInputDropDown_big1";

            if (objctlEventStart_month != null)
                objctlEventStart_month.className = "FormInputDropDown1";

            if (objctlEventStart_day != null)
                objctlEventStart_day.className = "FormInputDropDown1";

            if (objctlEventStart_year != null)
                objctlEventStart_year.className = "FormInputDropDown2";

            if (objdivctlEventEnd != null)
                objdivctlEventEnd.className = "FormInputDropDown_big1";

            if (objctlEventEnd != null)
                objctlEventEnd.style.width = "0";

            if (objctlEventEnd_month != null)
                objctlEventEnd_month.className = "FormInputDropDown1";

            if (objctlEventEnd_day != null)
                objctlEventEnd_day.className = "FormInputDropDown1";

            if (objctlEventEnd_year != null)
                objctlEventEnd_year.className = "FormInputDropDown2";

            if (objtdddlBackGroundColor != null) {
                objtdddlBackGroundColor.className = "FormInputText1_180";
            }

            var objddlBackGroundColor = document.getElementById("ctl02_ctlPostControl_ctlPanelBar_ctlEventDateRoundedTable_ddlBackGroundColor");
            var objddlBackGroundColor_DivLayer = document.getElementById("ddlBackGroundColor_DivLayer");

            if (objddlBackGroundColor != null)
                objddlBackGroundColor.style.margin = "0 0 0 7px";

            if (objddlBackGroundColor_DivLayer != null)
                objddlBackGroundColor_DivLayer.style.margin = "0 0 0 7px";

            if (objtdddlFontColor != null)
                objtdddlFontColor.className = "FormInputText1_180";

            var objddlFontColor = document.getElementById("ctl02_ctlPostControl_ctlPanelBar_ctlEventDateRoundedTable_ddlFontColor");
            var objddlFontColor_DivLayer = document.getElementById("ddlFontColor_DivLayer");
            if (objddlFontColor != null)
                objddlFontColor.style.margin = "0 0 0 7px";


            if (objddlFontColor_DivLayer != null)
                objddlFontColor_DivLayer.style.margin = "0 0 0 7px";

        }
        else {
            if (objctlEventStart_day != null) {
                objctlEventStart_day.style.margin = "0 0 0 30px";
            }
            if (objctlEventStart_year != null) {
                objctlEventStart_year.style.margin = "0 0 0 30px";
            }
            if (objctlEventEnd_day != null) {
                objctlEventEnd_day.style.margin = "0 0 0 30px";
            }
            if (objctlEventEnd_year != null) {
                objctlEventEnd_year.style.margin = "0 0 0 30px";
            }
            //Background Color:
            if (objtdddlBackGroundColor != null) {
                objtdddlBackGroundColor.className = "FormInputText1_180";

                var x = objtdddlBackGroundColor.getElementsByTagName("td");
                var i = 0;
                var sData = "";
                for (i = 0; i < x.length; i++) {
                    sData += x[i].innerHTML;
                }
                objtdddlBackGroundColor.innerHTML = sData;
                sData = "";
                var objddlBackGroundColor = document.getElementById("ctl02_ctlPostControl_ctlPanelBar_ctlEventDateRoundedTable_ddlBackGroundColor");
                var objddlBackGroundColor_DivLayer = document.getElementById("ddlBackGroundColor_DivLayer");

                if (objddlBackGroundColor != null)
                    objddlBackGroundColor.style.margin = "0 0 0 10px";


                if (objddlBackGroundColor_DivLayer != null)
                    objddlBackGroundColor_DivLayer.style.margin = "0 0 0 10px";
            }
            //Font Color
            if (objtdddlFontColor != null) {
                objtdddlFontColor.className = "FormInputText1_180";

                var x = objtdddlFontColor.getElementsByTagName("td");
                var i = 0;
                var sData = "";
                for (i = 0; i < x.length; i++) {
                    sData += x[i].innerHTML;
                }
                objtdddlFontColor.innerHTML = sData;
                sData = "";
                var objddlFontColor = document.getElementById("ctl02_ctlPostControl_ctlPanelBar_ctlEventDateRoundedTable_ddlFontColor");
                var objddlFontColor_DivLayer = document.getElementById("ddlFontColor_DivLayer");
                if (objddlFontColor != null)
                    objddlFontColor.style.margin = "0 0 0 10px";


                if (objddlFontColor_DivLayer != null)
                    objddlFontColor_DivLayer.style.margin = "0 0 0 10px";
            }
        }
    }

    if (sPage == "EditSignature.aspx") {
        if (objctlSignatureEditor != null) {
            objctlSignatureEditor.className = "";
        }
    }

    //
    if (sPage.substr(0, 5) == "Topic") {
        var objctlSignatureEditor = document.getElementById("ctl02_ctlTopic_ctlPanelBar");

        var x = objctlSignatureEditor.getElementsByTagName("td");
        var i = 0;
        for (i = 0; i < x.length; i++) {
            if (x[i].className == "PanelBar_Header") {
                x[i].innerHTML = x[i].innerHTML.replace(/<td nowrap>/gi, "<td>");
                x[i].innerHTML = x[i].innerHTML.replace(/<td nowrap="nowrap">/gi, "<td>");
            }
        }
    }

    var objctlMonth = document.getElementById("ctl02_ctlCOPPAForm_ctlPanelBar_ctlDateOfBirthRoundedTable_ctlDateOfBirth_month");
    var objctlDay = document.getElementById("ctl02_ctlCOPPAForm_ctlPanelBar_ctlDateOfBirthRoundedTable_ctlDateOfBirth_day");
    var objctlYear = document.getElementById("ctl02_ctlCOPPAForm_ctlPanelBar_ctlDateOfBirthRoundedTable_ctlDateOfBirth_year");

    if (!(objctlMonth == null || objctlDay == null || objctlYear == null)) {
        objctlMonth.style.width = "150px";
        objctlDay.style.width = "55px";
        objctlYear.style.width = "55px";

        if (IsFireFox()) {
            objctlMonth.style.marginLeft = "20px";
        }
    }

    var objctlMonth1 = document.getElementById("ctl02_ctlPanelBar_ctlDateOfBirth_month");
    var objctlDay1 = document.getElementById("ctl02_ctlPanelBar_ctlDateOfBirth_day");
    var objctlYear1 = document.getElementById("ctl02_ctlPanelBar_ctlDateOfBirth_year");

    if (!(objctlMonth1 == null || objctlDay1 == null || objctlYear1 == null)) {
        objctlMonth1.style.width = "150px";
        objctlDay1.style.width = "55px";
        objctlYear1.style.width = "55px";

        if (IsFireFox()) {
            objctlMonth1.style.marginLeft = "20px";
            objctlMonth1.style.marginRight = "20px";
            objctlDay1.style.marginRight = "20px";
            objctlYear1.style.marginRight = "20px";
        }
        else {
            objctlMonth1.style.marginLeft = "10px";
            objctlMonth1.style.marginRight = "20px";
            objctlDay1.style.marginRight = "20px";
            objctlYear1.style.marginRight = "20px";
        }
    }

    if (sPage == "EditPersonalDetails.aspx") {
        var objtxtInterests = document.getElementById("txtInterests");
        var txtBiography = document.getElementById("txtBiography");

        if (objtxtInterests != null) {
            objtxtInterests.className = "";
        }

        if (txtBiography != null) {
            txtBiography.className = "";
        }
    }

    if (IsIE()) {
        //alert("IF");
        var objdivDroupdownbox = document.getElementById("divDroupdownbox");
        var objdivDropdown = document.getElementById("divDropdown");
        if (objdivDroupdownbox != null)
            objdivDroupdownbox.className = "droupdownboxIE";

        if (objdivDropdown != null)
            objdivDropdown.className = "dropdownIE";
    }

    if (IsIE()) {
        var objdivProfileLink = $("divProfileLink");
        if (objdivProfileLink != null)
            objdivProfileLink.className = "profileLinkIE";

        var objdivInputuser = $("divInputuser");
        if (objdivInputuser != null)
            objdivInputuser.className = "inputuserIE";

        var objtxtProfileName = $("UC_Login_txtProfileName");
        if (objtxtProfileName != null)
            objtxtProfileName.style.marginTop = "2px";

        var objtxtPassword = $("UC_Login_txtPassword");
        if (objtxtPassword != null)
            objtxtPassword.style.marginTop = "2px";

        var objdivinputpassword = $("divinputpassword");
        if (objdivinputpassword != null)
            objdivinputpassword.className = "inputpasswordIE";
    }

    var objdiverrortext = $("diverrortext");
    if (objdiverrortext != null)
        objdiverrortext.className = "errortextLogin";

    if (IsIE()) {
        var objdivSendMeLoginButton = $("divSendMeLoginButton");
        if (divSendMeLoginButton != null)
            divSendMeLoginButton.className = "button_center2IE";

        var objdivbutton_center = $("divbutton_center");
        if (objdivbutton_center != null)
            objdivbutton_center.className = "button_centerIE";

    }

}
//End->After everypage this event fires

//JS for LINK WIDGET
function setDraggingControl() {
    var imgColorRed = document.getElementById("imgColorRed");
    Drag.init(imgColorRed, null, 0, 105, 0, 0);
    imgColorRed.onDragEnd = function(x, y) { setTextboxValue(x, 'txtColorRed'); }
    imgColorRed.onDrag = function(x, y) { setTextboxValue(x, 'txtColorRed'); }
    imgColorRed.style.left = "0px";
    document.getElementById("txtColorRed").value = 0;

    var imgColorGreen = document.getElementById("imgColorGreen");
    Drag.init(imgColorGreen, null, 0, 105, 0, 0);
    imgColorGreen.onDragEnd = function(x, y) { setTextboxValue(x, 'txtColorGreen'); }
    imgColorGreen.onDrag = function(x, y) { setTextboxValue(x, 'txtColorGreen'); }
    imgColorGreen.style.left = "0px";
    document.getElementById("txtColorGreen").value = 0;

    var imgColorBlue = document.getElementById("imgColorBlue");
    Drag.init(imgColorBlue, null, 0, 105, 0, 0);
    imgColorBlue.onDragEnd = function(x, y) { setTextboxValue(x, 'txtColorBlue'); }
    imgColorBlue.onDrag = function(x, y) { setTextboxValue(x, 'txtColorBlue'); }
    imgColorBlue.style.left = "0px";
    document.getElementById("txtColorBlue").value = 0;

    var imgBGColorRed = document.getElementById("imgBGColorRed");
    Drag.init(imgBGColorRed, null, 0, 105, 0, 0);
    imgBGColorRed.onDragEnd = function(x, y) { setTextboxValue(x, 'txtBGColorRed'); }
    imgBGColorRed.onDrag = function(x, y) { setTextboxValue(x, 'txtBGColorRed'); }
    imgBGColorRed.style.left = "105px";
    document.getElementById("txtBGColorRed").value = 255;

    var imgBGColorGreen = document.getElementById("imgBGColorGreen");
    Drag.init(imgBGColorGreen, null, 0, 105, 0, 0);
    imgBGColorGreen.onDragEnd = function(x, y) { setTextboxValue(x, 'txtBGColorGreen'); }
    imgBGColorGreen.onDrag = function(x, y) { setTextboxValue(x, 'txtBGColorGreen'); }
    imgBGColorGreen.style.left = "105px";
    document.getElementById("txtBGColorGreen").value = 255;

    var imgBGColorBlue = document.getElementById("imgBGColorBlue");
    Drag.init(imgBGColorBlue, null, 0, 105, 0, 0);
    imgBGColorBlue.onDragEnd = function(x, y) { setTextboxValue(x, 'txtBGColorBlue'); }
    imgBGColorBlue.onDrag = function(x, y) { setTextboxValue(x, 'txtBGColorBlue'); }
    imgBGColorBlue.style.left = "105px";
    document.getElementById("txtBGColorBlue").value = 255;
}

function getWidgetSubCategories1() {
    clearDropdown('drpSubCategory');
    clearDropdown('drpSubject');
    var categoryid = document.getElementById("drpCategory");
    document.getElementById('LinkWidget1_hdnCategory').value = document.getElementById('drpCategory').value;
    document.getElementById('LinkWidget1_hdnCategoryName').value = categoryid.options[categoryid.selectedIndex].text;
    //AjaxGetData('../PureAJAXBackProcess.aspx?categoryid='+ categoryid.value, subcategoryWidgetHandler);
    AjaxGetData('AjaxOperations.ashx?what=subcat&id=' + categoryid.value, subcategoryWidgetHandler);
}

function AjaxGetData(url, responseHandler) {
    if (window.XMLHttpRequest) {
        // browser has native support for XMLHttpRequest object
        req = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        // try XMLHTTP ActiveX (Internet Explorer) version
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if (req) {
        req.onreadystatechange = responseHandler;
        req.open('GET', url, true);
        req.setRequestHeader("content-type", "application/x-www-form-urlencoded");
        req.send('');
    }
    else {
        alert('Your browser does not seem to support XMLHttpRequest.');
    }
}

function subcategoryWidgetHandler() {
    try {
        //readyState of 4 or 'complete' represents 
        //that data has been returned
        if (req.readyState == 4 || req.readyState == 'complete') {
            var subcat = req.responseText.split('|');
            var subcatText = subcat[0].split('~');
            var subcatValue = subcat[1].split('~');
            var elSel = document.getElementById('drpSubCategory');
            document.getElementById("errorCategory").innerHTML = "";
            elSel.options.lenght = 0;

            for (i = 0; i < subcatText.length; i++) {
                try {
                    elSel.add(new Option(subcatText[i], subcatValue[i]), null) //add new option to end of "sample"
                }
                catch (e) { //in IE, try the below version instead of add()
                    elSel.add(new Option(subcatText[i], subcatValue[i])) //add new option to end of "sample"
                }
            }
            if (elSel.length > 0) {
                elSel.disabled = false;
                document.getElementById('drpSubject').options.lenght = 0;
                document.getElementById("LinkWidget1_hdnSubjectId").value = "0";
            }
        }
    }
    catch (e) {
        alert('Error in Ajax respone');
    }
}


function clearDropdown(drp) {
    if (document.getElementById(drp) != null) {
        document.getElementById(drp).length = 0;
    }
}
//Get list of subjects within selected subcategories
function getWidgetSubject1() {
    clearDropdown('drpSubject');
    var categoryid = document.getElementById("drpSubCategory");
    document.getElementById('LinkWidget1_hdnSubcategory').value = categoryid.value;
    AjaxGetData('AjaxOperations.ashx?what=subject&id=' + categoryid.value, subjectWidgetHandler);
}

function subjectWidgetHandler() {
    try {
        //readyState of 4 or 'complete' represents 
        //that data has been returned 
        if (req.readyState == 4 || req.readyState == 'complete') {
            // alert(req.responseText);
            var subcat = req.responseText.split('|');
            var subcatText = subcat[0].split('~');
            var subcatValue = subcat[1].split('~');

            var elSel = document.getElementById('drpSubject');
            elSel.options.lenght = 0;
            document.getElementById("errorSubCategory").innerHTML = "";

            for (i = 0; i < subcatText.length; i++) {
                try {
                    elSel.add(new Option(subcatText[i], subcatValue[i]), null) //add new option to end of "sample"
                }
                catch (e) { //in IE, try the below version instead of add()
                    elSel.add(new Option(subcatText[i], subcatValue[i])) //add new option to end of "sample"
                }
            }
            if (elSel.length > 0) {
                elSel.disabled = false;
                //document.getElementById('drpSubject').options.lenght = 0;
                document.getElementById("LinkWidget1_hdnSubjectId").value = "0"
            }
        }
    }
    catch (e) {
        alert('Error in Ajax respone');
    }
}

function setWidgetSubject1() {
    document.getElementById("LinkWidget1_hdnSubjectId").value = "0";
    var a = document.getElementById('drpSubject').value;
    if (!(a == null || a < 1)) {
        document.getElementById("errorSubject").innerHTML = "";
        document.getElementById("LinkWidget1_hdnSubjectId").value = document.getElementById('drpSubject').value;
    }
}


function FillCategory() {
    try {

        var subcat = document.getElementById('LinkWidget1_hdnCat').value.split('|');
        var subcatText = subcat[0].split('~');
        var subcatValue = subcat[1].split('~');

        var elSel = document.getElementById('drpCategory');
        elSel.options.lenght = 0;
        document.getElementById("errorCategory").innerHTML = "";

        for (i = 0; i < subcatText.length -1; i++) {
            try {
                elSel.add(new Option(subcatText[i], subcatValue[i]), null) //add new option to end of "sample"
            }
            catch (e) { //in IE, try the below version instead of add()
                elSel.add(new Option(subcatText[i], subcatValue[i])) //add new option to end of "sample"
            }
        }
        if (elSel.length > 0) {
            elSel.disabled = false;
        }
    }
    catch (e) {
        alert('Error in Ajax respone');
    }
}

function makeWidget() {
    document.getElementById("errorCategory").innerHTML = "";
    document.getElementById("errorSubCategory").innerHTML = "";
    document.getElementById("errorSubject").innerHTML = "";
    var objtxtCode = document.getElementById("txtCode");
    //objtxtCode.value = "";

    var isValid = true;

    var catid = document.getElementById("LinkWidget1_hdnCategory").value;
    if (catid == null || catid < 1) {
        document.getElementById("errorCategory").innerHTML = "Select category";
        isValid = false;
    }
    var subcatid = document.getElementById("drpSubCategory").value;
    if (subcatid == null || subcatid < 1) {
        document.getElementById("errorSubCategory").innerHTML = "Select sub category";
        isValid = false;
    }

    var subjectid = document.getElementById("LinkWidget1_hdnSubjectId").value;
    if (subjectid == null || subjectid < 1) {
        document.getElementById("errorSubject").innerHTML = "Select subject";
        isValid = false;
    }

    if (!isValid)
        return;

    AjaxGetData('AjaxOperations.ashx?what=widgetdet&id=' + subjectid, getWidgetHandler);
}

function getWidgetHandler() {
    try {
        //readyState of 4 or 'complete' represents 
        //that data has been returned 
        if (req.readyState == 4 || req.readyState == 'complete') {
            var sResult = req.responseText;
            var nStartPos = sResult.indexOf("#WidgetPopup#");
            var nEndPos = sResult.lastIndexOf("#WidgetPopup#");

            document.getElementById("divWidgetPopup").innerHTML = sResult.substring(nStartPos + 13, nEndPos);
            setDraggingControl();
            var sSubcatData = sResult.substring(nEndPos + 13);
            var subcat = sSubcatData.split('|');
            
            document.getElementById("LinkWidget1_hdnURL").value = subcat[0];
            document.getElementById("LinkWidget1_hdnSubjectName").value = subcat[1];
            document.getElementById("LinkWidget1_hdnSubjectURL").value = subcat[2];
            document.getElementById("divWidgetSampleText").innerHTML = subcat[3];
            showWidgetPopup();
        }
    }
    catch (e) {
        alert('Error in Ajax respone');
    }
}

function IsFireFox() {
    return (navigator.appName == 'Netscape');
}

function IsIE() {
    return (navigator.appName == "Microsoft Internet Explorer");
}

function showWidgetPopup() {
    showDiv('divWidgetPopup');    
    UpdateCode();
}

function showDiv(divID) {
    HideOtherPopups();
    var tipobj = document.getElementById(divID);
    tipobj.style.top = "0px";
    tipobj.style.visibility = "visible";
    document.onscroll = repositionhelpmenu(divID);
    return false;
}

function UpdateCode() {
    var sContent = "";
    $("colorsample2").style.backgroundColor = "#" + RGBtoHex($("txtBGColorRed").value, $("txtBGColorGreen").value, $("txtBGColorBlue").value);
    var sColour = "#" + RGBtoHex($("txtColorRed").value, $("txtColorGreen").value, $("txtColorBlue").value);
    if ($("lnkWidgSubject") != null)
        $("lnkWidgSubject").style.color = sColour;
    if ($("spnStatus") != null)
        $("spnStatus").style.color = sColour;
    if ($("lnkTop10") != null)
        $("lnkTop10").style.color = sColour;
    if ($("spnVotes") != null)
        $("spnVotes").style.color = sColour;
    if ($("lnkMore") != null)
        $("lnkMore").style.color = sColour;
    var nCount = 0;
    for (nCount = 1; nCount <= 10; nCount++) {
        var objdivItems = "divItems" + nCount;
        var objdivVotes = "divVotes" + nCount;
        if ($(objdivItems) != null)
            $(objdivItems).style.color = sColour;

        if ($(objdivVotes) != null)
            $(objdivVotes).style.color = sColour;
    }

    sContent = document.getElementById("divWidgetSampleText").innerHTML;
    sContent = sContent.replace(/~BGCOLOR~/gi, "#" + RGBtoHex(document.getElementById("txtBGColorRed").value, document.getElementById("txtBGColorGreen").value, document.getElementById("txtBGColorBlue").value));
    sContent = sContent.replace(/~COLOR~/gi, "#" + RGBtoHex(document.getElementById("txtColorRed").value, document.getElementById("txtColorGreen").value, document.getElementById("txtColorBlue").value));

    document.getElementById("divSample").innerHTML = sContent;
}

function setTextboxValue(x, txt) {
    var col = (255 * x) / 105;
    col = Math.round(col);
    document.getElementById(txt).value = col;
    UpdateCode();
}

function setImagePosition(txt, img) {
    var col = txt.value;
    if (col != NaN) {
        if (col < 0) { col = 0; txt.value = col; };
        if (col > 255) { col = 255; txt.value = col; };

        col = (col * 105) / 255;
        col = Math.round(col);

        document.getElementById(img).style.left = col + "px";
    }
    else {
        txt.value = 0;
        document.getElementById(img).style.left = "0px";
    }
    UpdateCode();
}

function RGBtoHex(R, G, B) { return toHex(R) + toHex(G) + toHex(B); }

function toHex(N) {
    if (N == null) return "00";
    N = parseInt(N);
    if (N == 0 || isNaN(N)) return "00";
    N = Math.max(0, N);
    N = Math.min(N, 255);
    N = Math.round(N);
    return "0123456789ABCDEF".charAt((N - N % 16) / 16) + "0123456789ABCDEF".charAt(N % 16);
}

function hideLinkWidget() {

    HidePopup('divWidgetPopup');
}

function HidePopup(divID) {
    var tipobj = document.getElementById(divID);
    //tipobj.style.display = "none"; 
    tipobj.style.visibility = "hidden";
    return false;
}

function GetRSSFeed() {
    document.getElementById("errorCategory").innerHTML = "";
    document.getElementById("errorSubCategory").innerHTML = "";
    document.getElementById("errorSubject").innerHTML = "";

    var isValid = true;

    var catid = document.getElementById("LinkWidget1_hdnCategory").value;
    if (catid == null || catid < 1) {
        document.getElementById("errorCategory").innerHTML = "Select category";
        isValid = false;
    }
    var subcatid = document.getElementById("drpSubCategory").value;
    if (subcatid == null || subcatid < 1) {
        document.getElementById("errorSubCategory").innerHTML = "Select sub category";
        isValid = false;
    }

    var subjectid = document.getElementById("LinkWidget1_hdnSubjectId").value;
    if (subjectid == null || subjectid < 1) {
        document.getElementById("errorSubject").innerHTML = "Select subject";
        isValid = false;
    }

    if (!isValid)
        return false;

    return true;
}

function repositionhelpmenu(divtoReposition) {
    var spanvar = document.getElementById(divtoReposition);

    if (spanvar != null) {
        if (spanvar.style.visibility == "visible") {
            var centerWidth = (window.screen.width - spanvar.offsetWidth) / 2;
            var centerHeight = (window.screen.height - (spanvar.offsetHeight + 200)) / 2;

            if (divtoReposition == "divStaticContents")
                centerHeight = (window.screen.height - (496 + 200)) / 2;

            //centerHeight = centerHeight - 50;
            JSFX_FloatDiv(divtoReposition, centerWidth, centerHeight).floatIt();
        }
    }
}

var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
function JSFX_FloatDiv(id, sx, sy) {
    var el = d.getElementById ? d.getElementById(id) : d.all ? d.all[id] : d.layers[id];
    var px = document.layers ? "" : "px";
    window[id + "_obj"] = el;
    if (d.layers) el.style = el;
    el.cx = el.sx = sx; el.cy = el.sy = sy;
    el.sP = function(x, y) { this.style.left = x + px; this.style.top = y + px; };

    el.floatIt = function() {
        var pX, pY;
        pX = (this.sx >= 0) ? 0 : ns ? innerWidth :
		document.documentElement && document.documentElement.clientWidth ?
		document.documentElement.clientWidth : document.body.clientWidth;
        pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ?
		document.documentElement.scrollTop : document.body.scrollTop;
        if (this.sy < 0)
            pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ?
		document.documentElement.clientHeight : document.body.clientHeight;
        this.cx += (pX + this.sx - this.cx) / 8; this.cy += (pY + this.sy - this.cy) / 8;
        this.sP(this.cx, this.cy);
        setTimeout(this.id + "_obj.floatIt()", 40);
    }
    return el;
}

function showWidgetCode() {
    var hdnSubjectId = document.getElementById("LinkWidget1_hdnSubjectId").value;
    var hdnURL = document.getElementById("LinkWidget1_hdnURL").value;
    var hdnSubjectName = document.getElementById("LinkWidget1_hdnSubjectName").value;
    var hdnSubjectURL = document.getElementById("LinkWidget1_hdnSubjectURL").value;
    var bgcolor = RGBtoHex(document.getElementById("txtBGColorRed").value, document.getElementById("txtBGColorGreen").value, document.getElementById("txtBGColorBlue").value)
    var textcolor = RGBtoHex(document.getElementById("txtColorRed").value, document.getElementById("txtColorGreen").value, document.getElementById("txtColorBlue").value);
    var code = '<div style="width:250px;height:250px;background-color: #' + bgcolor + '; color: #' + textcolor + ';"><div style="float: left; width: 230px; margin: 5px 0pt 0pt; text-align: center;"><a style="font-family: Arial; font-size: 14px; color: #' + textcolor + ';" href="' + hdnSubjectURL + '" title="' + hdnSubjectName + '">' + hdnSubjectName + '</a></div><script language="javascript" src="' + hdnURL + 'Syndication.aspx?id=' + hdnSubjectId + '&bgcolor=' + bgcolor + '&color=' + textcolor + '"></script></div>'
    document.getElementById("txtCode").value = code;
}

function onclickHandle(e) {
    if (window.event) // IE
    {

    }
    else if (e.which) {

    }
    //e = e || event; 
    alert(e.offsetX);
}

//Start->DivStatic Contents Ajax Operations
function showDivStaticContents(divID, sDataTitle) {
    HideOtherPopups();
    var tipobj = document.getElementById(divID);
    tipobj.style.top = "0px";
    tipobj.style.visibility = "visible";
    StaticDataInDev(sDataTitle);
    document.onscroll = repositionhelpmenu(divID);
    setTimeout("StaticDataDivAlign()", 30);
    return false;
}

function StaticDataDivAlign() {
    var objdivtermsPopup = document.getElementById("divtermsPopup");
    if (navigator.appName == "Microsoft Internet Explorer") {
        if (objdivtermsPopup != null) {
            objdivtermsPopup.className = "termsPopupIE";
        }
    }
}

function StaticDataInDev(sDataTitle) {
    AjaxGetDivData('AjaxOperations.ashx?what=sDataTitle&id=' + sDataTitle, StaticDataInDevHandler);
}

function AjaxGetDivData(url, responseHandler) {
    if (window.XMLHttpRequest) {
        // browser has native support for XMLHttpRequest object
        req = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        // try XMLHTTP ActiveX (Internet Explorer) version
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if (req) {
        req.onreadystatechange = responseHandler;
        req.open('GET', url, true);
        req.setRequestHeader("content-type", "application/x-www-form-urlencoded");
        req.send('');
    }
    else {
        alert('Your browser does not seem to support XMLHttpRequest.');
    }
}

function StaticDataInDevHandler() {
    try {
        //readyState of 4 or 'complete' represents 
        //that data has been returned 
        if (req.readyState == 4 || req.readyState == 'complete') {
            document.getElementById("divStaticContents").innerHTML = req.responseText;
        }
    }
    catch (e) {
        alert('Error in Ajax respone');
    }
}
//End->DivStatic Contents Ajax Operations

function hideDiv(divID) {
    var tipobj = document.getElementById(divID);
    tipobj.style.visibility = "hidden";
    return false;
}



//Start->Search .js
function checkSearchCriteria() {
    return true;
}

var offsetxpoint = -60; //Customize x offset of tooltip
var offsetypoint = 20; //Customize y offset of tooltip
var ie = document.all;
var ns6 = document.getElementById && !document.all;
var enabletip = false;
if (ie || ns6)
//var tipobj = document.all ? document.all["dhtmltooltip"] : document.getElementById ? document.getElementById("dhtmltooltip") : "";
    var tipobj = document.all ? document.all["dhtmltooltip"] : $ ? $("dhtmltooltip") : "";


function ietruebody() {
    return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body;
}

function showTT(thetext, thecolor, thewidth) {
    if (ns6 || ie) {
        //                if (typeof thewidth != "undefined") tipobj.style.width = thewidth + "px"
        //                if (typeof thecolor != "undefined" && thecolor != "") tipobj.style.backgroundColor = thecolor
        setValues(thetext);
        enabletip = true
        return false
    }
}
function setValues(thetext) {
    var s = new String();
    var arr = new Array();

    arr = thetext.split('#');
    if (arr.length >= 5) {
        document.getElementById('imgProfileUser').src = arr[0];
        document.getElementById('spName').innerHTML = arr[1];
        document.getElementById('spLastSeen').innerHTML = arr[5];
        document.getElementById('spSubjectsOwned').innerHTML = arr[2];
        document.getElementById('spSubjectsVotedIn').innerHTML = arr[3];
        document.getElementById('spDiscussion').innerHTML = arr[4];
    }
}

document.onmousemove = positiontip;

function positiontip(e) {
    if (enabletip) {
        var curX = (ns6) ? e.pageX : event.clientX + ietruebody().scrollLeft;
        var curY = (ns6) ? e.pageY : event.clientY + ietruebody().scrollTop;
        //Find out how close the mouse is to the corner of the window
        var rightedge = ie && !window.opera ? ietruebody().clientWidth - event.clientX - offsetxpoint : window.innerWidth - e.clientX - offsetxpoint - 20
        var bottomedge = ie && !window.opera ? ietruebody().clientHeight - event.clientY - offsetypoint : window.innerHeight - e.clientY - offsetypoint - 20

        var leftedge = (offsetxpoint < 0) ? offsetxpoint * (-1) : -1000
        var a = document.getElementsByTagName("div");

        for (var i = 0; i < a.length; i++) {
            if (a[i].id == "dhtmltooltip") {
                //alert("a")
                tipobj = a[i];
            }
        }

        //if the horizontal distance isn't enough to accomodate the width of the context menu
        if (rightedge < tipobj.offsetWidth)
        //move the horizontal position of the menu to the left by it's width
            tipobj.style.left = ie ? ietruebody().scrollLeft + event.clientX - tipobj.offsetWidth + "px" : window.pageXOffset + e.clientX - tipobj.offsetWidth + "px"
        else if (curX < leftedge)
            tipobj.style.left = "5px"
        else
        //position the horizontal position of the menu where the mouse is positioned
            tipobj.style.left = curX + offsetxpoint + "px"

        //same concept with the vertical position
        if (bottomedge < tipobj.offsetHeight)
            tipobj.style.top = ie ? ietruebody().scrollTop + event.clientY - tipobj.offsetHeight - offsetypoint + "px" : window.pageYOffset + e.clientY - tipobj.offsetHeight - offsetypoint + "px"
        else
            tipobj.style.top = curY + offsetypoint + "px"
        tipobj.style.visibility = "visible"
    }
}

function hideTT() {
    if (ns6 || ie) {
        enabletip = false
        //tipobj.style.visibility = "hidden"
        tipobj.style.left = "-1000px"
        tipobj.style.backgroundColor = ''
        tipobj.style.width = ''
    }
}

function showOriginal(obj) {
    if (obj.value == '') { obj.value = 'Search for a Top 10 list' };
    document.getElementById("results").style.visibility = "hidden";
}

function SetDefaultRowColor() {
    for (i = 0; i < rows.length; i++) {
        rows[i].className = 'DefaultRowColor';
    }
}

function hideCriteria() {
    document.getElementById("divCriteria").style.visibility = "hidden";
}

function stillCriteria() {
    document.getElementById("divCriteria").style.left = "50%";
    if (IsIE())
        document.getElementById("divCriteria").style.marginLeft = "275px";
    else
        document.getElementById("divCriteria").style.marginLeft = "280px";

    document.getElementById("divCriteria").style.visibility = "visible";
}

function showCriteria() {

    var b = findPos(document.getElementById("UC_Search_txtCriteria"));
    if (b != null) {
        document.getElementById("divCriteria").style.left = b[0] + "px";
        document.getElementById("divCriteria").style.top = b[1] + 4 + document.getElementById("UC_Search_txtCriteria").offsetHeight + "px";
    }

    var a = document.getElementById("divCriteria");
    if (a.style.visibility == "hidden") {
        a.style.visibility = "visible";
    }
    else {
        a.style.visibility = "hidden";
    }
}
//Start->autoComplete.js
var sWORD = '';
var UP = 38;
var DOWN = 40;
var ENTER = 13;
var index = -1;
var scrollindex = -1;
var TAB = 9;
var BACKSPACE = 8;
var DELETE = 46;
var ESC = 27;

var ALT = 18;
var CTRL = 17;
var SHIFT = 16;
var HOME = 36;
var END = 35;
var CAPS = 20;
var PAGEUP = 33;
var PAGEDOWN = 34;
var LEFT = 37;
var RIGHT = 39;
var SPACE = 32;

var table = null;
var rows = null;

var selectedRow = null;

function selectdata(tdata, inputBoxId, resultDivId) {
    alert(resultDivId);
    document.getElementById(inputBoxId).value = tdata;
    document.getElementById(resultDivId).innerHTML = '';
}

function GetAutoCompleteList(e, inputBoxId, resultDivId) {
    var keynum;
    var keychar;
    var numcheck;
    var c;
    sWORD = document.getElementById(inputBoxId).value;
    //alert("autoco");
    //    if (resultDivId == 'resultSubject') {
    //        isSubject = true;
    //    }
    //    if (resultDivId == 'resultItem') {
    //        isItem = true;
    //    }

    c = true;
    if (window.event) // IE
    {
        keynum = e.keyCode;
        if (e.keyCode == 9) {
            document.getElementById(resultDivId).innerHTML = '';
            document.getElementById(resultDivId).style.visibility = "hidden";
            return;
        }
    }
    else if (e.which) // Netscape/Firefox/Opera
    {
        keynum = e.which;
        if (e.which == 9) {
            document.getElementById(resultDivId).innerHTML = '';
            document.getElementById(resultDivId).style.visibility = "hidden";
            return;
        }
    }
    keychar = String.fromCharCode(keynum)
    numcheck = /\d/

    // If the down key is pressed
    if (keynum != DOWN && keynum != UP) {
        index = -1;
    }

    var b = findPos(document.getElementById(inputBoxId));

    //    if (b != null) {
    //        if (inputBoxId != "ctl00_CPH_UI_txtItemName") {
    //            document.getElementById(resultDivId).style.left = b[0] + "px";
    //            document.getElementById(resultDivId).style.top = b[1] + document.getElementById(inputBoxId).offsetHeight + "px";
    //        }
    //    }

    if (keynum == ALT || keynum == CTRL || keynum == SHIFT || keynum == HOME || keynum == END || keynum == CAPS || keynum == PAGEUP || keynum == PAGEDOWN || keynum == LEFT || keynum == RIGHT) {
        return;
    }

    if (keynum == DOWN) {
        MoveCursorDown(inputBoxId, resultDivId);
        return;
    }

    else if (keynum == UP) {
        MoveCursorUp(inputBoxId, resultDivId);
        return;
    }

    if (keynum == ESC) {
        document.getElementById(resultDivId).innerHTML = '';
        document.getElementById(resultDivId).style.visibility = "hidden";
        return;
    }
    if (keynum == SPACE) {
        sWORD = document.getElementById(inputBoxId).value + ' ';
    }
    else if (keynum == ENTER) {
        if (IsFireFox()) {
            document.getElementById(inputBoxId).value = selectedRow.textContent;
        }
        else {
            if (selectedRow == null) {
                table = document.getElementById(resultDivId);

                if (table == null) return;

                rows = table.getElementsByTagName("p");

                if (index >= 0 && index < rows.length) {

                    if (index < rows.length - 1) {
                        index = 0;
                        SetDefaultRowColor();
                        selectedRow = rows[index];
                        selectedRow.className = 'HighlightRow'
                    }
                }
            }
            if (selectedRow != null) {
                document.getElementById(inputBoxId).value = selectedRow.innerText;
            }
        }
        document.getElementById(resultDivId).innerHTML = '';
        document.getElementById(resultDivId).style.visibility = "hidden";
        // false is returned so that the postback won't occur when the return key is pressed

    }
    if (keynum != DOWN && keynum != UP && keynum != ESC && keynum != DELETE && (keynum >= 65 && keynum <= 90)) {
        sWORD = sWORD + keychar;
    }
    else if (keynum >= 48 && keynum <= 57) {
        sWORD = sWORD + keychar;
    }
    else if (keynum >= 96 && keynum <= 105) {
        sWORD = sWORD + (keynum - 96);
    }
    else if (keynum == BACKSPACE) {
        if (inputBoxId == 'UC_Search_txtSearch') {
            setTimeout("gotocallserver('" + inputBoxId + "', '" + resultDivId + "');", 500);
        }
        //        else if (inputBoxId == 'ctl00_CPH_UI_txtSubject') {
        //            setTimeout("gotocallserverSubject('" + inputBoxId + "', '" + resultDivId + "');", 500);
        //        }
        //        else if (inputBoxId == 'ctl00_CPH_UI_txtItemName') {
        //            setTimeout("gotocallserverItem('" + inputBoxId + "', '" + resultDivId + "');", 500);
        //        }

        return;
    }
    else if (keynum == ENTER || keynum == DELETE) {
        sWORD = document.getElementById(inputBoxId).value;

        if (keynum == DELETE) {
            var a = document.getElementById(inputBoxId);
            var isSelection = false;
            var startPos = a.selectionStart;
            var endPos = a.selectionEnd;
            var doc = document.selection;

            if ((!document.selection)) {
                if (inputBoxId == 'UC_Search_txtSearch') {
                    setTimeout("gotocallserver('" + inputBoxId + "', '" + resultDivId + "');", 500);
                }
                return;
            }
            else if (doc && (!startPos) && (!endPos)) {
                if (inputBoxId == 'UC_Search_txtSearch') {
                    setTimeout("gotocallserver('" + inputBoxId + "', '" + resultDivId + "');", 500);
                }
                return;
            }

            if (doc && doc.createRange().text.length != 0) {
                isSelection = true;
                sWORD = a.value.replace(doc.createRange().text, "");
            }
            else if (!doc && a.value.substring(startPos, endPos).length != 0) {
                isSelection = true;
                sWORD = a.value.replace(a.value.substring(startPos, endPos), "");
            }

            if (sWORD.length == 0) {
                document.getElementById(resultDivId).innerHTML = '';
                document.getElementById(resultDivId).style.visibility = "hidden";
                return;
            }

        }
        else {
            sWORD = document.getElementById(inputBoxId).value;
            if (inputBoxId == 'UC_Search_txtSearch') {
                setTimeout("gotocallserver('" + inputBoxId + "', '" + resultDivId + "');", 500);
            }
            return;
        }
    }
    // Call the server side method
    document.getElementById(resultDivId).innerHTML = "Loading......";
    if (inputBoxId == 'UC_Search_txtSearch') {
        CallServer(sWORD, resultDivId);
    }
    if (c == false) {
        return false;
    }
}

function gotocallserver(inputBoxId, resultDivId) {
    sWORD = document.getElementById(inputBoxId).value;
    CallServer(document.getElementById(inputBoxId).value, resultDivId);
}


function MoveCursorUp(inputBoxId, resultDivId) {
    selectedRow = null;
    table = document.getElementById(resultDivId);

    if (table == null) return;

    rows = table.getElementsByTagName("p");

    if (index > 0) {
        index--;

        SetDefaultRowColor();
        selectedRow = rows[index];
        selectedRow.className = 'HighlightRow';
        if (IsFireFox()) {
            document.getElementById(inputBoxId).value = selectedRow.textContent;
        }
        else {
            document.getElementById(inputBoxId).value = selectedRow.innerText;
        }
        if (scrollindex > 0)
            scrollindex--;
        if (((index + 1) * 19) > 0) {
            document.getElementById(resultDivId).scrollTop = document.getElementById(resultDivId).scrollTop - 19;
        }
    }
}

function MoveCursorDown(inputBoxId, resultDivId) {
    selectedRow = null;
    table = document.getElementById(resultDivId);

    if (table == null) return;

    rows = table.getElementsByTagName("p");

    if (index < rows.length) {

        if (index < rows.length - 1) {
            index++;
            SetDefaultRowColor();
            selectedRow = rows[index];
            selectedRow.className = 'HighlightRow';
            if (IsFireFox()) {

                document.getElementById(inputBoxId).value = selectedRow.textContent;
            }
            else {
                document.getElementById(inputBoxId).value = selectedRow.innerText;
            }
            if (scrollindex <= 9)
                scrollindex++;
            if (((scrollindex + 1) * 19) > 190) {
                document.getElementById(resultDivId).scrollTop = document.getElementById(resultDivId).scrollTop + 19;
            }
        }
    }
}

function SetDefaultRowColor() {
    for (i = 0; i < rows.length; i++) {
        rows[i].className = 'DefaultRowColor';
    }
}

function RecieveServerData(response, context) {
    //Dimple Changes
    if (response == "" || response == "NORES") {
        $(context).style.visibility = "hidden";
        $(context).innerHTML = '';
    }
    else {
        var eleResponse = response.split("|");
        var divCon = '';
        for (var i = 0; i < eleResponse.length; i++) {
            divCon = divCon + '<p onclick="setSearchText(\'' + eleResponse[i].replace(/''/gi, "''") + '\');" class="searchItems" onmouseover="setResultHover(1);" onmouseout="setResultHover(0);">' + eleResponse[i] + '</p>';
        }
        //onclick="setSearchText(\'' + eleResponse(i).replace(/''/gi, "''") + '\');"
        $(context).innerHTML = divCon;
        $(context).style.visibility = "visible";
    } 
//    document.getElementById(context).innerHTML = response;
//    if (response == "" || response == "NORES") {
//        document.getElementById(context).style.visibility = "hidden";
//    }
//    else {
//        document.getElementById(context).style.visibility = "visible";
//    }
}

function findPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        do {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;

        } while (obj = obj.offsetParent);
    }

    return [curleft, curtop];
}



function findPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        do {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;

        } while (obj = obj.offsetParent);
    }

    return [curleft, curtop];
}

function hideToolTipsSearch() {
    document.getElementById("divToolTipSearch").style.visibility = "hidden";
}

function setResultHover(val, obj) {

    if (obj != null && obj != 'undefined') {
        if (val == 1)
            obj.className = "searchItemsOver";
        else
            obj.className = "searchItems";
    }

    document.getElementById("resultHover").value = val;
}

function setSearch(arg) {
    document.getElementById("UC_Search_txtCriteria").value = arg;
    document.getElementById("UC_Search_txtCriteria").value = arg;
    document.getElementById("divCriteria").style.visibility = "hidden";
}

function setdefault(obj) {
    if (document.getElementById("results").style.visibility == "visible") {
        if (document.getElementById("resultHover").value == 0) {
            document.getElementById("results").innerHTML = '';
            document.getElementById("results").style.visibility = "hidden";
        }
    }
    else {
        if (obj.value.length == 0) { obj.value = 'Search for a Top 10 list' };
    }
}

function setSearchText(arg) {
    document.getElementById("UC_Search_txtSearch").value = arg;
    document.getElementById("results").innerHTML = '';
    document.getElementById("results").style.visibility = "hidden";
}

//End Search js

function showForgetPassword() {
    var objtxtUserName = document.getElementById("UC_Login_txtUserName");
    var objtxtemailid = document.getElementById("UC_Login_txtemailid");
    var objerrorUserName = document.getElementById("UC_Login_errorUserName");
    var objerrorEmail = document.getElementById("UC_Login_errorEmail");
    var objspanError = document.getElementById("spanError");
    var objerrorStaus = document.getElementById("errorStaus");

    if (objtxtUserName != null)
        objtxtUserName.value = "";

    if (objtxtemailid != null)
        objtxtemailid.value = "";

    if (objerrorUserName != null)
        objerrorUserName.innerHTML = "";

    if (objerrorEmail != null)
        objerrorEmail.innerHTML = "";

    if (objspanError != null)
        objspanError.innerHTML = "";

    if (objerrorStaus != null)
        objerrorStaus.innerHTML = "<img src='top10images/warning_icon.png' alt='' border='0' />"
        + "<div class='errortext'><div class='white12_error' id='spanError'></div></div><br /><br />";

    showDiv('UC_Login_divForgetPassword');
}

//Start->Hide all other Popups before show any popup.
function HideOtherPopups() {
    var objdivWhyJoin = document.getElementById("UC_Login_divWhyJoin");
    var objdivForgetPassword = document.getElementById("UC_Login_divForgetPassword");
    var objdivStaticContents = document.getElementById("divStaticContents");
    var objdivWidgetPopup = document.getElementById("divWidgetPopup");

    if (objdivWhyJoin != null)
        objdivWhyJoin.style.visibility = "hidden";
    if (objdivForgetPassword != null)
        objdivForgetPassword.style.visibility = "hidden";
    if (objdivStaticContents != null)
        objdivStaticContents.style.visibility = "hidden";
    if (objdivWidgetPopup != null)
        objdivWidgetPopup.style.visibility = "hidden";
}
//End->Hide all other Popups before show any popup.

function GoToSignUp() {
    var sPath = window.location.pathname;
    sPath = sPath.substring(sPath.lastIndexOf('/') + 1);
    window.location = "join-for-free.aspx?sPageName=" + sPath;
}

function ForgetPassword() {
    document.getElementById("UC_Login_errorUserName").innerHTML = "";
    document.getElementById("UC_Login_errorEmail").innerHTML = "";
    var objspanError = document.getElementById("spanError");
    if (objspanError != null)
        objspanError.innerHTML = "";
    document.getElementById("errorStaus").style.visibility = "hidden";
    var objtxtemailid = document.getElementById("UC_Login_txtemailid");

    var msg;
    msg = "";
    if (document.getElementById("UC_Login_txtUserName").value == '') {
        msg = "Please enter profile name.\n";
        document.getElementById("UC_Login_errorUserName").innerHTML = "Please enter profile name.";
    }
    if (objtxtemailid.value == '') {
        msg += "Please enter email address.\n";
        document.getElementById("UC_Login_errorEmail").innerHTML = "Please enter email address.";
    }
    else {
        if (emailCheckEP(objtxtemailid.value) == false) {
            msg += "Please enter vaid email address.\n";
            document.getElementById("UC_Login_errorEmail").innerHTML = "Please enter valid email address.";
        }
    }
    if (msg != '') {
        return false;
    }

    var arg;
    arg = "forgetpassword:" + document.getElementById("UC_Login_txtUserName").value;
    arg = arg + "~" + objtxtemailid.value;
    DoForgetPassword(arg, '', '');
}

function ForgetPasswordResult(response) {
    var objspanError = document.getElementById("spanError");
    var objerrorStaus = document.getElementById("errorStaus");

    objspanError.innerHTML = response;
    objerrorStaus.style.visibility = "visible";
}

//Start->Email validations
function emailCheckEP(emailStr) {
    if (emailStr == "") {
        return false;
    }
    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)  //Email address is incorrect
    {
        return false;
    }
    var user = matchArray[1];
    var domain = matchArray[2];
    for (i = 0; i < user.length; i++) //Ths username contains invalid characters.
    {
        if (user.charCodeAt(i) > 127) {
            return false;
        }
    }
    for (i = 0; i < domain.length; i++)  //Ths domain name contains invalid characters.
    {
        if (domain.charCodeAt(i) > 127) {
            return false;
        }
    }
    if (user.match(userPat) == null)  //The username doesn't seem to be valid.
    {
        return false;
    }
    var IPArray = domain.match(ipDomainPat);
    if (IPArray != null)  //Destination IP address is invalid!
    {
        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++) //The domain name does not seem to be valid.
    {
        if (domArr[i].search(atomPat) == -1) {
            return false;
        }
    }

    if (checkTLD && domArr[domArr.length - 1].length != 2 &&
    domArr[domArr.length - 1].search(knownDomsPat) == -1) //The address must end in a well-known domain or two letter " + "country.
    {
        return false;
    }

    if (len < 2) //This address is missing a hostname!
    {
        return false;
    }
    return true;
}
//End->Email validations

function validSpecialChar_Login(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode

    if (charCode == ENTER) {
        var a = document.getElementById("hrefLogin");
        a.focus();
        CheckLoginDet();
        return false;
    }

    if ((charCode > 64 && charCode < 91) || (charCode > 96 && charCode < 123) || charCode == 32 || charCode == 43 || charCode == 42 || charCode == 44 || charCode == 45 || charCode == 34 || charCode == 63 || charCode == 64 || charCode == 37 || charCode == 38 || charCode == 39 || charCode == 40 || charCode == 46 || charCode == 8)
        return true;

    if (charCode > 31 && (charCode < 48 || charCode > 57))
        return false;

    return true;
}

function passWordEnter(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode

    if (charCode == ENTER) {
        var a = document.getElementById("hrefLogin");
        a.focus();
        CheckLoginDet();
        return false;
    }
}

function CheckLoginDet() {
    document.getElementById("UC_Login_errorProfilename").innerHTML = "";
    document.getElementById("errorPassword").innerHTML = "";

    var msg;
    msg = "";
    if (document.getElementById("UC_Login_txtProfileName").value == '' || document.getElementById("UC_Login_txtProfileName").value == 'Profile Name') {
        msg = "Please enter profile name.\n";
        document.getElementById("UC_Login_errorProfilename").innerHTML = "Please enter profile name.";
    }
    if (document.getElementById("UC_Login_txtPassword").value == '') {
        msg += "Please enter password.\n";
        document.getElementById("errorPassword").innerHTML = "Please enter password.";
    }

    if (msg != '') {
        //alert("Please refer to the following error(s).\n\n" + msg)
        return false;
    }
    var arg;
    arg = "checklogin:" + document.getElementById("UC_Login_txtProfileName").value;
    arg = arg + "~" + document.getElementById("UC_Login_txtPassword").value;
    CheckValidLogin(arg, '');
}

function RecieveValidLogin(response) {
    document.getElementById("UC_Login_errorProfilename").innerHTML = "";
    document.getElementById("errorPassword").innerHTML = "";
    if (response == "true" || response == "True")
    { DoLogin1(); }
    else {
        //alert("Invalid userid/password");
        document.getElementById("UC_Login_errorProfilename").innerHTML = "Invalid Profile Name or Password.";
    }
}

function DoLogin1() {
    var arg;
    arg = "dologin:" + document.getElementById("UC_Login_txtProfileName").value;
    arg = arg + "~" + document.getElementById("UC_Login_txtPassword").value;
    var checked = $("UC_Login_chkRememberMe").checked;
    if (checked) {
        arg = arg + "~1";
    }
    else {
        arg = arg + "~0";
    }
    DoLogin(arg, '');
}

function RedirectLogin(response) {
    if (response == "true" || response == "True") {
        window.location = 'index.aspx';
    }
}

function hideToolTips() {
    document.getElementById("divToolTip").style.visibility = "hidden";
}

function showToolTipsSearch(ctrl, toolTipText) {
    if (ctrl != null) {
        var b = findPos(ctrl);
        if (b != null) {
            document.getElementById("divToolTipSearch").style.left = (b[0] - 220) + "px";
            document.getElementById("divToolTipSearch").style.top = (b[1] - 5) + "px";
        }
        document.getElementById("spanToolTipSearch").innerHTML = toolTipText;
        document.getElementById("divToolTipSearch").style.visibility = "visible";
    }
}

function hideToolTipsSearch() {
    $("divToolTipSearch").style.visibility = "hidden";
}

function $(id) { return document.getElementById(id); }

//<![CDATA[
var GlvDelayedNextPageNo;

function WebForm_CallbackComplete_SyncFixed() {
    // the var statement ensure the variable is not global
    for (var i = 0; i < __pendingCallbacks.length; i++) {
        callbackObject = __pendingCallbacks[i];
        if (callbackObject && callbackObject.xmlRequest &&
			(callbackObject.xmlRequest.readyState == 4)) {
            // SyncFixed: line move below // WebForm_ExecuteCallback(callbackObject);
            if (!__pendingCallbacks[i].async) {
                __synchronousCallBackIndex = -1;
            }
            __pendingCallbacks[i] = null;
            var callbackFrameID = "__CALLBACKFRAME" + i;
            var xmlRequestFrame = document.getElementById(callbackFrameID);
            if (xmlRequestFrame) {
                xmlRequestFrame.parentNode.removeChild(xmlRequestFrame);
            }
            // SyncFixed: the following statement has been moved down from above;
            WebForm_ExecuteCallback(callbackObject);
        }
    }
}

var OnloadWithoutSyncFixed = window.onload;

window.onload = function Onload() {
    if (typeof (WebForm_CallbackComplete) == "function") {
        // Set the fixed version
        WebForm_CallbackComplete = WebForm_CallbackComplete_SyncFixed;
        // CallTheOriginal OnLoad
        if (OnloadWithoutSyncFixed != null) OnloadWithoutSyncFixed();
    }
}
//]]

function showSubjectInfo()
{

}

function SetLoginRememberValue(chk) {
    //alert(chk.checked);
    setCookie("remembered", chk.checked, 1);
}

function setCookie(c_name, value, expiredays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    //exdate.setHours(exdate.getHours()+1);
    document.cookie = c_name + "=" + escape(value) +
    ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
}

function getCookie(c_name) {
    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 deleteCookie(c_name) {
    var d = new Date();
    document.cookie = c_name + "=;expires=" + d.toGMTString() + ";" + ";";
}

