//Common Function


function isHalfString(str)
{
	if(str.length != 0 )
	{
		str = str.toUpperCase();
		for (var i=0; i< str.length; ++i)
		{
			var ch = str.charAt(i);
			if(checkNotLetters(ch) && checkNotNumbers(ch) && ch !='_' && ch !='-')
			{
				return false;
			}
		}
	}
	return true;
}

function isInt(str)
{
	if(str.length != 0 )
	{
		str = str.toUpperCase();
		for (var i=0; i< str.length; ++i)
		{
			var ch = str.charAt(i);
			if(checkNotNumbers(ch))
			{
				return false;
			}
		}
	}
	return true;
}

function isMail(str)
{
	if(str.length == 0 ) return false;
	str = str.toUpperCase();
	var a = str.indexOf('@');
	if(a == -1) return false;

	var strUserName = str.substring(0,a);
	var strServerName = str.substring(a+1);
	if(strUserName.length == 0 ) return false;
	if(strServerName.length == 0 ) return false;

	for (var i=0; i< strUserName.length; ++i)
	{
		var ch = strUserName.charAt(i);
		if( checkNotLetters(ch) && checkNotNumbers(ch) && ch !='_' && ch !='-' && ch != '?')
		{
			return false;
		}
	}

	for (var i=0; i< strServerName.length; ++i)
	{
		var ch = strServerName.charAt(i);
		if( checkNotLetters(ch) && checkNotNumbers(ch) && ch !='_' && ch !='-' && ch !='.' && ch != '?' )
		{
			return false;
		}
	}
	return true;
}

function isDate(strValue,str)
{
	if(strValue.length == 0 ) return false;
	if("string" != typeof(str)||""==str) str = "yyyy/MM/dd-HH:mm:ss";
	if(strValue.length != str.length ) return false;
	if(str.indexOf('yyyy')==-1||str.indexOf('MM')==-1||str.indexOf('dd')==-1) return false;

	var i = 0;
	var tmpValue = "";
	i = str.indexOf('yyyy');
	tmpValue = strValue.substring(i,i+4);
	if(!isInt(tmpValue)) return false;
	i = str.indexOf('MM');
	tmpValue = strValue.substring(i,i+2);
	if(!isInt(tmpValue)) return false;
	i = str.indexOf('dd');
	tmpValue = strValue.substring(i,i+2);
	if(!isInt(tmpValue)) return false;

	if(str.indexOf('HH')!=-1)
	{
		i = str.indexOf('HH');
		tmpValue = strValue.substring(i,i+2);
		if(!isInt(tmpValue)) return false;
	}

	if(str.indexOf('HH')!=-1&&str.indexOf('mm')!=-1)
	{
		i = str.indexOf('mm');
		tmpValue = strValue.substring(i,i+2);
		if(!isInt(tmpValue)) return false;
	}

	if(str.indexOf('HH')!=-1&&str.indexOf('mm')!=-1&&str.indexOf('ss')!=-1)
	{
		i = str.indexOf('ss');
		tmpValue = strValue.substring(i,i+2);
		if(!isInt(tmpValue)) return false;
	}
	return true;
}


function checkNotLetters(c)
{
	if( c != 'A' && c != 'B' && c != 'C' && c != 'D' &&  c != 'E' && c != 'F' && c != 'G' && c != 'H' &&
	c != 'I' && c != 'J' && c != 'K' && c != 'L' &&  c != 'M' && c != 'N' && c != 'O' && c != 'P' &&
	c != 'Q' && c != 'R' && c != 'S' && c != 'T' &&  c != 'U' && c != 'V' && c != 'W' && c != 'X' &&
	c != 'Y' && c != 'Z' ) return true;
}

function checkNotNumbers(c)
{
	if( c != '1' && c != '2' && c != '3' && c != '4' &&  c != '5' && c != '6' && c != '7' && c != '8' &&
	c != '9' && c != '0') return true;
}

function lenToString(str,len)
{
	for(var i=str.length;i<len;i++)
	{
		str = "0"+str;
	}
	return str;
}