var objTabMain = null;

//-----------------------------------------------------------------------------------------------------------
// TAB
//-----------------------------------------------------------------------------------------------------------
function CreateTab(webRoot)
{
  try {
    // Content tab
    var objTab = new pinTab(document.getElementById("tabContent"));

    objTab.design = tabStyle;
    objTab.ImageUrl = webRoot + "components/tab/design/image/style" + objTab.design;

    //  var item = objTab.createItem("TabSeparator");
    //  item.width = "3px"; 
    //  objTab.add(item);

    var item = objTab.createItem();
    item.text = getString(800);
    item.title = getString(801);
    item.tag = "CONTENT";
    item.active = true;
    objTab.add(item);

    //  var item = objTab.createItem();
    //  item.text = "Templates"; 
    //  item.title = "Templates";
    //  item.tag = "TEMPLATES";
    //  item.active = false;
    //  objTab.add(item);

    var item = objTab.createItem();
    item.text = getString(802);
    item.title = getString(803);
    item.tag = "SEARCH";
    objTab.add(item);

    objTab.create();
  } catch (e) {
  }  
}

//-----------------------------------------------------------------------------------------------------------
// RIBBON
//-----------------------------------------------------------------------------------------------------------
function CreateRibbon(webRoot, mode)
{
  // 
  objTabMain = new pinTab(document.getElementById("tabMain"));
  
  objTabMain.design      = "10";
	objTabMain.ImageUrl = webRoot + "components/tab/design/image/style" + objTabMain.design;
	
/*
  var item = objTab.createItem("TabSeparator");
  item.width = "3px"; 
  objTab.add(item);
*/	

  var item = objTabMain.createItem();
  item.text = getString(900); 
  item.title = getString(901);
  item.tag = "STANDARD";
  item.active = true;
  objTabMain.add(item);

	if(mode == 1) {
    var item = objTabMain.createItem();
    item.text = getString(902); 
    item.title = getString(903);
    item.tag = "TOC";
    objTabMain.add(item);

    var item = objTabMain.createItem();
    item.text = getString(904); 
    item.title = getString(905);
    item.tag = "EDITOR";
    objTabMain.add(item);

    if(ext3) {
      var item = objTabMain.createItem();
      item.text = "Word Processor"; 
      item.title = "Word Processor";
      item.tag = "WP1";
      item.visible = false;
      objTabMain.add(item);

      var item = objTabMain.createItem();
      item.text = "Spread Sheet"; 
      item.title = "Spread Sheet";
      item.tag = "SS1";
      item.visible = false;
      objTabMain.add(item);
    }

// ###CW###
    if(ext1) {
      var item = objTabMain.createItem();
      item.text = "Corporate Wording"; 
      item.title = "Corporate Wording";
      item.tag = "CW";
      objTabMain.add(item);
    }
    
    if(ext2) {
      var item = objTabMain.createItem();
      item.text = "Check"; 
      item.title = "Check";
      item.tag = "CHECK";
      objTabMain.add(item);
    }    

  }
  
	objTabMain.create();
	
	// create section area 1
  var section = new pinSection(document.getElementById("tab1_section1")); 
	section.imageUrl = webRoot + "components/ribbon/section/";
	section.text = getString(906);
	section.create();
  section.area.innerHTML = "<iframe unselectable='on' allowtransparency='true' style='width:100%;height:56px' id='tab1toolbar1' src='" + webRoot + "components/toolbar/pinToolbar.html' frameborder=0></iframe>";
}

// this function is called when an item is clicked
function tabEventTabClick(item,tabId)
{
  activateTab(item);
}

