/* ---------- global variables ---------- */

var src2name_re          = new RegExp("_f[12]","g");
var image_directory_name = "img/";
var swap                 = new Array();
var rest                 = new Array();
var SARI_className       = "SARI";
var SARI_safemode        = 1;
var SARI_safemode_array  = new Array("img","input");
var mailto_className     = "mailto";

/*
SARI_safemode:
1 : searching for nodes with "SARI_className" from the nodes that have tag name in "SARI_safemode_array"
0 : searching for it from all of the nodes. but it's so expensive
you'd better choose "1", unless some special reasons can be found.
*/







/* ---------- start up items ----------
the item in the Array "startup_items" will be executed in order as a function, when the document is loaded.
when you want to add an attribute "onload" in body tag (and that sucks), you'd better make it a function and push into the Array "startup_items".
*/
var startup_items = new Array();
window.onload = function(){ for(var i=0 ; i<startup_items.length ; i++) startup_items[i](); };





/* ---------- Version ---------- */

if(ver < 5){
	if(nav == "MSIE" || nav == "MacIE"){
		ver_str = unescape("%u5F53%u30B5%u30A4%u30C8%u3092%u5B89%u5168%u30FB%u5FEB%u9069%u306B%u3054%u5229%u7528%u3044%u305F%u3060%u304F%u305F%u3081%u306B%0D%0A%u6700%u65B0%u306E%u30D6%u30E9%u30A6%u30B6%u306E%u3054%u5229%u7528%u3092%u304A%u52E7%u3081%u3057%u307E%u3059%u3002");
		ver_url = "http://www.microsoft.com/japan/ie/";
		version_up(ver_str,ver_url);
	}
	else if(nav != "NN7"){
		ver_str = unescape("%93%96%83T%83C%83g%82%F0%88%C0%91S%81E%89%F5%93K%82%C9%82%B2%97%98%97p%82%A2%82%BD%82%BE%82%AD%82%BD%82%DF%82%C9%0D%8D%C5%90V%82%CC%83u%83%89%83E%83U%82%CC%82%B2%97%98%97p%82%F0%82%A8%8A%A9%82%DF%82%B5%82%DC%82%B7%81B");
		ver_url = "http://home.netscape.co.jp/";
		version_up(ver_str,ver_url);
	}
}
else if(nav == "Opera" && ver < 7){
	ver_str = unescape("%u5F53%u30B5%u30A4%u30C8%u3092%u5B89%u5168%u30FB%u5FEB%u9069%u306B%u3054%u5229%u7528%u3044%u305F%u3060%u304F%u305F%u3081%u306B%0D%0A%u6700%u65B0%u306E%u30D6%u30E9%u30A6%u30B6%u306E%u3054%u5229%u7528%u3092%u304A%u52E7%u3081%u3057%u307E%u3059%u3002");
	ver_url = "http://www.jp.opera.com/";
	version_up(ver_str,ver_url);
}

function version_up(ver_str,ver_url){
	if(window.confirm(ver_str)){
		window.location.href = ver_url;
	}
	else{
		void(0);
	}
}






/* ---------- common library ---------- */

function puWindow(url,nam,wid,hei,prop){
	var offset = 100;
	var w = window.screen.width;
	var h = window.screen.height;
	var l = (w-wid)/2;
	var t = ((h-hei)/2)-offset;
	sty = prop;
	sty+= ",width=";
	sty+= wid;
	sty+= ",height=";
	sty+= hei;
	sty+= ",left=";
	sty+= l;
	sty+= ",top=";
	sty+= t;
	window.open(url,nam,sty);
}

function popup0(url,nam,wid,hei){
	prop = "status=yes,scrollbars=no,resizable=yes";
	puWindow(url,nam,wid,hei,prop);
}

function popup1(url,nam,wid,hei){
	prop = "status=yes,scrollbars=yes,resizable=yes";
	puWindow(url,nam,wid,hei,prop);
}

