// ia_research.js
// Version 1.00
// Version 1.01  画像のプリロードを修正
// Copyright (c)2007 econosy system http://www.econosys.jp/system/

//==================================================== ：onload
$(function(){
	// デフォルトのALTをセット
	//mo();

	// 全ての .icon を持つ <a>タグの中の<img>タグにイベントを登録
	$("a[@class=icon]/img").each(function(i) {
		$(this).hover(
	      function() { ia_text(this); } ,	// Mouse over
		  function() { ia_text_out(); }		// Mouse out
		);
		$(this).click(
	      function() { ia(this); return false; }
		);

	});

});


//==================================================== ：クリック時の動作
function ia(dom_obj) {

	$("#research_image").css('display', 'none');

	text=dom_obj.alt;
	file_name =dom_obj.src;

	file_name.match(/icon_([a-zA-Z0-9_.]+?)\.gif$/);
	file_head=RegExp.$1;
	jpeg_file_name=file_head+'.jpg';

	document.getElementById('imagename_text').innerHTML=text;


	// image change
	var preload = new Image();
	preload.onload = function (){
//alert('img load ok');
//		jq_obj=$("#research_image");
		dom_obj2=document.getElementById('research_image');
//alert(preload.width);
//		dom_obj2.width =preload.width;
//		dom_obj2.height=preload.height;
		$("#research_image").css('width', preload.width+'px');
		$("#research_image").css('height', preload.height+'px');
		dom_obj2.src='./research_images/'+jpeg_file_name;
		$("#research_image").css('display', 'block');

	}

	preload.src='./research_images/'+jpeg_file_name;



	// all border off (change class)
	$("a[@class=icon_on]").each(function(i) {
		$(this).removeClass("icon_on");
		$(this).addClass("icon");
//		$(this).css({
//			border : "1px solid white"
//		});
	});


	// change class
	parent_obj=dom_obj.parentNode;
	$(parent_obj).removeClass("icon");
	$(parent_obj).addClass("icon_on");
	
/*
	$(parent_obj).css({
		border : "1px solid red"
	});
*/
}


//==================================================== ：ajax_image_change
function ajax_image_change(dom_obj,uri) {
	
}


//==================================================== ：マウスオーバー時の動作
function ia_text(dom_obj) {

	text=dom_obj.alt;
	file_name =dom_obj.src;

	file_name.match(/icon_([a-zA-Z0-9_.]+?)\.gif$/);
	file_head=RegExp.$1;
	jpeg_file_name=file_head+'.jpg';

	document.getElementById('imagename_text').innerHTML=text;

}


//==================================================== ：マウスアウト時の動作
function ia_text_out() {

	var text='';

	// all border off (change class)
	$("a[@class=icon_on]/img").each(function(i) {
		text=this.alt;
	});
	document.getElementById('imagename_text').innerHTML=text;


}


