// JavaScript Document

try {
  document.execCommand('BackgroundImageCache',false,true);
} catch(e) { }

// IE6 png24
function setPng24(obj) {
  obj.width=obj.height=1; 
  obj.className=obj.className.replace(/\bpng24\b/i,''); 
  obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');";
  obj.src='';
  return '';
}


function eventcommon_swf(fw,fh,_src,_id){
  var html = ''
    + '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="'+_id+'" width="'+fw+'" height="'+fh+'" align="middle">\n'
    + '<param name="allowScriptAccess" value="always" />'
    + '<param name="movie" value="'+_src+'" />\n'
    + '<param name="quality" value="high" />\n'
    + '<param name="scale" value="noScale" />\n'
    + '<param name="wmode" value="transparent" />\n'
    + '<embed src="'+_src+'" wmode="transparent" scale="noScale" quality="high" width="'+fw+'" height="'+fh+'" id="'+_id+'" name="'+_id+'" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n'
    + '<\/object>\n';
  document.write(html);
}


function fnMenuRolOver_Type1() {
  this.oTrue = null;
  this.MenuImg = new Array();
  this.MenuImg["on"] = new Array();
  this.MenuImg["off"] = new Array();

  this.GoodsSetting = function() {
    this.MenuBox = document.getElementById(this.MenuName);
    this.MenuLi = this.MenuBox.getElementsByTagName("ul")[0].getElementsByTagName("li");
    this.MenuTotal = this.MenuLi.length;
    this.CurrentGoodBox = 0;

    for (var i=0 ; i<this.MenuTotal; i++) {
      this.MenuImg["off"][i] = document.createElement("IMG");
      this.MenuImg["off"][i].src = this.MenuLi.item(i).getElementsByTagName("a")[0].getElementsByTagName("img")[0].src;
      this.MenuImg["on"][i] = document.createElement("IMG");
      this.MenuImg["on"][i].src = this.MenuLi.item(i).getElementsByTagName("a")[0].getElementsByTagName("img")[0].src.replace("_off.", "_on.");
    }

    if ( this.RandomNum == 1 ) {
      this.RandomNumber = Math.floor(Math.random()*this.MenuTotal);
      
      if ( this.RandomNumber == this.MenuTotal ) {
        this.RandomNumber = this.RandomNumber - 1;
      }
      this.CurrentGoodBox = this.RandomNumber;
    }


    for ( var i=0; i<this.MenuTotal; i++) {
      this.MenuLink = this.MenuLi.item(i).getElementsByTagName("a")[0];
      this.MenuLinkBtn = this.MenuLink.getElementsByTagName("img")[0];

      if ( i == this.CurrentGoodBox ) {
        document.getElementById(this.DivName + i).style.display = "block";
        this.MenuLinkBtn.src = this.MenuImg["on"][i].src
      } else {
        document.getElementById(this.DivName + i).style.display = "none";
        this.MenuLinkBtn.src = this.MenuImg["off"][i].src
      }

      this.MenuLink.BtnNum = i;
      this.MenuLink.BtnBox = this.fnName;
      this.MenuLink.onmouseover = function() {
        eval( this.BtnBox +".fnMouseOver("+this.BtnNum+")");
      }
    }

    if ( this.AutoNum == 1 ) {
      if ( this.CurrentGoodBox == this.MenuTotal - 1 ) {
        this.NextNum = 0;
      } else {
        this.NextNum = this.CurrentGoodBox + 1;
      }
      this.oTrue = setTimeout( this.fnName + ".fnMouseOver('" + this.NextNum + "')" , this.ScrollTime );
    }
  }

  this.fnMouseOver = function(val) {
    val = parseInt(val);
    if ( this.AutoNum == 1 )  { clearTimeout(this.oTrue) }

    for ( var i=0; i<this.MenuTotal; i++) {
      this.MenuLink = this.MenuLi.item(i).getElementsByTagName("a")[0];
      this.MenuLinkBtn = this.MenuLink.getElementsByTagName("img")[0];

      if ( i == val ) {
        document.getElementById(this.DivName + i).style.display = "block";
        this.MenuLinkBtn.src = this.MenuImg["on"][i].src
      } else {
        document.getElementById(this.DivName + i).style.display = "none";
        this.MenuLinkBtn.src = this.MenuImg["off"][i].src
      }
    }
    if ( this.AutoNum == 1 ) {
      if ( val == this.MenuTotal - 1 ) {
        this.NextNum = 0;
      } else {
        this.NextNum = val + 1;
      }
      this.oTrue = setTimeout( this.fnName + ".fnMouseOver('" + this.NextNum + "')" , this.ScrollTime );
    }
  }
}


