/**
 * @version  1.00
 * @updated  2008/04/01
 */



if (jQuery.browser.safari && jQuery.browser.version < 500) {
	jQuery(window).load(function () {
		scroll();
		hover();
		if (jQuery('table.stripe')) stripe_table();
		if (jQuery('ul.horizon')) height();
	});
}
else {
	jQuery(document).ready(function () {
		scroll();
		hover();
		if (jQuery('table.stripe')) stripe_table();
		if (jQuery('ul.horizon')) height();
	});
}


/* scroll */

function scroll() {
	jQuery('head').append('<script type="text/javascript" src="/data/shared/js/lib/scroll.js"></script>');
	
	jQuery('a[href*=#page-top]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var target = jQuery(this.hash);
			target = target.length && target;
			if (target.length) {
				var sclpos = 30;
				var scldurat = 1200;
				var targetOffset = target.offset().top - sclpos;
				jQuery('html,body')
					.animate({scrollTop: targetOffset}, {duration: scldurat, easing: "easeOutExpo"});
				return false;
			}
		}
	});

}


/* hover */

function hover() {
	var preLoad = new Object();
	jQuery('img.hover,input.hover').not("[src*='_c.']").each(function(){
		var imgSrc = this.src;
		var fType = imgSrc.substring(imgSrc.lastIndexOf('.'));
		var imgName = imgSrc.substr(0, imgSrc.lastIndexOf('.'));
		var imgOver = imgName + '_c' + fType;
		preLoad[this.src] = new Image();
		preLoad[this.src].src = imgOver;
		jQuery(this).hover(
			function (){
				this.src = imgOver;
			},
			function (){
				this.src = imgSrc;
			}
		);
	});
}


/* stripe_table */

function stripe_table() {
	jQuery('table.stripe').each(function(){
		jQuery(this).children('tbody').each(function(){
			jQuery(this).children('tr:even').not('tr.tbl-h2,tr.tbl-h3').each(function(){
				this.className = 'even';
			});
		});
	});
}



/* height */

function height() {
	
	jQuery('ul.horizon').each(function(){
		var highest = 0;
		
		jQuery(this).children().each(function(){
			var height = jQuery(this).height();
			
			if(height > highest) {
				highest = height;
			}
			
			jQuery(this).children().height(highest);
		});
	});
}
