//////////////////////////////////////////////////
// blog default javascript
// www.overstyle.com/blog/
//////////////////////////////////////////////////


// SUBWINDOW +++++++++++++++++++++++++++++++++++++++++++++//
function Openwin(html,name,width,height,toolbar,location,status,menubar,scroll,resize) {
	opwin = window.open(html,name,"width="+width+",height="+height+",toolbar="+toolbar+",location="+location+",status="+status+",menubar="+menubar+",scrollbars="+scroll+",resizable="+resize+"");
	opwin.window.focus();
}


// COMMENT ERROR CHECK +++++++++++++++++++++++++++++++++++++++++++++//
function ErrorCheck() {
	var str = "";
	//お名前
	if(document.comments_form.author.value == ""){
		str = str + "お名前を入力してください。\n";
	}
	//メールアドレス
	mOBJ = document.comments_form.email.value;
	check = /.+@.+\..+/;
	if((mOBJ != "") && (!mOBJ.match(check))){
		str = str + "メールアドレスを正しく入力してください。\n";
	}
	//コメント
	if(document.comments_form.text.value == ""){
		str = str + "コメントを入力してください。";
	}
	if(str != ""){
		alert (str);
	return false;
	}
}


// COMMENT COOKIE PERMISSION +++++++++++++++++++++++++++++++++++++++++++++//
var HOST = 'www.overstyle.com';

function setCookie (name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
	document.cookie = curCookie;
}

function getCookie (name) {
	var prefix = name + '=';
	var c = document.cookie;
	var nullstring = '';
	var cookieStartIndex = c.indexOf(prefix);
		if (cookieStartIndex == -1)
			return nullstring;
		var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
			if (cookieEndIndex == -1)
				cookieEndIndex = c.length;
		return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

function deleteCookie (name, path, domain) {
	if (getCookie(name))
		document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
}

function fixDate (date) {
	var base = new Date(0);
	var skew = base.getTime();
		if (skew > 0)
			date.setTime(date.getTime() - skew);
}

function rememberMe (f) {
	var now = new Date();
		fixDate(now);
		now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
		setCookie('mtcmtauth', f.author.value, now, '', HOST, '');
		setCookie('mtcmtmail', f.email.value, now, '', HOST, '');
		setCookie('mtcmthome', f.url.value, now, '', HOST, '');
}

function forgetMe (f) {
	deleteCookie('mtcmtmail', '', HOST);
	deleteCookie('mtcmthome', '', HOST);
	deleteCookie('mtcmtauth', '', HOST);
	f.email.value = '';
	f.author.value = '';
	f.url.value = '';
}


function outside() {
	document.write("<img src='/bin/access/report.cgi?");
	document.write("dir=blog","&amp;");
	document.write("pix=",screen.width,"x",screen.height,"&amp;");
	document.write("ref=",document.referrer);
	document.write("' width='1' height='1' alt=''>");
}


