/*
  Panasonic Singapore
  JS FILE [menu_function.js]
  This file contains the definition of "menu highlight".

last updated -----------------------------------------------
06/12 added "domainName" value.
 -----------------------------------------------------------
 */



function setCssProperty(){
  this.w3c = document.getElementById; if (!this.w3c) return false;
  return this;
}

setCssProperty.prototype = {
  init : function(){
      CP.mainid = document.getElementById("maincol");if(!CP.mainid) return false;
      CP.maindivs = CP.mainid.getElementsByTagName("div");
      if(win&&ie){CP.setPageTitle();}
      for(var i=0,f=CP.maindivs.length; i < f ; i++){
        CP.setImg12ctxt1c(i);
        CP.setDl1c2c(i);
        CP.setTableStyle(i);
        CP.setBtnCol(i);
        CP.setThumbPos(i);
      }
      CP.bnrid = document.getElementById("bnrcol");if(!CP.bnrid) return false;
      CP.bnrdivs = CP.bnrid.getElementsByTagName("div");
      for(var i=0,f=CP.bnrdivs.length; i < f ; i++){
        CP.setBtnBnr(i);
      }
  },
  
  //div.img12c-txt1c
  //1px is bugfix of firefox 1.5
  setImg12ctxt1c : function(i){
    if(CP.getClsName(CP.maindivs[i]) == "img12c-txt1c"){
      divs = CP.maindivs[i].getElementsByTagName("div");
      if(divs.length < 13) return;
        lcol = divs[3];  rcol = divs[9];
        maxh = Math.max(lcol.offsetHeight,rcol.offsetHeight);
        if(ie){lcol.style.height = rcol.style.height = maxh + "px";}
        else{lcol.style.minHeight = rcol.style.minHeight = (maxh + 1) + "px";}
    }
  },
  
  //div.dl1c-2c,div.dl1c-2c-normal
  setDl1c2c : function(i){
    if(CP.getClsName(CP.maindivs[i]).indexOf("dl1c-2c") > -1){
      dl = CP.maindivs[i].getElementsByTagName("dl");
      dlarry = CP.getClsName(dl[0]).split(" ");
      for(var s = 0; s < dlarry.length ; s++){
        if (dlarry[s].indexOf("dtw") > -1){
          var stw = dlarry[s].substring(3);
          dts = dl[0].getElementsByTagName("dt");
          dds = dl[0].getElementsByTagName("dd");
          dts[0].setAttribute(CP.getClsAttr(),"first");
          dds[0].setAttribute(CP.getClsAttr(),"first");
          for(var g=0,f=dts.length ; g < f; g++){
            dts[g].style.width = ((gecko && !opera || (opera && vers > 8))? new Number(stw-18) : stw) + "px";
            if(ie5win){dds[g].style.marginLeft = (stw -3) + "px";
            }else{dds[g].style.width = new Number(573 - stw) + "px";}
            
            if(ie||opera){
                maxh = Math.max(dts[g].offsetHeight,dds[g].offsetHeight);
                dts[g].style.height = dds[g].style.height = maxh + "px";
              }
          }
          
        }
      }
      CP.maindivs[i].style.visibility = "visible";
    }
  },
  
  //table modules (table1c-2c,table1c-3c,table2c,!tableformc)
  setTableStyle : function(i){
    if(CP.getClsName(CP.maindivs[i]).match(/table[\d]/ig)){
      thed = CP.maindivs[i].getElementsByTagName("thead");
      tbdy = CP.maindivs[i].getElementsByTagName("tbody");
      fth = tbdy[0].getElementsByTagName("th");
      if(!fth[0]){fth = tbdy[0].getElementsByTagName("td");}
      ftr = tbdy[0].getElementsByTagName("tr");
      ftd = ftr[0].getElementsByTagName("td");
      clsname = (!thed.length)? "nothead" : "first";
      fth[0].setAttribute(CP.getClsAttr(),clsname);
      for(var s=0,f=ftd.length ; s < f ; s++){
        ftd[s].setAttribute(CP.getClsAttr(),clsname);
      }
    }
  },

  //div.txt3btnc
  setBtnCol : function(i){
    if(CP.getClsName(CP.maindivs[i]).indexOf("txt3btnc") > -1){
        div = CP.maindivs[i].getElementsByTagName("div");
        as = CP.maindivs[i].getElementsByTagName("a");
        divarry = CP.getClsName(div[0]).split(" ");
        for(var s = 0,f=divarry.length; s < f ; s++){
            if (divarry[s].indexOf("btnw") > -1){
                var stw = divarry[s].substring(4);
                div[0].style.width = stw/12 + "em";
                return;
            }
        }
    }
  },

  //div.thumbnail1c
  setThumbPos : function(i){
    if(CP.getClsName(CP.maindivs[i]) == "thumbnail1c"){
        imgs = CP.maindivs[i].getElementsByTagName("img");
        imgs[0].style.left = Math.floor((179 - imgs[0].getAttribute("width"))/2) + "px";
        imgs[0].style.top = Math.floor((179 - imgs[0].getAttribute("height"))/2) + "px";
    }
  },

  //#pagetitle (win ie only)
  setPageTitle : function(){
    CP.pt = document.getElementById("pagetitle");if(!CP.pt) return false;
    clrarry = CP.getClsName(CP.pt).split(" ");
    color = (clrarry.length > 1)? clrarry[1] : clrarry[0];
    CP.pt.style.backgroundImage ="url(/common/img/pagetitle/bg-pagetitle-" + color + ".gif)";
  },
  
  //button banner (btn-bnr)
  setBtnBnr: function(i){
    if(CP.getClsName(CP.bnrdivs[i]) == "btn-bnr"){
       ps = CP.bnrdivs[i].getElementsByTagName("p");
       var domainName = "http://" + dname;
       ps[0].style.backgroundImage = "url(" + domainName + "\/common\/img\/bnr\/" + CP.getClsName(ps[0]) + ")";
       if(!ie) {
         as = CP.bnrdivs[i].getElementsByTagName("a");
         as[0].setAttribute(CP.getClsAttr(),"notie");
       }
    }
  },
  
  setali : function(k,btn){
    btnco = (btn == "on")? "on" : "off" ;
    lis[k].setAttribute(CP.getClsAttr(),btnco);
  },
  
  getClsName : function(d){
    return new String(d.getAttribute(CP.getClsAttr())).toLowerCase();
  },
  
  getClsAttr : function(){
    return (ie)? "className" : "class";
  }
}

var CP = new setCssProperty();
window.addOnload(CP.init);







