/* ---------- 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{
		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);
	}
}





/* ---------- css switch ---------- */

if(!document.layers){
	if(window.location.href.split("/")[3] == "" || window.location.href.split("/")[3] == "main.php"){
		if(nav == "MacIE") document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/hom_css/MacIE.css\" media=\"screen,print\">");
		if(nav == "MSIE" && ver < 7)  document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/hom_css/WinIE.css\" media=\"screen,print\">");
		if(nav == "safari")  document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/hom_css/safari.css\" media=\"screen,print\">");
		if(nav == "MSIE" && ver < 5.5)  document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/hom_css/WinIE50.css\" media=\"screen,print\">");
	}
	else{
		if(nav == "MacIE") document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/_css/MacIE.css\" media=\"screen,print\">");
		if(nav == "MacIE") document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"_css/MacIE.css\" media=\"screen,print\">");
		if(nav == "MSIE" && ver < 7)  document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/_css/WinIE.css\" media=\"screen,print\">");
		if(nav == "MSIE" && ver < 7)  document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"_css/WinIE.css\" media=\"screen,print\">");
		document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/_css/safari.css\" media=\"screen,print\">");
		document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/_css/print.css\" media=\"print\">");
	}
}





/* ---------- 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(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; }
}





function mailto2link(){
	var tmp = getElementsByTagAndClassName("span","mailto");
	for(var i=0 ; i<tmp.length ; i++){
		tmp[i].onclick = function(){
			if(this.childNodes[0].nodeName == "IMG"){
				var address = this.childNodes[0].alt;
			}
			else{
				var address = this.childNodes[0].nodeValue;
			}
			window.location.href = "mailto:" + address;
		}
	}
}
startup_items[startup_items.length] = mailto2link;





/* ---------- navigation ---------- */
var MainNavigation_timer = new Array();
var MainNavigation_children = new Array();
function MainNavigation(){
	if(!document.getElementById("navi")) return;
	
	var tmp = document.getElementById("navi").childNodes;
	for(var i=0 ; i<tmp.length ; i++){
		if(tmp[i].nodeName != "LI") continue;
		
		if(tmp[i].getElementsByTagName("a").length < 1) continue;
		var target = tmp[i].getElementsByTagName("a")[0];
		target.onmouseover = function(){
			stopTimer(MainNavigation_timer);
			hideChild();
			
			
			var MyLi = this.parentNode;
			if(MyLi.getElementsByTagName("ul").length > 0){
				this.onclick = function(){ return false; }
				this.style.cursor = "default";
				var target = MyLi.getElementsByTagName("ul")[0];
				target.onmouseover = function(){ stopTimer(MainNavigation_timer); }
				target.onmouseout = function(){ MainNavigation_timer[MainNavigation_timer.length] = setTimeout("hideChild();",500); }


				if(nav == "MSIE" || nav == "MacIE"){
					var x = MyLi.offsetLeft + ((document.body.clientWidth - 757) / 2 ) + 0;
					if(nav == "MSIE" && ver < 6) x -= 18;
					
					target.style.pixelLeft = x;
				}
				else{
					var x = MyLi.offsetLeft + 0;
					target.style.left = x + "px";
				}


				
				showChild(target);
			}
		}
		
		target.onmouseout = function(){ MainNavigation_timer[MainNavigation_timer.length] = setTimeout("hideChild();",500); }
	}
}
startup_items[startup_items.length] = MainNavigation;

function showChild(target){
	target.style.display = "block";
	MainNavigation_children[MainNavigation_children.length] = target;
}

function hideChild(){
	for(var i=0 ; i<MainNavigation_children.length ; i++){
		MainNavigation_children[i].style.display = "none";
	}
	MainNavigation_children.length = 0;
}

function stopTimer(id){
	for(var i=0 ; i<id.length ; i++){
		clearTimeout(id[i]);
	}
	id.length = 0;
}

