﻿/*-------------------------------------------------------------------------------*/
/*                                  クッココラム                                 */
/*-------------------------------------------------------------------------------*/

function zc(){

 var self = this;
 this.ajax_path = 'http://www.ccucco.com/site/html/column/';
 this.ajax_container = '#zc_ajax_container';
 this.tickerOptions = {
  newsList: "#zc_column",
  startDelay: 1000,
  tickerRate: 65,
  loopDelay: 2000,
  placeHolder1: "_",
  placeHolder2: "_",
  balloon: '#zc_balloon',
  speaking: '#zc_speaking',
  silent: '#zc_silent',
  ctrResume: ".zc_resume",
  ctrFirst: ".zc_first",
  ctrPrev: ".zc_prev",
  ctrNext: ".zc_next",
  modalOverlay: '#modalOverlay',
  container: '#zc',
  mode_name : 'zc'
 }

 this.setUp = function(){
  this.loadIndex();
  $('#zc_footer').pngfix();
  $('#zc_baloon').pngfix();
  $('#zc_profile_title').toggle(
   function(){$('#zc_profile').slideDown();},
   function(){$('#zc_profile').slideUp();}
  );
 }
 
 this.loadIndex = function(){
  var url = this.ajax_path + 'index.html';
  $.ajax({
    url: url,
    cache: false,
    success: function(str){self.setIndex(str);}
  });
 }
 
 this.setIndex = function(str){
  $('#zc_index').html(str);
  
  var column_size = $('#zc_index ul li').size();  
  var r=Math.floor(Math.random()*column_size);
  var e = $('#zc_index ul li:eq(' + r + ')');
  this.selectColumn(e);
  $('#zc_index ul li').click(function(){self.selectColumn($(this));});
 }
 
 this.selectColumn = function(e){
  var file_name = e.attr('file_name');
  this.loadColumn(file_name);
 }
 
 this.loadColumn = function(file_name){
 var url = this.ajax_path + file_name;
 $.ajax({
    url: url,
    cache: false,
    success: function(str){self.startTicker(str);}
   });
 }
 
 this.startTicker = function(str){
  $(this.ajax_container).html(str);
  var headline = $('#zc_title').text();
  $('#zc_headline').html(headline);
  $().newsTicker(this.tickerOptions);
 }

}


/*-------------------------------------------------------------------------------*/
/*                               ショッピングガイド                              */
/*-------------------------------------------------------------------------------*/
 
function shopGuide(){

 var self = this;

 this.setGuide = function(){
  $('#guide_list li').click(function(){self.changeGuideItem($(this));});
  start_e = $('#guide_list li:eq(0)');
  this.changeGuideItem(start_e);
 }
 
 this.changeGuideItem = function(e){
  $('#guide_list li[class != "checked"]').css({backgroundPosition: '-520px 0'});
  $('#guide_list li[class = "checked"]').css({backgroundPosition: '-260px 0'});
  e.attr('class','checked').css({backgroundPosition: '0 0'});

  var idx = $('#guide_list li').index(e);
  $('#guide_contents>li').hide();
  $('#guide_contents>li:eq(' + idx + ')').fadeIn();
 }
 
}


