// JavaScript Document
var activehome;
function initRollOverImages() {
  var image_cache = new Object();
  $("img.catlist").each(function(i) {
    var imgsrc = this.src;
	active = activehome + '.jpg';
	var activeimg = '';
    var dot = this.src.lastIndexOf('.');
    var imgsrc_on = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
	//document.write(active);
	if(this.src.match(active)){
		//document.write(active);
		image_cache[this.src] = new Image();
		image_cache[this.src].src = imgsrc_on;
		this.src = imgsrc_on;
		activeimg = imgsrc_on;
	}else{
		image_cache[this.src] = new Image();
		image_cache[this.src].src = imgsrc_on;
	}
    $(this).hover(
      function() { this.src = imgsrc_on; },
      function() { 
	  	if(activeimg){
			this.src = imgsrc_on;
		}else{
			this.src = imgsrc;
		}
	  });
  });
}


/*function initRollOverImages() {
	var image_cache = new Object();
	//パス取得
	path = location.pathname;
	//カテゴリリスト・・・メニューの並び順との合わせ厳守
	var categories = new Array() ;
	//categories[0] = "/home/" ;
	
  $("img.catlist").each(function(i) {
    var imgsrc = this.src;
	var active ;
    var dot = this.src.lastIndexOf('.');
    var imgsrc_on = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);

	
	if(path.match(categories[i])){
	//	image_cache[this.src] = new Image();
		image_cache[this.src].src = imgsrc_on;
		this.src = imgsrc_on;
		active = imgsrc_on;
	}else if(i==0&&activehome){
		image_cache[this.src] = new Image();
		image_cache[this.src].src = imgsrc_on;
		this.src = imgsrc_on;
		active = imgsrc_on;
	}else{
		image_cache[this.src] = new Image();
		image_cache[this.src].src = imgsrc_on;
	//}
	
	$(this).hover(
		function() { this.src = imgsrc_on; },
		function() { 
			if(active!=imgsrc_on){
				this.src = imgsrc;
			}
		}
	 );
  });
}
*/
function initCurrentLinks() {
	var yuga = {
		// imageのプリローダー
		// URIを解析したオブジェクトを返すfunction
		URI: function(s){
			this.absolutePath = s;
		
			//同じ文書にリンクしているかどうか
			//alert(location.href);
			path = location.href;
			//this.isSelfLink = (this.absolutePath == location.href);
			this.isSelfLink = (path.match(this.absolutePath));
		
		}
	};

	//現在のページへのリンク
	$('a[@href]').each(function(){
		var href = new yuga.URI(this.getAttribute('href'));
		if (href.isSelfLink && !href.fragment) {
			$(this).addClass('current');
		}
	});
	
	
}
$(document).ready(initRollOverImages);
//$(document).ready(initCurrentLinks);

