
slider = function() {

    //スライド表示
    absLeft = 0;
    total = $('.thumb img').length;
    $totalImgs = $('.thumb img');

    //初期化
    $("#recipe_loading_value").text("0");

    thumbWidth = 0;
    thumbWidth = recipeBlock.getImgLength(total,$totalImgs);

    thumbWidth = total * 110;//150
    if(thumbWidth < 400){
      thumbWidth = 420;//最低サイズを設定
    }

    $('#innerContainer').css({ width: thumbWidth + 'px' });//コンテナの横の長さを設定する
    $('#innerContainer img').css({ display: 'inline' });//消す

    //左スクロール
    $('#slideLeftHigh').hover(function(e) {
      $('#innerContainer').stop();
      $('#innerContainer').animate({ "left": "0px" }, total*400, "linear")
      }, function() {
      $('#innerContainer').stop();
    });
    $('#slideLeftLate').hover(function(e) {
        $('#innerContainer').stop();
        $('#innerContainer').animate({ "left": "0px" }, total*100, "linear")
        }, function() {
        $('#innerContainer').stop();
    });

    //右スクロール
    $('#slideRightHigh').hover(function(e) {
      thumbWidth = recipeBlock.getImgLength(total,$totalImgs);
      $('#innerContainer').css({ width: thumbWidth + 'px' });

      //posLeft = $('#thumbnails').offset().left;
      //absLeft = e.pageX - posLeft;
      boxSize = $('#thumbnails').outerWidth();
      hiddenBit = thumbWidth - 400;//boxSize;// - absLeft;//- 370;//500;

      if(hiddenBit < 0){
        return;
      }
      $('#innerContainer').stop();
      $('#innerContainer').animate({ "left": -hiddenBit + "px" }, total*400, "linear")
      }, function() {
      $('#innerContainer').stop();
    });
    $('#slideRightLate').hover(function(e) {
        thumbWidth = recipeBlock.getImgLength(total,$totalImgs);
        $('#innerContainer').css({ width: thumbWidth + 'px' });
          posLeft = $('#thumbnails').offset().left;
          absLeft = e.pageX - posLeft;
          hiddenBit = thumbWidth - 370;//500;
          if(hiddenBit < 0){
            return;
          }
          $('#innerContainer').stop();
          $('#innerContainer').animate({ "left": -hiddenBit + "px" }, total*100, "linear")
          }, function() {
          $('#innerContainer').stop();
    });

    /**
    * レシピチェンジ
    */
    $('.thumb').click(function() {
      htmlStr = $(this).html();//htmlの取得
      currentLarge = $(this).attr('class').split(' ').slice(-1);//p4とか取得
      try{
         htmlStr = document.getElementById("p"+currentLarge).innerHTML;
        if(jQuery.browser.msie || jQuery.browser.safari ){
           htmlStr = document.getElementById("recipe_block "+currentLarge).innerHTML;
        }
        //レシピチェンジ二度押し対策
        $("#recipe_loading_value").text(""+currentLarge);
      }catch(e){

        //ロード画像の表示
        $("#recipe_block > div").remove();
        //$('#recipe_block').css('background-color','#FFFFFF');
        $("#recipe_block").html('<div><table width="630"  height="440" border="0" class="load_icon"><tr><td width="100%" height="100%" align="center" valign="center"><img alt="" src="g5/shared/image/ure.gif"></td></tr></table></div>').fadeIn(300);

        //レシピチェンジ用のフラグを設定する
        $("#recipe_loading_value").text(""+currentLarge);
        return;
      }


      $('#recipe_block').fadeOut(300, function() {

                if(jQuery.browser.msie){
                  //$('#recipe_block').css('background-image','url(\"g5/shopping/image/recipebg_head2_02.gif\")');
                }
                $('#recipe_block > div').remove();

                $('#recipe_block').html(htmlStr).fadeIn(300,function(){$('#recipe_block').scrollTop(0);
                                              $('.other_zairyo').css('display','none');
                                              if(!jQuery.browser.mozilla){
                                                $('#recipe_block').css('overflow-x','hidden');
                                              }
                                              //google analytics計測
                                              javascript:pageTracker._trackPageview("/urecipe/list.html?recipeId="+currentLarge+"&change=true");
                                            });//gallery();
              });
      });
}

var recipeBlock = {
  getImgLength:function(total, obj){
        $totalImgs = obj;
        var thumbWidth = 0;
        var imgWidth;
        for (x = 0; x < total; x++) {

          imgWidth = $($totalImgs[x]).outerWidth();

          //if(imgWidth != $($totalImgs[x]).outerWidth()){
            //alert('NG');
          //}
          var count = 0;
          while(imgWidth < 45){//画像サイズが取得できない対応 とりあえずsize45以下をチェック
            setTimeout(function(){}, 500 * (count + 1));
            imgWidth = $($totalImgs[x]).outerWidth();
            if(count == 10){
              //10回まわしたらあきらめる
              //thumbWidth += 50;
              break;
            }
            count++;
          }
          //thumbWidth +=$($totalImgs[x]).outerWidth()+17;
          thumbWidth += imgWidth + 10;//85
        }
    return thumbWidth;
  },

  loopWait:function( timeWait ){
      var timeStart = new Date().getTime();
      var timeNow = new Date().getTime();
      while( timeNow < (timeStart + timeWait ) )
      {
          timeNow = new Date().getTime();
      }
      return;
  },

  analytics:function(recipeId){

    javascript:pageTracker._trackPageview("/urecipe/list.html?recipeId="+recipeId+"&flame=true");
  }
};