/*-------------------------------------------------------------------------------*/
/*                                  トップメニュー                               */
/*-------------------------------------------------------------------------------*/

 function topNavi(ini){
  var self = this;
  this.tabItems = $('#top_navi_list li');
  this.tabItemsW = 140;
  this.body = $('#top_navi_body');
  this.body_minHeight = 84;
  this.body_maxHeight = 654;
  this.contents = $('#top_navi_contents');
  this.topNaviClose = $('#top_navi_close');
  this.images_path = 'http://www.ccucco.com/site_data/cabinet/item/';

  this.body_open = false;
  this.body_open_modal = false;
  this.idx = null;
  
  this.ajax_path = 'http://www.ccucco.com/site/html/genre/';
  this.ajax_url = [
                   'ajax_bag.html',
				   'ajax_stationary.html',
				   'ajax_watch.html',
				   'ajax_leathergoods.html',
				   'ajax_apparel.html',
				   'ajax_baby.html'
                  ];

				  
  this.setUp = function(){
   this.tabItems.click(function(){self.toggleTopNaviContents($(this));});
   this.topNaviClose.click(function(){self.closeTopNaviContents();});
  }
  
  this.toggleTopNaviContents = function(e){

   //if(!this.body_open_modal){
    this.body_open_modal = true;
	this.tabItems.stop();
	this.body.stop();
	
    this.breakSlideShow();
    var idx = this.tabItems.index(e);
    var bgPosX = this.tabItemsW*idx;

    if(this.body_open == true){
     if(idx == this.idx){
	  this.body_open = false;
	  this.contents.html('').hide();
	  this.topNaviClose.hide();
	  e.animate({marginTop: 0});
	  this.body.animate({height: this.body_minHeight},{duration: 750, complete: function(){}});
	 }
     else{
	  this.tabItems.eq(this.idx).animate({marginTop: 0});
	  this.contents.css({display: 'block', backgroundPosition: bgPosX + 'px 0'});
	  this.topNaviClose.show();
	  e.animate({marginTop: 25},{complete: function(){
	   self.loadTopMenuContents(idx);
	  }});
	 }    	
    }
    else{
	 self.body_open = true;
     //this.loadTopMenuContents(idx);
     e.animate({marginTop: 25});
     this.body.animate({height: this.body_maxHeight},{duration: 750, complete: function(){
      self.contents.css({display: 'block', backgroundPosition: bgPosX + 'px 0'});
      self.topNaviClose.show();
	  self.loadTopMenuContents(idx);
	 }});
    }

    this.idx = idx;
   //}
  }
  
  this.closeTopNaviContents = function(){
   this.breakSlideShow();
   this.body_open = false;
   this.contents.html('').hide();
   this.topNaviClose.hide();
   this.tabItems.eq(this.idx).animate({marginTop: 0});
   this.body.animate({height: this.body_minHeight},{duration: 750});
  }
  
  this.loadTopMenuContents = function(idx){
   var url = this.ajax_path + this.ajax_url[idx];
   $.ajax({
    url: url,
    cache: true,
    success: function(html){self.startBrandIntroduction(html);}
   });
  }
  
  this.startBrandIntroduction = function(html){
   this.contents.show().html(html);
   
   this.brand_size = $('#top_navi_brand_list li').size();
   
   this.brand_idx = $('#top_navi_brand_list').attr('start_index');
   if(!this.brand_idx){this.brand_idx = 0;}
   var start_e = $('#top_navi_brand_list li:eq(' + this.brand_idx + ')');
   this.setSlideShow(start_e);

   $('#top_navi_brand_list li').click(function(){self.setSlideShow($(this));});
   this.setTNBIscroll();

   this.body_open_modal = false;
  }
  
  /*---------------------------------
   tnbi slideshow
  ---------------------------------*/
  this.setSlideShow = function(e){
  
   this.breakSlideShow();

   this.brand_idx = $('#top_navi_brand_list li').index(e);
   $('#top_navi_brand_list li[sf="1"]').css({backgroundPosition: '-215px 0'});
   e.attr('sf',1).css({backgroundPosition: '0 0'});
   
   var images_names = e.attr('images').split(',');
   this.images_length = images_names.length;
   this.images_load_event = 0;
   this.images_load_count = 0;
   var s = '';
   for(i=0; i<this.images_length; i++){
    s += '<img src="' + this.images_path + images_names[i] + '" onerror="' + ini.obj_name + '.imageLoadListener(0)" onload="' + ini.obj_name + '.imageLoadListener(1)" />';
   }
   $('#top_navi_brand_preview_box').html(s);
  }
  
  this.imageLoadListener = function(fg){
   this.images_load_event++;
   if(fg == 1){this.images_load_count++;}

   if(this.images_load_event == this.images_length){
    this.images_length = this.images_load_count;
	
	this.slide_show = true;
    this.image_idx = 0;
    this.imageIn();
   }
  }

  this.breakSlideShow = function(){
   this.slide_show = false;
   clearTimeout(this.slide_show_interval);
   if(this.curr_img){this.curr_img.stop();}
  }
  
  this.imageIn = function(){
   if(this.slide_show){
    this.curr_img = $('#top_navi_brand_preview_box img:eq(' + this.image_idx + ')').css({top: -5});
    this.curr_img.fadeIn(750).animate({top: -190},{duration: 2000, complete: function(){self.imageOut();}});
   }
  }
  
  this.imageOut = function(){
   if(this.slide_show){
    clearTimeout(this.slide_show_interval);
    if(this.image_idx > 0){$('#top_navi_brand_preview_box img:eq(' + (this.image_idx - 1) + ')').hide();}
   
    this.slide_show_interval = setTimeout(function(){
	
     if(self.image_idx == self.images_length-1){
	 
      self.stepNextBrand();
	  //self.curr_img.fadeOut(500,function(){  
        //self.curr_img.css({top: -5});
		//self.image_idx = 0;
	    //self.imageIn();
       //});
	   
	 }
     else{
	  //self.curr_img.css({top: -5});
	  self.image_idx++;
	  self.imageIn();
	 }

	},1500);

   }
  }

  this.stepNextBrand = function(){
   if(this.brand_idx == (this.brand_size-1)){var next_idx = 0;}
   else{next_idx = this.brand_idx+1;}
   var next_e = $('#top_navi_brand_list li:eq(' + next_idx + ')');
   this.setSlideShow(next_e);
   this.adjustTnbiListPosition();
  }
  
  
  /*---------------------------------
   tnbi scroll
  ---------------------------------*/
  this.setTNBIscroll = function(){

   this.tnbiListBox = $('#top_navi_brand_list_box');
   this.tnbiList = $('#top_navi_brand_list');

   this.tnbiListBoxH = this.tnbiListBox.height();
   this.tnbiListH = this.tnbiList.height();
  
   this.tnbiListUp = $('#top_navi_brand_list_up');
   this.tnbiListDown = $('#top_navi_brand_list_down');
   this.tnbiListUpH = this.tnbiListUp.height();
  
   if(this.tnbiListH > this.tnbiListBoxH - this.tnbiListUpH*2){
    this.tnbiListUp.pngfix();
    this.tnbiListDown.pngfix();
    this.adjustTnbiListPosition();
  
    this.tnbiListUp.click(function(){self.tnbiListUpStart();});
    this.tnbiListDown.click(function(){self.tnbiListDownStart();});
   }
   else{
    this.tnbiList.css({top: this.tnbiListUpH});
    this.tnbiListUpOff(); this.tnbiListDownOff();
   }
  }

  this.adjustTnbiListPosition = function(){
   this.clearAlleffect(); 
   var tnbiListPos = this.tnbiList.position().top;
   var e = $('#top_navi_brand_list li:eq(' + this.brand_idx + ')');
   var curr_pos = e.position().top;
   var curr_h = e.height();
  
   if(curr_pos + curr_h > this.tnbiListBoxH - this.tnbiListUpH*2){
    var top = (this.tnbiListBoxH - this.tnbiListUpH) - (curr_pos + curr_h);
    var restH = this.tnbiListH - (curr_pos + curr_h);
    if(restH > 5){
     if(restH > this.tnbiListBoxH/2){restH = this.tnbiListBoxH/2 - this.tnbiListUpH;}
     top = top - restH;
    }
   }
   else if(tnbiListPos + curr_pos - this.tnbiListUpH < 0){
    if(curr_pos + curr_h > this.tnbiListBoxH/2){top = (this.tnbiListBoxH/2) - curr_pos + this.tnbiListUpH;}
    else{top = this.tnbiListUpH;}
   }

   if(top){this.tnbiList.animate({top: top},{duration: 1500, cueue: false, complete: function(){self.tnbiScrollActivate(self.tnbiList.position().top);}});}
   else{this.tnbiScrollActivate(tnbiListPos);}
  }
 
  this.startdelayTnbiAdjust = function(){
   this.clearAlleffect();
   this.delayTnbiAdjust = setTimeout(function(){self.adjustTnbiListPosition();},1500);
  }
 
  this.clearAlleffect = function(){
   if(this.delayTnbiAdjust){clearTimeout(this.delayTnbiAdjust);}
   //this.tnbiList.stop();
  }

  this.tnbiListUpOff = function(){this.tnbiListUp.css({backgroundPosition: '0 0', cursor: 'default'});}
  this.tnbiListUpActive = function(){this.tnbiListUp.css({backgroundPosition: '-215px 0', cursor: 'pointer'});}
  this.tnbiListUpOn = function(){this.tnbiListUp.css({backgroundPosition: '-430px 0', cursor: 'pointer'});}
  this.tnbiListDownOff = function(){this.tnbiListDown.css({backgroundPosition: '0 0', cursor: 'default'});}
  this.tnbiListDownActive = function(){this.tnbiListDown.css({backgroundPosition: '-215px 0', cursor: 'pointer'});}
  this.tnbiListDownOn = function(){this.tnbiListDown.css({backgroundPosition: '-430px 0', cursor: 'pointer'});}
 
  this.tnbiScrollActivate = function(tnbiListPos){
   if(tnbiListPos < this.tnbiListUpH){this.tnbiListUpActive();}else{this.tnbiListUpOff();}
   if(tnbiListPos > (this.tnbiListBoxH - this.tnbiListH - this.tnbiListUpH)){this.tnbiListDownActive();}else{this.tnbiListDownOff();}
  }
 
  this.tnbiListUpStart = function(){
   var tnbiListPos = this.tnbiList.position().top;
   if(tnbiListPos < this.tnbiListUpH){
    this.clearAlleffect();

     this.tnbiListUpOn();
     this.tnbiListDownActive();
	
	 var top = tnbiListPos + (this.tnbiListBoxH - this.tnbiListUpH*2);
	 if(top > this.tnbiListUpH){top = this.tnbiListUpH;}
     this.tnbiList.animate({top: top},{ cueue: false, complete: function(){
	  self.setTnbiListUp();
	  self.startdelayTnbiAdjust();
	 }});

   }
  }
 
  this.setTnbiListUp = function(){
   var tnbiListPos = this.tnbiList.position().top;
   if(tnbiListPos < this.tnbiListUpH){this.tnbiListUpActive();}
                        else{this.tnbiListUpOff();}
  }
 
  this.tnbiListDownStart = function(){

   var tnbiListPos = this.tnbiList.position().top;
   if(tnbiListPos > (this.tnbiListBoxH - this.tnbiListH - this.tnbiListUpH)){
    this.clearAlleffect();
    this.tnbiListDownOn();
    this.tnbiListUpActive();
  
    var top = tnbiListPos - (this.tnbiListBoxH - this.tnbiListUpH*2);
	var limit_top = this.tnbiListBoxH - this.tnbiListH - this.tnbiListUpH;
    if(top < limit_top){top = limit_top - 10;}
    this.tnbiList.animate({top: top},{ cueue: false, complete: function(){
	 self.setTnbiListDown();
     self.startdelayTnbiAdjust();
    }});
   }
  }
 
  this.setTnbiListDown = function(){
   var tnbiListPos = this.tnbiList.position().top;
   if(tnbiListPos > (this.tnbiListBoxH - this.tnbiListH - this.tnbiListUpH)){this.tnbiListDownActive();}
   else{this.tnbiListDownOff();}
  }

 }

 function currCategory(){
  
  var t = $('table[background="../html/images/item/dot_6.gif"]');
  if(!t.size()){t = $('table[background="../html/images/category/dot_6.gif"]');}
  var es = $('a.crumbsList');
  var es_size = es.size();
 
  if(t.size()){

   var cat_e = es.eq(1);
   var cat_url = cat_e.attr('href').replace('..','http://www.ccucco.com');
   var currA = $('#brand_list a[href="' + cat_url + '"]');
   var currLi = currA.parent();
   currA.pngfix().css({padding: '13px 5px 20px 25px', backgroundPosition: '0 0'});
  }

 }