function activateTab(item)
{
  if(item.tag == "STANDARD") {
    document.getElementById("ribbon_tab1_area").style.display = "block"; 
    document.getElementById("ribbon_tab2_area").style.display = "none"; 
    document.getElementById("ribbon_tab3_area").style.display = "none"; 
// ###CW###
    if(ext1)
      document.getElementById("ribbon_tab4_area").style.display = "none"; 
    if(ext2)
      document.getElementById("ribbon_tab5_area").style.display = "none"; 
// ###REMOTE###
    if(ext3) {
      document.getElementById("ribbon_tab6_area").style.display = "none"; 
      document.getElementById("ribbon_tab7_area").style.display = "none"; 
    }
  }
  if(item.tag == "TOC") {
    document.getElementById("ribbon_tab1_area").style.display = "none"; 
    document.getElementById("ribbon_tab2_area").style.display = "block"; 
    document.getElementById("ribbon_tab3_area").style.display = "none"; 
// ###CW###
    if(ext1)
      document.getElementById("ribbon_tab4_area").style.display = "none"; 
    if(ext2)
      document.getElementById("ribbon_tab5_area").style.display = "none"; 
    if(ext3){
      document.getElementById("ribbon_tab6_area").style.display = "none"; 
      document.getElementById("ribbon_tab7_area").style.display = "none"; 
    }
    if(firstTOC) {
      firstTOC = false;
	    // create section area 2
      var section = new pinSection(document.getElementById("tab2_section1")); 
	    section.imageUrl = webRoot + "components/ribbon/section/";
	    section.text = getString(907);
	    section.create();
	    section.area.innerHTML = "<iframe  unselectable='on' allowtransparency='true' style='width:100%;height:56px' id='tab2toolbar1' src='" + webRoot + "components/toolbar/pinToolbar.html' frameborder=0></iframe>";
    }
  }
  if(item.tag == "EDITOR") {
    document.getElementById("ribbon_tab1_area").style.display = "none"; 
    document.getElementById("ribbon_tab2_area").style.display = "none"; 
    document.getElementById("ribbon_tab3_area").style.display = "block"; 
// ###CW###
    if(ext1)
      document.getElementById("ribbon_tab4_area").style.display = "none"; 
    if(ext2)
      document.getElementById("ribbon_tab5_area").style.display = "none"; 
    if(ext3){
      document.getElementById("ribbon_tab6_area").style.display = "none"; 
      document.getElementById("ribbon_tab7_area").style.display = "none"; 
    }
    if(firstEditor) {
      firstEditor = false;
	    // create section area 3
      var section = new pinSection(document.getElementById("tab3_section1")); 
	    section.imageUrl = webRoot + "components/ribbon/section/";
	    section.text = getString(908);
	    section.create();
	    section.area.innerHTML = "<iframe unselectable='on' allowtransparency='true' style='width:100%;height:56px' id='tab3toolbar1' src='" + webRoot + "components/toolbar/pinToolbar.html' frameborder=0></iframe>";

      section = new pinSection(document.getElementById("tab3_section2")); 
	    section.imageUrl = webRoot + "components/ribbon/section/";
	    section.text = getString(909);
	    section.create();
	    section.area.innerHTML = "<iframe unselectable='on' allowtransparency='true' style='width:100%;height:56px' id='tab3toolbar2' src='" + webRoot + "components/toolbar/pinToolbar.html' frameborder=0></iframe>";

      section = new pinSection(document.getElementById("tab3_section3")); 
	    section.imageUrl = webRoot + "components/ribbon/section/";
	    section.text = getString(910);
	    section.create();
	    section.area.innerHTML = "<iframe unselectable='on' allowtransparency='true' style='width:100%;height:56px' id='tab3toolbar3' src='" + webRoot + "components/toolbar/pinToolbar.html' frameborder=0></iframe>";

      section = new pinSection(document.getElementById("tab3_section4")); 
	    section.imageUrl = webRoot + "components/ribbon/section/";
	    section.text = getString(911);
	    section.create();
	    section.area.innerHTML = "<iframe unselectable='on' allowtransparency='true' style='width:100%;height:56px' id='tab3toolbar4' src='" + webRoot + "components/toolbar/pinToolbar.html' frameborder=0></iframe>";
	  }
  }
  
  if(ext1) {
    if(item.tag == "CW") {
      document.getElementById("ribbon_tab1_area").style.display = "none"; 
      document.getElementById("ribbon_tab2_area").style.display = "none"; 
      document.getElementById("ribbon_tab3_area").style.display = "none"; 
  // ###CW###
      if(ext1)
        document.getElementById("ribbon_tab4_area").style.display = "block"; 
      if(ext2)
        document.getElementById("ribbon_tab5_area").style.display = "none"; 
      if(ext3){
        document.getElementById("ribbon_tab6_area").style.display = "none"; 
        document.getElementById("ribbon_tab7_area").style.display = "none"; 
      }
      if(firstCW) {
        firstCW = false;
	      // create section area 2
        var section = new pinSection(document.getElementById("tab4_section1")); 
	      section.imageUrl = webRoot + "components/ribbon/section/";
	      section.text = "Corporate Wording";
	      section.create();
	      section.area.innerHTML = "<iframe  unselectable='on' allowtransparency='true' style='width:100%;height:56px' id='tab4toolbar1' src='" + webRoot + "components/toolbar/pinToolbar.html' frameborder=0></iframe>";
      }
    }
  }

  if(ext2) {
    if(item.tag == "CHECK") {
      document.getElementById("ribbon_tab1_area").style.display = "none"; 
      document.getElementById("ribbon_tab2_area").style.display = "none"; 
      document.getElementById("ribbon_tab3_area").style.display = "none"; 
  // ###CW###
      if(ext1)
        document.getElementById("ribbon_tab4_area").style.display = "none"; 
      if(ext2)
        document.getElementById("ribbon_tab5_area").style.display = "block"; 
      if(ext3){
        document.getElementById("ribbon_tab6_area").style.display = "none"; 
        document.getElementById("ribbon_tab7_area").style.display = "none"; 
      }
      if(firstCheck) {
        firstCheck = false;
	      // create section area 2
        var section = new pinSection(document.getElementById("tab5_section1")); 
	      section.imageUrl = webRoot + "components/ribbon/section/";
	      section.text = "Check";
	      section.create();
	      section.area.innerHTML = "<iframe  unselectable='on' allowtransparency='true' style='width:100%;height:56px' id='tab5toolbar1' src='" + webRoot + "components/toolbar/pinToolbar.html' frameborder=0></iframe>";
      }
    }
  }

  // REMOTE
  if(ext3) {
    if(item.tag == "WP1") {
      document.getElementById("ribbon_tab1_area").style.display = "none"; 
      document.getElementById("ribbon_tab2_area").style.display = "none"; 
      document.getElementById("ribbon_tab3_area").style.display = "none"; 
      if(ext1)
        document.getElementById("ribbon_tab4_area").style.display = "none"; 
      if(ext2)
        document.getElementById("ribbon_tab5_area").style.display = "none"; 
      document.getElementById("ribbon_tab6_area").style.display = "block"; 
      document.getElementById("ribbon_tab7_area").style.display = "none"; 
      if(firstRemote1) {
        firstRemote1 = false;
	      // create section area 3
        var section = new pinSection(document.getElementById("tab6_section1")); 
	      section.imageUrl = webRoot + "components/ribbon/section/";
	      section.text = getString(908);
	      section.create();
	      section.area.innerHTML = "<iframe unselectable='on' allowtransparency='true' style='width:100%;height:56px' id='tab6toolbar1' src='" + webRoot + "components/toolbar/pinToolbar.html' frameborder=0></iframe>";

        section = new pinSection(document.getElementById("tab6_section2")); 
	      section.imageUrl = webRoot + "components/ribbon/section/";
	      section.text = getString(909);
	      section.create();
	      section.area.innerHTML = "<iframe unselectable='on' allowtransparency='true' style='width:100%;height:56px' id='tab6toolbar2' src='" + webRoot + "components/toolbar/pinToolbar.html' frameborder=0></iframe>";

        section = new pinSection(document.getElementById("tab6_section3")); 
	      section.imageUrl = webRoot + "components/ribbon/section/";
	      section.text = getString(910);
	      section.create();
	      section.area.innerHTML = "<iframe unselectable='on' allowtransparency='true' style='width:100%;height:56px' id='tab6toolbar3' src='" + webRoot + "components/toolbar/pinToolbar.html' frameborder=0></iframe>";

        section = new pinSection(document.getElementById("tab6_section4")); 
	      section.imageUrl = webRoot + "components/ribbon/section/";
	      section.text = getString(911);
	      section.create();
	      section.area.innerHTML = "<iframe unselectable='on' allowtransparency='true' style='width:100%;height:56px' id='tab6toolbar4' src='" + webRoot + "components/toolbar/pinToolbar.html' frameborder=0></iframe>";
	    }
	  }
    if(item.tag == "SS1") {
      document.getElementById("ribbon_tab1_area").style.display = "none"; 
      document.getElementById("ribbon_tab2_area").style.display = "none"; 
      document.getElementById("ribbon_tab3_area").style.display = "none"; 
      if(ext1)
        document.getElementById("ribbon_tab4_area").style.display = "none"; 
      if(ext2)
        document.getElementById("ribbon_tab5_area").style.display = "none"; 
      document.getElementById("ribbon_tab6_area").style.display = "none"; 
      document.getElementById("ribbon_tab7_area").style.display = "block"; 
      if(firstRemote2) {
        firstRemote2 = false;
	      // create section area 3
        var section = new pinSection(document.getElementById("tab7_section1")); 
	      section.imageUrl = webRoot + "components/ribbon/section/";
	      section.text = getString(908);
	      section.create();
	      section.area.innerHTML = "<iframe unselectable='on' allowtransparency='true' style='width:100%;height:56px' id='tab7toolbar1' src='" + webRoot + "components/toolbar/pinToolbar.html' frameborder=0></iframe>";
	    }
	  }
  }

  if(item.tag == "CONTENT") {
    document.getElementById("tree").style.display = "block"; 
    //document.getElementById("templates").style.display = "none"; 
    document.getElementById("search").style.display = "none"; 
  }

//  if(item.tag == "TEMPLATES") {
//    document.getElementById("tree").style.display = "none"; 
//    document.getElementById("templates").style.display = "block"; 
//    document.getElementById("search").style.display = "none"; 
//  }

  if(item.tag == "SEARCH") {
    document.getElementById("search").style.width = document.getElementById("tree").offsetWidth;
    document.getElementById("search").style.height = document.getElementById("tree").offsetHeight;
    document.getElementById("tree").style.display = "none"; 
    //document.getElementById("templates").style.display = "none"; 
    document.getElementById("search").style.display = "block"; 
  }
}



