if ( typeof Eduify == "undefined"){
	Eduify = function(){};
}

if ( typeof Eduify.Utils == "undefined"){
    Eduify.Utils = new function() {
        var isInProgress = false;
        var contextMenuFlag = true;
        var FocusControlId = null;
        var _BubbleWindow = null;
        var _DlgBhrId = "dlgShare_BehaviorID";
        var _ViewRptclip = null;
        return {
            GetCommonDialogID: function() {
                return _DlgBhrId;
            },
            CommonDlgClose: function() {
                if (Eduify.PBox) {
                    Eduify.PBox.HidePBoxStatus();
                }
            },
            HideEduifyDlg: function(pBahId) {
                $find(pBahId).hide();
            },
            GetContextMenuFlag: function() {
                return contextMenuFlag;
            },
            SetContextMenuFlag: function(val) {
                contextMenuFlag = val;
            },
            SwapWidgetVisibility: function(widBodyId, widInfoId, icn) {// providing the collapse/exapnd functionality to the widget
                //alert(widBodyId + " " + widInfoId);
                var widBody = $j("*[id$=" + widBodyId + "]")[0];
                var widInfo = $j("*[id$=" + widInfoId + "]")[0];
                if (widBody != null) {
                    //if(widBody.className.toUpperCase().indexOf("DN") == -1)
                    if (widBody.style.display != "none") {
                        widBody.style.display = "none";
                        //$j(widBody).slideDown("fast");
                        //widBody.className = widBody.className.toUpperCase().replace("DB","DN");
                        widInfo.value = "C";
                        icn.className = "icn_ex_co BI211";
                    }
                    else {
                        //$j(widBody).slideUp("fast");
                        widBody.style.display = "block";
                        //widBody.className = widBody.className.toUpperCase().replace("DN","DB");
                        widInfo.value = "E";
                        icn.className = "icn_ex_co BI212";
                    }
                }
            },
            //Open the Editor for the Provided Document Id
            OpenEditor: function(pDocId) {
                if (Eduify.UI && Eduify.UI.Common && _IsRegisterAjaxPro) {
                    var lUrlParam = Eduify.UI.Common.AJAXMethods.GetSQS([["documentId", pDocId.toString()]]).value;
                    Eduify.Utils.OpenEditorWithParams(lUrlParam);
                }
                else if (!_IsRegisterAjaxPro) {
                    $j.ajax({
                        type: "POST",
                        url: _AjaxPath,
                        async: false, // disabling async behavior to avoid popup blocker message
                        data: '{"pArgs": [["documentId", "' + pDocId.toString() + '"]]}',
                        beforeSend: function(xhr) {
                            xhr.setRequestHeader("Ajax-Method", "GetSQS");
                            xhr.setRequestHeader("Accept-Encoding", "gzip, deflate");
                        },
                        success: function(s) {
                            if (eval(s)) {
                                Eduify.Utils.OpenEditorWithParams(eval(s));
                            } else {
                                //file not allowed error
                                Eduify.Alert('error ::', 'Couldn\'t load document.', EdButtons.OkOnly, function() { }, function() { });
                            }
                        }
                    });
                }
            },
            //Open the Editor for the Provided url parameter
            OpenEditorWithParams: function(pUrlParam) {
                //replacing special characters for unique browser id for IE
                var lUniqueId = pUrlParam.replace(/%/gi, "");
                lUniqueId = lUniqueId.replace("?", "");
                lUniqueId = lUniqueId.replace("=", "");
                lUniqueId = lUniqueId.replace(/&/gi, "");

                //open editor document
                window.open('editor' + pUrlParam, 'eddoc' + lUniqueId, 'toolbar=0,menubar=0,location=0,channelmode=1,resizable=1');
            },
            OpenFile: function(pFileId) {
                //window.open("editor?documentId=-3&fileId=" + pFileId, 'edfile' + pFileId, 'toolbar=0,menubar=0,location=0,channelmode=1,resizable=1');
                if (Eduify.UI && Eduify.UI.Common && _IsRegisterAjaxPro) {
                    var lUrlParam = Eduify.UI.Common.AJAXMethods.GetSQS([["documentId", "-3"], ["fileId", pFileId.toString()]]).value;
                    Eduify.Utils.OpenEditorWithParams(lUrlParam);
                }
                else if (!_IsRegisterAjaxPro) {
                    $j.ajax({
                        type: "POST",
                        url: _AjaxPath,
                        async: false, // disabling async behavior to avoid popup blocker message
                        data: '{"pArgs": [["documentId", "-3"], ["fileId", "' + pFileId.toString() + '"]]}',
                        beforeSend: function(xhr) {
                            xhr.setRequestHeader("Ajax-Method", "GetSQS");
                            xhr.setRequestHeader("Accept-Encoding", "gzip, deflate");
                        },
                        success: function(s) {
                            if (eval(s)) {
                                Eduify.Utils.OpenEditorWithParams(eval(s));
                            } else {
                                //file not allowed error
                                Eduify.Alert('error ::', 'Couldn\'t load document.', EdButtons.OkOnly, function() { }, function() { });
                            }
                        }
                    });
                }
            },
            ReadEssayInEditor: function(pDocId, pEssayId) {
                window.open('editor?documentId=' + pDocId + '&essayId=' + pEssayId, 'edEssay' + pEssayId, 'toolbar=0,menubar=0,location=0,channelmode=1,resizable=1');
            },
            OpenEssayEditor: function(pAppPath) {
                var lPath = '';
                if (pAppPath) {
                    lPath = pAppPath + '/';
                }
                window.open(lPath + 'editor?documentId=-5&type=essay', 'edEssay', 'toolbar=0,menubar=0,location=0,channelmode=1,resizable=1');
            },
            OpenContestEssay: function() {
                window.open('Contest?param=myessay');
            },
            // Displays a Gray out Opaque Div over the screen
            GrayOutOn: function(pTop, pLeft, pWidth, pHeight, pTargetElementId, pzIndex) {
                var lOpDiv = document.createElement('div');
                var pnlContent = null;

                if (pTargetElementId != null && pTargetElementId.nodeType) {
                    pnlContent = pTargetElementId;
                }
                else if (pTargetElementId != null && pTargetElementId != "") {
                    pnlContent = $j("*[id$=" + pTargetElementId + "]")[0];
                } else {
                    pnlContent = $j("*[id$=pnlScreenContents]")[0];
                }

                if (pTop == -1 && pLeft == -1 && pWidth == -1 && pHeight == -1) {
                    pTop = Eduify.Utils.GetABSTop(pnlContent);
                    pLeft = Eduify.Utils.GetABSLeft(pnlContent);
                    pWidth = $j(pnlContent).outerWidth(true);
                    pHeight = $j(pnlContent).outerHeight(true);
                }
                document.body.appendChild(lOpDiv);
                lOpDiv.className = 'Elightbox_bg DB';
                lOpDiv.style.left = pLeft + "px";
                lOpDiv.style.top = pTop + "px";
                lOpDiv.style.width = pWidth + 5 + "px";
                if (typeof pzIndex != 'undefined') {
                    lOpDiv.style.zIndex = pzIndex;
                }
                lOpDiv.style.height = pHeight + 5 + "px";
                lOpDiv.style.display = "block";
            },
            // Removes a Gray out Opaque Div 
            GrayOutOff: function(pzIndex) {
                var lOpDiv = null;
                var lOpDiv1 = $j('.Elightbox_bg');
                if (typeof pzIndex != 'undefined') {
                    for (var lIndex = 0; lIndex < lOpDiv1.length; lIndex++) {
                        if (lOpDiv1[lIndex].style.zIndex == pzIndex) {
                            lOpDiv = lOpDiv1[lIndex];
                        }
                    }
                } else {
                    lOpDiv = lOpDiv1[0];
                }
                document.body.removeChild(lOpDiv);
            },
            // Retunrs the Absolute Left position of the provided element
            GetABSLeft: function(pElement) {
                var posleft = pElement.offsetLeft;
                if (pElement.offsetParent != null && pElement.offsetParent.tagName.toLowerCase() != "body")
                    posleft += Eduify.Utils.GetABSLeft(pElement.offsetParent);
                return posleft;
            },
            // Retunrs the Absolute Top position of the provided element
            GetABSTop: function(pElement) {
                var posTop = pElement.offsetTop;
                if (pElement.offsetParent != null && pElement.offsetParent.tagName.toLowerCase() != "body")
                    posTop += Eduify.Utils.GetABSTop(pElement.offsetParent);
                return posTop;
            },
            HidePrflIncmDlg: function() {
                if (window.history.length > 1) {
                    window.history.go(-1);
                }
                else {
                    window.location.replace('home');
                }
            },
            //WARP Panel Request Event for Default Grayout Effect
            RefRequest: function(oPanel, oEvent, pId) {
                if (!this.isInProgress) {
                    this.isInProgress = true;
                    Eduify.Utils.GrayOutOn(-1, -1, -1, -1, null, 50);
                }
                else {
                    oEvent.cancel = true;
                }
            },
            //WARP Panel Response Event for Default Grayout Effect
            RefResponse: function() {
                Eduify.Utils.GrayOutOff(50);
                this.isInProgress = false;
            },
            ReportInitializeTab: function(oWebTab) {

                //Left Slice Css Classes
                var lTabLCss = ["PB0 W8 H20 BI103 spTabBlueLeft BB1111",   //Default
                                "PB0 W8 H20 BI103 spTabWhiteLeft BB1102",  //Hover
                                "PB0 W8 H20 BI103 spTabWhiteLeft BB1102",  //Selected
                                "PB0 W8 H20 BI103 spTabBlueLeft BB1111"    //Disabled
                                ];
                //Right Slice Css Classes
                var lTabRCss = ["PB0 W8 H20 BI103 spTabBlueRight BB1111",  //Default
                                "PB0 W8 H20 BI103 spTabWhiteRight BB1102", //Hover
                                "PB0 W8 H20 BI103 spTabWhiteRight BB1102", //Selected
                                "PB0 W8 H20 BI103 spTabBlueRight BB1111"   //Disabled
                                ];
                var lTabMCss = [
                                "PB0 H20 DB PT6 TC BI103 FAB1500 CO02 spTabBlueRepeat BB1111",
                                "PB0 H20 DB PT6 TC BI103 FAB1500 CO119 spTabWhiteRepeat BB1102",
                                "PB0 H20 DB PT6 TC BI103 FAB1500 CO119 spTabWhiteRepeat BB1111",
                                "PB0 H20 DB PT6 TC BI103 FAB1500 CO02 spTabBlueRepeat BB1111"
                                ];
                //Resetting Defaults Css Classes
                for (var lIndex = 0; lIndex < 4; lIndex++) {
                    oWebTab._cssL[lIndex] = lTabLCss[lIndex];
                    oWebTab._cssR[lIndex] = lTabRCss[lIndex];
                }

                var ldivExportEmailPrint = $j("div[id$=EmailExportPrint]")[0];
                $j("#" + oWebTab.ID + "_tbl > tbody > tr:first").find("td:last").addClass("BB1111").html(ldivExportEmailPrint); ;

                $j("#" + oWebTab.ID + "_tbl > tbody > tr:first > td[id=sep]").addClass("H20 DIB BB1111");
                //Applying Css Classes for First User
                for (var index = 0; index < oWebTab.Tabs.length; index++) {
                    lTab = oWebTab.Tabs[index];
                    lTab.css = lTabMCss;
                    lTab.elemLeft.className = lTabLCss[0];
                    lTab.element.className = lTabMCss[0];
                    lTab.elemRight.className = lTabRCss[0];
                }
                // Applying Selected Css on Selected Tab
                lTab = lTab = oWebTab.Tabs[0];
                lTab = oWebTab.getSelectedTab();
                lTab.elemLeft.className = lTabLCss[2];
                lTab.element.className = lTabMCss[2];
                lTab.elemRight.className = lTabRCss[2];
                $j("#" + oWebTab.ID + "_cp")[0].className = "CB DB";

            },
            InitializeTab: function(oWebTab) {
                //Left Slice Css Classes
                var lTabLCss = ["PB0 W8 H20 BI103 spTabBlueLeft BB1111",   //Default
                                "PB0 W8 H20 BI103 spTabWhiteLeft BB1102",  //Hover
                                "PB0 W8 H20 BI103 spTabWhiteLeft BB1102",  //Selected
                                "PB0 W8 H20 BI103 spTabBlueLeft BB1111"    //Disabled
                                ];
                //Right Slice Css Classes
                var lTabRCss = ["PB0 W8 H20 BI103 spTabBlueRight BB1111",  //Default
                                "PB0 W8 H20 BI103 spTabWhiteRight BB1102", //Hover
                                "PB0 W8 H20 BI103 spTabWhiteRight BB1102", //Selected
                                "PB0 W8 H20 BI103 spTabBlueRight BB1111"   //Disabled
                                ];
                var lTabMCss = [
                                "PB0 W90 H20 DB PT6 TC BI103 FAB1500 CO02 spTabBlueRepeat BB1111 WSNWI",
                                "PB0 W90 H20 DB PT6 TC BI103 FAB1500 CO119 spTabWhiteRepeat BB1102 WSNWI",
                                "PB0 W90 H20 DB PT6 TC BI103 FAB1500 CO119 spTabWhiteRepeat BB1111 WSNWI",
                                "PB0 W90 H20 DB PT6 TC BI103 FAB1500 CO02 spTabBlueRepeat BB1111 WSNWI"
                                ];
                //Resetting Defaults Css Classes
                for (var lIndex = 0; lIndex < 4; lIndex++) {
                    oWebTab._cssL[lIndex] = lTabLCss[lIndex];
                    oWebTab._cssR[lIndex] = lTabRCss[lIndex];
                }

                $j("#" + oWebTab.ID + "_tbl > tbody > tr:first").find("td:last").addClass("BB1111");
                $j("#" + oWebTab.ID + "_tbl > tbody > tr:first > td[id=sep]").addClass("H19 DIB BB1111");
                //Applying Css Classes for First User
                for (var index = 0; index < oWebTab.Tabs.length; index++) {
                    lTab = oWebTab.Tabs[index];
                    lTab.css = lTabMCss;
                    lTab.elemLeft.className = lTabLCss[0];
                    lTab.element.className = lTabMCss[0];
                    lTab.elemRight.className = lTabRCss[0];
                }
                // Applying Selected Css on Selected Tab
                lTab = lTab = oWebTab.Tabs[0];
                lTab = oWebTab.getSelectedTab();
                lTab.elemLeft.className = lTabLCss[2];
                lTab.element.className = lTabMCss[2];
                lTab.elemRight.className = lTabRCss[2];
                $j("#" + oWebTab.ID + "_cp")[0].className = "CB DB";

            }, // Initiailize tab ends here
            //After Tab change Event for IG Tab Control
            AfterTabChange: function(oWebTab, oTab, oEvent) {
                //Resetting Content Pane Css and Bg Color.
                $j("#" + oWebTab.ID + "_cp")[0].className = "CB DB";
            },
            //After Tab change Event for AJAX Control Toolkit Tab Control
            AfterAJAXTabChange: function(sender, e) {
                //Resetting Content Pane Css and Bg Color.
                lCurrentTab = sender.get_activeTab();
                //Work for change page title
                lTitle = lCurrentTab._element.attributes.PageTitle.value; //lCurrentTab.getAttribute("PageTitle");
                if ($j("*[id$='lblTitle']")) {
                    $j("*[id$='lblTitle']")[0].innerHTML = lTitle;
                }
            },
            WorkBoxTabHeaderDiv: function(oWebTab) {

                Eduify.Utils.InitializeTab(oWebTab);
                var ldivAmount = $j("div[id$=divAmount]")[0];
                $j("#" + oWebTab.ID + "_tbl > tbody > tr:first").find("td:last").html(ldivAmount);

            },
            DocumentClick: function() {
                $j(document).click(
                    function(pEvent) {
                        if (FocusControlId != null) {
                            if (pEvent.target.id == (FocusControlId + "_input")) {
                                return false;
                            }
                            var combo = igcmbo_getComboById(FocusControlId);
                            if (combo != null) {
                                var lHidden = lHidden = document.getElementById(FocusControlId + "_HF");
                                var lFlag = 0;
                                if (lHidden != null && lHidden.value == combo.getDisplayValue()) {
                                    lFlag = 1;
                                }
                                else {
                                    lHidden.value = combo.getDisplayValue();
                                }
                                Eduify.Utils.WebComboPostBack(FocusControlId, lFlag);
                            }
                            FocusControlId = null;
                        }
                    }
                );
            },
            Init_Combo: function(cmbo) {

                cmb_img = document.getElementById(cmbo + "_img");
                cmb_img.className = "DN";
                cmb_img.height = cmb_img.width = "";
                cmb_img.style.height = cmb_img.style.width = "auto";
                cmb_img.src = "images/spacer.gif";

            },
            WebComboHideDropDown: function(webComboId, newValue, keyCode) {
                var combo = igcmbo_getComboById(webComboId);
                if (keyCode == 9) {
                    combo.setDropDown(false);
                }
            },
            WebCombo_EditKeyDown: function(webComboId, newValue, keyCode) {
                //Init_Combo(webComboId);
                //if user press enter or tab
                var lHidden;
                var flag = 0;
                var combo = igcmbo_getComboById(webComboId);
                FocusControlId = webComboId;
                if (document.createElement) {
                    lHidden = document.getElementById(webComboId + "_HF");
                    if (lHidden == null) {
                        lHidden = document.createElement('input');
                        lHidden.type = 'hidden';
                        lHidden.id = webComboId + "_HF";
                        document.forms[0].appendChild(lHidden);
                        lHidden.value = combo.getDisplayValue();
                    }
                    else {
                        if (lHidden.value == combo.getDisplayValue()) {
                            flag = 1;
                        }
                        else {
                            lHidden.value = combo.getDisplayValue();
                        }
                    }
                }
                if (keyCode == 9) {
                    Eduify.Utils.WebComboPostBack(webComboId, flag)
                }

            },
            WebComboPostBack: function(webComboId, flag) {

                var combo = igcmbo_getComboById(webComboId);
                combo.setDropDown(false);
                var str = combo.getDisplayValue();
                if (combo.getValue() != null && combo.selectedIndex == -1) {
                    setTimeout("Eduify.Utils.WebComboPostBack('" + webComboId + "','" + flag + "')", 0);
                }
                if ((combo.getValue() == null && (str != null) && (str != "")) || (combo.selectedIndex != -1)) {
                    if (flag == 0) {
                        __doPostBack(combo.UniqueId, str);
                    }
                }
            },
            ContextMenuStyle: function(id, lHeightClass, lMenuWidthClass, lTableWidthClass, lBorderWidth) {   /* This functin apples styles on context menu.*/
                var mainDiv = $j("#" + id + "_MainM > div")[0];
                var mainTable = $j("#" + id + "_MainM > div > table")[0];
                $j("#" + id + "_MainM").addClass(lMenuWidthClass);
                $j(mainTable).removeClass("BCT").addClass("AL BC2I");
                $j(mainTable).addClass(lHeightClass + " " + lTableWidthClass);

                /* Top elements Start */
                var lTopElm = document.createElement("div");
                lTopElm.className = "DB " + lMenuWidthClass;

                var lT1 = document.createElement("div");
                lT1.className = "AL W18 H18 Cont_LeftTop F02";
                var lT2 = document.createElement("div");
                lT2.className = "AL H18 BC2I " + lBorderWidth;
                var lT21 = document.createElement("div");
                lT21.className = "AL Cont_HorTopBg F02 " + lBorderWidth;
                lT2.appendChild(lT21);
                var lT3 = document.createElement("div");
                lT3.className = "AR W18 H18 Cont_RightTop F02";

                lTopElm.appendChild(lT1);
                lTopElm.appendChild(lT2);
                lTopElm.appendChild(lT3);
                /* Top elements end */

                /* Left element Start */
                var lLeftElm = document.createElement("div");
                lLeftElm.className = "AL W10 Cont_VerLeftBg F02 DIB " + lHeightClass;
                /* Left element end */

                /* Right element Start */
                var lRightElm = document.createElement("div");
                lRightElm.className = "AL W7 Cont_VerRightBg F02 DIB " + lHeightClass;
                /* Right element End */

                /* Bottom Elements Start*/
                var lBottomElm = document.createElement("div");
                lBottomElm.className = "DB " + lMenuWidthClass;

                var lB1 = document.createElement("div");
                lB1.className = "AL W18 H18 Cont_LeftBottom F02 PB3";
                var lB2 = document.createElement("div");
                lB2.className = "AL H18 BC2I " + lBorderWidth;
                var lB21 = document.createElement("div");
                lB21.className = "AL Cont_HorBottomBg H18 F02 MT9 " + lBorderWidth;
                lB2.appendChild(lB21);
                var lB3 = document.createElement("div");
                lB3.className = "AR W18 H18 Cont_RightBottom F02 PB3";

                lBottomElm.appendChild(lB1);
                lBottomElm.appendChild(lB2);
                lBottomElm.appendChild(lB3);
                /* Bottom Elements End*/
                if (mainDiv != undefined) {
                    mainDiv.insertBefore(lLeftElm, mainDiv.firstChild);
                    mainDiv.insertBefore(lTopElm, mainDiv.firstChild);
                    mainDiv.appendChild(lRightElm);
                    mainDiv.appendChild(lBottomElm);
                }
            },
            ///Resets the Iframe Border for Infragistcis Dialog Control
            DlgInit: function(oDialog, oParams) {
                oDialog.get_contentPane().get_iframe().frameBorder = 0;
                oDialog.get_contentPane().get_iframe().scrolling = "no";
            },
            TextBoxOnFocus: function(textbox, text) {   // This function set the value of textbox to empty.
                if (textbox.value == text) textbox.value = '';
            },
            TextBoxOnChange: function(textbox, text) {   // This function set the value of textbox to default value provided.
                if (textbox.value.length == 0) textbox.value = text;
            },
            OpenShareForRBox: function(pClipId, pIsAddBook) {
                if (pClipId == null || parseInt(pClipId) == "NaN" || pClipId <= 0) {
                    if (typeof Eduify.ClipList != "undefined") {
                        pClipId = Eduify.ClipList.GetSelectedClipId();
                    }
                }
                if (pClipId == null || pClipId == -1 || parseInt(pClipId) == "NaN") {
                    Eduify.Alert("error :: ", "Please select a clipping to share.", EdButtons.OkOnly);
                    return;
                }

                if (pIsAddBook) {
                    Eduify.Utils.OpenShareDlg(null, null, pClipId, null);
                } else {
                    Eduify.Utils.OpenAddressbookDlg(null, pClipId);
                }

            },
            OpenShareForRBoxAllSel: function(pClipId) {
                if (pClipId == null || parseInt(pClipId) == "NaN" || pClipId <= 0) {
                    if (typeof Eduify.ClipList != "undefined") {
                        pClipId = Eduify.ClipList.GetSelectedClipId();
                    }
                }
                if (pClipId == null || pClipId == -1 || parseInt(pClipId) == "NaN") {
                    Eduify.Alert("error :: ", "Please select a clipping to share.", EdButtons.OkOnly);
                    return;
                }
                Eduify.Utils.OpenHomeInviteDlg(null, pClipId);

            },
            OpenShareForPBox: function(pDocId, pFileId, pIsAddBook) {
                var lDocId = -1;
                var lFileId = -1;
                if (pDocId == null || parseInt(pDocId) == "NaN" || pDocId <= 0) {
                    if (typeof Eduify.PBox != "undefined") {
                        pDocId = Eduify.PBox.GetSelectedDocument();
                    }
                }

                if (pDocId == null || pDocId <= 0 || parseInt(pDocId) == "NaN") {
                    //Not a document                    
                    if (pFileId == null || parseInt(pFileId) == "NaN" || pFileId <= 0) {
                        if (typeof Eduify.PBox != "undefined") {
                            lFileId = Eduify.PBox.GetSelectedFile();
                        }
                    } else {
                        lFileId = pFileId;
                    }
                } else {
                    //Document
                    lDocId = pDocId;
                }

                if (lDocId == -1 && lFileId == -1) {
                    Eduify.Alert("error :: ", "Please select a document to share.", EdButtons.OkOnly);
                    return;
                }
                if (lDocId > 0) {
                    if (pIsAddBook) {
                        Eduify.Utils.OpenSharePermissionDlg(lDocId, null, null, 'false');
                    } else {
                        Eduify.Utils.OpenAddressbookDlg(pDocId, null);
                    }
                } else {
                    //File error
                    var lIsEduifyFile = Eduify.UI.Common.AJAXMethods.IsEditorAllowedFile(parseInt(lFileId)).value;
                    if (lIsEduifyFile) {
                        Eduify.Alert("error :: ", "This file cannot be shared. Please convert it to an Eduify document first.", EdButtons.OkOnly);
                    } else {
                        Eduify.Alert("error :: ", "This file cannot be shared currently. Please select another file.", EdButtons.OkOnly);
                    }
                }
            },
            OpenShareForPBoxAllSel: function(pDocId, pFileId) {
                var lDocId = -1;
                var lFileId = -1;
                if (pDocId == null || parseInt(pDocId) == "NaN" || pDocId <= 0) {
                    if (typeof Eduify.PBox != "undefined") {
                        pDocId = Eduify.PBox.GetSelectedDocument();
                    }
                }

                if (pDocId == null || pDocId <= 0 || parseInt(pDocId) == "NaN") {
                    //Not a document                    
                    if (pFileId == null || parseInt(pFileId) == "NaN" || pFileId <= 0) {
                        if (typeof Eduify.PBox != "undefined") {
                            lFileId = Eduify.PBox.GetSelectedFile();
                        }
                    } else {
                        lFileId = pFileId;
                    }
                } else {
                    //Document
                    lDocId = pDocId;
                }

                if (lDocId == -1 && lFileId == -1) {
                    Eduify.Alert("error :: ", "Please select a document to share.", EdButtons.OkOnly);
                    return;
                }

                if (lDocId > 0) {
                    Eduify.Utils.OpenSharePermissionDlg(lDocId, null, null, 'true');
                } else {
                    //File error
                    var lIsEduifyFile = Eduify.UI.Common.AJAXMethods.IsEditorAllowedFile(parseInt(lFileId)).value;
                    if (lIsEduifyFile) {
                        Eduify.Alert("error :: ", "This file cannot be shared. Please convert it to an Eduify document first.", EdButtons.OkOnly);
                    } else {
                        Eduify.Alert("error :: ", "This file cannot be shared currently. Please select another file.", EdButtons.OkOnly);
                    }
                }
            },
            //New Sharing Screen Methods
            OpenShareDlg: function(pDocId, pContent, pClipId, pShareType, pSourceFT, pUseLnkShrTxt) {
                var lDialogURL = "invite?";
                var lClipId = "";
                var lDocId = "";
                var lContent = "";

                if (pDocId != null && parseInt(pDocId) != "NaN" && pDocId > 0) {
                    lDocId = "did=" + pDocId;
                }
                else {
                    lDocId = "";
                }

                if (pClipId != null && parseInt(pClipId) != "NaN" && pClipId > 0) {
                    lClipId = "cid=" + pClipId;
                }
                else {
                    lClipId = "";
                }

                lDialogURL += lClipId;
                lDialogURL += "&" + lDocId;
                if (pSourceFT != null && parseInt(pSourceFT) != "NaN") {
                    lDialogURL += "&SourceFT=" + pSourceFT;
                }
                if (pContent != null && parseInt(pContent) != "NaN") {

                    var myUltraWebTab = igtab_getTabById(pContent);
                    if (myUltraWebTab == null) {
                        return;
                    }
                    var lSelectedTabIndex = myUltraWebTab.selected;
                    lDialogURL += "&content=" + lSelectedTabIndex;
                }
                if (pShareType != null && parseInt(pShareType) != "NaN") {
                    lDialogURL += "&psh=" + pShareType;
                }
                if (pUseLnkShrTxt != null) {
                    lDialogURL += "&ulst=" + pUseLnkShrTxt;
                }
                //set location in query string
                lDialogURL += "&" + "loc=" + this.GetCurrentLocation();

                //open invite dialog                
                Eduify.Dialog.showDialogWithUrl(_DlgBhrId, lDialogURL, 600, 690);
            },
            OpenAddressbookDlg: function(pDocId, pClipId) {
                var lDialogURL = "accountsemail?inDlg=true";
                var lReturnJS = "parent.Eduify.Utils.OpenShareDlg(";

                if (pClipId != null && parseInt(pClipId) != "NaN" && pClipId > 0) {
                    lReturnJS = "parent.Eduify.Utils.OpenShareDlg(";
                    if (pDocId != null && parseInt(pDocId) != "NaN" && pDocId > 0) {
                        lReturnJS = lReturnJS + pDocId + ",";
                    }
                    else {
                        lReturnJS = lReturnJS + "null,";
                    }

                    lReturnJS = lReturnJS + "null,";

                    if (pClipId != null && parseInt(pClipId) != "NaN" && pClipId > 0) {
                        lReturnJS = lReturnJS + pClipId + ",";
                    }
                    else {
                        lReturnJS = lReturnJS + "null,";
                    }
                    lReturnJS = lReturnJS + "null,null);";
                } else {
                    lReturnJS = "parent.Eduify.Utils.OpenSharePermissionDlg(";
                    if (pDocId != null && parseInt(pDocId) != "NaN" && pDocId > 0) {
                        lReturnJS = lReturnJS + pDocId + ",";
                    }
                    else {
                        lReturnJS = lReturnJS + "null,";
                    }
                    lReturnJS = lReturnJS + "null,null,'false');";
                }
                lDialogURL += "&next=" + lReturnJS;

                //open invite dialog                
                Eduify.Dialog.showDialogWithUrl(_DlgBhrId, lDialogURL, 600, 800);
            },
            GetCurrentLocation: function() {
                //get current Location
                var lLocation = window.location.href;
                lLocation = lLocation.substr(lLocation.lastIndexOf("/") + 1);
                if (lLocation.indexOf("?") > 0) {
                    lLocation = lLocation.substr(0, lLocation.indexOf("?"));
                }
                return lLocation;
            },
            OpenHomeInviteDlg: function(pDocId, pClipId) {
                var lDialogURL = "invite?sel=true";
                var lClipId = "";
                var lDocId = "";

                if (pDocId != null && parseInt(pDocId) != "NaN" && pDocId > 0) {
                    lDocId = "did=" + pDocId;
                }
                else {
                    lDocId = "";
                }

                if (pClipId != null && parseInt(pClipId) != "NaN" && pClipId > 0) {
                    lClipId = "cid=" + pClipId;
                }
                else {
                    lClipId = "";
                }

                lDialogURL += "&" + lClipId;
                lDialogURL += "&" + lDocId;

                //set location in query string
                lDialogURL += "&" + "loc=" + this.GetCurrentLocation();
                //open invite dialog
                Eduify.Dialog.showDialogWithUrl(_DlgBhrId, lDialogURL, 600, 690, 'W715-IE');
            },
            //New Sharing Screen Methods
            CloseShareDlg: function(reset) {
                try {
                    if (reset && parent.pBtnRefershSharing) {
                        parent.document.getElementById(parent.pBtnRefershSharing).click();
                    }
                } catch (e) { }
                //close invite dialog
                Eduify.Dialog.hideDialogWithUrl(_DlgBhrId);
            },
            //hide edit essay dialog
            HideEditEssayDlg: function() {
                var lDialog = $j("div[id$=wdwEdEssayDlg]")[0].control;
                if (typeof (lDialog) != 'undefined') {
                    lDialog.hide();
                }
            },
            CloseFirstLoginDlg: function(type, flag) {
                try {
                    if (flag) {
                        if (Eduify.UI && Eduify.UI.Common && _IsRegisterAjaxPro) {
                            Eduify.UI.Common.AJAXMethods.DisableFirstLoginDlg(type);
                        } else {
                            $j.ajax({
                                type: "POST",
                                url: _AjaxPath,
                                data: '{"type":' + parseInt(type) + '}',
                                beforeSend: function(xhr) {
                                    xhr.setRequestHeader("Ajax-Method", "DisableFirstLoginDlg");
                                    xhr.setRequestHeader("Accept-Encoding", "gzip, deflate");
                                },
                                success: function(s) {
                                    if (eval(s)) {                                                                           
                                    }
                                }
                            });
                        }
                    }

                } catch (e) { }
                //close dialog
                Eduify.Dialog.hideDialogWithUrl(_DlgBhrId);
            },
            AuditBoxShare: function(pFBConnect) {
                $j("input[id$=hfSelected]")[0].value = "0";
                $j("input[id$=hfSelectedType]")[0].value = "Invite";
                if (pFBConnect) {
                    Eduify.FBConnectNew.Login();
                    return false;
                }
            },
            PaperBoxShare: function(pAlert) {
                var lContent = Eduify.PBox.GetSelectedDocument();
                if (lContent != -1) {   //if eduify doc selected 
                    $j("input[id$=hfSelected]")[0].value = lContent;
                    $j("input[id$=hfSelectedType]")[0].value = "Document";
                    if (pAlert) {
                        Eduify.FBConnectNew.Login();
                        return false;
                    }
                } else {
                    lContent = Eduify.PBox.GetSelectedFile();
                    if (lContent != -1) {
                        $j("input[id$=hfSelected]")[0].value = lContent;
                        $j("input[id$=hfSelectedType]")[0].value = "File";
                        if (pAlert) {
                            Eduify.FBConnectNew.Login();
                            return false;
                        }
                    } else {
                        //If folder selected
                        Eduify.Alert("error :: ", "Please select a document to share.", EdButtons.OkOnly);
                        $j("input[id$=hfSelected]")[0].value = "";
                        $j("input[id$=hfSelectedType]")[0].value = "";
                        return false;
                    }
                }
            },
            ResearchBoxShare: function(pAlert) {
                var lContent = Eduify.ClipList.GetSelectedClipId();
                $j("input[id$=hfSelected]")[0].value = lContent;
                $j("input[id$=hfSelectedType]")[0].value = "Clipping";
                if (lContent == null || parseInt(lContent) <= 0 || parseInt(lContent) == "NaN") {
                    Eduify.Alert("error :: ", "Please select a clipping to share.", EdButtons.OkOnly);
                    return false;
                }
                if (pAlert) {
                    Eduify.FBConnectNew.Login();
                    return false;
                }
            },
            //Opens the Beta Invite Uninvited Users Dialog
            OpenInviteDialog: function(pUrl) {
                //open dialog                
                Eduify.Dialog.showDialogWithUrl(_DlgBhrId, pUrl, 595, 795);
            },
            OpenSearch: function(pObj) {
                var lsearchText = "";
                var lUrl = "";
                if (pObj != null) {
                    lsearchText = escape($j(pObj).text());
                } else {
                    lsearchText = escape($j("input[id$=txtSearch]").val());
                }

                if (lsearchText.toLowerCase() != "search for help") {
                    if (lsearchText == "") {
                        lUrl = "search";
                    } else {
                        lUrl = "search?q=" + lsearchText;
                    }
                    //open dialog                                  
                    Eduify.Dialog.showDialogWithUrl(_DlgBhrId, lUrl, 510, 700, 'W728_IE');
                }
            },
            OfferHelp: function(pUrl) {
                Eduify.Dialog.showDialogWithUrl(_DlgBhrId, pUrl, 410, 690, 'W714_IE');
                return false;
            },
            //Trade in points screen
            OpenTradeInDlg: function() {
                var lDialogURL = "tradein";
                Eduify.Dialog.showDialogWithUrl(_DlgBhrId, lDialogURL, 550, 700, 'W724-IE');
            },
            //Open firstlogin dialog
            OpenFirstLogin: function(type) {
                var lDialogURL,
                    lHeight,
                    lWidth;
                if (type == 'Home' && $j.browser.safari) {
                    lDialogURL = "firstloginSafari";
                }
                else {
                    lDialogURL = "firstlogin?type=" + type;
                }

                if ($j.browser.safari && type == 'Home') {
                    lHeight = 500;
                    lWidth = 740;
                }
                else {
                    lHeight = 620;
                    lWidth = 750;
                }
                Eduify.Dialog.showDialogWithUrl(_DlgBhrId, lDialogURL, lHeight, lWidth);

                //                if(lDialog._safari){
                //                    var _sHt = lDialog.getBody().offsetHeight - 10;
                //                    lDialog.getBody().style.height = _sHt + 'px';
                //                    lDialog.getBody().parentNode.style.height = _sHt + 'px';
                //                }
            },
            OpenEditEssayDlg: function() {
                var lDialog = $j("div[id$=wdwEdEssayDlg]")[0].control;
                if (lDialog == null || typeof (lDialog) == 'undefined') {
                    setTimeout("Eduify.Utils.OpenEditEssayDlg()", 500);
                    return;
                }
                var lDialogURL = "Pages/Wunderkind/GoEditIt";

                lDialog.get_contentPane().get_iframe().setAttribute("frameborder", "0");
                lDialog.get_contentPane().get_iframe().scrolling = "no";
                lDialog.get_contentPane().set_contentUrl(lDialogURL);
                lDialog.setSize("750px", "540px");  //width, height
                lDialog.show();
            },
            OpenPayment: function(pIsSSLEnable) {
                var lCurLoc = document.location.href.toLowerCase();
                if (pIsSSLEnable) {
                    lCurLoc = lCurLoc.replace("http", "https");
                }
                lCurLoc = lCurLoc.substr(0, lCurLoc.lastIndexOf("/") + 1);
                lCurLoc = lCurLoc + "payment";

                //Open common dialog               
                Eduify.Dialog.showDialogWithUrl(_DlgBhrId, lCurLoc, 530, 640);
            },
            OpenDlgWithUrl: function(pUrl, pWidth, pHeight, pClass) {
                //Open common dialog
                Eduify.Dialog.showDialogWithUrl(_DlgBhrId, pUrl, pHeight, pWidth, pClass);
            },
            OpenSharingNotAllowedDlg: function() {
                //Open common dialog               
                Eduify.Dialog.showDialogWithUrl(_DlgBhrId, "SharingNotAllowed", 235, 700, 'W724-IE');
            },
            //Open the Create Clip Dialog, Reuse the Sharing Dialog
            CreateClip: function(pEditorCall) {
                var lDialogURL = "CreateClip";
                if (pEditorCall) {
                    lDialogURL += "?edtitorcall=true";
                    if (Editor && Editor.actions) {
                        Editor.actions.hideDlg();
                    }
                }
                //Open common dialog               
                Eduify.Dialog.showDialogWithUrl(_DlgBhrId, lDialogURL, 555, 680);
            },
            //Registers a Cliend Side Hidden Field.
            RegHidden: function(pId, pValue) {
                var lJHidden = $j("#" + pId);
                var lHidden = null;
                if (lJHidden.length == 0) {
                    lHidden = $j("<input type='hidden' id='" + pId + "' name='" + pId + "' value='" + pValue + "' />")[0];
                    document.forms[0].appendChild(lHidden);
                }
                else {
                    lJHidden.val(pValue);
                }
            },
            HideCommonDlg: function(reloadPg) {
                if (reloadPg) {
                    parent.location = parent.location;
                }
                Eduify.Dialog.hideDialogWithUrl(_DlgBhrId);
            },
            RefreshCommonDialogParent: function(pId) {
                var lDlgElem = $j($find(_DlgBhrId)._popupElement);
                var lUpdatePanel = lDlgElem.parent().find("div[id$=" + pId + "]")
                if (lUpdatePanel.length > 0) {
                    // update panel found
                    __doPostBack(lUpdatePanel.attr('id'), "");
                }
            },
            //Hides an IG Dialog dy irs SeverSide Id
            HideIGDialogById: function(pServerSideId) {
                try {
                    var lDialog = $j("div[id$=" + pServerSideId + "]")[0].control;
                    if (typeof (lDialog) != 'undefined') {
                        lDialog.hide();
                    }
                } catch (e) { }
            },
            //Show an IG Dialog by its SeverSide Id
            ShowIGDialogById: function(pServerSideId) {
                try {
                    var lDialog = $j("div[id$=" + pServerSideId + "]")[0].control;
                    if (typeof (lDialog) != 'undefined') {
                        lDialog.show();
                    }
                } catch (e) { }
            },
            //Displays the Get Satisfaction Widget
            ShowGetHelp: function() {
                //Open common dialog               
                Eduify.Dialog.showDialogWithUrl(_DlgBhrId, "pages/getsatisfaction/getsatisfaction.htm", 250, 326);
            },
            //resizes the IG Dialog by its SeverSide Id
            ResizeDialog: function(pWdth, pHeight, pId) {
                try {
                    var lDialog = $j("div[id$=" + pId + "]")[0].control;
                    if (typeof (lDialog) != 'undefined') {
                        lDialog.setSize(pWdth + "px", pHeight + "px");
                    }
                } catch (e) { }
            },
            // Dialogue for PCheck Quota Upgrade
            OpenPCheckQuotaUpgradeDlg: function() {
                //Open common dialog               
                Eduify.Dialog.showDialogWithUrl(_DlgBhrId, "PCheckQuotaUpgrade", 440, 690);
            },
            OpenStorageQuotaUpgradeDlg: function() {
                //Open common dialog
                Eduify.Dialog.showDialogWithUrl(_DlgBhrId, "StorageQuotaUpgrade", 520, 680, 'W704-IE');
            },
            RefreshPCheckQuotaUpgradeDlgParent: function() {
                Eduify.PBox.RefreshPBox();
                //                var lPanelPaperBox = ig$($j("div[id$=warpAddFolder]")[0].id);
                //                if(lPanelPaperBox)
                //                {
                //                    lPanelPaperBox.refresh();
                //                }    
            },
            ProofreadApprove: function() {
                $j("*[id$=lblHeader]").text("paper clean-up in process");
                $j("div[id$=pnlProofread]").removeClass("DB").addClass("DN");
                $j("div[id$=pnlSmartMove]").removeClass("DN").addClass("DB");
            },
            EditingApprove: function() {
                $j("*[id$=lblHeader]").text("paper clean-up in process");
                $j("div[id$=pnlExpertEditing]").removeClass("DB").addClass("DN");
                $j("div[id$=pnlSmartMove]").removeClass("DN").addClass("DB");
            },
            PBoxProofread: function() {
                var lDocId = Eduify.PBox.GetSelectedDocument();
                if (lDocId > -1) {
                    $j("input[id$=hfDocId]")[0].value = lDocId;
                    $j("input[id$=hfDocType]")[0].value = "0"; //Document
                } else {
                    lDocId = Eduify.PBox.GetSelectedFile();
                    $j("input[id$=hfDocId]")[0].value = lDocId;
                    $j("input[id$=hfDocType]")[0].value = "1"; //File

                    if (lDocId < 0) {
                        Eduify.Alert(EdTitle.error, 'Please select a paper first.', EdButtons.OkayOnly, function() { }, function() { });
                        return false;
                    }
                }
            },
            ABoxSelDoc: function() {
                var lDocId = Eduify.ABox.GetSelectedId();
                var lType = Eduify.ABox.GetSelectedType();
                if (lDocId > 0) {
                    $j("input[id$=hdRefreshPanel]")[0].value = "true";
                    $j("input[id$=hfDocId]")[0].value = lDocId;
                    if (lType == "File") {
                        $j("input[id$=hfDocType]")[0].value = "1";
                    }
                    else if (lType == "Document") {
                        $j("input[id$=hfDocType]")[0].value = "0";
                    }
                } else {
                    $j("input[id$=hfDocId]")[0].value = "";
                    $j("input[id$=hfDocType]")[0].value = "";
                    Eduify.Alert(EdTitle.error, 'Please select a paper first.', EdButtons.OkOnly, function() { }, function() { });
                    return false;
                }
            },
            GetLocalTimeOffSet: function() {
                var now = new Date();
                var offset = now.getTimezoneOffset();
                $j("input[id$=hdTimeZoneOffset]")[0].value = offset;
            },
            UpdateTimeZone: function() {
                var now = new Date();
                var offset = now.getTimezoneOffset();
                Eduify.UI.Common.AJAXMethods.SetUserTimeZone(offset);
            },
            //Initiates a Refresh call for the IG Warp Panel with the Provided serverSide Id
            RefreshWarp: function(pSSId) {
                try {
                    var lPanel = ig$($j("div[id$=" + pSSId + "]")[0].id);
                    if (!lPanel) return;
                    lPanel.refresh();
                } catch (e) { }
            },
            RefreshUpdatePanel: function(pPanelId) {
                var lUpdatePanel = $j("div[id$=" + pPanelId + "]");
                if (lUpdatePanel.length == 0) {
                    __doPostBack(lUpdatePanel.attr('id'), '');
                }
            },
            SetButtonCss: function(pBgId, pBgCss, pLeftId, pLeftCss, pBtnId, pBtnCss, pRightId, pRightCss) {
                $j("div[id$=" + pBgId + "]").removeClass().addClass(pBgCss);
                $j("div[id$=" + pLeftId + "]").removeClass().addClass(pLeftCss);
                $j("input[id$=" + pBtnId + "]").removeClass().addClass(pBtnCss);
                $j("div[id$=" + pRightId + "]").removeClass().addClass(pRightCss);
            },
            btnHover: function(pObj, pLeftCss, pBtnCss, pRightCss) {
                $j("div:eq(0)", pObj).removeClass().addClass(pLeftCss);
                $j("input:nth-child(2)", pObj).removeClass().addClass(pBtnCss);
                $j("div:nth-child(3)", pObj).removeClass().addClass(pRightCss);
            },
            btnMouseHover: function(pObj, pBtnNewColorClass, pBtnOldColorClass) {
                $j(pObj).removeClass(pBtnOldColorClass).addClass(pBtnNewColorClass);
            },
            Redirect: function(pUrl) {
                window.location.replace(purl);
            },
            UpdateFBPoints: function(pNoOfInvites) {
                //var lCurrent = parseInt($j("span[id$=lblUserFBPoints]").text());
                var lCurrentPoints = 0;
                if ($j("span[id$=lblUserFBPoints]")[0]) {
                    _fbInviteCount += pNoOfInvites;
                    lCurrentPoints = _fbInviteCount * _pointsPerInvite;
                    $j("span[id$=lblUserFBPoints]").text(lCurrentPoints);
                }
            },
            SrchRefRequest: function(oPanel, oEvent, pId) {

                if (!this.isInProgress) {
                    this.isInProgress = true;
                    Eduify.Utils.GrayOutOn(-1, -1, -1, -1, oPanel.Id, 50);
                }
                else {
                    oEvent.cancel = true;
                }

            },
            SelectServiceType: function(pSelectId, pUnSelectId) {
                $j("div[id$=" + pSelectId + "]").removeClass("CO28").addClass("CO111");
                $j("div[id$=" + pSelectId + "1]").removeClass("sp_microsite_hr_grey1").addClass("sp_microsite_hr_blue1");
                $j("div[id$=" + pSelectId + "2]").removeClass("sp_microsite_hr_grey2").addClass("sp_microsite_hr_blue2");
                $j("div[id$=" + pSelectId + "3]").removeClass("sp_microsite_hr_grey3").addClass("sp_microsite_hr_blue3");
                $j("div[id$=" + pSelectId + "4]").removeClass("sp_microsite_hr_grey4").addClass("sp_microsite_hr_blue4");
                $j("div[id$=" + pSelectId + "5]").removeClass("sp_microsite_hr_grey5").addClass("sp_microsite_hr_blue5");

                $j("div[id$=" + pUnSelectId + "]").removeClass("CO111").addClass("CO28");
                $j("div[id$=" + pUnSelectId + "1]").removeClass("sp_microsite_hr_blue1").addClass("sp_microsite_hr_grey1");
                $j("div[id$=" + pUnSelectId + "2]").removeClass("sp_microsite_hr_blue2").addClass("sp_microsite_hr_grey2");
                $j("div[id$=" + pUnSelectId + "3]").removeClass("sp_microsite_hr_blue3").addClass("sp_microsite_hr_grey3");
                $j("div[id$=" + pUnSelectId + "4]").removeClass("sp_microsite_hr_blue4").addClass("sp_microsite_hr_grey4");
                $j("div[id$=" + pUnSelectId + "5]").removeClass("sp_microsite_hr_blue5").addClass("sp_microsite_hr_grey5");
            },
            SelectPaymentPlan: function(pSelectId, pUnSelectId1, pUnSelectId2) {
                $j("div[id$=" + pSelectId + "]").removeClass("CO121").addClass("CO111");
                if (pSelectId == "plusDiv") {
                    $j("div[id$=" + pSelectId + "1]").removeClass("sp_microsite_vr_grey6").addClass("sp_microsite_vr_blue1");
                    $j("div[id$=" + pSelectId + "2]").removeClass("sp_microsite_vr_grey7").addClass("sp_microsite_vr_blue2");
                    $j("div[id$=" + pSelectId + "3]").removeClass("sp_microsite_vr_grey8").addClass("sp_microsite_vr_blue3");
                    $j("div[id$=" + pSelectId + "4]").removeClass("sp_microsite_vr_grey9").addClass("sp_microsite_vr_blue4");
                    $j("div[id$=" + pSelectId + "5]").removeClass("sp_microsite_vr_grey10").addClass("sp_microsite_vr_blue5");
                } else {
                    $j("div[id$=" + pSelectId + "1]").removeClass("sp_microsite_vr_grey1").addClass("sp_microsite_vr_blue6");
                    $j("div[id$=" + pSelectId + "2]").removeClass("sp_microsite_vr_grey2").addClass("sp_microsite_vr_blue7");
                    $j("div[id$=" + pSelectId + "3]").removeClass("sp_microsite_vr_grey3").addClass("sp_microsite_vr_blue8");
                    $j("div[id$=" + pSelectId + "4]").removeClass("sp_microsite_vr_grey4").addClass("sp_microsite_vr_blue9");
                    $j("div[id$=" + pSelectId + "5]").removeClass("sp_microsite_vr_grey5").addClass("sp_microsite_vr_blue10");
                }

                $j("div[id$=" + pUnSelectId1 + "]").removeClass("CO111").addClass("CO121");
                if (pUnSelectId1 == "plusDiv") {
                    $j("div[id$=" + pUnSelectId1 + "1]").removeClass("sp_microsite_vr_blue1").addClass("sp_microsite_vr_grey6");
                    $j("div[id$=" + pUnSelectId1 + "2]").removeClass("sp_microsite_vr_blue2").addClass("sp_microsite_vr_grey7");
                    $j("div[id$=" + pUnSelectId1 + "3]").removeClass("sp_microsite_vr_blue3").addClass("sp_microsite_vr_grey8");
                    $j("div[id$=" + pUnSelectId1 + "4]").removeClass("sp_microsite_vr_blue4").addClass("sp_microsite_vr_grey9");
                    $j("div[id$=" + pUnSelectId1 + "5]").removeClass("sp_microsite_vr_blue5").addClass("sp_microsite_vr_grey10");
                } else {
                    $j("div[id$=" + pUnSelectId1 + "1]").removeClass("sp_microsite_vr_blue6").addClass("sp_microsite_vr_grey1");
                    $j("div[id$=" + pUnSelectId1 + "2]").removeClass("sp_microsite_vr_blue7").addClass("sp_microsite_vr_grey2");
                    $j("div[id$=" + pUnSelectId1 + "3]").removeClass("sp_microsite_vr_blue8").addClass("sp_microsite_vr_grey3");
                    $j("div[id$=" + pUnSelectId1 + "4]").removeClass("sp_microsite_vr_blue9").addClass("sp_microsite_vr_grey4");
                    $j("div[id$=" + pUnSelectId1 + "5]").removeClass("sp_microsite_vr_blue10").addClass("sp_microsite_vr_grey5");
                }

                $j("div[id$=" + pUnSelectId2 + "]").removeClass("CO111").addClass("CO121");
                if (pUnSelectId2 == "plusDiv") {
                    $j("div[id$=" + pUnSelectId2 + "1]").removeClass("sp_microsite_vr_blue1").addClass("sp_microsite_vr_grey6");
                    $j("div[id$=" + pUnSelectId2 + "2]").removeClass("sp_microsite_vr_blue2").addClass("sp_microsite_vr_grey7");
                    $j("div[id$=" + pUnSelectId2 + "3]").removeClass("sp_microsite_vr_blue3").addClass("sp_microsite_vr_grey8");
                    $j("div[id$=" + pUnSelectId2 + "4]").removeClass("sp_microsite_vr_blue4").addClass("sp_microsite_vr_grey9");
                    $j("div[id$=" + pUnSelectId2 + "5]").removeClass("sp_microsite_vr_blue5").addClass("sp_microsite_vr_grey10");
                } else {
                    $j("div[id$=" + pUnSelectId2 + "1]").removeClass("sp_microsite_vr_blue6").addClass("sp_microsite_vr_grey1");
                    $j("div[id$=" + pUnSelectId2 + "2]").removeClass("sp_microsite_vr_blue7").addClass("sp_microsite_vr_grey2");
                    $j("div[id$=" + pUnSelectId2 + "3]").removeClass("sp_microsite_vr_blue8").addClass("sp_microsite_vr_grey3");
                    $j("div[id$=" + pUnSelectId2 + "4]").removeClass("sp_microsite_vr_blue9").addClass("sp_microsite_vr_grey4");
                    $j("div[id$=" + pUnSelectId2 + "5]").removeClass("sp_microsite_vr_blue10").addClass("sp_microsite_vr_grey5");
                }
            },
            StartServiceOptionGrayOut: function(sender, args) {
                var pnlContent = $j("*[id$=pnlContents]")[0];
                Eduify.Utils.GrayOutOn(-1, -1, -1, -1, pnlContent, 50);
            },
            StopServiceOptionGrayOut: function(sender, args) {
                Eduify.Utils.GrayOutOff(50);
                if ($j("*[id$='hdnJSDump']")[0] && $j("*[id$='hdnJSDump']")[0].value != '') {
                    try {
                        eval($j("*[id$='hdnJSDump']")[0].value)
                        $j("*[id$='hdnJSDump']")[0].value = '';
                    }
                    catch (e) {
                        //alert(e.description)
                    }
                }
            },
            //Share Permission dialog with tabs open in paperbox
            OpenSharePermissionDlg: function(pDocId, pSelTab, pDisTab, pIsSelAllCont) {
                var lDialogURL = "SharePermission?";

                var lDocId = "";
                var lSelTab = "";
                var lDisTab = "";
                var lIsSelAllCont = "";

                if (pDocId != null) {
                    if (parseInt(pDocId) != "NaN" && pDocId > 0) {
                        lDocId = "did=" + pDocId;
                    }
                    else if (typeof pDocId == "string") {
                        lDocId = pDocId;
                    }
                }
                else {
                    lDocId = "";
                }

                if (pSelTab != null && parseInt(pSelTab) != "NaN") {
                    lSelTab = "stab=" + pSelTab;
                } else {
                    lSelTab = "";
                }

                if (pDisTab != null) {
                    lDisTab = "dtab=" + pDisTab;
                } else {
                    lDisTab = "";
                }

                if (pIsSelAllCont != null) {
                    lIsSelAllCont = "sel=" + pIsSelAllCont;
                } else {
                    lIsSelAllCont = "sel=false";
                }

                lDialogURL += lDocId;
                lDialogURL += "&" + lSelTab;
                lDialogURL += "&" + lDisTab;
                lDialogURL += "&" + lIsSelAllCont;

                //set location in query string
                lDialogURL += "&" + "loc=" + this.GetCurrentLocation();

                //open invite dialog                
                Eduify.Dialog.showDialogWithUrl(_DlgBhrId, lDialogURL, 600, 700, 'W728_IE');
            },
            SharePermissionRefRequest: function(oPanel, oEvent, pId) {
                if (!this.isInProgress) {
                    this.isInProgress = true;
                    Eduify.Utils.GrayOutOn(-1, -1, -1, -1, $j("*[id$='wtSharePermission'")[0], 50);
                }
                else {
                    oEvent.cancel = true;
                }
            },
            SharePermissionInitializeTab: function(oWebTab) {
                //Left Slice Css Classes
                var lTabLCss = ["PB0 W8 H20 BI103 spTabBlueLeft BB1111",   //Default
                                "PB0 W8 H20 BI103 spTabWhiteLeft BB1102",  //Hover
                                "PB0 W8 H20 BI103 spTabWhiteLeft BB1102",  //Selected
                                "PB0 W8 H20 BI103 spTabBlueLeft BB1111"    //Disabled
                                ];
                //Right Slice Css Classes
                var lTabRCss = ["PB0 W8 H20 BI103 spTabBlueRight BB1111",  //Default
                                "PB0 W8 H20 BI103 spTabWhiteRight BB1102", //Hover
                                "PB0 W8 H20 BI103 spTabWhiteRight BB1102", //Selected
                                "PB0 W8 H20 BI103 spTabBlueRight BB1111"   //Disabled
                                ];
                var lTabMCss = [
                                "PB0 W150 H20 DB PT6 TC BI103 FAB1500 CO02 spTabBlueRepeat BB1111 WSNWI",
                                "PB0 W150 H20 DB PT6 TC BI103 FAB1500 CO119 spTabWhiteRepeat BB1102 WSNWI",
                                "PB0 W150 H20 DB PT6 TC BI103 FAB1500 CO119 spTabWhiteRepeat BB1111 WSNWI",
                                "PB0 W150 H20 DB PT6 TC BI103 FAB1500 CO02 spTabBlueRepeat BB1111 WSNWI"
                                ];
                //Resetting Defaults Css Classes
                for (var lIndex = 0; lIndex < 4; lIndex++) {
                    oWebTab._cssL[lIndex] = lTabLCss[lIndex];
                    oWebTab._cssR[lIndex] = lTabRCss[lIndex];
                }

                $j("#" + oWebTab.ID + "_tbl > tbody > tr:first").find("td:last").addClass("BB1111");
                $j("#" + oWebTab.ID + "_tbl > tbody > tr:first > td[id=sep]").addClass("H18 DIB BB1111");
                //Applying Css Classes for First User
                for (var index = 0; index < oWebTab.Tabs.length; index++) {
                    lTab = oWebTab.Tabs[index];
                    lTab.css = lTabMCss;
                    lTab.elemLeft.className = lTabLCss[0];
                    lTab.element.className = lTabMCss[0];
                    lTab.elemRight.className = lTabRCss[0];
                }
                // Applying Selected Css on Selected Tab
                lTab = lTab = oWebTab.Tabs[0];
                lTab = oWebTab.getSelectedTab();
                lTab.elemLeft.className = lTabLCss[2];
                lTab.element.className = lTabMCss[2];
                lTab.elemRight.className = lTabRCss[2];
                $j("#" + oWebTab.ID + "_cp")[0].className = "CB DB";

            },
            SharePermissionCheckChange: function(chkbox) {
                var parentrow = chkbox.parentNode.parentNode;
                parentrow.getElementsByTagName("input")[0].checked = true;
            },
            PBoxFirstUserTutorial: function(type) {   /* This function show the Paperbox first user tutorial*/
                Eduify.Utils.GrayOutOn(-1, -1, -1, -1, null, 50);
                $j('div[id$=pnlNavigate]').removeClass('DN').addClass('DB');
                //Eduify.UI.Common.AJAXMethods.DisableFirstLoginDlg(type);

                $j.ajax({
                    type: "POST",
                    url: _AjaxPath,
                    data: '{"type":' + parseInt(type) + '}',
                    beforeSend: function(xhr) {
                        xhr.setRequestHeader("Ajax-Method", "DisableFirstLoginDlg");
                        xhr.setRequestHeader("Accept-Encoding", "gzip, deflate");
                    },
                    success: function(s) {
                        if (eval(s) != null) {
                        }
                    }
                });
            },
            ProvEdtrFirstLoginTutorial: function(type) {   /* This function show the Provider Editor first use tutorial*/
                Eduify.Utils.GrayOutOn(-1, -1, -1, -1, null, 50);
                $j('div[id$=pnlEditBar]').removeClass('DN').addClass('DB');
                Eduify.UI.Common.AJAXMethods.DisableFirstLoginDlg(type);
            },
            ProvEdtrFirstLoginNext: function(pPrev, pNext) {   /* This function will show the next tutorial dialog */
                $j('div[id$=' + pPrev + ']').removeClass('DB').addClass('DN');
                if (pNext) {
                    $j('div[id$=' + pNext + ']').removeClass('DN').addClass('DB');
                }
                else {
                    Eduify.Utils.GrayOutOff(50);
                }
            },
            SearchAndHideTutorialDlg: function(pText) {
                var lQTxt = $j('input[id$=inpSearchText]').val();
                if (parent.Editor && lQTxt != pText) {
                    parent.Editor.Dialogs.hideQuoteTutorialDlg(0, false);

                    parent.Editor.Dialogs.showAddQuoteDlg(lQTxt);
                }
            },
            CopyToClipboard: function(meintext, pSwfPath) {
                if (_ViewRptclip == null) {
                    ZeroClipboard.setMoviePath(pSwfPath);
                    _ViewRptclip = new ZeroClipboard.Client();
                    _ViewRptclip.setHandCursor(true);

                    _ViewRptclip.addEventListener('load', function(client) {
                        //  alert("Flash movie loaded and ready.");
                    });

                    _ViewRptclip.addEventListener('complete', function(client, pText) {
                        //alert(pText);
                        //				
                    });

                    _ViewRptclip.addEventListener('mouseOver', function(client) {
                        _ViewRptclip.setText(meintext);
                    });

                    // glue specifying our button AND its container
                    _ViewRptclip.glue('ctl00_cphScreenContents_ucViewReportContainer_btnLnk', 'divClipboardContainer');
                }

            },
            btnOverBO: function(Obj) {
                $j("div:eq(0)", Obj).removeClass("hp_btn_blue1").addClass("hp_btn_orange1");
                $j("div:nth-child(2)", Obj).removeClass("BI316").addClass("BI318");
                $j("div:nth-child(3)", Obj).removeClass("hp_btn_blue2").addClass("hp_btn_orange2");
                $j("div:nth-child(4)", Obj).removeClass("BI317").addClass("BI319");
                $j("div:nth-child(5)", Obj).removeClass("hp_btn_blue3").addClass("hp_btn_orange3");
            },
            btnOutBO: function(Obj) {
                $j("div:eq(0)", Obj).removeClass("hp_btn_orange1").addClass("hp_btn_blue1");
                $j("div:nth-child(2)", Obj).removeClass("BI318").addClass("BI316");
                $j("div:nth-child(3)", Obj).removeClass("hp_btn_orange2").addClass("hp_btn_blue2");
                $j("div:nth-child(4)", Obj).removeClass("BI319").addClass("BI317");
                $j("div:nth-child(5)", Obj).removeClass("hp_btn_orange3").addClass("hp_btn_blue3");
            },


            btnOverGB: function(Obj) {
                $j("div:eq(0)", Obj).removeClass("hp_btn_gray1").addClass("hp_btn_blue1");
                $j("div:nth-child(2)", Obj).removeClass("hp_btn_gray2").addClass("BI316");
                $j("div:nth-child(3)", Obj).removeClass("hp_btn_gray3").addClass("hp_btn_blue2");
                $j("div:nth-child(4)", Obj).removeClass("hp_btn_gray4").addClass("BI317");
                $j("div:nth-child(5)", Obj).removeClass("hp_btn_gray5").addClass("hp_btn_blue3");
            },
            btnOutGB: function(Obj) {
                $j("div:eq(0)", Obj).removeClass("hp_btn_blue1").addClass("hp_btn_gray1");
                $j("div:nth-child(2)", Obj).removeClass("BI316").addClass("hp_btn_gray2");
                $j("div:nth-child(3)", Obj).removeClass("hp_btn_blue2").addClass("hp_btn_gray3");
                $j("div:nth-child(4)", Obj).removeClass("BI317").addClass("hp_btn_gray4");
                $j("div:nth-child(5)", Obj).removeClass("hp_btn_blue3").addClass("hp_btn_gray5");
            },


            btnOverCO: function(Obj) {
                $j("div:eq(0)", Obj).removeClass("hp_btn_cyan1").addClass("hp_btn_orange1");
                $j("div:nth-child(2)", Obj).removeClass("hp_btn_cyan2").addClass("BI318");
                $j("div:nth-child(3)", Obj).removeClass("hp_btn_cyan3").addClass("hp_btn_orange2");
                $j("div:nth-child(4)", Obj).removeClass("hp_btn_cyan4").addClass("BI319");
                $j("div:nth-child(5)", Obj).removeClass("hp_btn_cyan5").addClass("hp_btn_orange3");
            },
            btnOutCO: function(Obj) {
                $j("div:eq(0)", Obj).removeClass("hp_btn_orange1").addClass("hp_btn_cyan1");
                $j("div:nth-child(2)", Obj).removeClass("BI318").addClass("hp_btn_cyan2");
                $j("div:nth-child(3)", Obj).removeClass("hp_btn_orange2").addClass("hp_btn_cyan3");
                $j("div:nth-child(4)", Obj).removeClass("BI319").addClass("hp_btn_cyan4");
                $j("div:nth-child(5)", Obj).removeClass("hp_btn_orange3").addClass("hp_btn_cyan5");
            },
            btnOverGrO: function(Obj) {
                $j("div:eq(0)", Obj).removeClass("hp_btn_green1").addClass("hp_btn_orange1");
                $j("div:nth-child(2)", Obj).removeClass("hp_btn_green2").addClass("BI318");
                $j("div:nth-child(3)", Obj).removeClass("hp_btn_green3").addClass("hp_btn_orange2");
                $j("div:nth-child(4)", Obj).removeClass("hp_btn_green4").addClass("BI319");
                $j("div:nth-child(5)", Obj).removeClass("hp_btn_green5").addClass("hp_btn_orange3");
            },
            btnOutGrO: function(Obj) {
                $j("div:eq(0)", Obj).removeClass("hp_btn_orange1").addClass("hp_btn_green1");
                $j("div:nth-child(2)", Obj).removeClass("BI318").addClass("hp_btn_green2");
                $j("div:nth-child(3)", Obj).removeClass("hp_btn_orange2").addClass("hp_btn_green3");
                $j("div:nth-child(4)", Obj).removeClass("BI319").addClass("hp_btn_green4");
                $j("div:nth-child(5)", Obj).removeClass("hp_btn_orange3").addClass("hp_btn_green5");
            },
            HideUsCitizenDlg: function() {
                $j("div[id$=wdwUSPerson]")[0].control.hide();
            },
            ViewCompanyBubble: function() {
                if (_BubbleWindow != null) {
                    $j('div[id$=' + _BubbleWindow + ']').removeClass('DB').addClass('DN');
                }
                $j('div[id$=pnlCompany]').removeClass('DN').addClass('DB');

                _BubbleWindow = "pnlCompany";
            },
            ViewAccountTypeBubble: function(pDivId) {
                if (_BubbleWindow != null) {
                    $j('div[id$=' + _BubbleWindow + ']').removeClass('DB').addClass('DN');
                }
                $j('div[id$=pnlAccountType]').removeClass('DN').addClass('DB');
                var height = pDivId.offsetTop + 30;
                $j('div[id$=pnlAccountType]').attr({ style: 'top:' + height + 'px' });
                _BubbleWindow = "pnlAccountType";
            },
            ViewBankRoutingBubble: function(pDivId) {
                if (_BubbleWindow != null) {
                    $j('div[id$=' + _BubbleWindow + ']').removeClass('DB').addClass('DN');
                }
                $j('div[id$=pnlBankRoutingNumber]').removeClass('DN').addClass('DB');
                var height = pDivId.offsetTop + 30;
                $j('div[id$=pnlBankRoutingNumber]').attr({ style: 'top:' + height + 'px' });
                _BubbleWindow = 'pnlBankRoutingNumber';
            },
            ViewBankAccountNumberBubble: function(pDivId) {
                if (_BubbleWindow != null) {
                    $j('div[id$=' + _BubbleWindow + ']').removeClass('DB').addClass('DN');
                }
                $j('div[id$=pnlBankAccountNumber]').removeClass('DN').addClass('DB');
                var height = pDivId.offsetTop + 30;
                $j('div[id$=pnlBankAccountNumber]').attr({ style: 'top:' + height + 'px' });
                _BubbleWindow = 'pnlBankAccountNumber';
            },
            ViewTaxEntityBubble: function(pDivId) {
                if (_BubbleWindow != null) {
                    $j('div[id$=' + _BubbleWindow + ']').removeClass('DB').addClass('DN');
                }
                $j('div[id$=pnlTaxEntity]').removeClass('DN').addClass('DB');
                var height = pDivId.offsetTop + 30;
                $j('div[id$=pnlTaxEntity]').attr({ style: 'top:' + height + 'px' });
                _BubbleWindow = 'pnlTaxEntity';
            },
            ViewSSNBubble: function(pDivId) {
                if (_BubbleWindow != null) {
                    $j('div[id$=' + _BubbleWindow + ']').removeClass('DB').addClass('DN');
                }
                $j('div[id$=pnlSSN]').removeClass('DN').addClass('DB');
                var height = pDivId.offsetTop + 30;
                $j('div[id$=pnlSSN]').attr({ style: 'top:' + height + 'px' });
                _BubbleWindow = 'pnlSSN';
            },
            DisableStatusDD: function(pEvent, pDDl) {
                var lSelectedIndex = pDDl.selectedIndex,
                    lMsg = '';

                if (lSelectedIndex == 1) {
                    pDDl.disabled = true;
                    lMsg = "Are you sure you've completed this project?";
                } else {
                    lMsg = "Are you sure you want a reassignment of this document?";
                }

                Eduify.Alert("Confirm:: ", lMsg, EdButtons.YesNo,
                    function() { setTimeout("__doPostBack('" + pDDl.name + "','')", 0); },
                    function() {
                        pDDl.disabled = false;
                        pDDl.selectedIndex = 0;
                        return false;
                    },
                    function() {
                        pDDl.disabled = false;
                        pDDl.selectedIndex = 0;
                        return false;
                    });

                pEvent.returnValue = false;
                pEvent.cancelBubble = true;
                if ($j.browser.mozilla) {
                    pEvent.preventDefault();
                }
                return false;
            },
            HideValidators: function() {
                //Hide all validation errors  
                if (window.Page_Validators) {
                    for (var vI = 0; vI < Page_Validators.length; vI++) {
                        var lValidator = Page_Validators[vI];
                        lValidator.isvalid = true;
                        ValidatorUpdateDisplay(lValidator);
                    }
                }
            },
            ShowAboutMeHelpPopup: function(pEvent, pControl, pData) {
                var lData = '',
                    lTop = '',
                    lLeft = '',
                    lPopupWidth = 200,
                    lControl;

                // Get Top and Left
                lControl = $j(pControl);
                lTop = lControl.position().top + lControl.height(); //pEvent.screenY; //'TOP505';
                lLeft = lControl.position().left - (lPopupWidth / 2) + (lControl.width() / 2); //pEvent.screenX; //'LE296';

                // Get appropriate data to display
                switch (pData) {
                    case 'ReferAFriend':
                        lData = "Refer a friend to your favorite provider. This will give you 100 points per friend who you referred and hired a provider.";
                        break;
                    case 'Subjects':
                        lData = "All of the subjects that the expert specializes in here are listed.";
                        break;
                    case 'Services':
                        lData = "Eduify's providers may help you with two services. These services are sold in Eduify coins.<br><br>Each Coin = ~ $1.<br>Page = 400 words";
                        break;
                    case 'CertifiedExpert':
                        lData = "Eduify tests every provider and will certify them as an expert. There are three levels in total for each area, so a 2 is pretty good.";
                        break;
                    case 'Testimonials':
                        lData = "Testimonial are feedback comments that the provider has highlighted as testimonials.";
                        break;
                    case 'RecentWork':
                        lData = "Here's a list of the recent work completed by this provider.";
                        break;
                    default:
                        lData = '';
                        break;
                }

                // Show Help Box
                Eduify.Utils.ShowHelpPopup(lData, lTop, lLeft);

                pEvent.stopPropagation();
                pEvent.cancelBubble = true;
            },
            ShowHelpPopup: function(pData, pTop, pLeft) {


                var lControl = $j('div[id$=pnlHelpPopup]');
                if (lControl.length > 0) {
                    lControl.hide();
                    lControl.find('div[id$=pnlHelpPopup_Data]').html(pData);
                    lControl.show();
                } else {
                    var lHtml = '<div class="AL W200 POA ZI1000" id="pnlHelpPopup">';
                    lHtml += '<div class="W24 H18 MA calloutBubble sp_cb_arrow_top">';
                    lHtml += '</div>';
                    lHtml += '<div class="AL WP100 H11 OH">';
                    lHtml += '<div class="AL W11 H11 calloutBubble">';
                    lHtml += '</div>';
                    lHtml += '<div class="AL W178 H11 calloutBubble sp_cb_top_brder">';
                    lHtml += '</div>';
                    lHtml += '<div class="AL W11 H11 calloutBubble sp_cb_tright_crn">';
                    lHtml += '</div>';
                    lHtml += '</div>';
                    lHtml += '<div class="AL W200 VM">';
                    lHtml += '<div class="AL W200 sp_cb_left">';
                    lHtml += '<div class="AL W186 sp_cb_right FAB1200 CO28 PL7 PR7">';
                    lHtml += '<div class="AL WP100 BC2">';
                    lHtml += '<div id="pnlHelpPopup_Data">' + pData + '</div>';
                    lHtml += '<br />';
                    lHtml += '</div>';
                    lHtml += '</div>';
                    lHtml += '</div>';
                    lHtml += '</div>';
                    lHtml += '<div class="AL W200 OH H29">';
                    lHtml += '<div class="AL W11 H29 calloutBubble sp_cb_bleft_crn">';
                    lHtml += '</div>';
                    lHtml += '<div id="lblClose" class="AL W178 calloutBubble sp_cb_bottom FAB1200 PT10 PB4 CO02 TR CUP" onclick="Eduify.Utils.HideHelpPopup();">';
                    lHtml += 'close</div>';
                    lHtml += '<div class="AL W11 H29 calloutBubble sp_cb_bright_crn">';
                    lHtml += ' </div>';
                    lHtml += '</div>';
                    lHtml += '</div>';
                    $j(document.body).append(lHtml);

                    lControl = $j('div[id$=pnlHelpPopup]');
                }
                // Set help box position                   
                lControl.css({ 'left': pLeft + 'px', 'top': pTop + 'px' });
            },
            HideHelpPopup: function() {
                $j('div[id$=pnlHelpPopup]').hide();
            },
            UpdatePoints: function() {//get points using ajax method and update home page points.
                var lPoints = Eduify.UI.Common.AJAXMethods.FetchTotalPoints();
                if (lPoints.error == null) {

                    var lPointsFields = $j("span[id='ctl00_lblPoints'],span[id='ctl00_cphScreenContents_main_lblPoints']")
                    if (lPointsFields.length > 0) {
                        lPointsFields.html(lPoints.value);
                    }
                    //$j("span[id='ctl00_cphScreenContents_main_lblPoints']")[0].innerHTML = lPoints.value;
                }
            },
            startAsyncTimer: function(pTimerId) {
                var lTimer = $find($j("*[id$=" + pTimerId + "]").attr("id"));
                lTimer.set_enabled(true);
                lTimer._startTimer();
            },
            stopAsyncTimer: function(pTimerId) {
                var lTimer = $find($j("*[id$=" + pTimerId + "]").attr("id"));
                lTimer.set_enabled(false);
                lTimer._stopTimer();
            },
            defaultErrorReady: function() {
                var lIsInIFrame = (window.location != window.parent.location) ? true : false;
                if (lIsInIFrame) {
                    $j('#cFooterWrapper').addClass('DN');
                }
            },
            pointsTooltip: function(pId) {
                var lElem = $j("#" + pId);
                if (lElem.length > 0) {
                    var lToolTip = $j("#PointsTip");
                    var lLeft = lElem.position().left - (lToolTip.width() / 2) + (lElem.width() / 2);
                    lElem.tooltip({
                        delay: 0,
                        left: lLeft,
                        top: 18,
                        pos: 'fix',
                        bodyId: 'PointsTip'
                    });
                }
            },
            ClearABoxPaperName: function() {
                if (typeof Eduify.ABox != "undefined") {
                    Eduify.ABox.ClearTxtPaperName();
                }
            },
            BounceEmailMouseOver: function(pObj) {
                $j('> a', pObj).removeClass('VSH');
                $j('> span', pObj).removeClass("FAN1442").addClass("FAB1442");
            },
            BounceEmailMouseOut: function(pObj) {
                $j('> a', pObj).addClass('VSH');
                $j('> span', pObj).removeClass("FAB1442").addClass("FAN1442");
            }
        };
    } ();
}
if(_IsRegisterAjaxPro){
    Object.extend(Array.prototype, {push: [].push}, false);
}
if(typeof Sys != "undefined" && Sys.Browser.agent == Sys.Browser.InternetExplorer) {
    Sys.UI.DomElement.getLocation = function(element) {
        if (element.self || element.nodeType === 9) return new Sys.UI.Point(0,0);
        var clientRect = element.getBoundingClientRect();
        if (!clientRect) {
            return new Sys.UI.Point(0,0);
        }

        try {
            var ownerDocument = element.document.documentElement;
            var offsetX = clientRect.left - 2 + ownerDocument.scrollLeft,
                offsetY = clientRect.top - 2 + ownerDocument.scrollTop;
        
            var f = element.ownerDocument.parentWindow.frameElement || null;
            if (f) {
                var offset = 2 - (f.frameBorder || 1) * 2;
                offsetX += offset;
                offsetY += offset;
            }
         
            return new Sys.UI.Point(offsetX, offsetY);
        }
        catch(ex) {
        }    
    }
}


