//汎用ウィンドウオープン
function openWin(url,name,property) {
	newwin =window.open(url,name,property);
	newwin.focus();
}

//ご意見＆ご質問オープン
function cntWin() {
	newwin =window.open('https://www.dandori.info/contact/contact.html','cnt','toolbar=no,location=no,resizable=yes,status=no,scrollbars=yes,width=500,height=440,left=0,top=0');
	newwin.focus();
}

//ブラウザオープン
function brwsWin(url) {
	newwin =window.open(url,'exp','toolbar=no,location=no,resizable=yes,status=no,scrollbars=yes,width=500,height=440,left=0,top=0');
	newwin.focus();
}

//プライバシーポリシーオープン
function privacyWin() {
    newwin
=window.open('http://www.webcrew.co.jp/info/privacy_pop.html','privacy','toolbar=no,location=no,resizable=yes,status=no,scrollbars=yes,width=500,height=500,left=0,top=0');
    newwin.focus();
}

//利用規約
function termWin() {
	newwin =window.open('http://www.webcrew.co.jp/info/terms_pop.html','terms','toolbar=no,location=no,resizable=yes,status=no,scrollbars=yes,width=500,height=500,left=0,top=0');
	newwin.focus();
}

//会員規約
function memberWin() {
	newwin =window.open('http://www.webcrew.co.jp/info/member_pop.html','member','toolbar=no,location=no,resizable=yes,status=no,scrollbars=yes,width=500,height=500,left=0,top=0');
	newwin.focus();
}

//チェックリストオープン
function expWin(url) {
	newwin =window.open(url,'exp','toolbar=no,location=no,resizable=yes,status=no,scrollbars=yes,width=450,height=400,left=0,top=0');
	newwin.focus();
}


//フォーム背景色
function colorChange() {
	this.skip  = ['submit', 'button', 'radio', 'checkbox', 'select'];
	this.color = { 'blur': '', 'focus': '#DFF5FF' };

	this.set = function() {
		for (var i = 0; i < document.forms.length; i++) {
			for (var f = 0; f < document.forms[i].length; f++) {
				var elm = document.forms[i][f];
				if(!this.checkSkip(elm)) continue;
				this.setColor(elm, 'focus');
				this.setColor(elm, 'blur');
			}      
		}
	}

	this.checkSkip = function(elm) {
		for(var i in this.skip) {
			if(elm.type == this.skip[i]) return false;
		}
		return true;
	}

	this.setColor = function(elm, type) { 
		var color = this.color[type];
		var event = function() { elm.style.backgroundColor = color; };

		if(elm.addEventListener) {
			elm.addEventListener(type, event, false); 
		} else if(elm.attachEvent) {
			elm.attachEvent('on'+type, event); 
		} else {
			elm['on'+type] = event;
		}
	}
}


//印刷用CSS切り替え
function checkCss(cssFile) {
	document.getElementById('myStyle').href = cssFile;
}

function switchCss() {
	if (self.name == "printWindow") { checkCss('../css/print.css'); }
}

function printOpen() {
	window.open(location,"printWindow");
} 


//Shopping左メニュー切り替え
function menuCategory() {
	var currentPath = location.pathname;
	var strPath = currentPath.split("/");
	var objTarget = document.getElementById(strPath[strPath.length-2]);
	if( strPath.length < 3 ) {
		return;
	} else if( strPath[strPath.length-3] != "shopping" ) {
		return;
	} else if( objTarget != null ) {
		objTarget.style.display = "block";
	}
}

////////////////////////////////////////////////////////

// ページのロード完了時に実行する内容を定義
function initPage () {
	switchCss();
	menuCategory();
}

window.onload = initPage;