/*----------------------------------------------------------------------------------------------------
  common.js
  sokun.net
  charset=utf-8
-----------------------------------------------------------------------------------------------------*/

/*--------------------------------------------------
  rollover
---------------------------------------------------*/

$(function(){
	$("img.rob").mouseover(function(){
		$(this).attr("src",$(this).attr("src").replace(/^(.+)_n(\.[a-z]+)$/, "$1_h$2"));
	}).mouseout(function(){
		$(this).attr("src",$(this).attr("src").replace(/^(.+)_h(\.[a-z]+)$/, "$1_n$2"));
	}).each(function(){
		$("<img>").attr("src",$(this).attr("src").replace(/^(.+)_n(\.[a-z]+)$/, "$1_h$2"));
	});
});

/*--------------------------------------------------
  rollover (sub navigation)
---------------------------------------------------*/

if (dir == 0) {
	var path = './';
} else if (dir == 1) {
	var path = '../';
} else if (dir == 2) {
	var path = '../../';
}

function snOver(vBoxId) { 
	var element = document.getElementById(vBoxId); 
	element.style.backgroundImage = 'url(' + path + 'images/common/navi/snavi_list_bg_h.jpg)'; 
}

function snOut(vBoxId) { 
	var element = document.getElementById(vBoxId); 
	element.style.backgroundImage = 'url(' + path + 'images/common/navi/snavi_list_bg_n.jpg)'; 
}

/*--------------------------------------------------
  display control
---------------------------------------------------*/

window.onload = function() {
	pageTopCtl();
}

function pageTopCtl() {
	if (document.documentElement.scrollHeight) {
		var vDH = document.documentElement.scrollHeight;
	} else if (document.body.scrollHeight) {
		var vDH = document.body.scrollHeight;
	}
	if (window.innerHeight) {
		var vWH = window.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight != 0) {
		var vWH = document.documentElement.clientHeight;
	} else if (document.body) {
		var vWH = document.body.clientHeight;
	}
	if (vDH > vWH) {
		var element = document.getElementById('pageTop');
		if (element) {
			element.style.display = 'block';
		}
	}
}

/*--------------------------------------------------
  scroll follow (use jQuery)
---------------------------------------------------*/

jQuery(function() {
	jQuery('#sideL').scrollFollow({ speed: 200, offset: -10 });
});

/*--------------------------------------------------
  smooth scroll (use jQuery)
---------------------------------------------------*/

jQuery.easing.quart = function(x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

jQuery(document).ready(function() {
	jQuery('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = jQuery(this.hash);
			$target = $target.length && $target || jQuery('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				jQuery('html,body').animate({ scrollTop: targetOffset }, 1200, 'quart');
				return false;
			}
		}
	});
});

/* END */