//Client Side Alert for Eduify Application
var EdButtons = {
    OkOnly : 0,
    OkCancel : 1,
    YesNo : 2,
    YesNoCancel : 3
};

var EdTitle = {
    error : 0,
    information : 1
};

Eduify.Alert = function(pTitle, pMsg, pButtons, pOkYesCallBack, pCancelNoCallBack, pCrossClickCallBack) {

    var lDialogDiv = $j("#alert")[0];
    var lButtonsArray = new Array();
    var lMainButtonsContainer = null;
    if (typeof lDialogDiv == "undefined") {
        lDialogDiv = $j("<div id=\"alert\"></div>")[0];
        document.body.appendChild(lDialogDiv);
    }

    lDialogDiv.className = "roundedBox W400 POAi ZI2000 DN";
    lDialogDiv.Header = CreateHeader(pCrossClickCallBack);
    lDialogDiv.BodyCont = CreateBody(pTitle, pMsg, pButtons);
    //lDialogDiv.BodyCont.appendChild($j("<div class=\"CB\"></div>")[0]);
    lDialogDiv.Footer = CreateFooter();
    lDialogDiv.appendChild(lDialogDiv.Header);
    lDialogDiv.appendChild(lDialogDiv.BodyCont);
    lDialogDiv.appendChild(lDialogDiv.Footer);

    lDialogDiv.closeIcon = $j("<div class=\"icon-close\"></div>")[0];
    lDialogDiv.appendChild(lDialogDiv.closeIcon);

    $j(lDialogDiv.closeIcon).click(function() {
        Eduify.HideAlert();
        if (typeof pCrossClickCallBack == "function") {
            pCrossClickCallBack.call();
        }
    });


    AttachEvents(pOkYesCallBack, pCancelNoCallBack);
    MakeModal();
    $j(lDialogDiv).removeClass("DN");
    AlignAlert();

    function CreateHeader() {
        var lHeader = $j("<div class=\"pnlTop\"></div>")[0];
        var lLeftC = $j("<div class=\"pnlTopLeft\"></div>")[0];
        var lRightC = $j("<div class=\"pnlTopRight\"></div>")[0];
        var lMiddleC = $j("<div class=\"pnlTopMiddle\"></div>")[0];
        lHeader.appendChild(lLeftC);
        lHeader.appendChild(lRightC);
        lHeader.appendChild(lMiddleC);
        return lHeader;
    }

    function CreateBody(pTitle, pMsg, pButtons) {
        var lBody = $j("<div class=\"pnlMiddle\"></div>")[0];
        var lBodyLeftCont = $j("<div class=\"pnlMiddleLeft\"></div>")[0];
        var lBodyRightCont = $j("<div class=\"pnlMiddleRight\"></div>")[0];
        var lBodyMiddleCont = $j("<div class=\"pnlMiddleMiddle\"></div>")[0];
        var lTitle = pTitle;
        switch (pTitle) {
            case EdTitle.error:
                lTitle = "error ::";
                break;
            case EdTitle.information:
                lTitle = "information ::";
                break;
        }

        lBody.appendChild(lBodyLeftCont);
        lBody.appendChild(lBodyRightCont);

        lBodyMiddleCont.appendChild($j("<div class=\"DB FAB2400 CO119 PL20 BB3130\">" + lTitle + "</div>")[0]);
        lBodyMiddleCont.appendChild($j("<div class=\"FAB1400 MT20 CO119 PL20 PR10\">" + pMsg + "</div>")[0]);
        AddButtons(pButtons, lBodyMiddleCont);
        lBody.appendChild(lBodyMiddleCont);
        return lBody;
    }

    function CreateFooter() {
        return $j("<div class=\"pnlBottom\"><div class=\"pnlBottomLeft\"></div><div class=\"pnlBottomRight\"></div><div class=\"pnlBottomMiddle\"></div>")[0];
    }


    function AddButtons(pButtons, pContainer) {
        var lButtonsContainer = $j("<div class=\"MT20 PL10 PR10 TC\"></div>")[0];
        switch (pButtons) {
            case EdButtons.OkCancel:
                lButtonsContainer.appendChild(CreateButton("Cancel", "small-x", "grey", "W100"));
                lButtonsContainer.appendChild(CreateButton("Ok", "small-x", "blue", "W100"));
                break;
            case EdButtons.YesNo:
                lButtonsContainer.appendChild(CreateButton("No", "small-x", "grey", "W100"));
                lButtonsContainer.appendChild(CreateButton("Yes", "small-x", "blue", "W100"));
                break;
            case EdButtons.YesNoCancel:
                lButtonsContainer.appendChild(CreateButton("No", "small-x", "grey", "W100"));
                lButtonsContainer.appendChild(CreateButton("Yes", "small-x", "blue", "W100"));
                lButtonsContainer.appendChild(CreateButton("Cancel", "small-x", "grey", "W100"));
                break;
            case EdButtons.OkOnly: default:
                lButtonsContainer.appendChild(CreateButton("Ok", "small-x", "blue", "W100"));
                break;
        }
        lMainButtonsContainer = lButtonsContainer;
        pContainer.appendChild(lButtonsContainer);
    }

    function CreateButton(pText, pButtonSize, pButtonColor, pButtonWidth) {
        var lContainer = $j("<div class=\"button " + pButtonSize + " " + pButtonColor + " " + pButtonWidth + " ML5 MR5 MT10\"  onmouseover=\"Eduify.Utils.btnMouseHover(this,'orange','" + pButtonColor + "');\" onmouseout=\"Eduify.Utils.btnMouseHover(this,'" + pButtonColor + "','orange');\" ></div>")[0];
        var lButtonLeft = $j("<div class=\"left\"></div>")[0];
        var lButtonRight = $j("<div class=\"right\"></div>")[0];
        var lButton = $j("<div class=\"middle\"><input value=\"" + pText + "\" class=\"WP100\" type=\"button\"/></div>")[0];

        lContainer.appendChild(lButtonLeft);
        lContainer.appendChild(lButtonRight);
        lContainer.appendChild(lButton);
        lButtonsArray.push(lButton);
        return lContainer;
    }

    function AttachEvents(pOkYesCallBack, pCancelNoCallBack) {
        for (var lIndex = 0; lIndex < lButtonsArray.length; lIndex++) {
            if (lIndex == 0) {
                $j(lButtonsArray[lIndex]).click(function() {
                    if (typeof pCancelNoCallBack == "function") {
                        pCancelNoCallBack.call();
                    }
                    Eduify.HideAlert();
                });
            } else {
                $j(lButtonsArray[lIndex]).click(function() {
                    if (typeof pOkYesCallBack == "function") {
                        pOkYesCallBack.call();
                    }
                    Eduify.HideAlert();
                });

            }
        }
        if (lButtonsArray.length == 1) {
            $j(lButtonsArray[0]).click(function() {
                if (typeof pOkYesCallBack == "function") {
                    pOkYesCallBack.call();
                }
                Eduify.HideAlert();
            });
        }
    }

    function AlignAlert(pContainer) {

        $j(lDialogDiv).css("top", ($j(window).height() - $j(lDialogDiv).outerHeight(true)) / 2 + $j(window).scrollTop() + "px");
        $j(lDialogDiv).css("left", ($j(window).width() - $j(lDialogDiv).outerWidth(true)) / 2 + $j(window).scrollLeft() + "px");
        if (lMainButtonsContainer != null) {
            lButtonsArray[0].focus();
        }
    }
    function MakeModal() {
        var lHeight = $j(document.body).height() + $j(window).scrollTop();
        var lWidth = $j(document.body).width() + $j(window).scrollLeft();
        Eduify.Utils.GrayOutOn(0, 0, lWidth, lHeight, document, "100002");
    }
};

