/* --------------------------------
file name   : global.js
last update : May 20, 2010
-------------------------------- */

$(document).ready(function(){
  userAgent();
	smoothScroll();
	rolloverImage();
	setTarget();
});
function userAgent() {
	var os, ua = navigator.userAgent;
	if (ua.match(/Win(dows )?NT 6\.0/)) {
		os = "win";
	} else if (ua.match(/Win(dows )?NT 6\.1/)) {
		os = "win";
	} else {
		os = "";
	}
	$('body').addClass(os);
}


function smoothScroll() {
	$('a[href^=#]').click(function() { 
		var href= this.hash; 
		var $target = $(href == '#_top' ? 'body' : href); 
		if($target.size()) { 
			var top = $target.offset().top; 
			$($.browser.safari ? 'body' : 'html').animate({scrollTop:top}, 800, 'swing'); 
		} 
		return false; 
	}); 
}
function rolloverImage() {
	var image_cache = new Object();
	$("img.rollover,.rollover a img").not("[src*='-ovr.'],[src*='-cur.']").each(function(i) {
		var imgsrc = this.src;
		var dot = this.src.lastIndexOf('.');
		var imgsrc_ovr = this.src.substr(0, dot) + '-ovr' + this.src.substr(dot, 4);
		image_cache[this.src] = new Image();
		image_cache[this.src].src = imgsrc_ovr;
		$(this).hover(
			function() { this.src = imgsrc_ovr; },
			function() { this.src = imgsrc; });
	});
}

function setTarget() {
	$("a[href*='http'],a[href*='pdf'],a[href*='mail']").each(function(i) {
		$(this).attr('target','_blank');
	});
}

