function $(id)
{
	return document.getElementById(id);
}

// 
function createXMLHttpRequest(cbFunc)
{
	var XMLHttpObject = null;

	try
	{
		XMLHttpObject = new XMLHttpRequest();
	}
	catch(e)
	{
		try
		{
			XMLHttpObject = new ActiveXObject('Msxml12.XMLHTTP');
		}
		catch(e)
		{
			try
			{
				XMLHttpObject = new ActiveXObject('Microsoft.XMLHTTP');
			}
			catch(e)
			{
				return null;
			}
		}
	}

	if(XMLHttpObject)
	{
		XMLHttpObject.onreadystatechange = cbFunc;

		return XMLHttpObject;
	}
}


// popupに使う

function popup(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// URLチェック
function checkUrl(str)
{
	var regUrl = /^(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)$/;

	if(str != "")
	{
		if(str.match(regUrl))
		{
			return true;
		}

		return false;
	}
	else
	{
		return true;
	}
}

// メールアドレスチェック
function checkEmail(str)
{
	var regMail = /[!#-9A-~]+@+[a-z0-9]+.+[^.]$/i;

	if(str != "")
	{
		if(str.match(regMail))
		{
			return true;
		}

		return false;
	}
	else
	{
		return true;
	}
}

// 郵便番号チェック
function checkPostCode(str)
{
	var regPostCode = /[0-9]{3}-[0-9]{4}$/i;

	if(str != "")
	{
		if(str.match(regPostCode))
		{
			return true;
		}

		return false;
	}
	else
	{
		return true;
	}
}

// 電話番号チェック
function checkTel(str)
{
	var regTel = /^\d{1,4}-\d{4}$|^\d{2,5}-\d{1,4}-\d{4}$/;

	if(str != "")
	{
		if(str.match(regTel))
		{
			return true;
		}

		return false;
	}
	else
	{
		return true;
	}
}

// 文字数チェック（バイト）
function checkStrByte(str, maxByte)
{
	if("" == str)
	{
		return true;
	}

	var i;
	var byteCount = 0;

	for(i = 0; i < str.length; i++)
	{
		if(escape(str.charAt(i)).length >= 4)
		{
			byteCount = byteCount + 2;
		}
		else
		{
			byteCount = byteCount + 1;
		}
	}

	if(byteCount > maxByte)
	{
		return false;
	}
	else
	{
		return true;
	}
}

// 数字チェック
function checkNumeric(str)
{
	if( str.match( /[^0-9]+/ ) ) {
		return false;
	}else{
		return true;
	}
}

// topics

function jumpAnchorTopic(){
	location.href="./#topics";
}
