// Title: Tigra Tree
// Description: See the demo at url
// URL: http://www.softcomplex.com/products/tigra_menu_tree/
// Version: 1.1 (size optimized)
// Date: 11-12-2002 (mm-dd-yyyy)
// Notes: This script is free. Visit official site for further details.

var tree_default_center_image = 'images/contactus_pic.jpg'; //center image which load onmouseover
var tree_default_frame = null;//if it is not null pages will be load to this framse 'ifrmDesk' for example.

var bSecondLoad  = false;

function tree(tm0,tm1)
{
      this.tm2=tm1;
      this.tm3=tm0;
      this.tm4=this;
      this.tm5=[];
      this.tm6=null;
      this.tm7=-1;
      this.tmFSel=true;
      this.tmFOpen=false;
      var tm8=new Image(),tm9=new Image();
      tm8.src=tm1['icon_e'];
      tm9.src=tm1['icon_l'];
      tm1['im_e']=tm8;
      tm1['im_l']=tm9;
      for(var i=0; i<64; i++)
      if(tm1['icon_'+i])
      {
            var tmA=new Image();
            tm1['im_'+i]=tmA;
            tmA.src=tm1['icon_'+i];
      }
      this.tmB=function(tmC)
                        {
                            var tmD=this.tm5[tmC];
//                            if(!tmC) this.tmFOpen = (!this.tmFOpen);
                            tmD.tmE(tmD.tmF);
                        };
      this.tmG=function(tmC){return this.tm5[tmC].tmG()};
      this.tmH=function(tmC){this.tm5[tmC].tmI(true)};
      this.tmJ=function(tmC){this.tm5[tmC].tmI()};
      this.tmK=[];
      for(var i=0; i<tm0.length; i++)new tmL(this,i);
      this.tmC=trees.length;
      trees[this.tmC]=this;
      for(var i=0; i<this.tmK.length; i++)
      {
            document.write(this.tmK[i].tmM());
            this.tmK[i].tmE();
      }
      this.tmB(0);

      /*
      * Opent current page functionality
      */
      var pn = document.location.href;
      var war = pn.split("/");
      var pagename = war[war.length-1];
      pagename = pagename.replace("#", "");

      var ar = GetChildToOpenArray(this, pagename);
      for(var i=1; i<ar.length; i++)
      {
            this.tmB(ar[i]);
      }
      setTimeout("fSecondLoad()", 5000);
}
function GetChildToOpenArray(cur_Child_tmK, pagename)
{
      var ar_ret = new Array();

      if(cur_Child_tmK.tm3[1]==pagename)
      {
           ar_ret = ar_ret.concat(cur_Child_tmK.tmC);
           return ar_ret;
      }
      for(var i=0; i<cur_Child_tmK.tmK.length; i++)
      {
              var chret = GetChildToOpenArray(cur_Child_tmK.tmK[i], pagename);
              if(chret.length>0)
              {

                 ar_ret = ar_ret.concat(cur_Child_tmK.tmC);
                 ar_ret = ar_ret.concat(chret);
                 return ar_ret;
              }
      }
      return ar_ret;
}
function tmL(tmN,tmO)
{
       this.tm7=tmN.tm7+1;
       this.tm3=tmN.tm3[tmO+(this.tm7?3:0)];
       if(!this.tm3)return;
       this.tm4=tmN.tm4;
       this.tmN=tmN;
       this.tmO=tmO;
       this.tmF=!this.tm7;
       this.tmC=this.tm4.tm5.length;
       this.tm4.tm5[this.tmC]=this;
       tmN.tmK[tmO]=this;
       this.tmK=[];
       for(var i=0; i<this.tm3.length-3;i++) new tmL(this,i);
        this.tmP=tmQ;
        this.tmE=tmR;
        this.tmG=tmS;
        this.tmM=tmT;
        this.tmI=tmU;
        this.tmV=function(){return this.tmO==this.tmN.tmK.length-1}
}

