﻿function setFullScreenTitle() {
  var fullScreenText = textFullScreen;
  
  if (!((typeof(window.opener) == "undefined") || (window.opener == null))) {
    fullScreenText = textNormalScreen;
  }
  
  document.getElementById("lnkFullScreen").innerText = fullScreenText;
  
}

function fullScreenOrClose() {
      if ((typeof(window.opener) == "undefined") || (window.opener == null)) {
        w = openFullscreen(window.location.href);
        //w.ChangeFullScreenName("Normal Screen");
      }
      else {
        top.close();
      }
}
  
function openFullscreen(page) {
  var yes = 1;
  var no = 0;
  var menubar = no; // The File, Edit, View Menus
  var scrollbars = no; // Horizontal and vertical scrollbars
  var locationbar = no; // The location box with the site URL
  var directories = no; // the "What's New", "What Cool" links
  var resizable = no; // Can the window be resized?
  var statusbar = no; // Status bar (with "Document: Done")
  var toolbar = no; // Back, Forward, Home, Stop toolbar
  if (navigator.appName == "Microsoft Internet Explorer"){ // better be ie6 at least
    windowprops = "width=" + (screen.width-10) + ",height=" + (screen.height-30) + ",top=0,left=0,fullscreen=1";
  }
  else { // i.e. if Firefox
    windowprops = "width=" + (screen.width-5) + ",height=" + (screen.height-30) + ",top=0,left=0";
  }
  
  windowprops += (menubar ? ",menubars" : "") +
  (scrollbars ? ",scrollbars" : "") +
  (locationbar ? ",location" : "") +
  (directories ? ",directories" : "") +
  (resizable ? ",resizable" : "") +
  (statusbar ? ",status" : "") +
  (toolbar ? ",toolbar" : "");
   w = window.open(page, 'fullPopup', windowprops);
   return w;
}


var dgMinimized = false;
var dgX = -1;
var dgY = -1;
var dgWidth = 0;
var dgHeight = 0;
var dgDockedEast = false;
var dgDockedSouth = false;
var dgCollapsed = false;

var resizeTimeout = 0;
var resizeTimerId = 0;

function DockCPSouth()
{
    dgDockedSouth = true;

    if (layout != null)
    {
        var south = Ext.getCmp("southRegion");
        var center = Ext.getCmp("centerRegion");
        var divFullHeight = document.getElementById("divFullHeight");
        south.show();
        if (dgCollapsed)
            south.collapse();
        center.setHeight(divFullHeight.offsetHeight + divFullHeight.scrollTop - south.height);
        center.show();
    }
    else
    {
        document.getElementById("centerpanel").style.width = "896px";
        document.getElementById("centerpanel").style.paddingLeft = "44px";
        DockLayout.init();
        
        var east = Ext.getCmp("eastRegion");
        var center = Ext.getCmp("centerRegion");
        var south = Ext.getCmp("southRegion");
        
        center.setWidth(document.body.offsetWidth);
        east.hide();
        if (dgCollapsed)
            south.collapse();
        
    }
    
    var southAccordion = document.getElementById("tdAccordionSouth");
    var southNotepad = document.getElementById("tdNotepadSouth");
    var southHeader = document.getElementById("divSouthRegionHeader");
    
    var accordion = document.getElementById("cpCenter");
    var notepad = document.getElementById("cpEast");
    var search = document.getElementById("search");
    
    southAccordion.appendChild(accordion);
    if (typeof(hideNotepad) != "undefined")
    {
      if (!hideNotepad)
        southNotepad.appendChild(notepad);
    }
    else
      southNotepad.appendChild(notepad);
    southHeader.appendChild(search);
    //debugger;
    searchCombo.setWidth(630);
    document.getElementById("divNotepadHeader").style.display = "block";
    
    dialog.hide();
    
    if (dgCollapsed)
        Rijden.Webservices.SaveNota.SaveNotepadPosition(dgX, dgY, dialog.width, dialog.height, false, false, true, true);
    else
        Rijden.Webservices.SaveNota.SaveNotepadPosition(dgX, dgY, dialog.width, dialog.height, false, false, true, false);
    
}
function UndockSouth()
{
    dgDockedSouth = false;
   
     Ext.getCmp("southRegion").hide(); //south
     
    var southAccordion = document.getElementById("cpCenter");
    var southNotepad = document.getElementById("cpEast");
    var dialogHeader = document.getElementById("tdDialogHeader");
    
    var accordion = document.getElementById("center");
    var notepad = document.getElementById("east");
    var search = document.getElementById("search");
    
    accordion.appendChild(southAccordion);
    notepad.appendChild(southNotepad);
    dialogHeader.appendChild(search);
    
    var divFullHeight = document.getElementById("divFullHeight");
    Ext.getCmp("centerRegion").setHeight(divFullHeight.offsetHeight + divFullHeight.scrollTop);
    searchCombo.setWidth(dialog.width - 80);
    
    dialog.show();
    
    Rijden.Webservices.SaveNota.SaveNotepadPosition(dgX, dgY, dialog.width, dialog.height, false, false, false, false);
}