function popup2(url,nam,wid,max){
	prop = "status=yes,scrollbars=yes,resizable=yes";
	var h = Math.floor(window.screen.height * 0.75);
	var hei = (max < h) ? max : h;
	puWindow(url,nam,wid,hei,prop);
}



function mailto2link(){
	var tmp = getElementsByTagAndClassName("span",mailto_className);
	for(var i=0 ; i<tmp.length ; i++){
		tmp[i].onclick = function(){
			var address = this.childNodes[0].nodeValue;
			window.location.href = "mailto:" + address;
		}
	}
}
startup_items[startup_items.length] = mailto2link;




function getElementsByTagAndClassName(tag_name,class_name){
	/*
	this is not a method but a function.
	This returns it as Array, when the corresponding elements are discovered.
	This returns false, when the corresponding tag name or class name is not able to be discovered.
	when you do not want to limit the kind of tag, you can use "*" for the 1st argument but it's so expensive.
	*/
	var return_array = new Array();
	if(!document.getElementsByTagName(tag_name)) return false;
	
	var tmp = document.getElementsByTagName(tag_name);
	for(var i=0 ; i<tmp.length ; i++){
		var class_array = tmp[i].className.split(" ");
		for(var c=0 ; c<class_array.length ; c++){
			if(class_array[c] == class_name){
				return_array[return_array.length] = tmp[i];
			}
		}
	}
	if(return_array.length < 1) return false;
	return return_array;
}




function getImageName(obj){
	/*
	this returns a character sequence which deleted the one for rollover effect from the sauce file name.
	this returns false, if "obj" doesn't have a property "src".
	*/
	if(!obj.src) return false;
	return obj.src.split(image_directory_name)[1].split(src2name_re)[0];
}




function SARI(){
	/*
	when you want to use the rollover effect in html coding, you'd better set "SARI_className" as the class attribute of the corresponding element.
	you have nothing to do to preload swap images :-)
	*/
	// expensive mode
	if(SARI_safemode == 0){
		var tmp = getElementsByTagAndClassName("*",SARI_className);
	}
	// normal mode
	else{
		var tmp = new Array();
		for(var sm=0 ; sm<SARI_safemode_array.length ; sm++){
			var tmp_safe = getElementsByTagAndClassName(SARI_safemode_array[sm],SARI_className);
			if(tmp_safe != false) tmp = tmp.concat(tmp_safe);
		}
	}
	
	for(var i=0 ; i<tmp.length ; i++){
		SwapAndRestoreImage(tmp[i]);
	}
}
startup_items[startup_items.length] = SARI;




function SwapAndRestoreImage(obj){
	/*
	when you want to use the rollover effect in any JavaScript, You'd better use this function.
	you can use any node as the argument.
	if the node is not "IMG" or "INPUT type=image", the 1st Image object of children is recognized as an object of the effect.
	if the sauce file name of an Image object is not a regular form or there is no Image object in children of the node, this will not be executed.
	although you can use this as the onmouseover or onmouseout attribute, i don't reccomend you it.
	*/
	var target;
	if(obj.nodeName == "IMG" || (obj.nodeName == "INPUT" && obj.type == "image")){
		target = obj;
	}
	else{
		if(!obj.getElementsByTagName("img")[0]) return;
		target = obj.getElementsByTagName("img")[0];
	}
	
	if(target.src.indexOf("_f1") == -1 && target.src.indexOf("_f2") == -1) return;
	
	// preload sequence
	var ImageName = getImageName(target);
	swap[ImageName] = document.createElement("img");
	swap[ImageName].src = target.src.replace(src2name_re,"_f2");
	rest[ImageName] = document.createElement("img");
	rest[ImageName].src = target.src;
	
	// rollover sequence
	target.onmouseover = function(){ if(swap[getImageName(this)]) this.src = swap[getImageName(this)].src; }
	target.onmouseout  = function(){ if(rest[getImageName(this)]) this.src = rest[getImageName(this)].src; }
}



/*ƒMƒƒƒ‰ƒŠ[*/
function chang_img(img_name){
   if(document.images)document.display.src = img_name;
}















/*
common script lib. Ver.3.1.0
2004.08.04.
*/
