/* ---------- 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");

/*
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{
		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 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(document.layers) return;
	
	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; }
}








/*
we have to use this script, as long as this site supports NN4.
however, If the rollover effect in NN4 can be stopped,
we will be able to get a little happiness by using a SARI script.
*/

function SARI_NN4_preload(){
//	if(nav != "NN4") return;
	
	var tmp = document.images;
	for(var i=0 ; i<tmp.length ; i++){
		if(tmp[i].src.indexOf("_f1") == -1) continue;
		
		var ImageName = getImageName(tmp[i]);
		swap[ImageName] = new Image();
		swap[ImageName].src = tmp[i].src.replace(src2name_re,"_f2");
		rest[ImageName] = new Image();
		rest[ImageName].src = tmp[i].src;
	}
}
startup_items[startup_items.length] = SARI_NN4_preload;

function SARI_NN4(e,ImageName){
//	if(nav != "NN4") return;
	
	act = e.type;
	if(act == "mouseover"){
		if(swap[ImageName]) document.images[ImageName].src = swap[ImageName].src;
	}
	else if(act == "mouseout"){
		if(rest[ImageName]) document.images[ImageName].src = rest[ImageName].src;
	}
}





/*
this site is due to open in a pop-up window from the "Ricoh" site.
However, some users may open this site direct in the independent window (ex. from a search engine like google)
so, when it links to the contents in a Ricoh site, it is necessary to distribute a target.
in such a case, describe "openParent" as follows for onclick attribute.
<a href="/foo/var/etc.html" onClick="return openPanret(this);">
*/

function openParent(obj){
	var url = obj.href;
	
	
	if(!window.opener || window.opener.closed){
		obj.target = "_blank";
		return true;
	}
	else{
		window.opener.location.href = url;
		return false;
	}
}










/*
common script lib. for Caplio Life in ricoh.co.jp Ver.3.1.0.b
2005.03.11.
*/
