var buttonStatus = "hidden";
var element;
var elementLayerItem;

function hideButton(){

  if(element){
    if(buttonStatus == 'hidden'){

      element.style.display = 'none';
    }
    else{
      element.style.display = 'block';
    }
  }
}

function hideAppendButton(){

  if(element){
    if(buttonStatus == 'hidden'){
      element.style.display = 'none';
      wToggleLayerElementsToAppend(elementLayerItem);
    }
    else{
      element.style.display = 'block';
    }
  }
}

function wEditPageBe(path, sourcePath, target, redirectEndEdit, referrer){




  var url = '/weblication/grid/scripts/wFilemanager.php?action=startedit&target=be&path=' + path + '&referrer=' + referrer + '&redirectEndEdit=' + redirectEndEdit;
  var target = '_blank';

  try{
    if(top.frames['wInnerMain']){
      top.frames['wInnerMain'].showPage(url, path, 'icons/button_edit.gif');
      return;
    }  
  } 
  catch(e){
  }  

  if(target == '_blank'){
    var winHeight = screen.availHeight - 64;
    var winWidth  = screen.availWidth  - 36;
    if(typeof wOpenWindowX == 'function'){ 
      wOpenWindowX(url, path, 'width=' + winWidth + ',height=' + winHeight + ',resizable=yes');
    }

    else if(typeof wOpenWindow == 'function'){
      wOpenWindow(url, path, winWidth, winHeight, 'resizable=yes');
    }
  }
  else{
    location.href = url;
  }
}

function wEditNavigationBe(path, sourcePath, target, redirectEndEdit, referrer){




  var url = '/weblication/grid/scripts/wFilemanager.php?action=startedit&target=be&path=' + path + '&referrer=' + referrer + '&redirectEndEdit=' + redirectEndEdit;

  var winHeight = 640;
  var winWidth  = 720;
  
  wOpenWindowX(url, path, 'width=' + winWidth + ',height=' + winHeight + ',resizable=yes');

}

function wInsertURLNavigationBe(path, referrer, redirectEndEdit){




  var url = '/weblication/grid/scripts/wFilemanager.php?action=startedit&target=be&path=' + path + '&referrer=' + referrer + '&redirectEndEdit=' + redirectEndEdit + '&linkUrl=' + encodeURIComponent(referrer);
  var winHeight = 640;
  var winWidth  = 720;
  wOpenWindowX(url, path, 'width=' + winWidth + ',height=' + winHeight + ',resizable=yes');

}

function wLogoutSystemBe(redirectURL){

  if(!redirectURL){
    redirectURL = location.href;
  }

  var url = '/weblication/grid/scripts/wSystem.php?action=logout&redirect=' + redirectURL;
  location.href = url;
}

function wLoginSystemBe(){




  var url = '/weblication/grid/scripts/wSystem.php';
  wOpenWindowX(url, 'wGridBackend', 'resizable=yes');
}

function wCreatePageBe(destDir, destName, template){




  var url = '/weblication/grid/scripts/wFilecreator.php?action=showmaskcreatedocument&destDir=' + destDir + '&destName=' + destName + '&template=' + template;
  url = url.replace(/amp;/g, '');
  var winHeight = 440;
  var winWidth  = 644;
  wOpenWindowX(url, '', 'width=' + winWidth + ',height=' + winHeight + ',resizable=no');
}

function wShowAdmin(weblicPath){

  var url = weblicPath + '/wScripts/index.php?script=admin';
  url = url.replace(/amp;/g, '');
  var winHeight = 640;
  var winWidth  = 800;
  wOpenWindowX(url, '', 'width=' + winWidth + ',height=' + winHeight + ',resizable=no');
}

function wShowVersionsPageBe(path, sourcePath, target, redirectEndEdit, referrer){

  var url = '/weblication/grid/scripts/wFilemanager.php?action=showversions&repository=&path=' + path + '&referrer=' + referrer + '&redirectEndEdit=' + redirectEndEdit;
  url = url.replace(/amp;/g, '');

  var winHeight = 420;
  var winWidth  = 720;
  wOpenWindowX(url, path, 'width=' + winWidth + ',height=' + winHeight + ',resizable=yes');
}

function wShowLayoutWizardBe(project, redirectEndEdit, referrer){

  var url = '/weblication/grid/scripts/wLayoutmanager.php?action=showlayoutwizardbe&repository=&project=' + project + '&referrer=' + referrer + '&redirectEndEdit=' + redirectEndEdit;
  url = url.replace(/amp;/g, '');

  var winHeight = 470;
  var winWidth  = 460;
  wOpenWindowX(url, '', 'width=' + winWidth + ',height=' + winHeight + ',resizable=yes');
}


function wShowLayoutManagerBe(project, redirectEndEdit, referrer){

  var url = '/weblication/grid/scripts/wProjectmanager.php?action=showmasklayouts&project=' + project;

  url = url.replace(/amp;/g, '');

  var winHeight = 441;
  var winWidth  = 643;
  wOpenWindowX(url, '', 'width=' + winWidth + ',height=' + winHeight + ',resizable=yes');
}

function refreshSession(){

  if(typeof wGetUrlAjax == 'function'){
    wGetUrlAjax('/weblication/grid/scripts/wSystem.php?action=refreshSession', refreshSessionResponse);
  }
  else{
    getUrl('/weblication/grid/scripts/wSystem.php?action=refreshSession', refreshSessionResponse);
  }  
}

function refreshSessionResponse(responseStr){
}

function wExecWorkflowBe(id, url, options){
  if(id == 'approve'){
    location.href = url;
  }
  else if(id == 'reject'){
    wOpenWindow(url, 'rejectWorkflow', '600', '600');
  }
  else if(id == 'versions'){
    wOpenWindow(url, 'versions', '900', '600');
  }
  else if(id == 'showStatus'){
    wOpenWindow(url, 'status', '900', '600', 'resizable=yes,scrollbars=yes,status=yes');
  }
  else if(id == 'showWorkflowFile'){
    location.href = url;
  }
  else {
    location.href = url;
  }
  
}




