﻿String.prototype.trim = function()
{
	return this.replace(/(^\s*)|(\s*$)/g, "");
}
try{document.execCommand("BackgroundImageCache", false, true);}catch(e){}
function resize(that)
{
	try{
	var height = that.scrollHeight+20;
	if (height<200)
	{
		height = 200;
	}
	that.style.height = height;
	}catch(e){}
}
function text_format(that)
{
	var body = "\n"+that.value;
	body = body.replace(/ |　/ig,"");
	body = body.replace(/\r\n/ig,"\n");
	body = body.replace(/\n\n/ig,"\n");
	body = body.replace(/\n\n/ig,"\n");
	body = body.replace(/\n\n/ig,"\n");
	body = body.replace(/\n\n/ig,"\n");
	body = body.replace(/\n/ig,"\n\n");
	body = body.replace("\n\n","");
	that.value=body;
}
function getCookie(namex)
{
	var cookies = document.cookie;
	var cookieHeader = namex + "=";
	var beginPosition = cookies.indexOf(cookieHeader);
	if (beginPosition != -1) 
	{
		var acookie = cookies.substring(beginPosition + cookieHeader.length);
		if (acookie.indexOf(";")>-1)
		{
			acookie = acookie.substring(0, acookie.indexOf(";"));
		}
		return acookie;
	}
	return "";
}
function clogin()
{
	if (getCookie("x_username")!=""&&getCookie("x_password")!="")
	{
		return true;
	}
	return false;
}
function not()
{
	return true;
}
function removejs(obj)
{
	var childs = obj.childNodes;
	for (i=0;i<childs.length;i++)
	{
		var tagname = childs[i].tagName;
		if (tagname!=null&&childs[i]!=obj)
		{
			childs[i].onabort = new Function("not()");
			childs[i].onblur = new Function("not()");
			childs[i].onchange = new Function("not()");
			childs[i].onclick = new Function("not()");
			childs[i].ondblclick = new Function("not()");
			childs[i].onerror = new Function("not()");
			childs[i].onfocus = new Function("not()");
			childs[i].ondblclick = new Function("not()");
			childs[i].onkeydown = new Function("not()");
			childs[i].onkeypress = new Function("not()");
			childs[i].onkeyup = new Function("not()");
			childs[i].onload = new Function("not()");
			childs[i].onmousedown = new Function("not()");
			childs[i].onmousemove = new Function("not()");
			childs[i].onmouseout = new Function("not()");
			childs[i].onmouseover = new Function("not()");
			childs[i].onmouseup = new Function("not()");
			childs[i].onreset = new Function("not()");
			childs[i].onresize = new Function("not()");
			childs[i].onselect = new Function("not()");
			childs[i].onsubmit = new Function("not()");
			childs[i].onunload = new Function("not()");
			childs[i].onpropertychange = new Function("not()");		
			removejs(childs[i]);	
		}
	}
}
function getDate()
{
	var d = new Date()
	var vYear = d.getFullYear()
	var vMon = d.getMonth() + 1
	var vDay = d.getDate()
	var sb = "";
	sb += (vYear)
	sb += ("-")
	sb += (vMon<10 ? "0" + vMon : vMon)
	sb += ("-")
	sb += (vDay<10 ?  "0"+ vDay : vDay )
	return sb;
}
function getDateTime()
{
	var d = new Date();
	var vYear = d.getFullYear();
	var vMon = d.getMonth() + 1;
	var vDay = d.getDate();
	var vHour = d.getHours();
	var vMinute = d.getMinutes();
	var vSecond = d.getSeconds();
	var sb = "";
	sb += (vYear);
	sb += ("-");
	sb += (vMon<10 ? "0" + vMon : vMon);
	sb += ("-");
	sb += (vDay<10 ?  "0"+ vDay : vDay );
	sb += (" ");
	sb += (vHour<10 ?  "0"+ vHour : vHour );
	sb += (":");
	sb += (vMinute<10 ?  "0"+ vMinute : vMinute );
	sb += (":");
	sb += (vSecond<10 ?  "0"+ vSecond : vSecond );
	return sb;
}
function getSmallDateTime()
{
	var d = new Date();
	var vMon = d.getMonth() + 1;
	var vDay = d.getDate();
	var vHour = d.getHours();
	var vMinute = d.getMinutes();
	var sb = "";
	sb += (vMon<10 ? "0" + vMon : vMon);
	sb += ("-");
	sb += (vDay<10 ?  "0"+ vDay : vDay );
	sb += (" ");
	sb += (vHour<10 ?  "0"+ vHour : vHour );
	sb += (":");
	sb += (vMinute<10 ?  "0"+ vMinute : vMinute );
	return sb;
}
function setAd2(ad)
{
	try
	{
		document.getElementById(ad).appendChild ( document.getElementById(ad+"s") );
		document.getElementById(ad+"s").style.display = "";
	}
	catch(e)
	{}
}
function setAd(ad)
{
	try
	{
		document.getElementById(ad).innerHTML = document.getElementById(ad+"s").innerHTML;
	}
	catch(e)
	{}
}
function str_len(txt)
{
	txt = txt.replace(/(<.*?>)/ig,'');
	txt = txt.replace(/([\u0391-\uFFE5])/ig,'11');
	var count = txt.length/2;
	return count;
}