//var main_recipe;
//var search_flg = 0;

var tsushoId = 0;
var main_recipe;
var height = 410;
var recipe = {

  setOtherRecipe:function(){
      var recpeId;
      var count = 1;
      $(main_recipe).find('.recipe_id').each(function(){
          recpeId = $(this).text();
          recipe.recommend(recpeId,count);
          //count++;
      });
  },

  open:function(htmlStr){
      $("#windowContent table").remove();
      $("#window").css({'width':645,'z-index':500});
      $("#window").css({'overflow-y':'auto'});//815

      $("#windowContent").append(htmlStr);

      $("#recipe_block").css({'width':'640px','height':height,'overflow-y':'auto','overflow-x':'hidden'});

      if(jQuery.browser.msie){
        document.getElementById('window').style.display = "block";
      }else{
        $("#window").fadeIn("normal");
      }
  },

  recommend:function(recipeID,count) {
    if(count != 1){
      return;
    }
      //ajax call
        if(!jQuery.browser.msie){
          jQuery().ajaxSend(function(event, XMLHttpRequest, options){
              XMLHttpRequest.overrideMimeType("text/plain; charset=shift_jis");
            });
        }
        
        
        
        $.ajax({
            url: './RecipeShousai.htm?recipeId='+recipeID+'&param=3&itemId='+tsushoId,
            dataType : 'html',
            timeout : 10000,
            scriptCharset:'SJIS',
            beforeSend:function(XHRoj){
            },
            success:function(msg,status){
              $("#recipe_block_none").append(msg);
              $("div#recipe_block_none > div > div").css({'height':height});
            //メインレシピ表示も行う場合
              checkId = $("#recipe_loading_value").text();
              if(recipeID == checkId){
                  $('#recipe_block').fadeOut(300, function() {
                      if(jQuery.browser.msie){
                        //$('#recipe_block').css('background-color','#FFFFFF');
                      }
                      $('#recipe_block > div').remove();
                      //$('#recipe_block').html(msg);.fadeIn(300);//$(msg).children("div").html()
                      $('#recipe_block').html(msg).fadeIn(300,function(){
                      							$('#recipe_block > div > div').css({'height':height});
                                            });
                    });
              }

            }
       });
   },

  load:function(loadUrl,num){
      if(!jQuery.browser.msie){
          jQuery().ajaxSend(function(event, XMLHttpRequest, options){
              XMLHttpRequest.overrideMimeType("text/plain; charset=shift_jis");
          });
      }
      //20100507 suzuki mod start
      var top = $("div#div_zentai").height();
      if(num == 0){
          height = top - 100;
      }else{
          height = top - 300;
      }

      if(num != 0 && height > 410){
        height = 410;
      }else if(num == 0 && height > 650){
      	height = 650;
      }
      
      if(top > 700){
        top = 700;
      }
      $.ajax({
            url: loadUrl,
            dataType : 'html',
            timeout : 10000,
            scriptCharset:'SJIS',
            beforeSend:function(XHRoj){
                $("#windowContent table").remove();
                if(num == 1){
                  $("#windowContent div").remove();
                }
                 //ロード画像の表示
                 $("#windowContent table").remove();
                 $("#windowContent").append('<table width="630"  height="'+(top-70)+'" 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>');

                 //表示位置の指定
                 if(jQuery.browser.msie){//ie
                     $("#window").css({'left':0,'top':0});
                 }else{
                   left = $("#centercontent").width() /2;
                   top  = $("#centercontent").height();
                   $("#window").css({'left':10,'top':10,'z-index':500});
                 }
                 if(jQuery.browser.msie){
                     document.getElementById('window').style.display = "block";
                   }else{
                     $("#window").fadeIn("normal");
                   }
            },
            success:function(msg,status){
              recipe.open(msg);
               if(num == 0){
                 $('#windowContent > div > div').css({'height':height});
               }
               main_recipe = msg;

            },
            complete:function(){
              if(num == 1){
                recipe.setOtherRecipe();
              }
            }
      });
  }
};



