///// for StepEngine /////

//フォーム初期値クリア
/* clearDefaultValue
----------------------------------------*/
defaultTxt = "（例）電話連絡は、17時以降にお願い致します。";

function clearDefaultValue(){
	//var textarea = document.getElementsByTagName("textarea");
	var textarea = document.getElementsByName("answer_Q_user_comment");

	/* textarea */
	//URLを取得して該当stepのみ動作
	var str = location.pathname;
	if(str.indexOf("/step/hchikaku/",0) != -1){
		for (i=0;i<textarea.length;i++){
			if (textarea[i].value == "" || textarea[i].value == defaultTxt){
				textarea[i].style.color = "#888888";
				textarea[i].value = defaultTxt;
				textarea[i].className += " default-value";
			}
			textarea[i].onfocus = function(){
				if (this.value == defaultTxt){
					this.style.color = "#000000";
					this.value = "";
					this.className = this.className.replace(/ default-value/, "");
				}
			}
			textarea[i].onblur = function(){
				if (this.value == ""){
					this.style.color = "#888888";
					this.value = defaultTxt;
					this.className += " default-value";
				}
			}
		}
	}
}

addEvent(window, 'load', clearDefaultValue);

/* add event
----------------------------------------*/
function addEvent(obj, evType, fn){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, false);
		return true;
	}
	else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	}
	else {
		return false;
	}
}

//フォーム背景色
/*
function colorChange() {
	this.skip  = ['submit', 'button', 'radio', 'checkbox', 'select-one', 'select-multiple'];
	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;
		}
	}
}
*/

// onload時にフォーム背景色設定を実行
/*
window.onload = function() {
   var formColor = new colorChange;
   formColor.set();
}
*/

//チェックボックス関連
//ディノス
function dinosWin() {
	newwin =window.open('/step/promo/dinos/','dinos','toolbar=no,location=no,resizable=yes,status=no,scrollbars=yes,width=480,height=600,left=0,top=0');
	newwin.focus();
}


//ヘルプウインドウオープン
function helpWin(url) {
	newwin =window.open(url,'help','toolbar=no,location=no,resizable=yes,status=no,scrollbars=yes,width=500,height=300,left=0,top=0');
	newwin.focus();
}


//ご意見＆ご質問オープン
function cntWin() {
	newwin =window.open('https://www.hchikaku.com/step/hchikaku/contact.htm','cnt','toolbar=no,location=no,resizable=yes,status=no,scrollbars=yes,width=500,height=440,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=520,height=500,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();
}
