/* !javascript Information *****************************
* 
* @Auther cyocun
*
***************************************************** */

$(function() {

	//swap images button
	var postfix = '_o';
	$('.swap').not('[src*="'+ postfix +'."]').each(function() {
		var img = $(this);
		var src = img.attr('src');
		var src_on = src.substr(0, src.lastIndexOf('.')) + postfix + src.substring(src.lastIndexOf('.'));
		$('<img>').attr('src', src_on);
		img.hover(function() {img.attr('src', src_on);},function() {img.attr('src', src);});});
	
	$(".blank").click(function(){
		window.open(this.href,'_blank');
	return false;
	});



	//smooth scroll
	$('a.scroll').click(
		function() {
			if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname)
				var target = $(this.hash);
				target = target.length && target;
				
				if (target.length)
					var sclpos = 30;
					var scldurat = 1200;
					var targetOffset = target.offset().top - sclpos;
					$('html,body').animate({scrollTop: targetOffset}, {duration: scldurat, easing: "easeOutExpo"});
					return false;
		}
	);
	
	/*-------------
	flatHeight
	--------------*/
	($.browser.safari ? $(window).load : $).call($(window), function () {
		/**
		* 【使い方】
		*
		* 1.親要素のclassに flatHeight-（1行の子要素数） を指定する。
		*   設定可能な親要素はdivとulのみ。
		*   例）<ul class="clearfix flatHeight-4">
		* 
		* 2.全子要素の高さを揃えたい場合は、
		*   親要素のclassに flatHeightParent を指定する。
		*   例）<ul class="clearfix flatHeightParent">
		*
		* 3.孫要素の高さを揃えたい場合は、
		*   親要素のclassに flatHeight-（1行の子要素数）C（孫要素のindex（0～）） を指定する。
		*   例）<ul class="clearfix flatHeight-4C1">
		*         <li>
		*           <div>                   </div>
		*           <div>このdivの高さが揃う</div>
		*           <div>                   </div>
		*
		* setFlatHeightElements()を実行することで要素リストが作成される。
		* ページがロードされた時、または、動的に作成された要素の高さを揃えたい場合に実行する。
		* 
		*/
		setFlatHeightElements();
	});

});
