////////////////////////////////////////////////
//
// util.js[ver1.1 080618]
//
////////////////////////////////////////////////

var util = {
	preloader: {
		loadedImages: [],
		load: function (url){
			var img = this.loadedImages;
			var l = img.length;
			img[l] = new Image();
			img[l].src = url;
		}
		},

     URI: function(s){
		this.originalPath = s;
		this.getAbsolutePath = function(path){
			if (!path.match(/^(mailto:)|(javascript:)/)) {
				var img = new Image();
				img.src = path;
				path = img.src;
				img.src = '#';
			}
			return path;
		};
		this.absolutePath = this.getAbsolutePath(s);
		this.isSelfLink = (this.absolutePath == location.href);
		var fields = {'schema' : 2, 'username' : 5, 'password' : 6, 'host' : 7, 'path' : 9, 'query' : 10, 'fragment' : 11};
		var r = /^((\w+):)?(\/\/)?((\w+):?(\w+)?@)?([^\/\?:]+):?(\d+)?(\/?[^\?#]+)?\??([^#]+)?#?(\w*)/.exec(this.absolutePath);
		for (var field in fields) {
			this[field] = r[fields[field]]; 
		}
	}
};


$(function(){
$('.hover').each(function(){					  
	this.originalSrc = $(this).attr('src');
		if ((/\d\.(jpg|gif|png)/).test(this.originalSrc)){
			this.rolloverSrc = this.originalSrc.replace(/(\.)(jpg|gif|png)/,"hover.$2");	
		}else{
			this.rolloverSrc = this.originalSrc.replace(/(\.)(jpg|gif|png)/,"Hover.$2");
		}	
	util.preloader.load(this.rolloverSrc);
});

$(".hover").hover(function(){
	$(this).attr('src',this.rolloverSrc);
}, function(){
	$(this).attr('src',this.originalSrc);
});

$('.gNavi li a').each(function(){
		var href = new util.URI(this.getAttribute('href'));
		if (href.isSelfLink && !href.fragment) {
			$(this).addClass('c');
		}
});

$('a.newwin').click(function(){
window.open(this.href, '_blank');
return false;
});
});
