//Date format is "May-27-2007"
function DateFormat(dd)
{
	if(dd != null && dd != undefined && dd!="")
	{
		var strTemp = "";
		var temp = dd.split('-');
		var d= new Date(temp[0],temp[1]-1,temp[2],temp[3],temp[4],temp[5]);
		d.setHours(-15);//USA Time

		var intArray = new Array(1,2,3,4,5,6,7,8,9,10,11,12);
		var strArray = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
		for(var i=0;i<intArray.length;i++)
		{
			if((d.getMonth()+1)==intArray[i])
			{
				strTemp = strArray[i];
				break;
			}
		}

		return strTemp + "-" + d.getDate() + "-" + d.getYear();
	}
	else
	{
		return "";
	}
}


function lTrim(str)
{
  if (str.charAt(0) == " ")
  {
    str = str.slice(1);
    // str = str.substring(1, str.length);
    str = lTrim(str);    
  }
  return str;
}


function rTrim(str)
{
  var iLength;
  
  iLength = str.length;
  if (str.charAt(iLength - 1) == " ")
  {

    str = str.slice(0, iLength - 1);
    // str = str.substring(0, iLength - 1);
    str = rTrim(str); 
  }
  return str;
}


function trim(str)
{
  return lTrim(rTrim(str));
}




//2007-01-02 00:00:33
function turntime(d)
{
	var time = new Date();
	var tempTime="";
	time = d;
	

	tempTime +=time.getMonth()+1;
	tempTime +='-';
	tempTime +=time.getDate();
	tempTime +='-';	
	tempTime += time.getFullYear();
	
	//tempTime +=' ';
	//tempTime +=time.toLocaleTimeString();
	
	return tempTime;
}

//--------------------------------------------------------------
//strInput
//maxlimit
//--------------------------------------------------------------
function strCounter(strInput,maxlimit) 
{
	var str="";
	str=strInput;
	str=str.replace(/[^\x00-\xff]/g,"**"); 
	if (str.length > maxlimit)
	{
		// field.value = field.value.substring(0, maxlimit);
		return getByteOfNum(strInput,maxlimit);
	}
	else
	{
		return strInput;
	}
}
function getByteOfNum(val, num)
{
	var ch,bytenum=0;
	var rs = "";
	var pt = /[^\x00-\xff]/;
	for (var i=0; i < num; i++)
	{
		ch = val.substr(i, 1);
		if (ch.match(pt))
		{
			bytenum += 2;
			if (bytenum > num)
			{
				return rs + '..';
			}
		}
		else
		{
			bytenum += 1;
		}
	
		rs += ch;
		
		if (bytenum == num)
		{
			return rs;
		}
	}
	return rs;
}

function strReplace(str)
{
	
	str=str.replace("'","''");
	str=str.replace("/","//");
	str=str.replace("?","/?");
	str=str.replace("%","/%");
	return str;
}

function Trim(y)
{
	while(y.search(' ')==0) y=y.replace(' ','');
	while(y.lastIndexOf(' ')==(y.length-1)){if(y.lastIndexOf(' ')==-1) break; y=y.substr(0,y.length-1);}	
}

