function h_strlen(str)
  {
    var i, len = 0;
	var cc;
    for (i = 0; i < str.length; i++)
    {
      cc = str.charCodeAt(i);
      if((cc >= 0)  && (cc < 256)) len++;
      else len += 2;
    }
    return len;
  }

function getCookie( name )
{
	var nameOfCookie = name + "=";
	var x = 0;
	while ( x <= document.cookie.length )
	{
		var y = (x+nameOfCookie.length);
		if ( document.cookie.substring( x, y ) == nameOfCookie )
		{
			if ( (endOfCookie=document.cookie.indexOf( ";", y )) == -1 )
				endOfCookie = document.cookie.length;
			return unescape( document.cookie.substring( y, endOfCookie ) );
		}
		x = document.cookie.indexOf( " ", x ) + 1;
		if ( x == 0 )
			break;
	}
	return "";
}

function setCookie( name, value,domain ,expiredays)
{
	var todayDate = new Date();

	todayDate.setDate(todayDate.getDate() + expiredays);

	document.cookie = name + "=" + escape( value ) + "; path=/; domain=" + domain + "; expires=" + todayDate.toGMTString() +";"
}

function isNumeric(num)
{
	var checkstr = "0123456789";
	for(i=0;i<num.length;i++)
	{
		if(checkstr.indexOf(num.charAt(i))< 0)
			return false;
	}	
	return true;
}

function isAlphaNumeric(num)
{
	var checkstr = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	for(i=0;i<num.length;i++)
	{
		if(checkstr.indexOf(num.charAt(i))< 0)
			return false;
	}	
	return true;
}


function ltrim(str)
{
	while(str.length >0)
	{
		if(str.charAt(0) == ' ') str = str.substring(1);
		else break;		
	}
	return str;
}
function rtrim(str)
{
	while(str.length>0)
	{
		if(str.charAt(str.length-1) == ' ') str = str.substring(0,str.length-1);
		else break; 
	}
	return str;
}
function trim(str)
{
	return rtrim(ltrim(str));
}
function blankExist(str)
{
	if(str.indexOf(" ") > -1 ) return true;
	else return false;
}