Eduify.HideAlert = function(){
   if($j("#alert").length > 0 )
   {
        document.body.removeChild($j("#alert").addClass("DN")[0]);
        Eduify.Utils.GrayOutOff("100002");
   }   
}

;(function($) {

   var helper = {},
		// the current tooltipped element
		current,
		// the title of the current element, used for restoring
		title,
		// timeout id for delayed tooltips
		tID,
		// IE 5.5 or 6
		IE = $.browser.msie && /MSIE\s(5\.5|6\.)/.test(navigator.userAgent),
		// flag for mouse tracking
		track = false;	
  $.etooltip = {
		blocked: false,
		defaults: {
			delay: 200,
			fade: false,
			showURL: false,
			extraClass: "",
			top: 15,
			left: 15,
			id: "tooltip",
			pos:"",
			bodyId: "",
			track:false
		},
		block: function() {
			$.etooltip.blocked = !$.etooltip.blocked;
		}
	};
	
   $.fn.extend({
       tooltip: function(settings) {
			settings = $.extend({}, $.etooltip.defaults, settings);
			createHelper(settings);
			return this.each(function() {
					$.data(this, "tooltip", settings);
					this.tOpacity = helper.parent.css("opacity");
					// copy tooltip into its own expando and remove the title
					this.tooltipText = this.title;
					$(this).removeAttr("title");
					// also remove alt attribute to prevent default tooltip in IE
					this.alt = "";
				})
				.mouseenter(save)
				.mouseleave(hide);
		}
   });
   
   
   function save(pEvent) {

		// if this is the current source, or it has no title (occurs with click event), stop
		if ( $.etooltip.blocked || this == current || (!this.tooltipText && !settings(this).bodyHandler && !settings(this).bodyId) )
			return;

		// save current
		current = this;
		title = this.tooltipText;
        helper.parent.hide();		
        
		if ( settings(this).bodyHandler ) {
			var bodyContent = settings(this).bodyHandler.call(this);
			if (bodyContent.nodeType || bodyContent.jquery) {
				helper.parent.empty().append(bodyContent)
				helper.body = bodyContent;
			} else {
				helper.parent.html( bodyContent );
			}
			
		}else if( settings(this).bodyId != '' ){
		    var bodyContent = $("#"+settings(this).bodyId).removeClass("DN");
			if (bodyContent.nodeType || bodyContent.jquery) {
				helper.parent.empty().append(bodyContent)
				helper.body = bodyContent;
			} else {
				helper.parent.html( bodyContent );
			}
		}else{
		    if(title != ''){
		        helper.parent.text(title);
			}
		}
		helper.parent.show();
		// if selected, update the helper position when the mouse moves
		track = !!settings(this).track;
		if(track){
		    $(document.body).bind('mousemove', update)
		}
		
		update(pEvent);
	}
   function hide(){
       helper.parent.hide();
       if(current != null && settings(current).bodyId != ''){
            if(helper.body != 'undefined' && helper.body != null){
                helper.body.addClass("DN").appendTo(document.body);
            }else{
                $(":first-child",helper.parent).addClass("DN").appendTo(document.body);
            }
       }
	   current = null;
   }
   function settings(element) {
		return $.data(element, "tooltip");
	}
   function createHelper(settings) {
		// there can be only one tooltip helper
		if( helper.parent )
			return;
		// create the helper, h3 for title, div for url
		document.body.appendChild($('<div id="' + settings.id + '"></div>')[0]);
			// add to document
			//.appendTo(document.body)
			// hide it at first
			//.hide();
        helper.parent = $("#"+settings.id).hide();
		// apply bgiframe if available
		if ( $.fn.bgiframe )
			helper.parent.bgiframe();
		
		// save references to title and url elements
//		helper.title = $('h3', helper.parent);
//		helper.body = $('div.body', helper.parent);
//		helper.url = $('div.url', helper.parent);
	}
	function update(event){
	    if($.etooltip.blocked)
			return;
		
		if (event && event.target.tagName == "OPTION") {
			return;
		}

		// stop updating when tracking is disabled and the tooltip is visible
		if ( !track && helper.parent.is(":visible")) {
			$(document.body).unbind('mousemove', update)
		}
		
		// if no current element is available, remove this listener
		if( current == null ) {
			$(document.body).unbind('mousemove', update);
			return;	
		}
		
		// remove position helper classes
		helper.parent.removeClass("viewport-right").removeClass("viewport-bottom");
		
	    var left = helper.parent[0].offsetLeft;
		var top = helper.parent[0].offsetTop;
		if (event) {
			currSet = settings(current);
			// position the helper 15 pixel to bottom right, starting from mouse position
			left = event.pageX + settings(current).left;
			top = event.pageY + settings(current).top;
			var right='auto';
			if (currSet.positionLeft) {
				right = $(window).width() - left;
				left = 'auto';
			}
			if(currSet.pos == "fix"){
				left = currSet.left; 
				top = currSet.top;
			}
			helper.parent.css({
				left: left+'px',
				right: right,
				top: top+'px'
			});
		}
		
		var v = viewport(),
			h = helper.parent[0];
		// check horizontal position
		if (v.x + v.cx < h.offsetLeft + h.offsetWidth) {
			left -= h.offsetWidth + 20 + settings(current).left;
			helper.parent.css({left: left + 'px'}).addClass("viewport-right");
		}
		// check vertical position
		if (v.y + v.cy < h.offsetTop + h.offsetHeight) {
			top -= h.offsetHeight + 20 + settings(current).top;
			helper.parent.css({top: top + 'px'}).addClass("viewport-bottom");
		}
	}
	function viewport() {
		return {
			x: $(window).scrollLeft(),
			y: $(window).scrollTop(),
			cx: $(window).width(),
			cy: $(window).height()
		};
	}
   
})(jQuery);