function SwapAndRestoreImage2(){
	var targetimg = document.getElementById('left-image');
	var catchtext = document.getElementById('item-title');
	var detailtext = document.getElementById('item-detail');
    var obj1 = document.getElementById('right-image1');
    var obj2 = document.getElementById('right-image2');
    var obj3 = document.getElementById('right-image3');
    var obj4 = document.getElementById('right-image4');
	var title1 = document.getElementById('item-title1');
	var title2 = document.getElementById('item-title2');
	var title3 = document.getElementById('item-title3');
	var title4 = document.getElementById('item-title4');
	var detail1 = document.getElementById('item-detail1');
	var detail2 = document.getElementById('item-detail2');
	var detail3 = document.getElementById('item-detail3');
	var detail4 = document.getElementById('item-detail4');

   obj1.onmouseover = function(){
	   if (this.src != null && this.src != "" && this.src != "http://royalcollection.co.jp/goods_images/no_image/NoImage.jpg") {
		   targetimg.src = this.src;
	   }
	   if(title1.value != null &&  title1.value != "") {
		   !!catchtext.firstChild && catchtext.removeChild( catchtext.firstChild );
		   catchtext.appendChild(document.createTextNode(title1.value))
	   }
	   if(detail1.value != null &&  detail1.value != "") {
		   !!detailtext.firstChild && detailtext.removeChild( detailtext.firstChild );
		   detailtext.appendChild(document.createTextNode(detail1.value))
	   }
   }
   obj2.onmouseover = function(){
	   if (this.src != null && this.src != "" && this.src != "http://royalcollection.co.jp/goods_images/no_image/NoImage.jpg") {
		   targetimg.src = this.src;
	   }
	   if(title2.value != null &&  title2.value != "") {
		   !!catchtext.firstChild && catchtext.removeChild( catchtext.firstChild );
		   catchtext.appendChild(document.createTextNode(title2.value))
	   }
	   if(detail2.value != null &&  detail2.value != "") {
		   !!detailtext.firstChild && detailtext.removeChild( detailtext.firstChild );
		   detailtext.appendChild(document.createTextNode(detail2.value))
	   }
   }
   obj3.onmouseover = function(){
	   if (this.src != null && this.src != "" && this.src != "http://royalcollection.co.jp/goods_images/no_image/NoImage.jpg") {
		   targetimg.src = this.src;
	   }
	   if(title3 != null && title3.value != "") {
		   !!catchtext.firstChild && catchtext.removeChild( catchtext.firstChild );
		   catchtext.appendChild(document.createTextNode(title3.value))
	   }
	   if(detail3.value != null &&  detail3.value != "") {
		   !!detailtext.firstChild && detailtext.removeChild( detailtext.firstChild );
		   detailtext.appendChild(document.createTextNode(detail3.value))
	   }
   }
   obj4.onmouseover = function(){
	   if (this.src != null && this.src != "" && this.src != "http://royalcollection.co.jp/goods_images/no_image/NoImage.jpg") {
		   targetimg.src = this.src;
	   }
	   if(title4.value != null &&  title4.value != "") {
		   !!catchtext.firstChild && catchtext.removeChild( catchtext.firstChild );
		   catchtext.appendChild(document.createTextNode(title4.value))
	   }
	   if(detail4.value != null &&  detail4.value != "") {
		   !!detailtext.firstChild && detailtext.removeChild( detailtext.firstChild );
		   detailtext.appendChild(document.createTextNode(detail4.value))
	   }
   }

}

   function openSWF(fn, nm, w, h, v, id) {
		var so = new SWFObject(fn, nm, w, h, v);	// SWFオブジェクト生成
		so.addParam("quality", "high");				// クオリティ設定
		so.addParam("wmode", "opaque");				// フレームレート設定
		so.write(id);								// 埋め込み対象ID
   }
   
startup_items[startup_items.length] = SwapAndRestoreImage2;

/*
common script lib. Ver.3.1.0
2004.08.04.
*/
	