//---------------------------------------------------------
//  ÀÌ¹ÌÁö ÄÁÆ®·Ñ °ü·Ã class - define
//  2009-01-21 : ¹ÚÁØÇü 
//---------------------------------------------------------

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

    var imageArray = new Array();
    this.imageArray = imageArray; // Àü¿ª °´Ã¼·Î

    var imgcursor;
    this.imgcursor = 0; //  ÀÌ¹ÌÁö Ä¿¼­ 
    
    var BaseUrl;
    this.BaseUrl = "";
    
    //  ÀÚµ¿ ÇÃ·¹ÀÌ ¸ðµå 
    var playmode;
    this.playmode = false; // trueÀÏ °æ¿ì ÀÚµ¿ ÇÃ·¹ÀÌ , falseÀÏ °æ¿ì ÇÃ·¹ÀÌ ¸ØÃã  

    //  »óÇ° ÇÃ·¹ÀÌ¸ðµå 
    var playmodegoods;
    this.playmodegoods = false; // trueÀÏ °æ¿ì ÀÚµ¿ ÇÃ·¹ÀÌ , falseÀÏ °æ¿ì ÇÃ·¹ÀÌ ¸ØÃã  
    
    //  ÀÌ¹ÌÁö ÀÚµ¿ ÇÃ·¹ÀÌ ÀÎ½ºÅÏ½º
    var inst_auto;
    this.inst_auto = null;
   
    // »óÇ° ÀÚµ¿ ÇÃ·¹ÀÌ ÀÎ½ºÅÏ½º 
    var inst_autogoods;
    this.inst_autogoods = null;

    //  ´ÜÀÏ ÀÌ¹ÌÁö ÀÌ¸§ Ç¥±â 
    var single_namel;
    this.single_name = null; 

    var ImgObj;
    this.ImgObj = null;

    var rollnumbers; // ·Ñ¸µ ¹è³Ê ³Ñ¹ö ÀÌ¹ÌÁö ¹è¿­
    this.rollnumbers = new Array();
    this.rollnumbers['default'] = new Array();
    this.rollnumbers['over'] = new Array();
    
    // ¼ýÀÚ 1~10±îÁö¸¸. ÀÌ¹ÌÁö ¹è¿­¿¡ ³Ö¾îÁØ´Ù.
    for (var i=1; i<11; i++) {
      this.rollnumbers['default'][i] = "roll_0"+i+"_.gif";
      this.rollnumbers['over'][i] = "roll_0"+i+"_o.gif";
    }
    
    // ·Ñ³Ñ¹ö ÀÌ¹ÌÁö ±âº» °æ·Î
    var rollnumbers_base;
    this.rollnumbers_base = "/img/img_icons/rollnum/";

    var now_layer;
    this.now_layer=0;

  }

