//=============================================
// mn()
//=============================================
var brwsr = 0; // ブラウザ判別用フラグ（Microsoft製IEなら「0」、それ以外なら「1」）;
if(navigator.appName.charAt(0) == "M") { brwsr = 0; }
else { brwsr = 1; }

var timerID = ""; // 遅延消去用のタイマー宣言;
var xpos = 0;     // ポップアップメニューの X座標;
var ypos = 0;     // ポップアップメニューの Y座標;
var tObj;         // ポップアップメニューのオブジェクト;
var xObj;         // 元メニューのオブジェクト;

function mn(n,m){
	if(timerID!=""){
		clearTimeout(timerID);
	}
	dlt2();
	tObj = "";
	xObj = "";
	xpos = 0;
	ypos = 0;
	tObj = document.getElementById(n);
	xObj = document.getElementById(m);

	tObj.style.visibility="visible";
	getXpos(xObj);
	getYpos(xObj);
	ypos += xObj.offsetHeight;

//	if(brwsr==0){ 
//		tObj.style.filter = 'alpha(opacity = 100)';
//	}

	tObj.style.left = xpos - 0 + "px";
	if(n=="dv5"){
		tObj.style.left = xpos - 60 + "px";
	}
	if(brwsr==0){ 
		tObj.style.top = ypos - 0 + "px";
	}else{
		tObj.style.top = ypos - 0 + "px";
	}
	tObj.style.zIndex = "1";
}

function dlt(){
	if(timerID!=""){clearTimeout(timerID);}
	timerID = setTimeout("dlt2()",100);
}

function dlt2(){
	var dval;
	var tval;
	for (i=1;i<7;i++){
		dval = "dv" + i;
		tval = "g0" + i + 1;
		document.getElementById(dval).style.visibility = "hidden";
		document.getElementById(dval).style.zIndex = "0";
	}
}

function getXpos(obj){
	xpos = obj.offsetLeft;
	if(obj.offsetParent != null){
		xpos += getXpos(obj.offsetParent);
	}
	return xpos;
}

function getYpos(obj){
	ypos = obj.offsetTop;
	if(obj.offsetParent != null){
		ypos += getYpos(obj.offsetParent);
	}
	return ypos;
}



//=============================================
// iepngfix
//=============================================
/*
 * IE PNG Fix v1.4
 *
 * Copyright (c) 2006 Takashi Aida http://www.isella.com/aod2/
 *
 */

// IE5.5+ PNG Alpha Fix v1.0RC4
// (c) 2004-2005 Angus Turnbull http://www.twinhelix.com

// This is licensed under the CC-GNU LGPL, version 2.1 or later.
// For details, see: http://creativecommons.org/licenses/LGPL/2.1/

