/* ---------- ---------- ---------- ---------- */

//initUserEnv
function initUserEnv(){
	this.isWin		= navigator.userAgent.indexOf("Win") != -1 ? true : false;
	this.isMac		= navigator.userAgent.indexOf("Mac") != -1 ? true : false;
	this.isNs		= navigator.appName.indexOf("Netscape") != -1 ? true : false;
	this.isNs4		= (document.layers) ? true : false;
	this.isNs4_7	= navigator.userAgent.indexOf("4.7") != -1 ? true : false;
	this.isNs6		= navigator.userAgent.indexOf("Netscape6") != -1 ? true : false;
	this.isNs7		= navigator.userAgent.indexOf("Netscape/7") != -1 ? true : false;
	this.isMoz		= navigator.userAgent.indexOf("Gecko") != -1 ? true : false;
	this.isIe		= navigator.userAgent.indexOf("MSIE") != -1 ? true : false;
	this.isIe4		= navigator.userAgent.indexOf("MSIE 4") != -1 ? true : false;
	this.isIe5		= navigator.userAgent.indexOf("MSIE 5") != -1 ? true : false;
	this.isIe6		= navigator.userAgent.indexOf("MSIE 6") != -1 ? true : false;
	this.isOp		= navigator.userAgent.indexOf("Opera") != -1 ? true : false;
	this.isW3CDom	= (document.getElementById) ? true : false;
	this.isMsDom	= (document.all) ? true : false;
	this.isNsDom	= (document.layers) ? true : false;
	this.isDom		= (this.isW3CDom || this.isMsDom || this.isNsDom) ? true : false;
	return this;
}
var userEnv = new initUserEnv();


//checkBlowser
function checkBlowser(){
	return (userEnv.isW3CDom)? 1:0;
}

//getFlashPlayerVersion
function getSwfVersion(){
	var flashVersion = 0;
	if (userEnv.isIe && userEnv.isWin) {
		try{flashVersion= new ActiveXObject("ShockwaveFlash.ShockwaveFlash").FlashVersion();}catch(e){flashVersion=0};
		flashVersion = Math.floor (flashVersion / 0x10000);
	} else {
		if (userEnv.isNs && !navigator.plugins) {
			flashVersion = 0;
		} else {
			var s = "application/x-shockwave-flash";
			if (navigator.mimeTypes && navigator.mimeTypes[s] && navigator.mimeTypes[s].enabledPlugin) {
				flashVersion=navigator.plugins["Shockwave Flash"].description.match (/\d+/);
			} else {
				flashVersion = 0;
			}
		}
	}
	return flashVersion;
}

//printSwf
function printSwf(swf,xml){
	if(getSwfVersion () < 7){
	}else{
		var prm;
		if(swf == 'key-02'){
			prm = ' width="690" height="270"';
		}else if(swf == 'key_cate'){
			prm = ' width="690" height="73"';
		}else if(swf == 'topics'){
			prm = ' width="337" height="251"';
		}
		
		prm += ' align="middle"'
		document.getElementById('blockNoFlash').style.display='none';
		document.write(
			'<object'
			+ ' classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'
			+ ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"'
			+ ' id="' + swf + '"'
			+ prm + '>'
			+ '<param name="allowScriptAccess" value="sameDomain" />'
			+ '<param name="movie" value="/3w/navi/swf/' + swf + '.swf?ver=2" />'
			+ '<param name="flashvars" value="xmldir=' + xml + '"/>'
			+ '<param name="quality" value="high" />'
			+ '<param name="bgcolor" value="#ffffff" />'
			+ '<embed'
			+ ' src="/3w/navi/swf/'+ swf + '.swf"'
			+ ' flashvars="xmldir=' + xml + '"'
			+ ' quality="high"'
			+ ' bgcolor="#ffffff"'
			+ ' name="' + swf + '"'
			+ ' allowScriptAccess="sameDomain"'
			+ ' type="application/x-shockwave-flash"'
			+ ' pluginspage="http://www.macromedia.com/go/getflashplayer"'
			+ prm + '/>'
			+ '</object>'
		);
	}
}

//openerWindow
function openerWindow(url){
	if(!window.opener || window.opener.closed){
		window.open(url);
	}else{
		window.opener.location.href = url;
	}
}

//widow focus change
function changeOpener(moPath){
	var win=null;
	if ((navigator.userAgent.indexOf("Mac") > -1)) {
		if(window.opener){
			window.opener.location.href=moPath; 
			window.opener.focus();
		}else{ win=window.open(moPath,win);}
	}else{ 
		if(!window.opener.closed){
			window.opener.location.href=moPath; 
			window.opener.focus();
		}else{ win=window.open(moPath,win);}
	}
	
}

function checkBoxNotAll(_arg){
	_arg.parentNode.getElementsByTagName('input')[0].checked=false;
}
function checkBoxAll(_arg){
	for(i = 0;i<_arg.parentNode.getElementsByTagName('input').length;i++){
		if(i !=0){
		_arg.parentNode.getElementsByTagName('input')[i].checked = false;
		}else{
			_arg.parentNode.getElementsByTagName('input')[i].checked = true;
		}
	}
}

