var arr_fontSize  = {"fsSmall": "9pt",
                     "fsMiddle": "11pt",
                     "fsLarge" : "13pt"
                     };
var cookieName = "uheroFontSize";

$(document).ready(function(){
  // IEチラツキ防止
 $("html, body").css("background", "#fbfbfb url('../images/bg_footer.gif') top left repeat");
  
  // fsChanger 20111201 atarashi@uTeam
  var fontsizeCookie = $.cookie(cookieName);

  if(fontsizeCookie){
    $("html").css("font-size", arr_fontSize[fontsizeCookie]);
    $("."+fontsizeCookie).addClass("active");
  }else{
    $("html").css("font-size", arr_fontSize["fsMiddle"]);
    $(".fsMiddle").addClass("active");
  }
  fsImgChanger();
  
  $(".fsSmall, .fsMiddle, .fsLarge").click(function(){
    if($(this).hasClass(".active"))
      return false;
    $(".fsSmall, .fsMiddle, .fsLarge").removeClass("active");
    $.cookie(cookieName, $(this).attr("class"), {expires: 7, path: '/'});
    $("html").css("font-size", arr_fontSize[$(this).attr("class")]);
    
    $(this).addClass("active");
    fsImgChanger();
  });

  // new_window 20111201 atarashi@uTeam
  $(".new_window").click(function(){
    window.open($(this).attr("href"), "newWin");
    return false;
  });

  $(".new_window").keydown(function(e){
    if(e.keyCode == 13){
      $(this).bind("click.prevent", function(e){ e.preventDefault(); });
      $(this).trigger("click");
      return false;
    }
  });
});

/**
 * fsChanger画像変更関数 20111201 atarashi@uTeam
 */
function fsImgChanger(){
  $(".fsSmall, .fsMiddle, .fsLarge").each(function(){
    if($(this).hasClass("active")){ //on
      $(this).find("img").attr("src", $(this).find("img").attr("src").replace(/_on\.(png|gif)$/, ".$1").replace(/\.(png|gif)/, "_on.$1"));
    }else{ //off
      $(this).find("img").attr("src", $(this).find("img").attr("src").replace(/_on\.(png|gif)$/, ".$1"));
    }
  });
}
