

/* -----------------------------------------------------------------
Customized by CSS HappyLife
Licensed under the MIT License:

jQuery_Auto 0.9 + yuga.js 0.3.0 + heightLine customize
--------------------------------------------------------------------
- Original

+  jQuery_Auto.js
     http://sputnik.pl/code/javascript/jquery_auto

+  yuga.js
     http://kyosuke.jp/portfolio/javascript/yuga.html


----------------------------------------------------------------- */
/*
 *
 * Copyright (c) 2007 Kyosuke Nakamura (kyosuke.jp)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Since:     2006-10-30
 * Modified:  2007-06-18
 *
 * jQuery 1.1.2
 * ThickBox 3
 * Interface 1.2 (Effects scroll)
 */


var yuga = {

	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){
			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 a = this.absolutePath.split('://');
		this.schema = a[0];
		if(a[1]){
			var d = a[1].split('/');
			this.host = d.shift();
			var f = d.pop();
			this.dirs = d;
			this.file = f.split('?')[0].split('#')[0];
			var fn = this.file.split('.');
			this.fileExtension = (fn.length == 1) ? '' : fn.pop();
			this.fileName = fn.join('.');
			var fq = f.split('?');
			this.query = (fq[1]) ? fq[1].split('#')[0] : '';
			var ff = f.split('#');
			this.fragment = (ff[1]) ? ff[1].split('?')[0] : '';
		}
	}
};

$(function(){
	
	$('.navigation a img,.bnr a img').each(function(){
		this.originalSrc = $(this).attr('src');
		this.rolloverSrc = this.originalSrc.replace(/(\.gif|\.jpg|\.png)/, "_on$1");
		yuga.preloader.load(this.rolloverSrc);
	}).hover(function(){
		if($(this).attr("className")!="active"){
			$(this).attr('src',this.rolloverSrc);
		}
	},function(){
		if($(this).attr("className")!="active"){
			$(this).attr('src',this.originalSrc);
		}
	});

	$('a[@href]').not('[@href^="mailto:"]').each(function(){
		var href = new yuga.URI(this.getAttribute('href'));
		var thisHref = location.href;
		if (href.isSelfLink && !href.fragment) {
			$(this).addClass('current');
			$(this).find('img').each(function(){
			$(this).unbind('mouseover');
				$(this).unbind('mouseout');
				this.currentSrc = this.getAttribute('src').replace(/(\.gif|\.jpg|\.png)/, "_on$1");
				$(this).attr('src',this.currentSrc);
			});
		}
	});

	$('.local a,.return a').click(function(){
		var targetHref = $(this).attr('href');
		$(targetHref).ScrollTo(400,'easeout');
		return false;
	});
/*
	$('a[@href^="http://"]').click(function(){
		window.open(this.href, '_blank');
		return false;
	});
*/
	

});


$.auto = {
	init: function() {
		for (module in $.auto) {
			if ($.auto[module].init)
				$.auto[module].init();
		}
	}
};

function current_img(str){
	var id="#"+str;
	var originalSrc = $(id).attr('src');
	var onSrc = originalSrc.replace(/(\.gif|\.jpg|\.png)/, "_on$1");
	$(id).attr('src',onSrc);
	$(id).attr("className","active");
}

$(document).ready($.auto.init);





