//サムネイル画像サイズ調整
jQuery.event.add(window, "load", resize100);
jQuery.event.add(window, "load", resize110);
jQuery.event.add(window, "load", resize150);
jQuery.event.add(window, "load", resize240);


function resize100(){
  $('img.re100').each(function(){
    var w = $(this).width();
    var h = $(this).height();
    if (w >= h) {
      $(this).width(100);
      $(this).height("auto");
    } else {
      $(this).width("auto");
      $(this).height(100);
    }
  });
}
function resize110(){
  $('img.re110').each(function(){
    var w = $(this).width();
    var h = $(this).height();
    if (w >= h) {
      $(this).width(110);
      $(this).height("auto");
    } else {
      $(this).width("auto");
      $(this).height(110);
    }
  });
}
function resize150(){
  $('img.re150').each(function(){
    var w = $(this).width();
    var h = $(this).height();
    if (w >= h) {
      $(this).width(150);
      $(this).height("auto");
    } else {
      $(this).width("auto");
      $(this).height(150);
    }
  });
}
function resize240(){
  $('img.re240').each(function(){
    //var w = $(this).width();
    //var h = $(this).height();
    var newImg = new Image();
    newImg.src=$(this).attr("src");
    var w= newImg.width;
    var h= newImg.height;
    if(w>120 && h>120){
      if (w >= h) {
        $(this).width(240);
        $(this).height("auto");
      } else {
        $(this).width("auto");
        $(this).height(240);
      }
    }
  });
}


//マウスオーバー動作登録
function setGenruMenu(path){
  onMHover('#shopheader .btn_home a',"HOME",path+'home.gif',path+'home_rool.gif');
  onMHover('#shopheader .btn_kaitori a',"高額買取",path+'kaitori.gif',path+'kaitori_rool.gif');
  onMHover('#shopheader .btn_houga a',"邦画",path+'houga.gif',path+'houga_rool.gif');
  onMHover('#shopheader .btn_youga a',"洋画",path+'youga.gif',path+'youga_rool.gif');
  onMHover('#shopheader .btn_anime a',"アニメ",path+'anime.gif',path+'anime_rool.gif');
  onMHover('#shopheader .btn_idol a',"アイドル",path+'idol.gif',path+'idol_rool.gif');
  onMHover('#shopheader .btn_general a',"アラカルト",path+'general.gif',path+'general_rool.gif');
  //onMHover('#shopheader .btn_adult a',"アダルト",path+'adult.gif',path+'adult_rool.gif');
  onMHover('#shopheader .btn_akb48 a',"AKB48",path+'akb.gif',path+'akb_rool.gif');
  onMHover('#shopheader .btn_bluray a',"Blu-ray",path+'bluray.gif',path+'bluray_rool.gif');
}
//マウスオーバー登録関数
function onMHover(sel,title,out,over){
  $(sel).empty().append('<img src="'+out+'" alt="'+title+'">');
  $(sel).hover(
    function () {$(sel+">img").attr("src",over);},
    function () {$(sel+">img").attr("src",out);}
  );
}
//マウスオーバー動作登録
function setGenruMenu_kaitori(path){
  onMHover('#shopheader .btn_home a',"HOME",path+'home.gif',path+'home_rool.gif');
  onMHover('#shopheader .btn_kaitori a',"買取センター",path+'kaitori.gif',path+'kaitori_rool.gif');
  onMHover('#shopheader .btn_flow a',"買取の流れ",path+'flow.gif',path+'flow_rool.gif');
  onMHover('#shopheader .btn_qaa a',"よくある質問",path+'qaa.gif',path+'qaa_rool.gif');
  onMHover('#shopheader .btn_inquiry a',"お問合せ",path+'inquiry.gif',path+'inquiry_rool.gif');
  onMHover('#shopheader .btn_shopabout a',"店舗案内",path+'shopabout.gif',path+'shopabout_rool.gif');
}
//アダルト用マウスオーバー動作登録
function setGenruMenu_adult(classname,select){
  if(select=="")select="home";
  $(".btn_"+select+" a").attr("class","genre_selected");
  $(classname).hover(function(){if($(this).parent().attr("class")!="btn_"+select)$(this).attr("class","genre_menu_over")},function(){if($(this).parent().attr("class")!="btn_"+select)$(this).attr("class","genre_menu_out")});
}

//マウスオーバー動作登録
function setGenruMenu_shop(path){
  onMHover('#shopheader .btn_home a',"HOME",path+'home.gif',path+'home_rool.gif');
  onMHover('#shopheader .btn_houga a',"邦画",path+'houga.gif',path+'houga_rool.gif');
  onMHover('#shopheader .btn_youga a',"洋画",path+'youga.gif',path+'youga_rool.gif');
  onMHover('#shopheader .btn_anime a',"アニメ",path+'anime.gif',path+'anime_rool.gif');
  onMHover('#shopheader .btn_general a',"アラカルト",path+'general.gif',path+'general_rool.gif');
}


//検索ボックス初期化
function initSearch(ao,genre,kwd){
  if(ao=="")ao="and";
  $("#search input[name='sop_ao']").val([ao]);
  $("#search select[name='sop_genre']").val([genre]);
  $("#search input[name='sop_kwd']").val(kwd);

  //通常検索hidden要素初期化
  $("#search input[name='Submit']").click(function(){
    //転送先を修正
    var genre=$("#search select[name='sop_genre']").val();
    $("#search form").attr("action","http://"+genre+".monkey.co.jp/list.php#itemlist");
    //$("#search form").attr("action","http://localhost/monkeysoft/"+genre+"/list.php");
    $("#search input[type=hidden]").each(function(index){$(this).val("");});
  });
}
//アダルト検索ボックス初期化
function initSearch_adult(ao,genre,kwd){
  if(ao=="")ao="and";
  $("#search input[name='sop_ao']").val([ao]);
  $("#search select[name='sop_genre2']").val([genre]);
  $("#search input[name='sop_kwd']").val(kwd);

  //通常検索hidden要素初期化
  $("#search input[name='Submit']").click(function(){
    $("#search input[type=hidden]").each(function(index){$(this).val("");});
  });
}