if (typeof IEPNGFIX == 'undefined') {
//--============================================================================

var IEPNGFIX = {
	blank:  'http://www.isella.com/aod2/images/blank.gif',
	filter: 'DXImageTransform.Microsoft.AlphaImageLoader',

	fixit: function (elem, src, method) {
		if (elem.filters[this.filter]) {
			var filter = elem.filters[this.filter];
			filter.enabled = true;
			filter.src = src;
			filter.sizingMethod = method;
		}
		else {
			elem.style.filter = 'progid:' + this.filter +
				'(src="' + src + '",sizingMethod="' + method + '")';
		}
	},

	fixwidth: function(elem) {
		if (elem.currentStyle.width == 'auto' &&
			elem.currentStyle.height == 'auto') {
			elem.style.width = elem.offsetWidth + 'px';
		}
	},

	fixchild: function(elem, recursive) {
		if (!/MSIE (5\.5|6\.|7\.)/.test(navigator.userAgent)) return;

		for (var i = 0, n = elem.childNodes.length; i < n; i++) {
			var childNode = elem.childNodes[i];
			if (childNode.style) {
				if (childNode.style.position) {
					childNode.style.position = childNode.style.position;
				}
				else {
					childNode.style.position = 'relative';
				}
			}
			if (recursive && childNode.hasChildNodes()) {
				this.fixchild(childNode, recursive);
			}
		}
	},

	fix: function(elem) {
		if (!/MSIE (5\.5|6\.|7\.)/.test(navigator.userAgent)) return;

		var bgImg =
			elem.currentStyle.backgroundImage || elem.style.backgroundImage;

		if (elem.tagName == 'IMG') {
			if ((/\.png$/i).test(elem.src)) {
				this.fixwidth(elem);
				this.fixit(elem, elem.src, 'scale');
				elem.src = this.blank;
				elem.runtimeStyle.behavior = 'none';
			}
		}
		else if (bgImg && bgImg != 'none') {
			if (bgImg.match(/^url[("']+(.*\.png)[)"']+$/i)) {
				var s = RegExp.$1;
				this.fixwidth(elem);
				elem.style.backgroundImage = 'none';
				this.fixit(elem, s, 'scale'); // crop | image | scale

				if (elem.tagName == 'A' && elem.style) {
					if (!elem.style.cursor) {
						elem.style.cursor = 'pointer';
					}
				}

				this.fixchild(elem);
				elem.runtimeStyle.behavior = 'none';
			}
		}
	},

	hover: function(elem, hvImg) {
		var bgImg = elem.style.backgroundImage;

		if (!bgImg && elem.currentStyle) bgImg = elem.currentStyle.backgroundImage;

		if (elem.tagName == 'IMG' && hvImg) {
			var image = elem.src;
			elem.onmouseover = function() {
				elem.src = hvImg;
				IEPNGFIX.fix(elem);
			};
			elem.onmouseout = function() {
				elem.src = image;
				IEPNGFIX.fix(elem);
			};
		}
		else if (bgImg && bgImg != 'none' && hvImg) {
			elem.onmouseover = function() {
				elem.style.backgroundImage = 'url(' + hvImg + ')';
				IEPNGFIX.fix(elem);
			};
			elem.onmouseout = function() {
				elem.style.backgroundImage = bgImg;
				IEPNGFIX.fix(elem);
			};
		}

		IEPNGFIX.fix(elem);
	}
};

//--============================================================================
} // end if (typeof IEPNGFIX == 'undefined')

//=============================================
// SmartRollOver()
//=============================================
function initRollovers() {
	if (!document.getElementById) return

	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {	
		if (aImages[i].className == 'ov') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);

			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;

			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	

			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

//=============================================
// OpenWin()
//=============================================
var PS1 = 'width=650, height=550, resizable=no, toolbar=no, scrollbars=yes, directories=no, status=yes, location=no,menubar=no';
var PS2 = 'width=400, height=450, resizable=no, toolbar=no, scrollbars=no, directories=no, status=yes, location=no,menubar=no';
var PS3 = 'width=850, resizable=yes, toolbar=no, scrollbars=yes, directories=no, status=yes, location=no,menubar=no';
var PS4 = 'width=640, height=640, resizable=no, toolbar=no, scrollbars=no, directories=no, status=yes, location=no,menubar=no';

function pop1(url){
	if (url) {
		win = window.open(url,'popup',PS1);
		win.focus();
	}
}

function pop2(url){
	if (url) {
		win = window.open(url,'popup',PS2);
		win.focus();
	}
}

function pop3(url){
	if (url) {
		win = window.open(url,'yoyaku',PS3);
		win.focus();
	}
}

function pop4(url){
	if (url) {
		win = window.open(url,'cm',PS4);
		win.focus();
	}
}

function popXmas() {
	var pop_4c = window.open('http://www.bridaldiamond.co.jp/xmasfair2007/xmasfair2007.html','pop_4c','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=640,height=480');
	x = (screen.width - 700) / 2;
	y = 152;
	pop_4c.moveTo(x,y);
		if(navigator.appVersion.charAt(0)>=3){
		pop_4c.focus()
	}
}



//=============================================
// BlWin2()
//=============================================
function BLinks() {
	if (!document.getElementsByTagName) return;

	var anchors = document.getElementsByTagName("a");

	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") &&
		anchor.getAttribute("rel") == "bl")
		anchor.target = "_blank";
	}
}






//=============================================
// init()
//=============================================

function init() {
	BLinks();
	initRollovers();
}


window.onload=init;
