/* default setting */
var gUseragent = navigator.userAgent;
var gMac = (gUseragent.indexOf('Mac') != -1) ? true : false;
var gWin = (gUseragent.indexOf('Win') != -1) ? true : false;
var gIE =  (gUseragent.indexOf('MSIE') != -1) ? true : false;
var gNetscape = (navigator.appName.indexOf('Netscape') != -1) ? true : false;
var gOpera = (gUseragent.indexOf('Opera') != -1) ? true : false;
var gSafari = (gUseragent.indexOf('Safari') != -1) ? true : false;
var gFirefox = (gUseragent.indexOf('Firefox') != -1) ? true : false;
var gGecko = (gUseragent.indexOf('Gecko/') != -1) ? true : false;
var gIE4 = null;
var gIE5 = null;
var gIE6 = null;
var gNN4 = null;
var gNN6 = null;
var gNN7 = null;
var gOpera6 = null;
var gOpera7 = null;
var gOpera8 = null;
if (gOpera) {
	gOpera6 = (gUseragent.indexOf('Opera 6') != -1 || gUseragent.indexOf('Opera/6') != -1) ? true : false;
	gOpera7 = (gUseragent.indexOf('Opera 7') != -1 || gUseragent.indexOf('Opera/7') != -1) ? true : false;
	gOpera8 = (gUseragent.indexOf('Opera 8') != -1 || gUseragent.indexOf('Opera/8') != -1) ? true : false;
} else if (gIE) {
	gIE4 = (gUseragent.indexOf('MSIE 4') != -1) ? true : false;
	gIE5 = (gUseragent.indexOf('MSIE 5') != -1) ? true : false;
	gIE6 = (gUseragent.indexOf('MSIE 6') != -1) ? true : false;
}
if (gNetscape) {
	gNN4 = (gUseragent.indexOf('Mozilla/4') != -1) ? true : false;
	gNN6 = (gUseragent.indexOf('Netscape6') != -1) ? true : false;
	gNN7 = (gUseragent.indexOf('Netscape/7') != -1) ? true : false;
}


/* sponsorbanner */
function sponsorBanner() {
	with (document) {
		open();
		writeln('<' + 'a href="');
		writeln('http://www.ekokoro.jp/ec/ec0198.html');
 		writeln('">');
		writeln('<' + 'img src="');
		writeln('/marchant/img/at_omc_468x60.gif');
		writeln('" width="468" height="60" alt="');
		writeln('OMC 地球にやさしいカード');
		writeln('" /></a>');
		close();
	}
}


/* make window */
function makeWindow(url, windowname, properties, width, height, screenx, screeny) {
	var width = parseInt(width);
	var height = parseInt(height);
	var toolbar;
	var location;
	var directories;
	var status;
	var menubar;
	var resizable;
	var scrollbars;
	var dependent;
	properties.charAt(0) == '1' ? toolbar = 'yes' : toolbar = 'no';
	properties.charAt(1) == '1' ? location = 'yes' : location = 'no';
	properties.charAt(2) == '1' ? directories = 'yes' : directories = 'no';
	properties.charAt(3) == '1' ? status = 'yes' : status = 'no';
	properties.charAt(4) == '1' ? menubar = 'yes' : menubar = 'no';
	properties.charAt(5) == '1' ? resizable = 'yes' : resizable = 'no';
	properties.charAt(6) == '1' ? scrollbars = 'yes' : scrollbars = 'no';
	properties.charAt(7) == '1' ? dependent = 'yes' : dependent = 'no';
	if (location == 'yes') {
		if (gMac && gNN4) { width += 15; height += 15;
		} else if (gMac && gIE5) { height += 19;
		} else if (gMac && gIE4) { width += 2; height += 6;
		} else if (gWin && (gIE6 || gIE5 || gIE4)) { height -= 19;
		} else if (gSafari) { width += -2; height += 50; }
	}
	if (scrollbars == 'yes') {
		if (gNN6 || gNN7) { width += 15; height += 1;
		} else if (gMac && gNN4) { width += 15;
		} else if (gMac && gIE5) { height -= 16;
		} else if (gMac && gIE4) { height -= 14;
		} else if (gWin && (gNN4 || gIE6 || gIE5 || gIE4)) { width += 16;
		} else { width += 15; height += 3; }
	} else {
		if (gNN6 || gNN7) { width += 1; height += 1;
		} else if (gMac && gIE4) { width += 2; }
	}
	if (status == 'yes') {
		if (gMac && gNN4) { width -= 15; height -= 15;
		} else if(gMac && gIE4){ height += 16; }
	} else {
		if (gMac && (gNN6 || gNN7)) { height += 80;
		} else if (gWin && (gNN6 || gNN7)) { height += 20;
		} else if (gSafari) { height += 20; }
	}
	if (screenx == '' || screeny == '' || screenx < 0 || screeny < 0) {
		if (screen.availWidth && screen.availHeight) {
			screenx = Math.round((screen.availWidth - width) / 2);
			screeny = Math.round((screen.availHeight - height) / 2);
		} else { screenx = 0; screeny = 0; }
	}
	var echo = 'width=' + width + ',height=' + height + ',toolbar=' + toolbar + ',location=' + location + ',directories=' + directories + ',status=' + status + ',menubar=' + menubar + ',resizable=' + resizable + ',scrollbars=' + scrollbars + ',dependent=' + dependent + ',left=' + screenx + ',top=' + screeny;
	window.open(url, windowname, echo);
	return false;
}


function targetBlank(url) {
	window.open(url, '_blank', 'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes,dependent=no');
	return false;
}

function openerCheck() {
	if (!!window.opener) {
		if (gWin && gIE4) { return !window.opener.closed;
		} else { return typeof window.opener.document == 'object'; }
	} else { return false; }
}

function windowOpener(url) {
	top.window.close();
	if (openerCheck()) { window.opener.location.href = url;
	} else { targetBlank(url); }
}

function comboboxLink(combobox, target) {
	var url = combobox.options[combobox.selectedIndex].value;
	if (combobox.selectedIndex == 0) { return false;
	} else if (target == '_blank') { targetBlank(url); return true;
	} else { document.location.href = url; return true; }
}


/* print button */
if(gWin && gIE4) {
	with (document) {
		open();
		writeln('<object id="WB" style="display: none;" classid="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></object>');
		writeln('<' + 'script language="VBScript">');
		writeln('Sub window_onunload');
		writeln('  On Error Resume Next');
		writeln('  Set WB = nothing');
		writeln('End Sub');
		writeln('Sub vbWindowprint');
		writeln('  OLECMDID_PRINT = 6');
		writeln('  OLECMDEXECOPT_DONTPROMPTUSER = 2');
		writeln('  OLECMDEXECOPT_PROMPTUSER = 1');
		writeln('  On Error Resume Next');
		writeln('  WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
		writeln('End Sub');
		writeln('<' + '/script>');
		close();
	}
}

function windowPrint() {
	if(gWin && gIE4) { vbWindowprint();
	} else if(window.print) { window.print();
	} else { alert('ご利用のブラウザでは\nこのボタンによる印刷の実行がサポートされておりません。\nお手数ですがブラウザのプリントメニューから印刷して下さい。'); }
}

function show_finish_button(imageid, imagefile) {
	imagekey = "cblogofinish_"+imageid;
	document.images[imagekey].src = imagefile;
}