function fnGoodsMove_Type1() {
  this.GoodsSetTime = null;
  this.BannerCurrent = 0;

  this.GoodsSetting = function() {
    this.ObjBox = document.getElementById(this.DivName);
    this.PrevBtnLink = document.getElementById(this.PrevBtn);
    this.NextBtnLink = document.getElementById(this.NextBtn);
    this.ObjUl = this.ObjBox.getElementsByTagName("ul")[0];
    this.ObjLi = this.ObjUl.getElementsByTagName("li");
    this.ObjLiNum = this.ObjLi.length;
    this.TotalWidth = this.DateWidth * this.ObjLiNum;

    this.ObjBox.style.width = this.TotalWidth + "px";

    if ( this.ObjLiNum % this.DateNum == 0 ) {
      this.BannerEnd = this.TotalWidth - ( this.DateWidth * this.DateNum );
    } else {
      this.BannerEnd = this.TotalWidth - this.DateWidth;
    }

    this.BannerPrevLeft = this.BannerEnd;
    this.BannerNextLeft = this.DateWidth * this.DateNum ;
    
    this.PrevBtnLink.href = "javascript:" + this.fnName +"._moveFrame(" + this.BannerPrevLeft + ",'prev')";
    this.NextBtnLink.href = "javascript:" + this.fnName +"._moveFrame(" + this.BannerNextLeft + ",'next')";
    
    this.GoodsSetTime = setTimeout( this.fnName + "._moveFrame('" + this.BannerNextLeft + "','next')" , 3000 );
  }

  this._moveFrame = function(val,fnmove) {
    clearTimeout(this.GoodsSetTime)
    
    if ( Math.abs(val - this.BannerCurrent) > 5 ) {
      this.BannerCurrent = this.BannerCurrent + ( val - this.BannerCurrent ) * this.Speed;
    } else {
      this.BannerCurrent = val;
    }

    this.ObjUl.style.left = ( -1 * this.BannerCurrent ) + "px";

    if ( this.BannerCurrent != val ) {
      this.GoodsSetTime = setTimeout(this.fnName + "._moveFrame(" + val + ",'" + fnmove + "')",10);
    } else {
      this.CurrentPicNum = this.BannerCurrent / this.DateWidth;

      this.BannerPrevLeft = this.BannerCurrent - ( this.DateWidth * this.DateNum );
      this.BannerNextLeft = this.BannerCurrent + ( this.DateWidth * this.DateNum );

      if ( this.BannerCurrent == 0 ) {
        this.BannerPrevLeft = this.BannerEnd;
      } else if ( this.BannerCurrent == this.BannerEnd ) {
        this.BannerNextLeft = 0;
      }
      this.PrevBtnLink.href = "javascript:" + this.fnName +"._moveFrame(" + this.BannerPrevLeft + ",'prev')";
      this.NextBtnLink.href = "javascript:" + this.fnName +"._moveFrame(" + this.BannerNextLeft + ",'next')";
    }

    this.GoodsSetTime = setTimeout( this.fnName + "._moveFrame('" + this.BannerNextLeft + "','next')" , 3000 );
  }
}
