// JavaScript Document


// rollover  
function rollOver(){
	var preLoad = new Object();
	$('img.ov,input.ov').not("[src*='_ov.']").each(function(){
		var imgSrc = this.src;
		var fType = imgSrc.substring(imgSrc.lastIndexOf('.'));
		var imgName = imgSrc.substr(0, imgSrc.lastIndexOf('.'));
		var imgOver = imgName + '_ov' + fType;
		preLoad[this.src] = new Image();
		preLoad[this.src].src = imgOver;
		$(this).hover(
				function (){
					this.src = imgOver;
				},
				function (){
					this.src = imgSrc;
				}
		);
	});
}
$(document).ready(rollOver);

// pagescroll
/*
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 }, 700, 'quart');
				return false;
			}
		}
	});

});
*/
// popup 

$(function () {
	$('.bubbleInfo').each(function () {
		 var distance = 10;
		 var time = 250;
		 var hideDelay = 500;
		 var hideDelayTimer = null;
		 var beingShown = false;
		 var shown = false;
		 var trigger = $('.trigger', this);
		 var info = $('.popup', this).css('opacity', 0);
		 $([trigger.get(0), info.get(0)]).mouseover(function () {
			  if (hideDelayTimer) clearTimeout(hideDelayTimer);
			  if (beingShown || shown) {
					// don't trigger the animation again
					return;
			  } else {
					// reset position of info box
					beingShown = true;
					info.css({
						 top: -20,
						 left: -60,
						 display: 'block'
					}).animate({
						 top: '-=' + distance + 'px',
						 opacity: 1
					}, time, 'swing', function() {
						 beingShown = false;
						 shown = true;
					});
			  }
			  return false;
		 }).mouseout(function () {
			  if (hideDelayTimer) clearTimeout(hideDelayTimer);
			  hideDelayTimer = setTimeout(function () {
					hideDelayTimer = null;
					info.animate({
						 top: '-=' + distance + 'px',
						 opacity: 0
					}, time, 'swing', function () {
						 shown = false;
						 info.css('display', 'none');
					});
			  }, hideDelay);
			  return false;
		 });
	});
});

