(function($){
	$(function() {
	//easyOverのターゲット設定
    $("img.ahover, .ahoverArea img").easyOver();
	//IE5,6にてPNG有効化 (pngfixの読み込みが必要)
    //$("img[src$=png],p.png").enablePNG();
  //HTML5タグ有効化
  	  $.enableHTML5();
	//アンカーリンクをスムージング
		$(".pagetop a[href^=#]").smoothScroll();
	//heightline
	  $(".separator").heightline(".box");
	});
})(jQuery);

/**
 * auto link to active
 */
(function($){
  $(function(){
    var matcher = location.pathname.match(/(.*)\/.*/);
    var path = matcher[1];

    if (/^(\/v2)?\/visual/.test(path)){
      $('a[rel="VISUAL"]').addClass("active");
    }
    else if(
      /^(\/v2)?\/item\/homme/.test(path) ||
      /^(\/v2)?\/look\/homme/.test(path)
    ){
      $('a[rel="HOMME"]').addClass("active");
    }
    else if (
      /^(\/v2)?\/item\/femme/.test(path) ||
      /^(\/v2)?\/look\/femme/.test(path)
    ) {
      $('a[rel="FEMME"]').addClass("active");
    }
    else if (
      /^(\/v2)?\/item\/accessory/.test(path) ||
      /^(\/v2)?\/look\/accessory/.test(path)
    ) {
      $('a[rel="ACCESSORY"]').addClass("active");
    }
    else if (/^(\/v2)?\/shoplist/.test(path)){
      $('a[rel="SHOPLIST"]').addClass("active");
    }
    else if (/^(\/v2)?\/column/.test(path)){
      $('a[rel="COLUMN"]').addClass("active");
    }
    else if (/^(\/v2)?\/news/.test(path)){
      $('a[rel="NEWS"]').addClass("active");
    }
    else if (/^(\/v2)?\/order/.test(path)){
      $('a[rel="ORDER"]').addClass("active");
    }
    else if (/^(\/v2)?\/law/.test(path)){
      $('a[rel="LAW"]').addClass("active");
    }
    else if (/^(\/v2)?\/about/.test(path)){
      $('a[rel="ABOUT US"]').addClass("active");
    }
    else if (/^(\/v2)?\/contact/.test(path) ||
             /^(\/v2)?\/admin\/plugins\/MailForm/.test(path)
    ){
      $('a[rel="CONTACT"]').addClass("active");
    }
    else {
      $('a[rel="HOME"]').addClass("active");
    }
	});
})(jQuery);

(function(){
  $(function(){
    $(".items").each(function(){
      var cnt = 0;
      var elmArr = [];
      $(this).find(".item").each(function(){
        cnt++;
        var amari = cnt%3;
        elmArr[amari] = this;
        if(amari == 0){
          var maxBodyHeight = 0;
          var maxTitleHeight = 0;
          $(elmArr).each(function(){
            var $title = $(this).find("h3");
            maxTitleHeight = Math.max(maxTitleHeight, $title.height());
            maxBodyHeight  = Math.max(maxBodyHeight, $(this).height());
          });
          $(elmArr).height(maxBodyHeight);
          $(elmArr).each(function(){
            var $title = $(this).find("h3");
            $title.height(maxTitleHeight);
          });
        }
        if(amari == 1){
          $(this).css("clear", "both");
        }
      });
    });
    
    if(!$(".topItemsArea").size()){
      $('li.lookitem .thumb a').colorbox({maxWidth:"85%", maxHeight:"85%",rel:'group1'});
      $('li.item').each(function(){

        if($(this).hasClass("lookitem")) return;
        if($(".orderitems").size()) return;

        var $firstColor = $(this).find('ul a:first');
        $(this).find('ul a').each(function(){
          $(this).css("outline","none");
          $(this).colorbox({maxWidth:"85%", maxHeight:"85%"});
        });
        $(this).find('.thumb a').click(function(){
          $firstColor.click();
          return false;
        });
      });
      
      $(document).bind('cbox_open', function(){
        $("#cboxOverlay").height(10000);
      });
    }

  })
})(jQuery);

(function($){
  $(function(){
    $("#FooterTwitter").each(function(){
      var $this = $(this)
      $this.find(".togglePop").click(function(){
        $this.find(".pop").toggle();
        return false;
      });
    })
  });
})(jQuery);