function tmR(tmW)
{
      var tmX=tmY('i_div'+this.tm4.tmC+'_'+this.tmC);
      if(!tmX)return;
      if(!tmX.innerHTML)
      {
            var tmK=[];
            for(var i=0; i<this.tmK.length; i++) tmK[i]=this.tmK[i].tmM();

            tmX.innerHTML=tmK.join('');
      }
      tmX.style.display=(tmW?'none':'block');
      this.tmF=!tmW;
//      this.tmF=!this.tmF;
      var tmZ=document.images['j_img'+this.tm4.tmC+'_'+this.tmC],tma=document.images['i_img'+this.tm4.tmC+'_'+this.tmC];
      if(tmZ)tmZ.src=this.tmP(true); //true
      if(tma)tma.src=this.tmP();
      this.tmI();
}
function tmS(tmb)
{
     if(!tmb)
     {
          var tmc=this.tm4.tm6;
          this.tm4.tm6=this;
          if(tmc)tmc.tmG(true);
     }
     var tma=document.images['i_img'+this.tm4.tmC+'_'+this.tmC];
     if(tma)tma.src=this.tmP();

     tmY('i_txt'+this.tm4.tmC+'_'+this.tmC).style.fontWeight=tmb?'normal':'bold';
     this.tmI();
     return Boolean(this.tm3[1])
}
function tmU(tmd)
{
         window.setTimeout('window.status="'+(tmd?'':this.tm3[0]+(this.tm3[1]?' ('+this.tm3[1]+')':''))+'"',10)
}
function tmT()
{
       var tme=[],tmf=this.tmN;
       for(var i=this.tm7;i>1;i--)
       {
            tme[i]='<img src="'+this.tm4.tm2[tmf.tmV()?'icon_e':'icon_l']+'" border="0" align="absbottom">';
            tmf=tmf.tmN
       }
       return '<table cellpadding="0" cellspacing="0" border="0">'+
                '<tr><td nowrap>'+
                  (this.tm7?
                        tme.join('')+
                        (
                        this.tmK.length?
                              '&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="trees['+this.tm4.tmC+'].tmB('+this.tmC+');" onmouseover="trees['+this.tm4.tmC+'].tmJ('+this.tmC+')" onmouseout="trees['+this.tm4.tmC+'].tmH('+this.tmC+')">'+
                              '<img src="'+this.tmP(true)+'" border="0" align="absbottom" name="j_img'+this.tm4.tmC+'_'+this.tmC+'"></a>'
                        :'&nbsp;&nbsp;&nbsp;&nbsp;<img src="'+this.tmP(true)+'" border="0" bordercolor="white" align="absbottom">')
                  :'')+
                  '<a style="cursor: hand; TEXT-DECORATION: none; " target="'+this.tm4.tm2['target']+'" onclick="'+(this.tm3[1]?'loadFile(\''+this.tm3[1]+'\'); ':' ')+
                  ((this.tm3.length>3 && this.tmC!=0)?' trees['+this.tm4.tmC+'].tmB('+this.tmC+')':'')+
//ondblclick="trees['+this.tm4.tmC+'].tmB('+this.tmC+')"
//                  ((this.tmC!=0)?
//                     (' trees['+this.tm4.tmC+'].tmB(0); ')
//                     : ' return trees['+this.tm4.tmC+'].tmG('+this.tmC+')')+
                     '" onmouseover="trees['+this.tm4.tmC+'].tmJ('+this.tmC+');'+(this.tm3[2]!=null?' loadPreview(\''+this.tm3[2]+'\');':'')+'" onmouseout="trees['+this.tm4.tmC+'].tmH('+this.tmC+'); document.getElementById(\'imgPreview\').src=\''+tree_default_center_image+'\';" class="t'+this.tm4.tmC+'i" id="i_txt'+this.tm4.tmC+'_'+this.tmC+'">'+
                  '<img src="'+this.tmP()+'" border="0" '+((!this.tmC)?' onmouseover="(!trees['+this.tm4.tmC+'].tmFOpen?this.src=\''+this.tmP(-1)+'\':\'\');" '+
                  ' onmouseout="(!trees['+this.tm4.tmC+'].tmFOpen?this.src=\''+this.tmP(-1)+'\':\'\')")'+
                  ' onclick="trees['+this.tm4.tmC+'].tmB(0); trees['+this.tm4.tmC+'].tmFOpen = (! trees['+this.tm4.tmC+'].tmFOpen)"': ' ')+
                        ' align="absbottom" name="i_img'+this.tm4.tmC+'_'+this.tmC+'" id="i_img'+this.tm4.tmC+'_'+this.tmC+'" class="t'+this.tm4.tmC+'im"><font '+(this.tm3[2]!=null?(' onmouseover="loadPreview(\''+this.tm3[2]+'\');" onmouseout="document.getElementById(\'imgPreview\').src=\''+tree_default_center_image+'\';" '):'')+(this.tmK.length?' class="product_list" ':' class="product_list_1" ')+'>'+this.tm3[0]+'</font></a></td></tr></table>'+
                  (this.tmK.length?
                        '<div id="i_div'+this.tm4.tmC+'_'+this.tmC+'" style="display:none"></div>'
                        :'');


}//onclick=" trees['+this.tm4.tmC+'].tmFOpen = (!(trees['+this.tm4.tmC+'].tmFOpen)); this.src=\'javascript:trees['+this.tm4.tmC+'].tmP(-1);\';"

function tmQ(tmg)
{
     if(tmg!=-1)
     {
          return this.tm4.tm2['icon_'+
          ((this.tm7?0:32)+(this.tmK.length?16:0)+(this.tmK.length&&this.tmF?8:0)+(!tmg&&this.tm4.tm6==this?4:0)+
          (tmg?2:0)+(tmg&&this.tmV()?1:0))];
     }
     else
     {

                if(!this.tmFSel)
                {
                        this.tmFSel = true;
                        return this.tm4.tm2['icon_56'];
                }
                else
                {
                        this.tmFSel = false;
                        return this.tm4.tm2['icon_48'];
                }
     }
}

var trees=[];
var timerId;
tmY=document.all?function(tmh){return document.all[tmh]}:function(tmh){return document.getElementById(tmh)};

function loadFile(fileName)
{
         if(tree_default_frame==null)
         {
                 document.location = fileName;
         }
         else
         {
                 document.getElementById(tree_default_frame).src=fileName;
         }
}

function loadPreview(strFileName)
{
         if(bSecondLoad)document.getElementById('imgPreview').src=strFileName;
}
function fSecondLoad()
{
        bSecondLoad = true;
}