//---------------------------------------------------------
//   ¹è³Ê °ü·Ã Å¬·¡½º
//---------------------------------------------------------

	//---------------------------------------------------------
	//   »ý¼ºÀÚ 
	//---------------------------------------------------------
  function Banner(inst_Common){

		var form;
		var add;
		var max_num;
		var max_goods;
		var show;
		var count;
		var ImgCnt; 
  var anibanarray; // ¾Ö´Ï¹è³Ê ¹è¿­

	
			//  °ø¿ë Å¬·¡½º ÀÎ½ºÅÏ½º ·Îµù
		this.inst_Common = inst_Common;
		this.add = 0;
		this.max_goods = 15;  // ÄíÅ°¿¡ ´ãÀ» ÃÖ´ë »óÇ°°¹¼ö
		this.show = document.getElementById("show");
		this.count = document.getElementById("count");
  this.anibanarray = new Array(); // ¾Ö´Ï¹è³Ê¿ë ¹è¿­
    
  //  ÇÃ·¹ÀÌ ¸ðµå 
  var playmode;
  this.playmode = false; // trueÀÏ °æ¿ì ÀÚµ¿ ÇÃ·¹ÀÌ , falseÀÏ °æ¿ì ÇÃ·¹ÀÌ ¸ØÃã  

  // ÀÚµ¿ ÇÃ·¹ÀÌ ¹è³Ê ÀÎ½ºÅÏ½º 
  var inst_autobans;
  this.inst_autobans = null;
  
  // ¹è³Ê ¹è¿­ÀÇ ÇöÀç Ä¿¼­
  var bancursor;
  this.bancursor=0;

	// function - End
}