/*-------------------------------------------------------------------------------*/
/*                                  ブランドサーチ                               */
/*-------------------------------------------------------------------------------*/

 function brandSearch(ini){
  
  var self = this;
  var keys = $(ini.keys_id + ' li');
  var letters = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
  
  this.setSearch = function(){
   this.brandIndexer();
   this.setKeys();
   this.setCurrentBrand();
   $(ini.next_id).mousedown(function(){self.downNextKey();});
   $(ini.prev_id).mousedown(function(){self.downPrevKey();});
   $(ini.all_id).mousedown(function(){self.clearIni();});
  }
  
  this.setKeys = function(){
   keys.each(function(i){
    var e = $(this);
   
    var xPos = self.getXPos(i);
	var yPos = self.getYPos(i);

    e.css({backgroundPosition: xPos + 'px ' + yPos + 'px'})
     .mouseover(function(){self.onKey(e, xPos, yPos)})
     .mouseout(function(){self.outKey(e, xPos, yPos)});

	 if(i < (keys.size()-1)){
	  e.mousedown(function(){self.downKey(e, xPos, yPos, i)});
	 }
	 else{e.mousedown(function(){self.clearIni();});}
   });
  }
  
  this.getXPos = function(i){
   if(!(i%7)){var xPos = 0;}
   else if(!((i-1)%7)){xPos = -25;}
   else if(!((i-2)%7)){xPos = -50;}
   else if(!((i-3)%7)){xPos = -75;}
   else if(!((i-4)%7)){xPos = -100;}
   else if(!((i-5)%7)){xPos = -125;}
   else{xPos = -150;}
   return xPos;
  }

  this.getYPos = function(i){
   if(i<=6){var yPos = 0;}
   else if(i<=13){yPos = -30;}
   else if(i<=20){yPos = -60;}
   else if(i<=27){yPos = -90;}
   else{}
   return yPos;
  }

  this.onKey = function(e, xPos, yPos){
   if(e.attr('cur_key') != 1){
    e.css({backgroundPosition: (xPos -180) + 'px ' + (yPos - 2) + 'px'});
   }
  }

  this.outKey = function(e, xPos, yPos){
   if(e.attr('cur_key') != 1){
    e.css({backgroundPosition: xPos + 'px ' + yPos + 'px'});
   }
  }

  this.downKey = function(e, xPos, yPos ,i){
  
   $(ini.status_id).slideDown();
   this.resetCurKey(this.curXPos, this.curYPos);
   this.curXPos = xPos;
   this.curYPos = yPos;
   this.curI = i;
   e.attr('cur_key',1).css({backgroundPosition: (xPos -180) + 'px ' + (yPos - 2) + 'px'});
   var letter = letters[i];
   $(ini.ini_id).html(letter);
   $(ini.root + ' > li[bi="' + letter + '"]').show();
   $(ini.root + ' > li[bi!="' + letter + '"]').hide();
  }
  
  this.remoteDownKey = function(L){
   var i = letters.indexOf(L);
   var e = $(ini.keys_id + ' li:eq(' + i + ')');
   var xPos = this.getXPos(i);
   var yPos = this.getYPos(i);
   this.downKey(e,xPos,yPos,i);
  }
  
  this.downPrevKey = function(){
   var i = this.curI;
   if(i || i==0){
    if(0 < i){var prevI = i - 1;}
	                    else{prevI = keys.size()-2;}
						
    var e = $(ini.keys_id + ' li:eq(' + prevI + ')');
    var xPos = this.getXPos(prevI);
    var yPos = this.getYPos(prevI);
    this.downKey(e,xPos,yPos,prevI);
   }
  }
  
  this.downNextKey = function(){
   var i = this.curI;
   if(i || i==0){
    if(i < (keys.size()-2)){var nextI = i + 1;}
	                    else{nextI = 0;}
						
    var e = $(ini.keys_id + ' li:eq(' + nextI + ')');
    var xPos = this.getXPos(nextI);
    var yPos = this.getYPos(nextI);
    this.downKey(e,xPos,yPos,nextI);
   }
  }

  this.resetCurKey = function(xPos, yPos){
   $(ini.keys_id + ' li[cur_key="1"]').attr('cur_key',0).css({backgroundPosition: xPos + 'px ' + yPos + 'px'});
  }
  
  this.clearIni = function(xPos, yPos){
   $(ini.status_id).slideUp();
   this.resetCurKey(this.curXPos, this.curYPos);
   $(ini.root + " li").show();
  }
  
  this.setCurrentBrand = function(){
   var par_a = $('a.crumbsList:eq(1)');
   if(par_a){
    var cat_url = par_a.attr("href");
    if(cat_url){cat_url = cat_url.replace('..','http://www.ccucco.com');}
	var curr_a = $(ini.root + ' li a[href*="' + cat_url + '"]');
    if(curr_a.size()){curr_a.parent(ini.list_unit).addClass("current_brand");}
   }
  }
  
  this.brandIndexer = function(){
   var e = $(ini.root + " > li");
   e.each(function(){
    var bi = $(this).text().substr(0,1).toUpperCase();
	$(this).attr('bi',bi);
   });
  }
  
 }


/*-------------------------------------------------------------------------------*/
/*                   　　　　パンくずリストデコレーション　　　                  */
/*-------------------------------------------------------------------------------*/

function topicPath(){
  
 var t = $('table[background="../html/images/item/dot_6.gif"]');
 if(!t.size()){t = $('table[background="../html/images/category/dot_6.gif"]');}
 var es = $('a.crumbsList');
 var es_size = es.size();
 
 if(t.size()){
  var s = '<div id="topic_path"><a class="topic_path_top" href="http://www.ccucco.com/"></a>';

  var e = es.eq(1);
  str = e.html();
    if(str.match('<br') || str.match('<BR')){var c = 'topic_path_double';}
    else{c = 'topic_path_single';}
    s += '<a class="' + c + '" href="' + e.attr('href') + '">' + e.html() + '</a>';
 
  s += '</div>';
  t.replaceWith(s);
 }

}


/*-------------------------------------------------------------------------------*/
/*                                 サブカテゴリーUI                              */
/*-------------------------------------------------------------------------------*/