function DockCPEast()
{
    dgDockedEast = true;
   
    
    if (layout != null)
    {
        var east = Ext.getCmp("eastRegion");
        var center = Ext.getCmp("centerRegion");
        var divFullHeight = document.getElementById("divFullHeight");
        east.setHeight(divFullHeight.offsetHeight + divFullHeight.scrollTop);
        east.show();
        if (dgCollapsed)
            east.collapse();
        center.setHeight(divFullHeight.offsetHeight + divFullHeight.scrollTop);
        center.setWidth(document.body.offsetWidth - east.width - 5);
        center.show();
    }
    else
    {
        document.getElementById("centerpanel").style.width = "896px";
        document.getElementById("centerpanel").style.paddingLeft = "44px";
        DockLayout.init();
        
        var east = Ext.getCmp("eastRegion");
        var south = Ext.getCmp("southRegion");
        var divFullHeight = document.getElementById("divFullHeight");
        south.hide();
         if (dgCollapsed)
            east.collapse();
        var center = Ext.getCmp("centerRegion");
        center.setHeight(divFullHeight.offsetHeight + divFullHeight.scrollTop);
        east.setHeight(divFullHeight.offsetHeight + divFullHeight.scrollTop);
    }
    
    var eastAccordion = document.getElementById("tdAccordionEast");
    var eastNotepad = document.getElementById("tdNotepadEast");
    var eastHeader = document.getElementById("divEastRegionHeader");
    
    var accordion = document.getElementById("cpCenter");
    var notepad = document.getElementById("cpEast");
    var search = document.getElementById("search");
    
    eastAccordion.appendChild(accordion);
    if (typeof(hideNotepad) != "undefined")
    {
      if (!hideNotepad)
        eastNotepad.appendChild(notepad);
    }
    else
      eastNotepad.appendChild(notepad);
    eastHeader.appendChild(search);
    
    searchCombo.setWidth(250);
    document.getElementById("divEastNotepadHeader").style.display = "block";
    
    dialog.hide();
    
    if (dgCollapsed)
        Rijden.Webservices.SaveNota.SaveNotepadPosition(dgX, dgY, dialog.width, dialog.height, false, true, false, true);
    else
        Rijden.Webservices.SaveNota.SaveNotepadPosition(dgX, dgY, dialog.width, dialog.height, false, true, false, false);
}
function UndockEast()
{
    //debugger;
    dgDockedEast = false;
    
    Ext.getCmp("eastRegion").hide();
    
    var CPBody = document.getElementById("divDialogBody");
    var eastAccordion = document.getElementById("cpCenter");
    var eastNotepad = document.getElementById("cpEast");
    var dialogHeader = document.getElementById("tdDialogHeader");
    
    var accordion = document.getElementById("center");
    var notepad = document.getElementById("east");
    var search = document.getElementById("search");
    
    accordion.appendChild(eastAccordion);
    notepad.appendChild(eastNotepad);
    dialogHeader.appendChild(search);
    
    Ext.getCmp("centerRegion").setWidth(document.body.offsetWidth);
    
    dialog.show();
    searchCombo.setWidth(dialog.width - 80);
    
    Rijden.Webservices.SaveNota.SaveNotepadPosition(dgX, dgY, dialog.width, dialog.height, false, false, false, false);
}
function CollapseRegionEast()
{
    Rijden.Webservices.SaveNota.SaveNotepadPosition(dgX, dgY, dialog.width, dialog.height, false, true, false, true);
}
function CollapseRegionSouth()
{
    Rijden.Webservices.SaveNota.SaveNotepadPosition(dgX, dgY, dialog.width, dialog.height, false, false, true, true);
}
function ExpandRegionEast()
{
    Rijden.Webservices.SaveNota.SaveNotepadPosition(dgX, dgY, dialog.width, dialog.height, false, true, false, false);
}
function ExpandRegionSouth()
{
    Rijden.Webservices.SaveNota.SaveNotepadPosition(dgX, dgY, dialog.width, dialog.height, false, false, true, false);
}

function ResizeRegionSouth(region, newWidth, newHeight)
{
    if (newHeight != null)
    {
      document.getElementById("tdAccordionSouth").style.height = newHeight - 33 + "px";
      document.getElementById("tdNotepadSouth").style.height = newHeight - 33 + "px";
    }
}

function ChangeOpacity(elm)
{
//  if (navigator.userAgent.indexOf("MSIE") >= 0)
//    elm.style.filter = "alpha(opacity=100)";
//  else
//  {
//    elm.style.opacity = "1";
//    elm.focus();
//  }
  elm.value = "";
}
function RestoreOpacity(elm)
{
//  if (navigator.userAgent.indexOf("MSIE") >= 0)
//    elm.style.filter = "alpha(opacity=50)";
//  else
//    elm.style.opacity = ".50";
  elm.value = searchText;
}

function blockEnter(e)
{
    if (!e) var e = window.event;
    if (e.keyCode == 13)
    {
      return false;
    }    
}


