﻿
		function OwnerOn()
		{document.getElementById('Progress').style.visibility = "visible";}
		function OwnerOff()
		{document.getElementById('Progress').style.visibility = "hidden";}
		
		function on()
		{parent.document.getElementById('Progress').style.visibility = "visible";}
		function off()
		{parent.document.getElementById('Progress').style.visibility = "hidden";}
		
		
		//Toggles the "Document Data" to either Pinned or Docked State
		function toggleDocDataPanel()
		{
		    var theTableCell = document.getElementById('CellForDocDataTable');
		    var thePDFCell = document.getElementById('CellForPDFImage');
			var theMainMenuText = document.getElementById('ExpandedMenuDocTableCellText');
			var theMenuMinMax = document.getElementById('DocumentPanelMinMax');
			var theMenuMax = document.getElementById('ExpandedMenuDocTableCellPin');
			
			//var theMainMenuDocMenu = document.getElementById('DocPanelEditMenu');
			var theImage = document.getElementById('DockPanelImage');
			var theMenuRow = document.getElementById('MenuRow');
			var theBottomCell = document.getElementById('MainDocTableBottomCell');
			var theBottomCellTextDiv = document.getElementById('CollapsedTextDiv');
			var theBottomCellWebGridDiv = document.getElementById('WebGridDiv');
			var strSize = "";

			if (window.g_bPinned)
			{
				theTableCell.style.width = '24px';
				thePDFCell.style.width = '';
				
				theBottomCell.style.width = '24px';
				theBottomCell.style.backgroundImage = 'url(./images/VBlueVertRight.gif)';
				theBottomCellTextDiv.style.visibility = 'visible';
				theBottomCellWebGridDiv.style.visibility = 'hidden';
				
				theMenuRow.style.backgroundImage = 'url(./images/VBlueVertRight.gif)';
				theMenuRow.style.backgroundRepeat = 'repeat-y';
				theMenuMax.style.backgroundRepeat = 'repeat-y';
				theMainMenuText.style.display = 'none';
				//theMainMenuDocMenu.style.display = 'none';
				theMenuMinMax.innerHTML = '«';
				window.g_bPinned = false;
			}
			else
			{		
				theTableCell.style.width = '250px';
				thePDFCell.style.width = '';
				
				theBottomCell.style.width = '250px';
				theBottomCell.style.backgroundImage = '';				
				theBottomCellTextDiv.style.visibility = 'hidden';
				theBottomCellWebGridDiv.style.visibility = 'visible';
				
				theMenuRow.style.backgroundImage = 'url(./images/VBlue.gif)';
				theMenuRow.style.backgroundRepeat = 'repeat-x';
				theMenuMax.style.backgroundRepeat = 'repeat-x';				
				theMainMenuText.style.display = '';
				//theMainMenuDocMenu.style.display = '';
				theMenuMinMax.innerHTML = '»';
				window.g_bPinned = true;
			}
		}
				
		function ExpandMenu()
		{
		    parent.document.getElementById('CellForDocDataTable').style.width = '250px';
			parent.document.getElementById('CellForPDFImage').style.width = '';
				
			parent.document.getElementById('MainDocTableBottomCell').style.width = '250px';
			parent.document.getElementById('MainDocTableBottomCell').style.backgroundImage = '';				
			parent.document.getElementById('CollapsedTextDiv').style.visibility = 'hidden';
			parent.document.getElementById('WebGridDiv').style.visibility = 'visible';
				
			parent.document.getElementById('MenuRow').style.backgroundImage = 'url(./images/VBlue.gif)';
			parent.document.getElementById('MenuRow').style.backgroundRepeat = '';
			parent.document.getElementById('ExpandedMenuDocTableCellText').style.display = '';
			//parent.document.getElementById('DocPanelEditMenu').style.display = '';
			parent.document.getElementById('DocumentPanelMinMax').innerHTML = '»'
			parent.window.g_bPinned = true;
		}
		
		function CollapseMenu()
		{
		    parent.document.getElementById('CellForDocDataTable').style.width = '24px';
			parent.document.getElementById('CellForPDFImage').style.width = '';
				
			parent.document.getElementById('MainDocTableBottomCell').style.width = '24px';
			parent.document.getElementById('MainDocTableBottomCell').style.backgroundImage = 'url(./images/VBlueVertRight.gif)';
			parent.document.getElementById('CollapsedTextDiv').style.visibility = 'visible';
			parent.document.getElementById('WebGridDiv').style.visibility = 'hidden';
				
			parent.document.getElementById('MenuRow').style.backgroundImage = 'url(./images/VBlueVertRight.gif)';
			parent.document.getElementById('MenuRow').style.backgroundRepeat = 'repeat-y';
			parent.document.getElementById('ExpandedMenuDocTableCellText').style.display = 'none';
			//parent.document.getElementById('DocPanelEditMenu').style.display = 'none';
			parent.document.getElementById('DocumentPanelMinMax').innerHTML = '«'
			parent.window.g_bPinned = false;
		}
		
		var bMouseOver = false;
		function toggleMouseOver()
		{
		    if(bMouseOver)
		    {
		        parent.document.getElementById('DocumentPanelMinMax').style.color = 'dbe1ff';
		        parent.document.getElementById('DocumentPanelMinMax').style.fontWeight = '';
		        bMouseOver = false;		    
		    }
		    else
		    {
		        parent.document.getElementById('DocumentPanelMinMax').style.color = 'edf0ff';
		        parent.document.getElementById('DocumentPanelMinMax').style.fontWeight = 'bold';
		        bMouseOver = true;
		    }
		}
		
		var bFMouseOver = false;
		function toggleFMouseOver()
		{
		    if(bFMouseOver)
		    {
		        parent.document.getElementById('FunctionPanelMinMax').style.color = 'dbe1ff';
		        parent.document.getElementById('FunctionPanelMinMax').style.fontWeight = '';
		        bFMouseOver = false;		    
		    }
		    else
		    {
		        parent.document.getElementById('FunctionPanelMinMax').style.color = 'edf0ff';
		        parent.document.getElementById('FunctionPanelMinMax').style.fontWeight = 'bold';
		        bFMouseOver = true;
		    }
		}
		
		//Toggles the "Document Data" to either Pinned or Docked State
		function toggleFunction()
		{
		    var theTableCell = document.getElementById('CellForFunctions');
		    var thePDFCell = document.getElementById('CellForPDFImage');
			var theMainMenuText = document.getElementById('FunctionText');
			var theMenuMinMax = document.getElementById('FunctionPanelMinMax');
			var theMenuRow = document.getElementById('FunctionRow');
			var theBottomCell = document.getElementById('FunctionTableBottomCell');
			var theBottomCellTextDiv = document.getElementById('CollapsedFunctionText');
			var theBottomCellWebGridDiv = document.getElementById('WebListBarDiv');
			var listbar = iglbar_getListbarById("UltraWebListbar1");
			var strSize = "";

			if (!window.g_bFPinned)
			{
				theTableCell.style.width = '24px';
				thePDFCell.style.width = '';
				
				theBottomCell.style.width = '24px';
				theBottomCell.style.backgroundImage = 'url(./images/VBlueVertLeft.gif)';
				theBottomCellTextDiv.style.visibility = 'visible';
				theBottomCellWebGridDiv.style.visibility = 'hidden';
				
				theMenuRow.style.backgroundImage = 'url(./images/VBlueVertLeft.gif)';
				theMenuRow.style.backgroundRepeat = 'repeat-y';
				theMainMenuText.style.display = 'none';
				theMenuMinMax.innerHTML = '»';
				if (listbar.SelectedGroup.txt == "Login")
				    listbar.Groups[0].findControl("ListBox1").style.visibility = 'hidden';
				window.g_bFPinned = true;
			}
			else
			{		
				theTableCell.style.width = '250px';
				thePDFCell.style.width = '';
				
				theBottomCell.style.width = '250px';
				theBottomCell.style.backgroundImage = '';				
				theBottomCellTextDiv.style.visibility = 'hidden';
				theBottomCellWebGridDiv.style.visibility = 'visible';
				
				theMenuRow.style.backgroundImage = 'url(./images/VBlue.gif)';
				theMenuRow.style.backgroundRepeat = '';
				theMainMenuText.style.display = '';				
				theMenuMinMax.innerHTML = '« ';				
				if (listbar.SelectedGroup.txt == "Login")
				    listbar.Groups[0].findControl("ListBox1").style.visibility = 'visible';
				window.g_bFPinned = false;
			}
		}

		function updateGrid(oType)
		{
		    var strType = oType;
		    var localWebGrid = igtbl_getGridById("UltraWebGrid1");
		    var parentWebGrid = parent.igtbl_getGridById("UltraWebGrid1");
		    var iRowLen = parentWebGrid.Rows.length;
		    
		    //loop through and empty out old row data
		    for(var i=0; i<iRowLen; i++)
            {
                parentWebGrid.Rows.getRow(0).remove();
            }            
            
            //get the selected row they clicked on
            for(var rowID in localWebGrid.SelectedRows)
            {
                var rowSelected = igtbl_getRowById(rowID);
                if (strType == 'Browse')
                {
                    var strDocumentTypeName = rowSelected.getCell(0).getValue()
                    //loop through the columns in the localGrid
                    for (var y=0; y < localWebGrid.Bands[1].Columns.length; y++)
                    {
                        //if the column is not hidden then its good
                        if (localWebGrid.Bands[1].Columns[y].Hidden == false)
                        {
                            //make a new row in the parent (login) grid
                            var gridRow = parentWebGrid.Rows.addNew();
                            //Set the first cell to the field value ****have to strip out doctype still***
                            var strHeaderVal = localWebGrid.Bands[1].Columns[y].HeaderText;
                            var strFieldName = strHeaderVal.substring(0, (strHeaderVal.length - strDocumentTypeName.length)-1);
                            gridRow.getCell(0).setValue(strFieldName);
                            gridRow.getCell(1).setValue(rowSelected.getCell(y).getValue());                        
                        }//end if not hidden
                    }//end column loop
                }//end browse
                else //query
                {
                    //loop through the columns in the localGrid
                    for (var y=0; y < localWebGrid.Bands[0].Columns.length; y++)
                    {
                        //make a new row in the parent (login) grid
                        var gridRow = parentWebGrid.Rows.addNew();
                        //Set the first cell to the field value ****have to strip out doctype still***
                        var strHeaderVal = localWebGrid.Bands[0].Columns[y].HeaderText;
                        gridRow.getCell(0).setValue(strHeaderVal);
                        gridRow.getCell(1).setValue(rowSelected.getCell(y).getValue());                        
                    }//end column loop
                }//end query
            }//end selected row loop
		}//end function
		
		function ShowDocDataGrid()
		{
		    if (parent.window.g_strShowDocDataPanel == '1')
		    {
                if (parent.window.g_strExpandDefault == '1')
		            ExpandMenu();
		        else
		            parent.document.getElementById('CollapsedTextDiv').style.visibility = 'visible';
		        parent.document.getElementById('CellForDocDataTable').style.visibility = 'visible';
		    }	
		}
		
		function HideDocDataGrid()
		{
		    CollapseMenu();
		    parent.document.getElementById('CellForDocDataTable').style.visibility = 'hidden';
		    parent.document.getElementById('CollapsedTextDiv').style.visibility = 'hidden';	
		}

		function DocDataAppSettings(strAppExpand, strAppShow)
		{
		    parent.window.g_strExpandDefault = strAppExpand;
		    parent.window.g_strShowDocDataPanel = strAppShow;
		}

        function UseScriptsSetting(strUseScripts)
		{
		    parent.window.g_strUseScripts = strUseScripts;
		}
		
        function MakeKeySpanURL()
		{
		    window.g_KeySpanURL = "http://" + location.host + "/FortisPortal/KQLogin.aspx";
		}
		
		function MoveOn(strWhereTo)
		{
		    if (strWhereTo == "UploadDocument")
		        parent.location.href='Upload.aspx';
		    //else
		        //parent.location.href='Upload.aspx';
		}		            
		
   function UltraWebMenu1_ItemClick(menuId, itemId)
    {
        var parentMenu = igmenu_getMenuById("UltraWebMenu1");
        var documentWebGrid = igtbl_getGridById("UltraWebGrid1");
        var bAllowEdit = "NotSet";
        
        if (itemId  == "UltraWebMenu1_1_1")
        {
            bAllowEdit = true;
        //newcell2.AllowEditing = Infragistics.WebUI.UltraWebGrid.AllowEditing.Yes
            document.getElementById('ButtonSave').disabled = false;
            document.getElementById('ButtonCancel').disabled = false;
        }
        if (itemId  == "UltraWebMenu1_1_2")
        {
            bAllowEdit = false;
            document.getElementById('ButtonSave').disabled = true;
            document.getElementById('ButtonCancel').disabled = true;
        }
        //loop through the columns in the localGrid
        if (bAllowEdit != "NotSet")
        {
            for (var y=0; y < documentWebGrid.Rows.length; y++)
            {
                //get the current row
                var gridRow = documentWebGrid.Rows.getRow(y);
                //if it should be editable.. make it so
                if (bAllowEdit)
                    gridRow.getCell(1).setEditable(true);
                else
                    gridRow.getCell(1).setEditable(false);

            }//end row loop
        }
    }