function subCategoryUI(ini){

 this.target_parrent = '#common_src';
 this.container = 'div#SCUI';
 this.header = 'div#sc_header';
 this.scNboxId = 'sc_navi_box';
 this.scNupId = 'sc_navi_up';
 this.scNdownId = 'sc_navi_down';
 this.navi = 'ul#sc_navi';
 this.contents = 'ul#sc_contents';
 this.sc_title_container = 'div#sc_title_container';
 this.sc_prevId = 'sc_prev';
 this.sc_nextId = 'sc_next';
 this.sc_title_box = 'div#sc_title_box';
 this.scTtitleId = 'scTtitle';
 this.scTsizeXid = 'scTsizeX';
 this.scTsizeYid = 'scTsizeY';
 this.scTsizeBoxId = 'scTsizeBox';
 
 this.item_box_class = 'i_box';
 this.discount_rate_class = 'd_r';
 this.item_name_class = 'i_n';
 this.price_class = 'pr';
 this.discount_price_class = 'd_p';

 this.sc_float_preview = 'div#sc_float_preview';
 this.scFPtitleId = 'scFPtitle';
 this.scFPsizeBox = 'scFPsizeBox';
 this.scFPimgBoxId = 'scFPimgBox';
 this.scFPsizeYid = 'scFPsizeY';
 this.scFPsizeXid = 'scFPsizeX';
 this.scFPsizeZid = 'scFPsizeZ';
 this.scFPmsgId = 'scFPmsg';
 this.scFPcurrId = 'scFPcurr';
 this.scFPitemCount = 'scFPitemCount';
 this.scFPss_interval = 750;
 
 this.item_span = 116;
 this.line_item_size = 4;
 this.navi_select = '#333';
 this.navi_select_sub2 = '#58f';
 this.navi_select_bg = '#dfdfdf';
 
 this.image_path = 'http://www.ccucco.com/site_data/cabinet/item/';
 this.gallery_size = 6;
 this.option_gallery_size = 7;
 this.max_gallery_size = 7;
 
 this.scFPimgsArray = [];
 
 var self = this;

 this.build = function(){
  var scFPtag = this.sc_float_preview.split('#')[0];
  var scFPid = this.sc_float_preview.split('#')[1];
  var scFP = '<' + scFPtag + ' id="' + scFPid + '"><div id="' + this.scFPtitleId + '"></div><div id="' + this.scFPsizeBox + '"><div id="' + this.scFPsizeXid + '"></div><div id="' + this.scFPsizeYid + '"></div><div id="' + this.scFPimgBoxId + '"></div><div id="' + this.scFPsizeZid + '"></div></div><div id="' + this.scFPmsgId + '"></div></' + scFPtag + '>';

  var cBooks = '<div id="zoomTransition"></div><div id="cBooks"><ul id="cBooks_pages"></ul><div id="cBooks_close"></div><div id="cBooks_prev_page"></div><img id="cBooks_page_turn" src="http://www.ccucco.com/site/library/css_bg/cbooks_page_turn.png" /><div id="cBooks_next_page"></div></div>';
  $("body").append(scFP + cBooks);
  this.set_cBooks();

  this.renderer();
  this.scFP = $('#' + this.sc_float_preview.split('#')[1]);
  this.tableIndexer();
  $(this.target_parrent).hide();
  
  this.navi_offset = $(this.navi).offset();
  var scFPleft = this.navi_offset.left + 210;
  this.scFP.css({left: scFPleft});

  $(this.navi + ' li').click(function(){self.changeSc($(this));})
                       .mouseover(function(){self.showFloatPreview($(this));})
                       .mousemove(function(e){self.moveFloatPreview(e);});
  $(this.navi).hover(
                      function(){self.scFP.show(); $(self.sc_float_preview).pngfix();},
                      function(){self.scFP.hide();}
					 );
  this.setStartCondition();
 }


 this.showFloatPreview = function(li_obj){
  this.scFPss = false;
  var sc_idx = li_obj.attr('idx');
  var title = li_obj.find('h4').html();
  //var img_src = li_obj.attr('img_src');
  
  if(!this.scFPimgsArray[sc_idx]){
   var title_table = ini.target.find('table.tt:eq(' + sc_idx + ')');
   var first_table_idx = title_table.attr('id').substr(1) - 0 + 1;
   var imgs = ini.target.find('table:eq(' + first_table_idx + ') img');
   //img_src = imgs.eq(0).attr('src');
   //li_obj.attr('img_src',img_src);
   this.scFPimgsArray[sc_idx] = imgs;
  }
  
  var min_item_size = li_obj.attr('min_item_size');
  var item_size = li_obj.attr('item_size');
  
  if(!min_item_size){
   min_item_size = ini.target.find('table:eq(' + first_table_idx + ') img').size();
   li_obj.attr('min_item_size',min_item_size);
  }

  var first_img = '<img src="' + this.scFPimgsArray[sc_idx].eq(0).attr('src') + '" />';
  var size_y = li_obj.attr('size_y'); if(size_y){size_y = '高さ<br />' + size_y;}else{size_y = ' ';}
  var size_x = li_obj.attr('size_x'); if(size_x){size_x = '幅' + size_x;}else{size_x = ' ';}
  var size_z = li_obj.attr('size_z'); if(size_z){size_z = 'マチ<br />' + size_z;}else{size_z = ' ';}

  var msg = '<span id="' + this.scFPcurrId + '">1</span> / <span id="' + this.scFPitemCount + '">';
  this.scFPcurrId
  if(item_size){msg += item_size + '</span>アイテム';}
  else{
   if(min_item_size<5){msg += min_item_size + '</span>アイテム';}
   else{msg += min_item_size + '</span>アイテム以上...';}
  }
  
  $('#' + this.scFPtitleId).html(title);
  $('#' + this.scFPsizeXid).html(size_x);
  $('#' + this.scFPsizeYid).html(size_y);
  $('#' + this.scFPimgBoxId).html(first_img);
  $('#' + this.scFPsizeZid).html(size_z);
  $('#' + this.scFPmsgId).html(msg);
  this.scFP.show();
  if(this.scFPssTimer){this.scFPssTimer.stop();}
  this.scFPslideShow(sc_idx);
 }
 
 
 this.scFPslideShow = function(sc_idx){
  this.scFPss = true;
  var imgs = this.scFPimgsArray[sc_idx];
  var imgs_size = imgs.length;
  var target = $('#' + self.scFPimgBoxId + ' img');
  var counter = $('#' + self.scFPcurrId);
  var c = 1;
  this.scFPssTimer = $.timer(this.scFPss_interval, function (timer){
   if(self.scFPss && c < imgs_size){
	var img_src = imgs.eq(c).attr('src');
	target.attr('src',img_src);
	counter.html(c+1);
    c++;
    //timer.reset(self.scFPss_interval);
   }else{
    c = 0;
	//timer.reset(self.scFPss_interval);
   }
  });
 }
 

 this.moveFloatPreview = function(e){
  var posX = this.navi_offset.left + 210;
  var posY = e.pageY;
  this.scFP.css({top: posY-110});
 }

 
 this.hideFloatPreview = function(){
  this.scFPss = false;
  this.scFP.hide();
 }


 this.renderer = function(){
  var scNtag = this.navi.split('#')[0];              var scNid = this.navi.split('#')[1];
  var scCtag = this.contents.split('#')[0];          var scCid = this.contents.split('#')[1];
  var scN = '<div id="' + this.scNboxId + '"><' + scNtag + ' id="' + scNid + '">'; //sub category Navigation
  var scC = '<' + scCtag + ' id="' + scCid + '">'; //sub category Contents

  scC += '<' + this.sc_title_container.split('#')[0] + ' id="' + this.sc_title_container.split('#')[1] + '"><div id="' + this.sc_prevId + '"></div><div id="' + this.sc_nextId + '"></div><' + this.sc_title_box.split('#')[0] + ' id="' + this.sc_title_box.split('#')[1] + '"><div id="' + this.scTsizeXid + '"></div><div id="' + this.scTsizeYid + '"></div><div id="' + this.scTsizeBoxId + '"></div><div id="' + this.scTtitleId + '"></div></div></div>';

  var cat_anchors = ini.target.find('a[name]'); //category anchors
  this.scFPimgsArray = new Array(cat_anchors.size());

  cat_anchors.each(function(i){
   $(this).next('table').attr('class','tt'); //marking title tables
   var scNames = $(this).attr('name').replace(/　/,' ').split(' ');
   var scName = scNames[0];
   var scNameDecorated = [];
   var scSizeStr;
   var sizeYXZ = ['','','']; //need for no size item! if without this, an error

   for(j=1; j<scNames.length; j++){
    scNameDecorated = self.listDecoration(j,scNames[j]);
	if(!scNameDecorated[1]){
     scName += scNameDecorated[0];
	}
	if(scNameDecorated[1]){scSizeStr = scNameDecorated[0]};
   }

   if(scSizeStr){
    sizeYXZ = self.getItemSize(scSizeStr);
   }

   scN += '<li idx="' + i + '" size_y="' + sizeYXZ[0] + '" size_x="' + sizeYXZ[1] + '" size_z="' + sizeYXZ[2] + '"><a href="#sc' + i+'' + '"><h4>' + scName + '</h4></a></li>';
   scC += '<li></li>';
  });
  scN += '</' + scNtag + '><div id="' + this.scNupId + '"></div><div id="' + this.scNdownId + '"></div></div>';
  scC += '</' + scCtag + '>';

  var header = $(this.container).children(this.header);//.hide();
  header.after(scN+scC).hide();
  $(this.contents + ' li').hide();
 }
 

 this.listDecoration = function(i,str){
  var size_flag = 0;
  if(i == 2){new_str = '<br />';}
  if(str.search(/[0-9\.]+(cm|ｃｍ)/) >= 0){
   size_flag = 1;
   new_str = '<br /><span class="size">' + str.replace(/ｃｍ/,'cm').replace(/[Xx]/,'×') + '</span>';
  }
  else{new_str = ' <span class="sub2cat">' + str + '</span>';}
  return [new_str,size_flag];
 }


 this.getItemSize = function(str){
  var sizeY = str.match(/高さ([0-9\.]+(cm|mm))/) + '';
  var sizeYval = sizeY.split(',')[1];
  if(!sizeYval){sizeYval = '';}
  var sizeX = str.match(/幅([0-9\.]+(cm|mm))/) + '';
  var sizeXval = sizeX.split(',')[1];
  if(!sizeXval){sizeXval = '';}
  var sizeZ = str.match(/マチ([0-9\.]+(cm|mm))/) + '';
  var sizeZval = sizeZ.split(',')[1];
  if(!sizeZval){sizeZval = '';}
  return [sizeYval,sizeXval,sizeZval];
 }
 
 
 this.tableIndexer = function(){
  this.tables = ini.target.find('table');
  this.tables.each(function(j){$(this).attr('id','t' + j);});
 }
 
 
 this.setStartCondition = function(){
  
  this.curr_id = location.hash.substr(3);
  //if(location.hash == '#cat'){this.curr_id == ini.start_index;}
  if(!this.curr_id || isNaN(this.curr_id - 0)){
   this.curr_id = ini.start_index;
   this.url = document.location.href.split('#')[0];
   document.location.href = this.url + '#sc' + this.curr_id;
  }
  var e = $(this.navi + ' li:eq(' + this.curr_id + ')');

  this.sc_idx = this.curr_id;
  this.setSCNscroll();
  this.setSCchanger();
  this.changeSc(e);
 }
 
 
 this.setSCchanger = function(){
  this.sc_size = $(this.navi + ' li').size();
  $('#' + this.sc_prevId).click(function(){self.sc_prev();});
  $('#' + this.sc_nextId).click(function(){self.sc_next();});
 }


 this.sc_prev = function(){
  if(this.sc_idx > 0){var idx = this.sc_idx - 1;}
  else{idx = this.sc_size-1;}
  var e = $(this.navi + ' li:eq(' + idx + ')');
  this.changeSc(e);
 }


 this.sc_next = function(){
  if(this.sc_idx < this.sc_size-1){var idx = this.sc_idx +1;}
  else{idx = 0;}
  var e = $(this.navi + ' li:eq(' + idx + ')');
  this.changeSc(e);
 }
 
 /*---------------------------------
  SC navi scroll
 ---------------------------------*/
 this.setSCNscroll = function(){
  var box = $('#' + this.scNboxId);
  this.scn = $(this.navi);
  this.scnH = this.scn.height();
  this.scNboxH = box.height();
  
  this.scNup = $('#' + this.scNupId);
  this.scNdown = $('#' + this.scNdownId);
  this.scNupH = this.scNup.height();
  
  if(this.scnH > this.scNboxH - this.scNupH*2){
   this.scNup.pngfix();
   this.scNdown.pngfix();
   this.adjustSCNposition();
   
   box.hover(
    function(){},
	function(){self.startDelaySCNadjust();}
   );
  
   
   this.scNup.click(function(){self.scNupStart();});
   this.scNdown.click(function(){self.scNdownStart();});
  }
  else{
   this.scn.css({top: this.scNupH});
   this.scNupOff(); this.scNdownOff();
  }
 }

 this.adjustSCNposition = function(){
  this.clearAlleffect(); 
  var scnPos = this.scn.position().top;
  var e = $(this.navi + ' li:eq(' + this.sc_idx + ')');
  var curr_pos = e.position().top;
  var curr_h = e.height();
  
  if(curr_pos + curr_h > this.scNboxH - this.scNupH*2){
   var top = (this.scNboxH - this.scNupH) - (curr_pos + curr_h);
   var restH = this.scnH - (curr_pos + curr_h);
   if(restH > 5){
    if(restH > this.scNboxH/2){restH = this.scNboxH/2 - this.scNupH;}
    top = top - restH;
   }
  }
  else if(scnPos + curr_pos - this.scNupH < 0){
   if(curr_pos + curr_h > this.scNboxH/2){top = (this.scNboxH/2) - curr_pos + this.scNupH;}
   else{top = this.scNupH;}
  }

  if(top){this.scn.animate({top: top},{duration: 1000, complete: function(){self.scNscrollActivate(self.scn.position().top);}});}
  else{this.scNscrollActivate(scnPos);}
 }
 
 this.startDelaySCNadjust = function(){
  this.clearAlleffect();
  this.delaySCNadjust = setTimeout(function(){self.adjustSCNposition();},1500);
 }
 
 this.clearAlleffect = function(){
  this.scn.stop();
  if(this.delaySCNadjust){clearTimeout(this.delaySCNadjust);}
 }

 this.scNupOff = function(){this.scNup.css({backgroundPosition: '0 0', cursor: 'default'});}
 this.scNupActive = function(){this.scNup.css({backgroundPosition: '-215px 0', cursor: 'pointer'});}
 this.scNupOn = function(){this.scNup.css({backgroundPosition: '-430px 0', cursor: 'pointer'});}
 this.scNdownOff = function(){this.scNdown.css({backgroundPosition: '0 0', cursor: 'default'});}
 this.scNdownActive = function(){this.scNdown.css({backgroundPosition: '-215px 0', cursor: 'pointer'});}
 this.scNdownOn = function(){this.scNdown.css({backgroundPosition: '-430px 0', cursor: 'pointer'});}
 
 this.scNscrollActivate = function(scnPos){
  if(scnPos < this.scNupH){this.scNupActive();}else{this.scNupOff();}
  if(scnPos > (this.scNboxH - this.scnH - this.scNupH)){this.scNdownActive();}else{this.scNdownOff();}
 }
 
 this.scNupStart = function(){
  this.clearAlleffect();
  var scnPos = this.scn.position().top;
  if(scnPos < this.scNupH){
   this.scNupOn();
   this.scNdownActive();
   
   var top = scnPos + (this.scNboxH - this.scNupH*2);
   if(top > this.scNupH){top = this.scNupH;}
   this.scn.animate({top: top},{complete: function(){self.scNupSet();}});
  }
 }
 
 this.scNupSet = function(){
  var scnPos = this.scn.position().top;
  if(scnPos < this.scNupH){this.scNupActive();}
                       else{this.scNupOff();}
 }
 
 this.scNdownStart = function(){
  this.clearAlleffect();
  var scnPos = this.scn.position().top;
  if(scnPos > (this.scNboxH - this.scnH - this.scNupH)){
   this.scNdownOn();
   this.scNupActive();
  
   var top = scnPos - (this.scNboxH - this.scNupH*2);
   var limit_top = this.scNboxH - this.scnH - this.scNupH;
   if(top < limit_top){top = limit_top - 10;}
   this.scn.animate({top: top},{complete: function(){self.scNdownSet();}});
  }
 }
 
 this.scNdownSet = function(){
  var scnPos = this.scn.position().top;
  if(scnPos > (this.scNboxH - this.scnH - this.scNupH)){this.scNdownActive();}
  else{this.scNdownOff();}
 }
 
 
 /*---------------------------------
  change SC
 ---------------------------------*/
 this.changeSc = function(e){

  var old = $(this.contents + ' li[dFg = "1"]');
  if(old.size()>0){
   old.attr('dFg','0').hide();
  }

  this.changeScStyle(e);

  //var sc_idx = $(this.navi + ' li').index(e);
  var sc_idx = e.attr('idx') - 0;
  this.sc_idx = sc_idx;
  var sc_title = e.find('h4').text();
  $('#' + this.scTtitleId).html(sc_title);

  var title_table = ini.target.find('table.tt:eq(' + sc_idx + ')');
  var first_table_idx = title_table.attr('id').substr(1) - 0 + 1;

  var sc_size = $(this.navi + ' li').size();
  if(sc_idx == sc_size - 1){
   var last_table_idx = this.tables.size() - 1;
  }
  else{
   var next_title_table = ini.target.find('table.tt:eq(' + (sc_idx+1) + ')');
   last_table_idx = next_title_table.attr('id').substr(1) - 0 - 1;
  }

  var curr = $(this.contents + ' li:eq(' + sc_idx + ')');

  if(!curr.attr('rFg')){
   this.i_counter = 0;
   curr.attr({rFg:1, dFg: 1}).html(this.scStr(first_table_idx,last_table_idx));
   var items = $(this.contents + ' li:eq(' + sc_idx + ') div.' + this.item_box_class);
   var items_count = items.size();
   items.click(function(){self.cBooksLounch($(this));});
   e.attr('item_size',items_count);
   this.scFPimgsArray[sc_idx] = items.find('img');
  }
  else{
   curr.attr({dFg: 1});
   items_count = e.attr('item_size');
  }

  if(this.cBooksChangeItems(items_count)){curr.fadeIn('750');}
  
  var w = e.attr('size_x');
  var h = e.attr('size_y');
  this.setTitleBox(w,h);
  
  this.adjustSCNposition();
 }


 this.setTitleBox = function(w,h){
  var size_x = w.replace('cm','').replace('mm','') - 0;
  var size_y = h.replace('cm','').replace('mm','') - 0;
  
  if(size_x && size_y){
   var x_rate = size_x/200;
   if(x_rate>1){size_x = size_x/x_rate; size_y = size_y/x_rate;}
   else{
    if(size_x < 75){size_x = size_x*2.6; size_y = size_y*2.6}
    else if(size_x < 100){size_x = size_x*2; size_y = size_y*2}
    else{}
   }

   $('#' + this.scTsizeYid).css({paddingTop: size_y/2.5}).html(h).show();
   var pL = $('#' + this.scTsizeYid).width() + (size_x/2.5);
   $('#' + this.scTsizeXid).css({paddingLeft: pL}).html(w).show();
   $('#' + this.scTsizeBoxId).css({width: size_x, height: size_y}).show();
  }
  else{
   $('#' + this.scTsizeXid).hide();
   $('#' + this.scTsizeYid).hide();
   $('#' + this.scTsizeBoxId).hide();
  }
  
  var box_h = $(this.sc_title_box).height() + 20;
  $('#' + this.sc_prevId).height(box_h);
  $('#' + this.sc_nextId).height(box_h);
 }
 

 this.scStr = function(f,l){

  var scStr = '';
  for(var i = f; i <= l; i++){
   var items = ini.target.find('table:eq(' + i + ') a');
   items.each(function(j){
	self.i_counter++;
    scStr += self.itemStr($(this));
   });
  }
  return scStr;
 }
 
 
 this.itemStr = function(item){
  
  var item_url = item.attr('href');
  var img_url = item.children('img').attr('src');
  
  if(item.children('font').size() == 4){
   var discount_rate = item.children('font:eq(0)').html() + ' ▼';
   var item_name = item.children('font:eq(1)').html();
   var price = item.children('font:eq(2)').html();
   var discount_price = item.children('font:eq(3)').html();
  }
  else{
   discount_rate = null;
   item_name = item.children('font:eq(0)').html();
   discount_price = item.children('font:eq(1)').html();
  }

  var s = '<div item_url="' + item_url + '" class="' + this.item_box_class + '" idx="' + (this.i_counter-1) + '">';
  s += '<img src="' + img_url + '" />';
  if(discount_rate){s += '<span class="' + this.discount_rate_class + '">' + discount_rate + '</span>';}
  s += '<p><span class="' + this.item_name_class + '">' + item_name + '</span>';
  //if(price){s += '<span class="' + this.price_class + '">' + price + '</span>';}
  s += '<span class="' + this.discount_price_class + '">' + discount_price + '</span>';
  s += '</p></div>';

  return s;
 }


 this.changeScStyle = function(e){
  $(this.navi + ' li').attr('style','');
  $(this.navi + ' li a').attr('style','');
  $(this.navi + ' li a span').attr('style','');
  e.children('a').css({
                        color: this.navi_select,
						backgroundColor: this.navi_select_bg
                       });
  //e.children('a').children('h4').children('span').css({color: this.navi_select_sub2});
 }

 /*---------------------------
   cBooks initialize
 ---------------------------*/ 
 this.set_cBooks = function(){
 
  this.mode_name = 'cbooks';

  this.zt = $('#zoomTransition');
  this.modalOverlay = $('#modalOverlay');
  this.cBooks = $('#cBooks');
  this.cBooks_close = $('#cBooks_close');
  
  this.cBooks_prev_page = $('#cBooks_prev_page');
  this.cBooks_prev_page_able = {backgroundPosition: '0 0', cursor: 'pointer'}
  this.cBooks_prev_page_disable = {backgroundPosition: '-90px 0px', cursor: 'default'}

  this.cBooks_next_page = $('#cBooks_next_page');
  this.cBooks_next_page_able = {backgroundPosition: '-200px 0px', cursor: 'pointer'}
  this.cBooks_next_page_disable = {backgroundPosition: '0 0', cursor: 'default'}
  
  this.cBooksWidth = 900;
  this.cBooksHeight = 704;
  this.cBooksShadow_size = 25;
  this.ztF_w = this.cBooksWidth - this.cBooksShadow_size*2;
  this.ztF_h = this.cBooksHeight - this.cBooksShadow_size*2;
  
  this.cBooks_imgs_size = 6;
  this.cBooks_option_imgs_size = 7;
  this.cBooks_image_path = 'http://www.ccucco.com/site_data/cabinet/item/';
  
  this.cBooksPageWidth = 758;
  
  this.page_turn_blocker = false;
  this.page_turn_nextStart = {width: 0, left: 848, opacity: 0}
  this.page_turn_nextFinish = {width: 90, left: -10, opacity: 0.7}
  this.page_turn_prevStart = {width: 124, left: -34, opacity: 1.0}
  this.page_turn_prevFinish = {width: 0, left: 800, opacity: 0.8}
  
  this.cBooks_prev_page.click(function(){self.cBooks_prevPage();});
  this.cBooks_next_page.click(function(){self.cBooks_nextPage();});
  
  this.cBooks_tabLeftOn = {backgroundPosition: '0 -22px'}
  this.cBooks_tabLeftOff = {backgroundPosition: '0 0'}
  this.cBooks_tabRightOn = {backgroundPosition: 'right -22px'}
  this.cBooks_tabRightOff = {backgroundPosition: 'right 0'}
 }
 
 /*---------------------------
   cBooks items change
  ---------------------------*/
 this.cBooksChangeItems = function(items_count){
  this.items_count = items_count;
  this.cBooksImagesLoadCounters = new Array(items_count);
  
  var s = '';
  for(i=0; i<this.items_count; i++){
   s += '<li class="cBooks_page" idx="' + (this.items_count-i-1) + '"></li>';
  }
  
  $('#cBooks_pages').html(s);
  return true;
 }
 
 /*---------------------------
   cBooks Lounch & Close
  ---------------------------*/
 this.cBooksLounch = function(e){
 
  this.curr_item_idx = e.attr('idx');
  this.cBooksPageRender(e,this.curr_item_idx,1);

  var offset = e.offset();
  this.ztS_left = offset.left;
  this.ztS_top = offset.top;
  this.ztS_w = e.width();
  this.ztS_h = e.height();

  this.cBooksPopup();
  this.modalOverlay.click(function(){self.cBooksHide();});
  this.cBooks_close.click(function(){self.cBooksHide();});
  
  if(0 < this.curr_item_idx && this.curr_item_idx < this.items_count-1){
   this.cBooks_prev_page.css(this.cBooks_prev_page_able); //html(this.curr_item_idx);
   this.cBooks_next_page.css(this.cBooks_next_page_able); //html(this.curr_item_idx - 0 + 2);
  }
  else if(this.curr_item_idx == 0){
   this.cBooks_prev_page.css(this.cBooks_prev_page_disable); //.html('');
   if(this.items_count == 1){this.cBooks_next_page.css(this.cBooks_next_page_disable);}
   else{this.cBooks_next_page.css(this.cBooks_next_page_able);} //.html(this.curr_item_idx - 0 + 2);}
  }
  else{
   this.cBooks_prev_page.css(this.cBooks_prev_page_able); //.html(this.curr_item_idx);
   this.cBooks_next_page.css(this.cBooks_next_page_disable); //.html(this.curr_item_idx - 0 + 1);
  }

 }

 this.cBooksPopup = function(){

  var arrPageSizes = getPageSize();
  var arrPageScroll = getPageScroll();

  this.modalOverlay.css({
   backgroundColor:	'#fff',
   opacity:	0,
   width: arrPageSizes[0],
   height: arrPageSizes[1]
  }).show();

  if(arrPageSizes[0] >= this.cBooksWidth){
   var cBooksLeftPos = (arrPageSizes[0]/2) - (this.cBooksWidth/2);
  }else{cBooksLeftPos = 0;}
  
  var finalTop = arrPageScroll[1] + (arrPageSizes[3] / 10);
  var finalLeft = cBooksLeftPos;
  
  this.ztF_left = finalLeft + this.cBooksShadow_size;
  this.ztF_top = finalTop + this.cBooksShadow_size;
  
  this.zt.css({left: this.ztS_left, top: this.ztS_top, width: this.ztS_w, height: this.ztS_h, opacity: 0.4, display: 'block'})
          .animate(
                   {left: this.ztF_left, top: this.ztF_top, width: this.ztF_w, height: this.ztF_h, opacity: 0.8},
                   {duration: 200, queue: false , complete: function(){$(this).hide(); self.cBooksShow(finalLeft,finalTop);}}
			      );
 }
 
 this.cBooksShow = function(finalLeft, finalTop){
  this.modalOverlay.attr('mode',this.mode_name).css({opacity: 0.65});
  this.cBooks.css({left: finalLeft, top: finalTop}).show();
  this.cBooksLeft = this.cBooks.offset().left;
 }
 
 this.cBooksHide = function(){
  if($(this.modalOverlay).attr('mode') == this.mode_name){
   var e = $(this.contents + ' li:eq(' + this.sc_idx + ') div.' + this.item_box_class + ':eq(' + this.curr_item_idx + ')');
   var offset = e.offset();
   this.ztS_left = offset.left;
   this.ztS_top = offset.top;
   this.ztS_w = e.width();
   this.ztS_h = e.height();
   
   this.modalOverlay.css({opacity: 0});
   $('li.cBooks_page').css({width: 0});
   this.cBooks.hide();
   this.zt.show()
           .animate(
                    {left: this.ztS_left, top: this.ztS_top, width: this.ztS_w, height: this.ztS_h, opacity: 0.4},
                    {duration: 200, queue: false, complete: function(){self.zt.fadeOut(350,function(){self.modalOverlay.attr('mode','null').hide();});}}
		           );
  }
 }
 
 /*---------------------------
   cBooks PageRender
  ---------------------------*/
 this.cBooksPageRender = function(e,idx,show_option){
  var page_container = $('li.cBooks_page[idx="' + idx + '"]');
  if(!show_option){page_container.hide().css({width: 0});}
  if(!page_container.attr('rFg') || !this.cBooksImagesLoadCounters[idx]){
   page_container.html(this.cBooksPageSrc(e,idx))
                 .attr('rFg','1');
  }
  if(show_option){page_container.show().css({width: this.cBooksPageWidth});}
  return false;
 }
 
 this.cBooksPageSrc = function(e,idx){
  this.item_url = e.attr('item_url');
  var img_url = e.find('img').attr('src');
  this.p_code = getPcodeFromImgUrl(img_url);
  this.discount_rate = e.find('.d_r').text();
  this.item_name = e.find('.i_n').text();
  this.price = e.find('.pr').text();
  this.discount_price = e.find('.d_p').text();

  this.cBooksImagesLoadCounters[idx] = [0,0,0];
  var s = '<div class="cBooks_imgs_base">' + this.cBooksImageStackRender(this.p_code,idx) + '</div>';
  s += '<div class="cBooks_imgs_slider"></div>';
  s += '<div class="cBooks_infoBox"><p class="i_n">' + this.item_name + '</p><p class="d_p">' + this.discount_price + '</p>';
  s += '<a class="cBooks_link0" href="' + this.item_url + '">⇒さらに詳しく...</a>';
  s += '<a class="cBooks_link1" href="' + this.item_url + '"></a></div>';

  return s;
 }
 
 
 this.cBooks_prevPage = function(){
  if((this.curr_item_idx-0) > 0 && !this.page_turn_blocker){
  
   this.page_turn_blocker = true;
   var prev_idx = this.curr_item_idx-1;
   var e = $(this.contents + ' li:eq(' + this.sc_idx + ') div.' + this.item_box_class + ':eq(' + prev_idx + ')');
   
  
   var page_container = $('li.cBooks_page[idx="' + this.curr_item_idx + '"]');
   var prev_page_container = $('li.cBooks_page[idx="' + prev_idx + '"]');
   var page_turn = $('#cBooks_page_turn');
   page_container.hide().css({width: 0});

   this.cBooks_next_page.css(this.cBooks_next_page_disable); //.html('');
   page_turn.css(self.page_turn_prevStart)
            .show()
            .animate(
                     self.page_turn_prevFinish,
                     500,
                     function(){
                                  self.cBooksPageRender(e,prev_idx);
                                  prev_page_container.css({width: self.cBooksPageWidth}).show();
								  $(this).fadeOut('fast');
								  self.cBooks_next_page.css(self.cBooks_next_page_able); //.html(prev_idx + 2);
								  self.page_turn_blocker = false;
								  self.scUIchecker(prev_idx);
                                 }
                    );
   this.curr_item_idx = prev_idx;
   this.cBooks_prev_page.css(this.cBooks_prev_page_able); //.html(prev_idx);
   if(prev_idx == 0){this.cBooks_prev_page.css(this.cBooks_prev_page_disable).html('');}
  }
 }

 this.cBooks_nextPage = function(){
  if(this.curr_item_idx < this.items_count-1 && !this.page_turn_blocker){
   
   this.page_turn_blocker = true;
   var next_idx = (this.curr_item_idx-0)+1;
   var e = $(this.contents + ' li:eq(' + this.sc_idx + ') div.' + this.item_box_class + ':eq(' + next_idx + ')');

   var page_container = $('li.cBooks_page[idx="' + this.curr_item_idx + '"]');
   var next_page_container = $('li.cBooks_page[idx="' + next_idx + '"]');
   var page_turn = $('#cBooks_page_turn');
   page_container.animate({width: 0},500);
   
   this.curr_item_idx = next_idx;
   this.cBooks_next_page.css(this.cBooks_next_page_disable); //.html('');

   page_turn.css(self.page_turn_nextStart)
            .show()
            .animate(
                     self.page_turn_nextFinish,
                     650,
                     function(){
                                  self.cBooksPageRender(e,next_idx);
                                  self.cBooks_prev_page.css(self.cBooks_prev_page_able); //.html(next_idx);
                                  next_page_container.css({width: self.cBooksPageWidth}).show();
                                  $(this).fadeOut('fast');
                                  if(next_idx == self.items_count-1){self.cBooks_next_page.css(self.cBooks_next_page_disable);} //.html(next_idx+1);}
                                  else{self.cBooks_next_page.css(self.cBooks_next_page_able);} //.html(next_idx+2);}
								  self.page_turn_blocker = false;
								  self.scUIchecker(next_idx);
                                 }
                    );		 
  }
 }


 this.cBooksImageStackRender = function(p_code,idx){
  var s = '<div class="cBooks_imgs">';

  var src0 = this.cBooks_image_path + p_code + '-0.gif';
  s += '<img src="' + src0 + '" onerror="' + ini.obj_name + '.imageLoadListener(' + idx + ',this,0)" onload="' + ini.obj_name + '.imageLoadListener(' + idx + ',this,1)" />';
  
  var src1 = this.cBooks_image_path + p_code + '-0.jpg';
  s += '<img src="' + src1 + '" onerror="' + ini.obj_name + '.imageLoadListener(' + idx + ',this,0)" onload="' + ini.obj_name + '.imageLoadListener(' + idx + ',this,1)" />';
  
  for(var i = this.cBooks_imgs_size; i >=1 ; i--){
   var src = this.cBooks_image_path + p_code + '-' + i + '.jpg';
   s += '<img src="' + src + '" onerror="' + ini.obj_name + '.imageLoadListener(' + idx + ',this,0)" onload="' + ini.obj_name + '.imageLoadListener(' + idx + ',this,1)" />';
  }
    
  for(var j = 5; j >= 1; j--){
   var s2 = this.cBooks_image_path + p_code + '-0' + j + '.jpg';
   s += '<img src="' + s2 + '" onerror="' + ini.obj_name + '.imageLoadListener(' + idx + ',this,0)" onload="' + ini.obj_name + '.imageLoadListener(' + idx + ',this,1)" />';
  }
  s += '</div>';

  return s;
 }


 this.imageLoadListener = function(idx,e,lFg){
  this.cBooksImagesLoadCounters[idx][0]++;
  if(!lFg){
   $(e).remove();
   this.cBooksImagesLoadCounters[idx][1]++;
  }
  var max_img_size = this.cBooks_imgs_size + this.cBooks_option_imgs_size;
  if(this.cBooksImagesLoadCounters[idx][0] == max_img_size){
   if(this.cBooksImagesLoadCounters[idx][1] == max_img_size){
    $('#cbooks_imgs').html('<span>No images...</span>'); 
   }
   else{
    this.cBooksImagesLoadCounters[idx][2] = 1;
	if(idx == this.curr_item_idx){
     if(this.cBooksImagesLoadCounters[idx][0] - this.cBooksImagesLoadCounters[idx][1] >1){
	  $('li.cBooks_page[idx="' + idx + '"] .cBooks_imgs').css({backgroundImage: 'none'});
      this.cBooks_imageChangeUI(idx);
	 }
	 else{
	  $('li.cBooks_page[idx="' + idx + '"] .cBooks_imgs img').show();
	  $('li.cBooks_page[idx="' + idx + '"] .cBooks_imgs_slider').hide();
	 }
	}
   }

  }
 } 

 
 this.scUIchecker = function(idx){
  var page = $('li.cBooks_page[idx="' + idx + '"]');
  if(this.cBooksImagesLoadCounters[idx][2] && !page.attr('acui')){
   //$('li.cBooks_page[idx="' + idx + '"] .cBooks_imgs').unbind('mousemove');
   this.cBooks_imageChangeUI(idx);
  }
 }
 

 this.cBooks_imageChangeUI = function(idx){
  var imgs_slider = $('li.cBooks_page[idx="' + idx + '"] .cBooks_imgs_slider');
  var imgs_size = this.cBooksImagesLoadCounters[idx][0] - this.cBooksImagesLoadCounters[idx][1];

  var slider_width = Math.floor(598/imgs_size);
  var s = '';
  for(i = 0; i<imgs_size; i++){
   s += '<div><span class="cBooks_tabR">pic.' + (i+1) + '</span></div>';
  }
  
  imgs_slider.html(s);
  $('li.cBooks_page[idx="' + idx + '"] .cBooks_imgs_slider div').css({width: slider_width});

  imgs_slider.mousemove(function(e){self.cBooks_imageSlideEvent(e,idx,slider_width,imgs_size);});
								   
  this.cBooks_imageChanger(idx,0);
  $('li.cBooks_page[idx="' + idx + '"]').attr('acui',1);
 }
 

 this.cBooks_imageSlideEvent = function(e,idx,slider_width,imgs_size){
  var posX = e.pageX - this.cBooksLeft - 90;
  var img_idx = Math.floor(posX/slider_width);
  if(img_idx >= imgs_size){img_idx = imgs_size-1;}
  this.cBooks_imageChanger(idx,img_idx);
 }
 
 
 this.cBooks_imageChanger = function(item_idx,img_idx){  
  $('li.cBooks_page[idx="' + item_idx + '"] .cBooks_imgs img').hide();
  $('li.cBooks_page[idx="' + item_idx + '"] .cBooks_imgs_slider div').css(this.cBooks_tabLeftOff);
  $('li.cBooks_page[idx="' + item_idx + '"] .cBooks_imgs_slider span').css(this.cBooks_tabRightOff);
  
  $('li.cBooks_page[idx="' + item_idx + '"] .cBooks_imgs img:eq(' + img_idx + ')').show();
  $('li.cBooks_page[idx="' + item_idx + '"] .cBooks_imgs_slider div:eq(' + img_idx + ')').css(this.cBooks_tabLeftOn);
  $('li.cBooks_page[idx="' + item_idx + '"] .cBooks_imgs_slider div:eq(' + img_idx + ') span').css(this.cBooks_tabRightOn);
 }




}

