//Check URL - a url can be "page.htm?number@archor_name" - By SiC/CYAN
function checkURL() {
  if (!document.getElementById("tb_content") ) return 0;
        var str=new String(unescape(window.location));
        var n=str.indexOf("?")  ==-1 ? "" : str.substring(str.indexOf("?")+1,str.length);
        var url=str.indexOf("?")==-1 ? str : str.substring(0,str.indexOf("?"));
        var nx=n.split("&");
        var tmp_str=nx[0].substring(0,4);
  if (document.getElementById("tb_content").height ) {
          document.getElementById("tb_content").height = screen.availHeight - document.getElementById("tb_navbar").clientHeight - 64;
  }
        if (tmp_str=="cell"){
          var cell=nx[0].substring(5,6);
          switchCell(cell);
        }else{
          switchCell(1);
        }
}
var smpager_header_table=new Array();
//Change Cell Content - By SiC/CYAN
//function switchCell(n, hash,withnotabcontent) {
function initswitchCell(uniqid,NbRowHeader) {
  for(var i=1;i<=NbRowHeader;i++){
    smpager_header_table[uniqid+'_'+i] = document.getElementById("divrowheader_"+i+"_"+uniqid).innerHTML ;
    //alert(smpager_header_table[i]);
  }
}

function displayRowForswitchCell(NumRow,NbRowHeader,uniqid) {
  var numCurrRows;
  var i;
  numCurrRows = 0;
  for(i=NumRow+1;i<=NbRowHeader;i++){
    //alert("P "+i);
    numCurrRows++;
    document.getElementById("divrowheader_"+numCurrRows+"_"+uniqid).innerHTML  = smpager_header_table[uniqid+'_'+i];
    document.getElementById("rowendheader_"+i+"_"+uniqid).className="tab-onlyleft";
  }


  for(i=1;i<=NumRow;i++){
    //alert("D "+i);
    numCurrRows++;
    document.getElementById("divrowheader_"+numCurrRows+"_"+uniqid).innerHTML  = smpager_header_table[uniqid+'_'+i];
    document.getElementById("rowendheader_"+i+"_"+uniqid).className="tab-onlyleft";

  }
  document.getElementById("rowendheader_"+NumRow+"_"+uniqid).className="tab-none";
}
function switchCell(n, rowNum,NbRowHeader,uniqid,iframeurl,forceReload) {
  displayRowForswitchCell(rowNum,NbRowHeader,uniqid);
  if (!rowNum){
    rowNum=1;
  }
  if (!NbRowHeader){
    NbRowHeader=1;
  }
  for (var CombienYaDeCellule=1;CombienYaDeCellule<=100;CombienYaDeCellule++){
    if (!document.getElementById("navcell_"+CombienYaDeCellule+"_"+uniqid)){
      break;
    }
  }
  CombienYaDeCellule--;

  //alert(NbRowHeader);
  //alert(n +"/"+ rowNum +"/"+ NbRowHeader);
  withnotabcontent=false;
  nc=document.getElementsByName("navcell");
  if(nc){
    for (var i =1 ;i<=CombienYaDeCellule;i++){
      if (i == n){
        document.getElementById("navcell_"+i+"_"+uniqid).className="tab-on"
        document.getElementById("tb_"+i+"_"+uniqid).className="tab-content show-table";
        iframeob=document.getElementById("tbiframe_"+i+"_"+uniqid);
        if (iframeob){
          if ((iframeob.src =="")||forceReload){
            iframeob.src=iframeurl;
          }
        }
      }else{
        document.getElementById("navcell_"+i+"_"+uniqid).className="tab-off"
        document.getElementById("tb_"+i+"_"+uniqid).className="hide-table";
      }
    }

    return 1;
    t=document.getElementsByName("tb")
    //tabh=document.getElementsByName("rowheader_"+rowNum);
    //alert(RowNb);
    for(i=0;i<nc.length;i++){
      if (i == n-1){
        nc.item(n-1).className="tab-on";
        //alert(i+" on");
        if (!withnotabcontent) t.item(n-1).className="tab-content show-table";
      }else{
        nc.item(i).className="tab-off";
        //alert(i+" off");
        if (!withnotabcontent) t.item(i).className="hide-table";
      }
    }
  }else if(navcell){
    for(i=0;i<navcell.length;i++){
      if (i == n-1){
        navcell[n-1].className="tab-on";
        //if (!withnotabcontent) tb[n-1].className="tab-content show-table";
      }else{
        navcell[i].className="tab-off";
        //if (!withnotabcontent) tb[i].className="hide-table";
      }
    }
  }
  //if(hash){
  //  document.location="#"+hash;
  //}
}

//function switchCellByName(name, hash,withnotabcontent) {
function switchCellByName(name, hash,withnotabcontent) {
  nc=document.getElementsByName("navcell");
  if(nc){
    t=document.getElementsByName("tb")
    for(i=0;i<nc.length;i++){
      if (i == n-1){
        nc.item(n-1).className="tab-on";
        //if (!withnotabcontent) t.item(n-1).className="tab-content show-table";
      }else{
        nc.item(i).className="tab-off";
        //if (!withnotabcontent) t.item(i).className="hide-table";
      }
    }
  }else if(navcell){
    for(i=0;i<navcell.length;i++){
      if (i == n-1){
        navcell[n-1].className="tab-on";
        //if (!withnotabcontent) tb[n-1].className="tab-content show-table";
      }else{
        navcell[i].className="tab-off";
        //if (!withnotabcontent) tb[i].className="hide-table";
      }
    }
  }
  //if(hash){
  //  document.location="#"+hash;
  //}
}