Banner.prototype={

		//-----------------------------------------------------------------------------
		//    ¹è³Ê ·¹ÀÌ¾î ¿òÁ÷ÀÌ´Â ¸Þ¼­µå
		//-----------------------------------------------------------------------------
		SlidingBanner : function() {

				var obj_layer = document.getElementById('floater')

				// ÄíÅ°¿¡¼­ »óÇ°Á¤º¸ °¡Á®¿À±â
				str = this.inst_Common.GetCookie('banner_g');

				// ¿À´Ãº» »óÇ°ÀÌ ÀÖÀ»¶§¸¸ Ãâ·Â
				if (str == "") { obj_layer.style.display="none"; }
				else { obj_layer.style.display="block"; }

				windowHeight = document.body.clientHeight;
				windowWidth = document.body.clientWidth;
				scrollY = document.documentElement.scrollTop;

				obj_layer.style.top = 50 + scrollY;

		// function - End
		},

		//-----------------------------------------------------------------------------
		//    ¹è³Ê ·¹ÀÌ¾î¿¡ »óÇ°Ãâ·Â
		//-----------------------------------------------------------------------------
		showGoods : function(state,width,cnt) {

				// 11¹ø ½ºÅ² ºÎÅÍ´Â _head.tpl¿¡ inst_Shop.ImgCnt·Î Àû¿ë
				// 10¹ø ½ºÅ²±îÁö´Â _head.tpl °ú detail.tpl µÎ±ºµ¥ inst_Banner.showGoods('',inst_Shop.SlidingWidth,5);
				// 2009-02-24 ³²ÇüÁø
				this.ImgCnt = cnt == undefined ? 4:cnt;// ½½¶óÀÌµù ¹è³Ê ÀÌ¹ÌÁö °¹¼ö

				this.show.innerHTML="";
				var str,goods_data,goods_info,co;
				// ÄíÅ°¿¡¼­ »óÇ°ÄÚµå¿Í ÀÌ¹ÌÁö °¡Á®¿À±â
				str = this.inst_Common.GetCookie('banner_g');
				goods_array = str.split('|');

				// ÃÑ»óÇ° °¹¼ö
				this.max_num = goods_array.length-1;

				goods_data = "";
				goods_count = 0;
				co = 0;

				if ( this.add > this.max_num ) { this.add = 1 }
				if ( this.add < 0 ) { this.add = this.max_num-1 }

				for(i = 0+this.add; i <this.ImgCnt+this.add ; i++) 	{
						if ( goods_array[i] != null && goods_array[i] != '' ) {
								goods_info = goods_array[i].split('^');
								goods_data = goods_data+"<div style='padding:2px 0;'><a href='http://"+document.domain+"/?action=Detail&GoodsCode="+goods_info[0]+"'><img src='"+goods_info[1]+"' width='"+width+"px' style='cursor:hand; border-bottom:1px solid #E7E7E7;'></a></div>";
								co++;
						}
				}

				for(i = 0; i < this.ImgCnt-co ; i++) 	{
						if ( goods_array[i] != null && goods_array[i] != '' && this.max_num > this.ImgCnt ) {
								goods_info = goods_array[i].split('^');
								goods_data = goods_data+"<div style='padding:2px 0;'><a href='http://"+document.domain+"/?action=Detail&GoodsCode="+goods_info[0]+"'><img src='"+goods_info[1]+"' width='"+width+"px' style='cursor:hand; border-bottom:1px solid #E7E7E7;'></a></div>";
						}
				}

				this.show.innerHTML="<div>"+goods_data+"</div>";
				this.count.innerHTML=this.max_num;

		},

		//-----------------------------------------------------------------------------
		//   ÄíÅ°±Á±â
		//-----------------------------------------------------------------------------
		B_SetCookie : function(sName, sValue) {

				var goods_info,goods_array,goods_back;

				goods_info = this.inst_Common.GetCookie(sName);
				goods_array = goods_info.split('|');

				// °°Àº»óÇ°ÄÚµåÀÇ »óÇ°ÀÌ ÀÖÀ¸¸é ÆÐ½º~
				if ( this.inst_Common.in_array(goods_array, sValue) === false) { return false; }

				//  ÃÖ´ë 15°³±îÁö¸¸ ÄíÅ°¿¡ ´ãÀ½
				if (this.max_num >= this.max_goods) {
						goods_info = "";
						for(i = 0; i <this.max_goods-1 ; i++) 	{
								goods_info = goods_info + goods_array[i] + "|";
						}
				}

				sValue = sValue + "|" + goods_info; 
				this.inst_Common.SetCookie(sName,sValue);

		},

		//-----------------------------------------------------------------------------
		//   »óÇ° À§,¾Æ·¡ ÀÌµ¿
		//-----------------------------------------------------------------------------
		AddCount : function(no,AddCount) {
				if (this.max_num > this.ImgCnt) {
						this.add = this.add+no;
						this.showGoods('',AddCount,this.ImgCnt);
				}
		},



//===================================================================================================================
// 
//                                                                      ·Ñ¸µ ¹è³Ê °ü·Ã ¸Þ¼Òµåµé 2009-04-21 
//
//===================================================================================================================


  //-----------------------------------------------------------------------------
  //  ¹è³Ê ÇÃ·¹ÀÌ
  //-----------------------------------------------------------------------------
  PlayBan : function(turm) {
   
    if (this.playmode==false) {
      this.inst_autobans = window.setInterval("inst_Banner.NextBan();", turm); 
      this.playmode = true;
    }

  // function - End
  },

  //-----------------------------------------------------------------------------
  //  ´ÙÀ½ ¹è³Ê 
  //-----------------------------------------------------------------------------
  NextBan : function() {

    for (var i=0; i<this.anibanarray.length; i++) {
      if( this.bancursor==i ) {
       this.Filter_A();
       document.getElementById(this.anibanarray[i]).style.display='block';
      }
      else { document.getElementById(this.anibanarray[i]).style.display='none'; }
    }
    this.PlusCursor();
 
  // function - End
  },

  //-----------------------------------------------------------------------------
  //  ¹è³Ê ¸ØÃã 
  //-----------------------------------------------------------------------------
  StopBan : function() {
   
    if (this.playmodegoods==true) {
      window.clearInterval(this.inst_autogoods); 
      this.playmodegoods = false;
    }

  // function - End
  },

  //-----------------------------------------------------------------------------
  //  ÀÌÀü ¹è³Ê 
  //-----------------------------------------------------------------------------
  PrevBan : function() {
   
    if (this.playmodegoods==true) {
      window.clearInterval(this.inst_autogoods); 
      this.playmodegoods = false;
    }

  // function - End
  },

  //-----------------------------------------------------------------------------
  //  ¹è³Ê ·Îµù
  //-----------------------------------------------------------------------------
  LoadBan : function() {
   
    if (this.playmodegoods==true) {
      window.clearInterval(this.inst_autogoods); 
      this.playmodegoods = false;
    }

  // function - End
  },

  //-----------------------------------------------------------------------------
  //  Ä¿¼­ Áõ°¡ 
  //-----------------------------------------------------------------------------
  PlusCursor : function() {
    
    //  ÇÑ¹ÙÄû µ¹¸é Ã³À½À¸·Î
    if(this.bancursor+1 >= this.anibanarray.length ) { this.bancursor = 0; }
    else { this.bancursor++; }

  // function - End
  },

  //-----------------------------------------------------------------------------
  //  Ä¿¼­ °¨¼Ò 
  //-----------------------------------------------------------------------------
  MinusCursor : function() {

    //  ÇÑ¹ÙÄû µ¹¸é Ã³À½À¸·Î
    if(this.bancursor-1 < 0 ) { this.bancursor = this.anibanarray.length-1; }
    else { this.bancursor--; }

  // function - End
  },

  //-----------------------------------------------------------------------------
  //  ÆäÀÌµå¾Æ¿ô È¿°ú ÁÖ´Â ÇÊÅÍ
  //-----------------------------------------------------------------------------
  Filter_A : function() {
    document.getElementById(this.anibanarray[this.bancursor]).style.filter = "blendTrans(duration=3)";
    document.getElementById(this.anibanarray[this.bancursor]).style.filter = "blendTrans(duration=crossFadeDuration)";
    document.getElementById(this.anibanarray[this.bancursor]).filters.blendTrans.Apply();
    document.getElementById(this.anibanarray[this.bancursor]).filters.blendTrans.Play();
  // function - End
  }

// class - End
}
