// Use jQuery

/*
	PreLoad & RollOver (_off -> _over)
----------------------------------------------------------------------*/
$(function(){
	var preLoad = new Object();
	$('img').each(function(){
		try {
			if ($(this).attr('src').match(/_off\./i)) {
				var preImg = $(this).attr('src').replace(/_off\./i, '_over.');
				preLoad[preImg] = new Image();
				preLoad[preImg].src = preImg;
				$(this).hover(function(){
					$(this).attr('src', $(this).attr('src').replace(/_off\./i, '_over.'));
				},
				function(){
					$(this).attr('src', $(this).attr('src').replace(/_over\./i, '_off.'));
				});
			}
		} catch(e){}
	});
});

/*
	Go Top Page (#top)
----------------------------------------------------------------------*/
$(function(){
	$('a').click(function(){
		if ($(this).attr('href').match(/#top/i)) {
			$(this).blur();
			$('html,body').animate({scrollTop: 0}, 1000, 'easeOutExpo');
			return false;
		}
	});
});

/*
	Pop Up Window (#popup)
----------------------------------------------------------------------*/
$(function(){
	var defaultWidth = 640;
	$('a').click(function(){
		if ($(this).attr('target').match(/popup/i)) {
			$(this).blur();
			var t = $(this).attr('target');
			var r = $(this).attr('rel').split(',');
			if (!r[1]) {
				r[1] = (navigator.userAgent.indexOf('Opera', 0) >= 0)
				? $(window).innerHeight() - 30
				: screen.availHeight - 110;
			}
			if (!r[0]) {
				r[0] = defaultWidth;
			}
			var o =
				',toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=yes'+
				',screenX=0,screenY=0,left=10,top=10';
			window.open(this.href, t, 'width='+r[0]+',height='+r[1]+o);
			return false;
		}
	});
});