//Add To Favorite
function addToFavorite(){
  if ((navigator.appVersion.indexOf("MSIE") > 0) && (parseInt(navigator.appVersion) >= 4)) {
    window.external.AddFavorite(location.href, unescape(document.title));
  }
}

// Collection Of Macromedia Dreamweaver Functions

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

//Gradual-Highlight image script- By Dynamic Drive
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for use
// style="filter:alpha(opacity=30);-moz-opacity:0.3" onMouseover="imgFadehigh(this)" onMouseout="imgFadelow(this)"
function imgFadehigh(which2){
  theobject=which2
  highlighting=setInterval("imgFadehighlightit(theobject)",50)
}
function imgFadelow(which2){
  clearInterval(highlighting)
  if (which2.style.MozOpacity)
    which2.style.MozOpacity=0.3
  else if (which2.filters)
    which2.filters.alpha.opacity=30
}

function imgFadehighlightit(cur2){
  if (cur2.style.MozOpacity<1)
    cur2.style.MozOpacity=parseFloat(cur2.style.MozOpacity)+0.1
  else if (cur2.filters&&cur2.filters.alpha.opacity<100)
    cur2.filters.alpha.opacity+=10
  else if (window.highlighting)
    clearInterval(highlighting)
}
  //  fonction version CdM  
function qdplusMinusOnDiv(pdivId,pimgId,pplusSrc,pminusSrc,pmaxHeight,strAlldivIdImgID,src){

  var oimg = document.getElementById(pimgId);
  var odiv = document.getElementById(pdivId);
  var open = 0;
  if ((odiv.style.height == 0 ) || (odiv.style.height == '0px')){
    open=1;
    odiv.style.height =pmaxHeight+"px";
    oimg.src = pminusSrc;
  }else{
    odiv.style.height ="0px";
    oimg.src = pplusSrc;
  }
  if (strAlldivIdImgID){
    var arrPrefix = strAlldivIdImgID.split('|');
    var allIFRAME = document.getElementsByTagName("iframe");//strAlldivIdImgID.split('|');
    var allIMGS = document.getElementsByTagName("img");//strAlldivIdImgID.split('|');
    var i;
    if (open==1){
      for(i=0;i<allIFRAME.length;i++){
          //alert(i);
          //alert(allIFRAME[i].id.substring(0,arrPrefix[0].length));
          //alert(arrPrefix[0]);
        if (allIFRAME[i].id.substring(0,arrPrefix[0].length)==arrPrefix[0]){
          if (pdivId != allIFRAME[i].id){
            allIFRAME[i].style.height ="0px";
          }
        }
      }
      for(i=0;i<allIMGS.length;i++){
        if (allIMGS[i].id.substring(0,arrPrefix[1].length)==arrPrefix[1]){
          if (pimgId != allIMGS[i].id){
            allIMGS[i].src=pplusSrc;
          }else{
            allIMGS[i].src=pminusSrc;
          }
        }
      }
    }
  }
  if (src){
    oiframe=document.getElementById(pdivId);
    if (oiframe){
      if (oiframe.src==""){
        oiframe.src=src;
      }
    }
  }
  //'ata_frm_{$row.fields.act_idx->colValue}'
  //document.getElementById().style.height=200;"><img id="img_plus_{$row.fields.act_idx->colValue}" src='./_explorer/plus.gif' border=0
}



/*  fonction version QD
function qdplusMinusOnDiv(pdivId,pimgId,pplusSrc,pminusSrc,pmaxHeight){
  var oimg = document.getElementById(pimgId);
  var odiv = document.getElementById(pdivId);
  if ((odiv.style.height == 0 ) || (odiv.style.height == '0px')){
    odiv.style.height =pmaxHeight+"px";
    oimg.src = pminusSrc;
  }else{
    odiv.style.height ="0px";
    oimg.src = pplusSrc;
  }
  //'ata_frm_{$row.fields.act_idx->colValue}'
  //document.getElementById().style.height=200;"><img id="img_plus_{$row.fields.act_idx->colValue}" src='./_explorer/plus.gif' border=0
}  */


// EditorAddDropdownTags Plugin for HTMLArea-3.0
// Implementation by Olivier MICHAUD
//
// Distributed under the same terms as HTMLArea itself.
// This notice MUST stay intact for use (see license.txt).
//
// $Id: list-type.js,v 1.1 2004/03/19 14:14:27 mishoo Exp $

function EditorAddDropdownTags(editor,params) {
  this.editor = editor;
  var cfg = editor.config;
  var toolbar = cfg.toolbar;
  var self = this;
  var options = {};
  options = params[0];

  var obj = {
    id            : "EditorAddDropdownTags",
    tooltip       : "",
    options       : options,
    action        : function(editor) { self.onSelect(editor, this); },
    refresh       : function(editor) { self.updateValue(editor, this); },
    context       : ""
  };
  cfg.registerDropdown(obj);
  toolbar[1].splice(0, 0, "EditorAddDropdownTags");

};

EditorAddDropdownTags._pluginInfo = {
  name          : "EditorAddDropdownTags",
  version       : "0.1",
  developer     : "Olivier MICHAUD",
  developer_url : "http://www.quickdev.org/",
  c_owner       : "Quickdev TEAM",
  sponsor       : "None",
  sponsor_url   : "none",
  license       : "htmlArea"
};

EditorAddDropdownTags.prototype.onSelect = function(editor, obj) {
  var tbobj = editor._toolbarObjects[obj.id];
  var index = tbobj.element.selectedIndex;
  var tagvalue = tbobj.element.value;
  editor.insertHTML(tagvalue);
};
EditorAddDropdownTags.prototype.updateValue = function(editor, obj) {
};

