﻿// JScript File

         
    function popUpSmall(url) {
          sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=656,height=506');
          self.name = "mainWin";
         }
        function popUpMedium(url) {
          sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=850,height=690');
          self.name = "mainWin";
         }
        function RedirectSmall(startURL) {
            self.resizeTo(672, 560);
            self.location=startURL;
        }
        function RedirectMedium(startURL) {
            self.resizeTo(850, 680);
            self.location=startURL;
        }
        function RedirectLarge(startURL) {
            self.resizeTo(930, 710);
            self.location=startURL;
        }         
        
    function ToggleDisplay(ClientID)
    {
        var obj = document.getElementById(ClientID);
        
        if (obj.style.display=='block') 
        {obj.style.display='none'} 
        else 
        {obj.style.display='block'}
    }
    
    function ToggleClass(ClientID)
    {
        var obj = document.getElementById(ClientID);
        var objClassName = obj.className;
        
        if (objClassName.indexOf('Expand') > -1)
        { obj.className = objClassName.replace('Expand','Collapse'); }
        else if (objClassName.indexOf('Collapse') > -1)
        { obj.className = objClassName.replace('Collapse','Expand'); }
    }
    
    function ScrollToElement(ID)
    {
        theElement = document.getElementById(ID)
        
        var selectedPosX = 0;
        var selectedPosY = 0;
              
        while(theElement != null)
        {
            selectedPosX += theElement.offsetLeft;
            selectedPosY += theElement.offsetTop;
            theElement = theElement.offsetParent;
        }
                        		      
        window.scrollTo(selectedPosX,selectedPosY);
    }

    var gControlToUpdateWithReturnValue;
    var gbtnRefresh;
    var gCurrentPopUpWindow;
    
    //This is an IE only modal which will allow the user to navigate via a find content user control. The modal will
    // return the id of the content selected. -1 is returned if no selection is made.
    function CEModalPop(ModalControlType, ControlToUpdateWithReturnValue, btnRefresh)
    {
        var height;
        var width;
        //this case statement is a bit awkward because it would have been a lot of work to go back
        //through all the modals to support a cleaner pass of the ModalControlType. Original code
        //assumed one char and then appended to a URL below. So, if we need to pass "10", just
        //do another switch inside "1" and test the second char.
        switch (ModalControlType.substring(0,1))
        {
            case "1":   
                switch (ModalControlType.substring(1,2))
                {
                    case "0": //InteractiveDecisionTree Content (ID=10)
                        height="800";
                        width="800";
                        break;
                    default: //Document (ID=1)
                        height="575";
                        width="800";
                        break;
                }
                break;
            case "2":   //Notice
                height="575";
                width="800";
                break;
            case "3":   //LinkList
                height="575";
                width="800";
                break;
            case "4":   //CalendarEvent
                height="750";
                width="900";
                break;
            case "5":   //Location
                height="575";
                width="800";
                break;
            case "6":   //Instructor
                height="575";
                width="800";
                break;
            case "7":   //CBTQuiz
                height="800";
                width="1200";
                break;
            case "8":   //Notification
                height="425";
                width="800";
                break;
            case "9":   //InteractiveDecisionTree Question
                height="800";
                width="800";
                break;
            default:
                height="800";
                width="800";
        }
        
        var centerHeight = (window.screen.height - height) / 2;
        var centerWidth = (window.screen.width - width) / 2;
        
        if (gCurrentPopUpWindow != null) { gCurrentPopUpWindow.close(); }

        gControlToUpdateWithReturnValue=ControlToUpdateWithReturnValue;
        gbtnRefresh=btnRefresh;

        gCurrentPopUpWindow = window.open('./ContentEditor_Modal.aspx?ModalControl=' + ModalControlType, null, 'height=' + height + 'px,width=' + width + 'px,left=' + centerWidth + ',top=' + centerHeight + ',scrollbars=yes');
    }
    
    function CEModalReturn(retVal)
    {
        if (retVal != -1) { document.getElementById(gControlToUpdateWithReturnValue).value = retVal; }
        if (gbtnRefresh != '') { document.getElementById(gbtnRefresh).click(); }
    }