//ポップアップ用
function checkBoxNotAll2(){
	document.getElementById('inputOutPopup').getElementsByTagName('input')[0].checked=false;
}
function checkBoxAll2(){
	document.getElementById('inputInPopup').getElementsByTagName('input')[0].checked = false;
	for(i = 0;i<document.getElementById('inputInPopup').getElementsByTagName('input').length;i++){
		document.getElementById('inputInPopup').getElementsByTagName('input')[i].checked = false;
	}
}

//検索結果用
function checkBoxNotAll3(ID){
	document.getElementById(ID).getElementsByTagName('input')[0].checked=false;
}
function checkBoxAll3(ID){
	targetInputs = document.getElementById(ID).getElementsByTagName('input');
	for(i = 0;i<targetInputs.length;i++){
		targetInputs[i].checked = (i !=0) ? false : true ;
	}
}
var switchTriggerFlag = false;
function switchTrigger(ID){
	target = document.getElementById(ID);
	target.style.display = (switchTriggerFlag) ? "block" : "none";
	switchTriggerFlag    = (switchTriggerFlag) ? false : true;	
	btnStyle = document.getElementById('switchTriggerBtn').style;
	btnStyle.background   = (switchTriggerFlag) ? '#F5F5F5' : '#D7D7D7';
	btnStyle.borderBottom = (switchTriggerFlag) ? '1px solid #cccccc' : 'none' ;
	
}

//ポップアップアラートの表示・非表示
function popupAlert(_arg){
	target=document.getElementsByName('popupAlertWin')[_arg];
	if (target.popupAlertflag){ 
		target.popupAlertflag=false;
		target.style.visibility = "hidden";
	}else{
		target.popupAlertflag=true;
		target.style.visibility = "visible";
	}
	for(i=0;i<document.getElementsByName('popupAlertWin').length;i++){
		if(i!=_arg){
			target=document.getElementsByName('popupAlertWin')[i];
			if (target.popupAlertflag){ 
				target.popupAlertflag=false;
				target.style.visibility = "hidden";
			}
		}
	}
	
}
//ポップアップアラートの外側をクリックしたらアラートを消去
function popupAlertClose(_arg){
	if(_arg>=0){
		target=document.getElementsByName('popupAlertWin')[_arg];
		if (target.popupAlertflag){
			target.popupAlertflag=false;
			target.style.visibility = "hidden";
		}
	}else{
		if(!popupAlertWinflag && !popupAlertBtnflag){
			for(i=0;i<document.getElementsByName('popupAlertWin').length;i++){
				target=document.getElementsByName('popupAlertWin')[i];
				if (target.popupAlertflag){
					target.popupAlertflag=false;
					target.style.visibility = "hidden";
				}
			}
		}
	}
}

var popupAlertBtnflag=false;
function popupAlertBtn(){
	popupAlertBtnflag=!popupAlertBtnflag;
}
var popupAlertWinflag=false;
function popupAlertWin(){
	popupAlertWinflag=!popupAlertWinflag;
}
//swapImage
function MM_preloadImages() {
	var d = document;
	if (d.images) {
		if (!d.MM_p) {
			d.MM_p = new Array();
		}
		var i, j = d.MM_p.length, a = MM_preloadImages.arguments;
		for (i=0; i<a.length; i++) {
			if (a[i].indexOf("#") != 0) {
				d.MM_p[j] = new Image();
				d.MM_p[j++].src = a[i];
			}
		}
	}
}
function MM_swapImage() {
	var i, j = 0, x, a = MM_swapImage.arguments;
	document.MM_sr = new Array();
	for (i=0; i<(a.length-2); i += 3) {
		if ((x=MM_findObj(a[i])) != null) {
			document.MM_sr[j++] = x;
			if (!x.oSrc) {
				x.oSrc = x.src;
			}
			x.src = a[i+2];
		}
	}
}
function MM_swapImgRestore() {
	var i, x, a = document.MM_sr;
	for (i=0; a && i<a.length && (x=a[i]) && x.oSrc; i++) {
		x.src = x.oSrc;
	}
}
function MM_findObj(n, d) {
	var p, i, x;
	if (!d) {
		d = document;
	}
	if ((p=n.indexOf("?"))>0 && parent.frames.length) {
		d = parent.frames[n.substring(p+1)].document;
		n = n.substring(0, p);
	}
	if (!(x=d[n]) && d.all) {
		x = d.all[n];
	}
	for (i=0; !x && i<d.forms.length; i++) {
		x = d.forms[i][n];
	}
	for (i=0; !x && d.layers && i<d.layers.length; i++) {
		x = MM_findObj(n, d.layers[i].document);
	}
	if (!x && d.getElementById) {
		x = d.getElementById(n);
	}
	return x;
}