/*-------------------------------------------------------------------------------*/
/*                                   　commons                                   */
/*-------------------------------------------------------------------------------*/

function tagRemover(str){
 var name = str.replace(/<\/?[^>]+>/gi, '');
 return name;
 //return str;
}

function getPcodeFromImgUrl(url){
 var url_es = url.split("/");
 var last_idx = url_es.length - 1;
 var f_name = url_es[last_idx];
 
 var p_code = f_name.split("-")[0];
 
 return p_code;
}

/**
 * From --- jQuery lightBox plugin
 * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
 * and adapted to me for use like a plugin from jQuery.
 * @name jquery-lightbox-0.5.js
 * @author Leandro Vieira Pinho - http://leandrovieira.com
 * @version 0.5
 * @date April 11, 2008
 * @category jQuery plugin
 * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
 * @license CC Attribution-No Derivative Works 2.5 Brazil - http://creativecommons.org/licenses/by-nd/2.5/br/deed.en_US
 * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
 */
 
function getPageSize(){
 var xScroll, yScroll;
 if (window.innerHeight && window.scrollMaxY) {
  xScroll = window.innerWidth + window.scrollMaxX;
  yScroll = window.innerHeight + window.scrollMaxY;
 }
 else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
  xScroll = document.body.scrollWidth;
  yScroll = document.body.scrollHeight;
 }
 else{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
  xScroll = document.body.offsetWidth;
  yScroll = document.body.offsetHeight;
 }
 var windowWidth, windowHeight;
 if (self.innerHeight) {	// all except Explorer
  if(document.documentElement.clientWidth){
   windowWidth = document.documentElement.clientWidth; 
  }
  else {
   windowWidth = self.innerWidth;
  }
  windowHeight = self.innerHeight;
 }
 else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
  windowWidth = document.documentElement.clientWidth;
  windowHeight = document.documentElement.clientHeight;
 }
 else if (document.body) { // other Explorers
  windowWidth = document.body.clientWidth;
  windowHeight = document.body.clientHeight;
 }	
 // for small pages with total height less then height of the viewport

 if(yScroll < windowHeight){
  pageHeight = windowHeight;
 }
 else{ 
  pageHeight = yScroll;
 }
 // for small pages with total width less then width of the viewport
 if(xScroll < windowWidth){	
  pageWidth = xScroll;		
 }
 else{
  pageWidth = windowWidth;
 }
 arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
 return arrayPageSize;
};

function getPageScroll() {
 var xScroll, yScroll;
 if (self.pageYOffset) {
  yScroll = self.pageYOffset;
  xScroll = self.pageXOffset;
 }
 else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
  yScroll = document.documentElement.scrollTop;
  xScroll = document.documentElement.scrollLeft;
 }
 else if (document.body) {// all other Explorers
  yScroll = document.body.scrollTop;
  xScroll = document.body.scrollLeft;	
 }
 arrayPageScroll = new Array(xScroll,yScroll);
 return arrayPageScroll;
};


