// use all page
dispatcher('.', function () {
  $(function () {
    // ロールオーバー
    $('.btn').meca('hover');
    // 外部リンク
    $('a.external').meca('external');
    // pngfix
    $('.pngfix').meca('pngfix');
    // pngfix（背景画像）
    $('.bgpng').meca('bgpngfix');
    // 高さ揃え
    $('.heightAlign').meca('heightAlign');
    // IE6でposition fixed
    $('.fixed').meca('positionFixed');
    // スムーズスクロール
    $('a[href^="#"]').meca('smoothScroll');
    // OSのクラス追加
    $('body').meca('addOsClass');
    // IEで画像のlabel押せるようにする
    $('label img').meca('labelClickable');
    // active
    $('.hasActive').meca('active');
    //placeholder
    $('input[placeholder], textarea[placeholder]').meca('placeholder');
  });
});

function dispatcher (path, func) {
  dispatcher.path_func = dispatcher.path_func || []
  if (func) return dispatcher.path_func.push([path, func]);
  for(var i = 0, l = dispatcher.path_func.length; i < l; ++i) {
    var func = dispatcher.path_func[i];
    var match = path.match(func[0]);
    match && func[1](match);
  };
};
dispatcher(location.pathname);

$(function(){
	//背景100%処理
	if($('#supersize').length>0){
		$.fn.supersized.options = {
			slideshow: 0
		}
		$('#supersize').supersized();
	}
	
	//トップページボタンアニメーション
	$('#contentHome #main #blockMovie a').each(function(){
	var _deftop = $(this).next().css('top').split('px')[0];
	$(this).hover(
	function(){
		$(this)
		.css({ 
			backgroundColor: "#ffffff",
			opacity: 0.7
		})
		.parent().css({
			backgroundColor: "#ffffff"
		})
		.end()
		.next()
		.stop(true,true)
		.css({ top : _deftop })
		.animate({
			top: _deftop-10
		},200)
		.animate({
			top: _deftop
		},200,"swing")
	},
	function(){
		$(this).css({ 
			backgroundColor: "#000000",
			opacity: 1
		})
	});
	
	$('#contentHome #main #blockBanner a').hover(
	function(){
		$(this)
		.css({ 
			backgroundColor: "#ffffff",
			opacity: 0.7
		})
		.parent().css({
			backgroundColor: "#ffffff"
		})
	},
	function(){
		$(this).css({ 
			backgroundColor: "#000000",
			opacity: 1
		});
	});
	});
	
	//コンテンツ上下中央寄せ
	function positioningMainContents(){
		var _target = $('#blockEntry,#blockSmirnoffMovie,#blockSmirnoffMovieEnd,#blockError');
		if(_target.length <= 0) return;
		var offset;
		if(_target[0].id=='contentHome'){
			offset = 25;
		}else if(_target[0].id=='blockSmirnoffMovie'){
			offset = 30;
		}else{
			offset = 0;
		}
		var mainH = ($('#footer').offset().top-_target.height())/2-offset;
		_target.css({
			'top' : mainH
		});
	}
	/*
	$(window).bind('resize',function(){
		positioningMainContents();
	});
	
	$(function(){
		positioningMainContents();
	})
	*/
	//footer伸ばす
	function fitFooter(){
		var _f = $('#footer');
		var _h = $(window).height()-_f.offset().top;
		if(_f.offset().top<10){
			_h = 100;
		}
		if(_h<100) _h = 100;
		_f.css({ height:_h });
	}
	
	$(window).bind('resize',function(){
		fitFooter();
	});
	
	
	$(function(){
		setTimeout(function(){
			fitFooter();
		},100);
	});
	
	//セレクトボックス
	if($('#selectCountry').length>0){
		$('#selectCountry').easySelectBox();
	};

});