SingImage.prototype={
// class - Start

  //-----------------------------------------------------------------------------
  //  ½ÃÀÛ Ä¿¼­¸¦ ³»ºÎ Àü¿ªÈ­
  //-----------------------------------------------------------------------------
  GetStartCursor : function(startcursor) {
    this.imgcursor = startcursor-1;
  // function - End
  },

  //-----------------------------------------------------------------------------
  //  ÀÌ¹ÌÁö µ¥ÀÌÅÍ ¼¼ÆÃ 
  //  ±âº» :  ÀÌ¹ÌÁö Á¤º¸ ¹è¿­ Á¤ÀÇ ¹× Àü¿ªÈ­ 
  //  1. ÀÌ¹ÌÁö ±âº» °æ·Î 
  //  2. ÀÌ¹ÌÁö ÆÄÀÏ¸í : String 
  //  3. ÀÌ¹ÌÁö ±×·ì ±¸ºÐÀÚ : String 
  //  4. ¹®ÀÚ¿­ ±¸ºÐÀÚ 
  //-----------------------------------------------------------------------------
  SetImages : function(BaseUrl, Images, Groups , Names ,Sep ) {

    this.imageArray['Image'] = new Array();
    this.imageArray['Groups'] = new Array();
    this.imageArray['Names'] = new Array();

    this.imageArray['Image'] = Images.split(Sep);
    this.imageArray['Groups'] = Groups.split(Sep);
    this.imageArray['Names'] = Names.split(Sep);

    this.BaseUrl = BaseUrl;
  // function - End
  },

  //-----------------------------------------------------------------------------
  //  »óÇ° Á¤º¸ ¼¼ÆÃ
  //-----------------------------------------------------------------------------
  SetGoods : function(BaseUrl, Images, Names, Sales, Goods_no ,Sep) {

    this.imageArray['Image'] = new Array();
    this.imageArray['Names'] = new Array();
    this.imageArray['Sales'] = new Array();
    this.imageArray['Goods_no'] = new Array();

    this.imageArray['Image'] = Images.split(Sep);
    this.imageArray['Names'] = Names.split(Sep);
    this.imageArray['Sales'] = Sales.split(Sep);
    this.imageArray['Goods_no'] = Goods_no.split(Sep);
    
    this.BaseUrl = BaseUrl;
  // function - End
  },


  //-----------------------------------------------------------------------------
  //  ´ÜÀÏ ÀÌ¹ÌÁö ºä Ç¥±â ÀÌ¸§ ³»ºÎ ¼¼ÆÃ 
  //-----------------------------------------------------------------------------
  GetImgName_Single : function(NameObj) {
    this.single_name = NameObj;
  // function - End
  },

  //-----------------------------------------------------------------------------
  //  ÀÌ¹ÌÁö ÀÚµ¿ ÇÃ·¹ÀÌ 
  //-----------------------------------------------------------------------------
  PlayImage : function(ImgObjName,section, turm ) {
    
    this.ImgObj = document.getElementById(ImgObjName);
    if (this.playmode==false) { 
      this.inst_auto = window.setInterval("inst_SingImage.NextImage('"+section+"');", turm); 
      this.playmode = true;
    }
    
  // function - End
  },

  //-----------------------------------------------------------------------------
  //  »óÇ° ÀÚµ¿ ÇÃ·¹ÀÌ 
  //-----------------------------------------------------------------------------
  PlayGoods : function(name_id,cost_id, turm ) {

//    this.ImgObj = document.getElementById(ImgObjName);
    if (this.playmodegoods==false) { 
      this.inst_autogoods = window.setInterval("inst_SingImage2.NextGoods('"+name_id+"','"+cost_id+"');", turm); 
      this.playmodegoods = true;
    }
    
  // function - End
  },

  //-----------------------------------------------------------------------------
  //  ÀÌ¹ÌÁö ¿ÀºêÁ§Æ® »ý¼º 
  //-----------------------------------------------------------------------------
  SetImageObj : function(ImgObjName) {
    this.ImgObj = document.getElementById(ImgObjName);
  // function - End
  },


  //-----------------------------------------------------------------------------
  //  ÀÌ¹ÌÁö ¸ØÃã 
  //-----------------------------------------------------------------------------
  StopImage : function() {
   
    if (this.playmode==true) {
      window.clearInterval(this.inst_auto); 
      this.playmode = false;
    }

  // function - End
  },

  //-----------------------------------------------------------------------------
  //  »óÇ° ¸ØÃã 
  //-----------------------------------------------------------------------------
  StopGoods : function() {
   
    if (this.playmodegoods==true) {
      window.clearInterval(this.inst_autogoods); 
      this.playmodegoods = false;
    }

  // function - End
  },

  //-----------------------------------------------------------------------------
  //  ÆäÀÌµå¾Æ¿ô È¿°ú ÁÖ´Â ÇÊÅÍ Àû¿ë : ÇöÀç Àû¿ëÇÏÁö ¾Ê°íÀÖÀ½ IE 7.0 ÀÌ»ó¿¡¼­¸¸ ÀÛµ¿ÇÔ  
  //-----------------------------------------------------------------------------
  Filter_A : function() {
    this.ImgObj.style.filter = "blendTrans(duration=3)";
    this.ImgObj.style.filter = "blendTrans(duration=crossFadeDuration)";
    this.ImgObj.filters.blendTrans.Apply();
    this.ImgObj.filters.blendTrans.Play();
  // function - End
  },

  //-----------------------------------------------------------------------------
  //  ´ÙÀ½ÀÌ¹ÌÁö·Î ³Ñ±æ¶§ 
  //-----------------------------------------------------------------------------
  NextImage : function(section) {

    switch (section) {
      
      case "single" :
        this.Filter_A();
        this.PlusCursor();
        this.ImgObj.style.background = "url("+this.ReturnCursorImg(this.imgcursor)+")"; //  ÀÌ¹ÌÁö º¯°æ
      break;
      
      //  Ãß°¡µÉ¶§ Ãß°¡ÇØÁÖ°í
      case "widthnumbers" : 
        this.Filter_A();
        this.PlusCursor();
        this.ImgObj.style.background = "url("+this.ReturnCursorImg(this.imgcursor)+")"; //  ÀÌ¹ÌÁö º¯°æ
        this.RollingNumbers(); // ¹øÈ£ ÀÌ¹ÌÁöµé ·Ñ¸µ      
      break;
      
      case "nextclick" :
        this.Filter_A();
        this.PlusCursor();
        this.ImgObj.src= this.ReturnCursorImg_full(this.imgcursor); //  ÀÌ¹ÌÁö º¯°æ
      break;
      
    }

  // function - End
  },

  //-----------------------------------------------------------------------------
  //  »óÇ°¸í º¯°æ  
  //-----------------------------------------------------------------------------
  ChangeName : function(name_id) {
    var name = document.getElementById(name_id);
    name.innerHTML= this.imageArray['Names'][this.imgcursor]; //  ÀÌ¹ÌÁö º¯°æ
  // function - End
  },

  //-----------------------------------------------------------------------------
  //  ´ÙÀ½ ÆÇ¸Å°¡  
  //-----------------------------------------------------------------------------
  ChangeCost : function(cost_id) {
    var cost = document.getElementById(cost_id);
    cost.innerHTML= this.imageArray['Sales'][this.imgcursor]; //  ÀÌ¹ÌÁö º¯°æ
  // function - End
  },

  //-----------------------------------------------------------------------------
  //  ´ÙÀ½»óÇ°À¸·Î ÀÌµ¿
  //-----------------------------------------------------------------------------
  NextGoods : function(name_id,cost_id) {
  
    this.NextImage('nextclick'); // Ä¿¼­´Â ¿©±â¼­ ÀÌµ¿ÇÑ´Ù.
    this.ChangeName(name_id);
    this.ChangeCost(cost_id);

  // function - End
  },

  //-----------------------------------------------------------------------------
  //  ÀÌÀü »óÇ°À¸·Î ÀÌµ¿
  //-----------------------------------------------------------------------------
  PrevGoods : function(name_id,cost_id) {
  
    this.PrevImage('nextclick'); // Ä¿¼­´Â ¿©±â¼­ ÀÌµ¿ÇÑ´Ù.
    this.ChangeName(name_id);
    this.ChangeCost(cost_id);

  // function - End
  },

  //-----------------------------------------------------------------------------
  //  ¼±ÅÃÇÑ ÀÌ¹ÌÁö·Î º¯°æÇÒ ¶§ 
  //-----------------------------------------------------------------------------
  SelectImage : function(number) {
   
    this.imgcursor = number-1; // ÇöÀçÄ¿¼­ º¯°æ 
    this.Filter_A();
    this.ImgObj.style.background = "url("+this.ReturnCursorImg(this.imgcursor)+")"; //  ÀÌ¹ÌÁö º¯°æ
    this.RollingNumbers(); // ¹øÈ£ ÀÌ¹ÌÁöµé ·Ñ¸µ      

  // function - End
  },

  //-----------------------------------------------------------------------------
  //  ´ÙÀ½ÀÌ¹ÌÁö·Î ³Ñ±æ¶§ 
  //-----------------------------------------------------------------------------
  PrevImage : function(section) {

    switch (section) {
      
      //  ±âº» ÀÌ¹ÌÁö Ãâ·Â ÇüÅÂ 1°³ÀÌ¹ÌÁö °¡Áö°í ³Ñ±æ ¶§ 
      case "single" :
        this.Filter_A();
        this.MinusCursor();
        this.ImgObj.style.background = "url("+this.ReturnCursorImg(this.imgcursor)+")"; //  ÀÌ¹ÌÁö º¯°æ
      break;

      //  Ãß°¡µÉ¶§ Ãß°¡ÇØÁÖ°í
      case "widthnumbers" : 
        this.Filter_A();
        this.MinusCursor();
        this.ImgObj.style.background = "url("+this.ReturnCursorImg(this.imgcursor)+")"; //  ÀÌ¹ÌÁö º¯°æ 
        this.RollingNumbers(); // ¹øÈ£ ÀÌ¹ÌÁöµé ·Ñ¸µ      
      break;

      case "nextclick" :
        this.Filter_A();
        this.MinusCursor();
        this.ImgObj.src= this.ReturnCursorImg_full(this.imgcursor); //  ÀÌ¹ÌÁö º¯°æ
      break;

    }

  // function - End
  },

  //-----------------------------------------------------------------------------
  //  ÇöÀç Ãâ·Â µÇ¾îÀÖ´Â ÀÌ¹ÌÁö¿Í Ãâ·Â ÇÏ·Á´Â ÀÌ¹ÌÁö°¡ °°ÀºÁö ¿©ºÎ ÆÇ´Ü
  //  ¾È¾²ÀÓ 2009-03-19 
  //-----------------------------------------------------------------------------
  ComparisonImage : function(ImgObj) {
    
    var NowImage = this.ReturnCursorImg(this.imgcursor);

    //  ÇöÀç Ãâ·ÂµÈ ÀÌ¹ÌÁö¿Í ÇöÀç ÀÌ¹ÌÁö Ä¿¼­°¡ °¡¸®Å°´Â ÀÌ¹ÌÁö°¡ °°ÀºÁö ÆÇ´ÜÇØ¼­ ¸®ÅÏ
    if ( ImgObj.src == NowImage ) { return false; } else { return true;}

  // function - End
  },

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

  // function - End
  },

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

    //  ÇÑ¹ÙÄû µ¹¸é Ã³À½À¸·Î
    if(this.imgcursor-1 < 0 ) { this.imgcursor = this.imageArray['Image'].length-1; }
    else { this.imgcursor--; }

  // function - End
  },

  //-----------------------------------------------------------------------------
  //  ¼ýÀÚ ÀÌ¹ÌÁö ·Ñ¸µ 
  //-----------------------------------------------------------------------------
  RollingNumbers : function() {
    
    var str = "";
    for (var i=0; i< this.imageArray['Image'].length; i++) { var str = str+(i+1)+","; }
    str = inst_Common.CutTail(str,",",str.length);

    inst_Common.ShowDefOne("rollimgnumber_",str, this.rollnumbers, (this.imgcursor+1), this.rollnumbers_base);
 
  // function - End
  },

  //-----------------------------------------------------------------------------
  //  Ä¿¼­¸¦ ¹Þ¾Æ¼­ ÇØ´ç ÀÌ¹ÌÁöÀÇ ¸µÅ©¸¦ ¸®ÅÏ 
  //-----------------------------------------------------------------------------
  ReturnLink : function() {

    return this.imageArray['Groups'][this.imgcursor];
  
  // function - End
  },

  //-----------------------------------------------------------------------------
  //  Å¬¸¯ÇÑ ¸µÅ©·Î ÀÌµ¿ 
  //-----------------------------------------------------------------------------
  GotoLink : function() {

   var link = this.ReturnLink();
   document.location.href=link;
   
  // function - End
  },

  //-----------------------------------------------------------------------------
  //  Å¬¸¯ÇÑ »óÇ°À¸·Î ÀÌµ¿ 
  //-----------------------------------------------------------------------------
  GotoGoods : function() {
   var link = "/?action=Detail&GoodsCode="+this.imageArray['Goods_no'][this.imgcursor];
   document.location.href=link;
  // function - End
  },

  //-----------------------------------------------------------------------------
  //  ÀÌ¹ÌÁö Ä¿¼­¸¦ ¹Þ¾Æ¼­ ÇØ´ç Ä¿¼­°¡ °¡¸®Å°´Â ÀÌ¹ÌÁöÀÇ °æ·Î¸¦ ¸®ÅÏÇØÁØ´Ù.
  //-----------------------------------------------------------------------------
  ReturnCursorImg_full : function(Cursor) {
    return this.BaseUrl+this.imageArray['Image'][this.imgcursor];
  // function - End
  },

  //-----------------------------------------------------------------------------
  //  ÀÌ¹ÌÁö Ä¿¼­¸¦ ¹Þ¾Æ¼­ ÇØ´ç Ä¿¼­°¡ °¡¸®Å°´Â ÀÌ¹ÌÁöÀÇ °æ·Î¸¦ ¸®ÅÏÇØÁØ´Ù.
  //-----------------------------------------------------------------------------
  ReturnCursorImg : function(Cursor) {
    return this.imageArray['Image'][this.imgcursor];
  // function - End
  }

//----------------------------------
// class - End
//----------------------------------
}

//  °´Ã¼ »ý¼º 
var inst_SingImage = new SingImage();

//  °´Ã¼ »ý¼º 
var inst_SingImage2 = new SingImage();