// JavaScript Document
/*
	public function
	By:jerome
*/

function chkRegValue(){
		$("v_reg_email").style.display = "none";
		$("v_reg_username").style.display = "none";
		$("v_reg_password").style.display = "none";
		$("v_reg_repassword").style.display = "none";
		$("v_reg_first_name").style.display = "none";
		$("v_reg_country").style.display = "none";
		$("v_reg_car_have").style.display = "none";
		if($("email").value == ''){
				$("email").focus();
				$("v_reg_email").style.display = "";
				return false;
		}
		if($("login_name").value == ''){
				$("login_name").focus();
				$("v_reg_username").style.display = "";
				return false;
		}else if($("login_name").value.length < 3){
				$("login_name").focus();
				$("v_reg_username").style.display = "";
				$("v_reg_username").innerHTML = "Username must be 3-16 characters.";
				return false;
		}
		if($("passwd").value == ''){
				$("passwd").focus();
				$("v_reg_password").style.display = "";
				return false;
		}else if($("passwd").value.length < 5){
				$("passwd").focus();
				$("v_reg_password").style.display = "";
				$("v_reg_password").innerHTML = "Password must be 5-15 characters.";
				return false;
		}
		if($("passwd1").value == ''){
				$("passwd1").focus();
				$("v_reg_repassword").style.display = "";
				return false;
		}
		if($("passwd").value != $("passwd1").value){
				$("passwd").focus();
				$("v_reg_password").style.display = "";
				$("v_reg_password").innerHTML = "The password is not same.";
				return false;
		}
		if($("first_name").value == ''){
				$("first_name").focus();
				$("v_reg_first_name").style.display = "";
				return false;
		}
		if($("country").value == ''){
				$("country").focus();
				$("v_reg_country").style.display = "";
				return false;
		}
		if($("car_have").value == ''){
				$("car_have").focus();
				$("v_reg_car_have").style.display = "";
				return false;
		}
		return true;
}



function chkNoticeValue(){
		$("v_n_subject").style.display = "none";
		$("v_n_desc").style.display = "none";
		if($("notice_title").value == ''){
				$("notice_title").focus();
				$("v_n_subject").style.display = "";
				return false;
		}
		if($("notice_description").value == ''){
				$("notice_description").focus();
				$("v_n_desc").style.display = "";
				return false;
		}
		return true;
}

function chkAlbumValue(){
		$("v_album_name").style.display = "none";
		$("v_album_desc").style.display = "none";
		if($("album_name").value == ''){
				$("album_name").focus();
				$("v_album_name").style.display = "";
				return false;
		}
		if($("album_description").value == ''){
				$("album_description").focus();
				$("v_album_desc").style.display = "";
				return false;
		}
		return true;
}

function chkEventValue(){
		$("v_e_name").style.display = "none";
		$("v_e_desc").style.display = "none";
		$("v_e_category").style.display = "none";
		$("v_e_tags").style.display = "none";
		$("v_e_organizer").style.display = "none";
		$("v_e_place").style.display = "none";
		$("v_e_location").style.display = "none";
		if($("title").value == ''){
				$("title").focus();
				$("v_e_name").style.display = "";
				return false;
		}
		if($("description").value == ''){
				$("description").focus();
				$("v_e_desc").style.display = "";
				return false;
		}
		if($("category").value==""){
				$("category").focus();
				$("v_e_category").style.display = "";
				return false;
		}
		if($("tags").value == ''){
				$("tags").focus();
				$("v_e_tags").style.display = "";
				return false;
		}
		
		if($("model_have").value=="true"  && $("car_model").value==""){
				$("v_e_car").innerHTML = "Please select car model.";
				return false;
		}
		if($("makeyear_have").value=="true" && $("car_makeyear").value==""){
				$("v_e_car").innerHTML = "Please select car make year.";
				return false;
		}

		if($("organizer").value == ''){
				$("organizer").focus();
				$("v_e_organizer").style.display = "";
				return false;
		}
		if($("place").value == ''){
				$("place").focus();
				$("v_e_place").style.display = "";
				return false;
		}
		if($("country").value == ''){
				$("country").focus();
				$("v_e_location").style.display = "";
				return false;
		}else{
			if($("province_have").value=="true" && $("province").value==""){
				$("province").focus();
				$("v_e_location").style.display = "";
				$("v_e_location").innerHTML = "You must select province / state.";
				return false;
			}
			if($("city_have").value=="true" && $("city").value==""){
				$("city").focus();
				$("v_e_location").style.display = "";
				$("v_e_location").innerHTML = "You must select city.";
				return false;
			}
		}
		return true;
}


function chkForumValue(){
		$("v_f_subject").style.display = "none";
		$("v_f_desc").style.display = "none";
		if($("forum_title").value == ''){
				$("forum_title").focus();
				$("v_f_subject").style.display = "";
				return false;
		}
		if($("forum_description").value == ''){
				$("forum_description").focus();
				$("v_f_desc").style.display = "";
				return false;
		}
		return true;
}

function chkReplyForumValue(){
		$("v_reply_forum").style.display = "none";
		if($("replycontent").value == ''){
				$("v_reply_forum").style.display = "";
				return false;
		}
		return true;
}


function chkInviteUserValue(){
		//$("v_invite_email").style.display = "none";
		//$("v_invite_user").style.display = "none";
		$("v_invite_message").style.display = "none";
		var invite_type = $("invite_type").value;
		//alert(invite_type);
		if(invite_type == 0){
			if($("invite_user").value == ''){
				$("v_invite_user").style.display = "none";
				$("invite_user").focus();
				$("v_invite_user").style.display = "";
				return false;
			}
		}else{
			if($("invite_email").value == ''){
					$("v_invite_email").style.display = "none";
					$("invite_email").focus();
					$("v_invite_email").style.display = "";
					return false;
			}else if(!/(\S)+[@]{1}(\S)+[.]{1}(\w)+/.test(document.getElementById('invite_email').value)){
					$("v_invite_email").style.display = "";
					$("v_invite_email").innerHTML = "Please enter a valid email address.";
					$("invite_email").focus();
					return false;
				}
		}
		
		if($("invite_message").value == ''){
				$("invite_message").focus();
				$("v_invite_message").style.display = "";
				return false;
		}
		
		return true;
}

function chkAddReGroupValue(){
		$("v_invite_leader").style.display = "none";
		$("v_invite_group_name").style.display = "none";
		if($("invite_leader").value == ''){
				$("invite_leader").focus();
				$("v_invite_leader").style.display = "";
				return false;
		}
		if($("invite_group").value == ''){
				$("invite_group").focus();
				$("v_invite_group_name").style.display = "";
				return false;
		}
		return true;
}

function chkSendMsgValue(){
		$("v_msg_to").style.display = "none";
		$("v_msg_subject").style.display = "none";
		$("v_msg_content").style.display = "none";
		if($("recv_user").value == ''){
				$("recv_user").focus();
				$("v_msg_to").style.display = "";
				return false;
		}
		if($("msg_title").value == ''){
				$("msg_title").focus();
				$("v_msg_subject").style.display = "";
				return false;
		}
		var msg_content = $("msg_content").value;
		if($("msg_content").value == ''){
			 $("msg_content").focus();
                         $("v_msg_content").style.display = "";
                         return false;
		}
		if(!checkByteLength(msg_content,10,300)){
			$("msg_content").focus();
			$("v_msg_content").style.display = "";
			$("v_msg_content").innerHTML = "Message must be at least 10 characters long.";
			return false;
		}
		return true;
}

function chkShoutValue(){
		$("v_shoutbox_txt").style.display = "none";
		var msg_content = $("shoutbox").value;
		if(!checkByteLength(msg_content,3,200)){
				$("shoutbox").focus();
				$("v_shoutbox_txt").style.display = "";
				$("v_shoutbox_txt").innerHTML = "";
				return false;
		}
		return true;
}
/*
	Check Add Group Form Value	
*/
function chkAddGroupValue(){
		$("v_group_name").style.display = "none";
		$("v_group_category").style.display = "none";
		$("v_group_tags").style.display = "none";
		$("v_group_desc").style.display = "none";
		if($("groupname").value == ''){
				$("groupname").focus();
				$("v_group_name").style.display = "";
				return false;
		}else if(isnumber($("groupname").value)){
				$("groupname").focus();
				$("v_group_name").style.display = "";
				$("v_group_name").innerHTML = "Group name must contain at least 1 letter.";
				return false;		
		}
		if($("group_category").value == ''){
				$("group_category").focus();
				$("v_group_category").style.display = "";
				return false;
		}
		
		if($("grouptags").value != ''){
			var tag=document.getElementById("grouptags").value;
			tags=tag.split(",");
			for(i=0;i<tags.length;i++){
				v=tags[i];
				if(bytes(v)<2){
					$("v_group_tags").style.display = "";
					$("v_group_tags").innerHTML = "Tags must be a minimum of 2 characters long.";
					return false;
				}
			}
		}else{
				$("grouptags").focus();
				$("v_group_tags").style.display = "";
				return false;
		}
		var groupdesc = $("groupdesc").value;
		if(groupdesc == ''){
			$("groupdesc").focus();
			$("v_group_desc").style.display = "";
			return false;
		}else if(!checkByteLength(groupdesc,10,1000)){
				$("groupdesc").focus();
				$("v_group_desc").style.display = "";
				$("v_group_desc").innerHTML = "Group description must be at least 10 characters long.";
				return false;
		}
		return true;
}


function chkInviteValue(){
		$("v_invite_group").style.display = "none";
		$("v_invite_email").style.display = "none";
		$("v_invite_user").style.display = "none";
		if($("invite_group").value == ''){
				$("invite_group").focus();
				$("v_invite_group").style.display = "";
				return false;
		}
		if($("invite_email").value == ''){
				$("invite_email").focus();
				$("v_invite_email").style.display = "";
				return false;
		}
		if($("invite_user").value == ''){
				$("invite_user").focus();
				$("v_invite_user").style.display = "";
				return false;
		}
		return true;
}


function chkInviteFValue(){
		$("v_friend_email").style.display = "none";
		$("v_invite_msg").style.display = "none";
		if($("invite_email").value == ''){
			$("invite_email").focus();
			$("v_friend_email").style.display = "";
			$("v_friend_email").innerHTML = "Please enter at least one valid email address.";
			return false;
		}else{

			var str=document.getElementById('invite_email').value;
			var patn=/^[_a-zA-Z0-9\-]+(\.[_a-zA-Z0-9\-]*)*@[a-zA-Z0-9\-]+([\.][a-zA-Z0-9\-]+)+$/;
			if(!patn.test(str)){
				$("invite_email").focus();
				$("v_friend_email").style.display = "";
				$("v_friend_email").innerHTML = "Please enter at least one valid email address.";
				return false;
			}
			
		}
		if($("invite_message").value == ''){
			$("invite_message").focus();
			$("v_invite_msg").style.display = "";
			return false;
		}
		return true;
}



function chkBlogValue(){
		$("v_content_title").style.display = "none";
		$("v_content_txt").style.display = "none";
		$("v_content_tags").style.display = "none";
		if($("content_title").value == ''){
				$("content_title").focus();
				$("v_content_title").style.display = "";
				return false;
		}
		var oEditor = FCKeditorAPI.GetInstance('editor');
		if(oEditor.GetXHTML( true ) == "" ){
			$("v_content_txt").style.display = "";
			return false;
		}
		if($("content_tags").value != ''){
			var tag=document.getElementById("content_tags").value.trim();
			tags=tag.split(",");
			for(i=0;i<tags.length;i++){
				v=tags[i];
				if(bytes(v)<2){
					$("v_content_tags").style.display = "";
					$("v_content_tags").innerHTML = "Tags must be a minimum of 2 characters long.";
					return false;
				}
			}
		}else{
				$("content_tags").focus();
				$("v_content_tags").style.display = "";
				return false;
		}
		if($("model_have").value=="true"  && $("car_model").value==""){
				$("v_content_car").innerHTML = "Please select car model.";
				return false;
		}
		if($("makeyear_have").value=="true" && $("car_makeyear").value==""){
				$("v_content_car").innerHTML = "Please select car make year.";
				return false;
		}
		return true;
}

function chkPhotoValue(){
		$("v_image_title").style.display = "none";
		$("v_image_desc").style.display = "none";
		$("v_image_value").style.display = "none";
		$("v_image_format").style.display = "none";
		$("v_content_tags").style.display = "none";
		if($("content_title").value == ''){
				$("content_title").focus();
				$("v_image_title").style.display = "";
				return false;
		}
		if($("content_description").value == ''){
				$("content_description").focus();
				$("v_image_desc").style.display = "";
				return false;
		}
		if($("content_tags").value != ''){
			var tag=document.getElementById("content_tags").value.trim();
			tags=tag.split(",");
			for(i=0;i<tags.length;i++){
				v=tags[i];
				if(bytes(v)<2){
					$("v_content_tags").style.display = "";
					$("v_content_tags").innerHTML = "Tags must be a minimum of 2 characters long.";
					return false;
				}
			}
		}else{
				$("content_tags").focus();
				$("v_content_tags").style.display = "";
				return false;
		}
		var strFileName = $("pfile").value;
		var FileType;
		if(strFileName == '' && $("pfileurl").value ==''){
				$("pfile").focus();
				$("v_image_value").style.display = "";
				return false;
		}
		if(strFileName != ''){
				FileType = strFileName.substr(strFileName.lastIndexOf(".")+1);
				FileType = FileType.toLowerCase();
				if(FileType != ''){
					if(FileType == 'gif' || FileType == 'jpeg' || FileType =='jpg' || FileType == 'png' || FileType =='bmp'){
							
					}else{
							$("pfile").focus();
							$("v_image_format").style.display = "";
							return false;
					}
				}
		}
		if($("model_have").value=="true"  && $("car_model").value==""){
				$("v_content_car").innerHTML = "Please select car model.";
				return false;
		}
		if($("makeyear_have").value=="true" && $("car_makeyear").value==""){
				$("v_content_car").innerHTML = "Please select car make year.";
				return false;
		}
		return true;
}



function chkVideoValue(){
		$("v_video_title").style.display = "none";
		$("v_content_video").style.display = "none";
		$("v_content_desc").style.display = "none";
		$("v_image_value").style.display = "none";
		$("v_image_format").style.display = "none";
		$("v_content_tags").style.display = "none";
		if($("content_title").value == ''){
				$("content_title").focus();
				$("v_video_title").style.display = "";
				return false;
		}
		if($("content_video").value == ''){
				$("content_video").focus();
				$("v_content_video").style.display = "";
				return false;
		}
		if($("content_description").value == ''){
				$("content_description").focus();
				$("v_content_desc").style.display = "";
				return false;
		}
		
		if($("content_tags").value != ''){
			var tag=document.getElementById("content_tags").value.trim();
			tags=tag.split(",");
			for(i=0;i<tags.length;i++){
				v=tags[i];
				if(bytes(v)<2){
					$("v_content_tags").style.display = "";
					$("v_content_tags").innerHTML = "Tags must be a minimum of 2 characters long.";
					return false;
				}
			}
		}else{
				$("content_tags").focus();
				$("v_content_tags").style.display = "";
				return false;
		}

		var strFileName = $("vfile").value;
		var FileType;
		if(strFileName == '' && $("vfileurl").value ==''){
				$("vfile").focus();
				$("v_image_value").style.display = "";
				return false;
		}
		if(strFileName != ''){
				FileType = strFileName.substr(strFileName.lastIndexOf(".")+1);
				FileType = FileType.toLowerCase();
				if(FileType != ''){
					if(FileType == 'gif' || FileType == 'jpeg' || FileType =='jpg' || FileType == 'png' || FileType =='bmp'){
							return true;
					}else{
							$("vfile").focus();
							$("v_image_format").style.display = "";
							return false;
					}
				}
		}		
		
		return true;
}

function chkAccountBaseInfo(){
		$("v_uinfo_email").style.display = "none";
		if($("email").value == ''){
				$("email").focus();
				$("v_uinfo_email").style.display = "";
				return false;
		}
		return true;
}

/*
#Group Function
*/
function chkPostForumValue(){
		$("v_forum_title").style.display = "none";
		$("v_forum_content").style.display = "none";
		if($("forum_title").value == ''){
				$("forum_title").focus();
				$("v_forum_title").style.display = "";
				return false;
		}
		if($("forum_content").value == ''){
				$("forum_content").focus();
				$("v_forum_content").style.display = "";
				return false;
		}
		strOverflow($("forum_content"));
		document.getElementById("btn_Ok").disabled = true;
		return true;
}

function chkCarValue(){
		$("v_car_nick").style.display = "none";
		$("v_car_desc").style.display = "none";
		$("v_car_tags").style.display = "none";
		if($("car_nick").value == ''){
				$("car_nick").focus();
				$("v_car_nick").style.display = "";
				return false;
		}
		if($("car_desc").value == ''){
				$("car_desc").focus();
				$("v_car_desc").style.display = "";
				return false;
		}
		if($("car_tags").value != ''){
			var tag=document.getElementById("car_tags").value;
			tags=tag.split(",");
			for(i=0;i<tags.length;i++){
				v=tags[i];
				if(bytes(v)<2){
					$("v_car_tags").style.display = "";
					$("v_car_tags").innerHTML = "Tags must be a minimum of 2 characters long.";
					return false;
				}
			}
		}else{
			$("car_tags").focus();
			$("v_car_tags").style.display = "";
			return false;
		}
		return true;
}


/*
	UI Functions
*/

function validateNum(obj) {
    var str = obj.value;
    var patn = new RegExp("\\d{" + getAttrValueByName(obj, "minlen") + "," + getAttrValueByName(obj, "maxlen") + "}");
    if (patn.test(str)) return 0;
    return 1;
}

function getMailServer(str) {
    //be sure str is a correct email address
    str = str.trim();
    return str.substr(str.indexOf("@") + 1);
}

function validateSameAs(obj) {
    var v1,v2;
    if (!getAttrValueByName(obj, "sameas")) return true;
    v1 = obj.value;
    v2 = document.getElementById(getAttrValueByName(obj, "sameas")).value;
    if (v1 == v2) return true;
    return false;
}
function checkByteLength(str, minlen, maxlen) {
    if (str == null) return false;
    var l = str.length;
    var blen = 0;
    for (i = 0; i < l; i++) {
        if ((str.charCodeAt(i) & 0xff00) != 0) {
            blen ++;
        }
        blen ++;
    }
    if (blen > maxlen || blen < minlen) {
        return false;
    }
    return true;
}
String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

function checkform()
{
	var str,theform;
	theform=document.formCreateContent;
	for (i=0;i<theform.selList.length;i++){
		if (i==0){
			theform.selStr.value=theform.selList.options[i].value;
		}else{
			theform.selStr.value=theform.selList.options[i].value+","+theform.selStr.value;
		}
	}
	return true;
}

function addList()
{theform=document.formCreateContent;
	var rlist,llist;
	rlist=theform.left_list;
	llist=theform.selList;
	for(var i = rlist.length - 1; i >= 0; i --) {
	  if(rlist.options[i].selected) {
	   llist.options.length++;
	   llist.options[llist.options.length-1].value = rlist.options[i].value;
	   llist.options[llist.options.length-1].text = rlist.options[i].text;
	
	   for(var j = i; j < rlist.options.length - 1; j ++) {
		rlist.options[j].value = rlist.options[j+1].value;
		rlist.options[j].text = rlist.options[j+1].text;
	   }
	   rlist.length --;
	  }
 }
}
function addall()
{
theform=document.formCreateContent;
	var rlist,llist;
	rlist=theform.left_list;
	llist=theform.selList;
	for(var i = rlist.length - 1; i >= 0; i --) {
	   llist.options.length++;
	   llist.options[llist.options.length-1].value = rlist.options[i].value;
	   llist.options[llist.options.length-1].text = rlist.options[i].text;
	for(var j = i; j < rlist.options.length - 1; j ++) {
		rlist.options[j].value = rlist.options[j+1].value;
		rlist.options[j].text = rlist.options[j+1].text;
	   }
	   rlist.length --;
 }
}
function delList()
{theform=document.formCreateContent;
	var rlist,llist;
	rlist=theform.left_list;
	llist=theform.selList;
	for(var i = llist.length - 1; i >= 0; i --) {
		if(llist.options[i].selected) {
		   rlist.options.length++;
		   rlist.options[rlist.options.length-1].value = llist.options[i].value;
		   rlist.options[rlist.options.length-1].text = llist.options[i].text;
		   for(j = llist.selectedIndex; j < llist.options.length - 1; j ++) {
				llist.options[j].value = llist.options[j+1].value;
				llist.options[j].text = llist.options[j+1].text;
		   }
		   llist.length --;
		}
 	}

}
///////
function delall()
{
theform=document.formCreateContent;
	var rlist,llist;
	llist=theform.left_list;
	rlist=theform.selList;
	for(var i = rlist.length - 1; i >= 0; i --) {
	   llist.options.length++;
	   llist.options[llist.options.length-1].value = rlist.options[i].value;
	   llist.options[llist.options.length-1].text = rlist.options[i].text;
	for(var j = i; j < rlist.options.length - 1; j ++) {
		rlist.options[j].value = rlist.options[j+1].value;
		rlist.options[j].text = rlist.options[j+1].text;
	   }
	   rlist.length --;
 }
}
/////////////////////////////
function delOne()
{theform=document.formCreateContent;
	var rlist,llist;
	rlist=theform.left_list;
	llist=theform.selList;
	if(llist.selectedIndex < 0 || llist.selectedIndex > llist.options.length)return;
	 var i;
	 rlist.options.length++;
	 rlist.options[rlist.options.length-1].value = llist.options[llist.selectedIndex].value;
	 rlist.options[rlist.options.length-1].text = llist.options[llist.selectedIndex].text;
	 for(i = llist.selectedIndex; i < llist.options.length - 1; i ++) {
	  llist.options[i].value = llist.options[i+1].value;
	  llist.options[i].text = llist.options[i+1].text;
	 }
	 llist.length --;

}
function addOne()
{theform=document.formCreateContent;
	var rlist,llist;
	rlist=theform.left_list;
	llist=theform.selList;
	if(rlist.selectedIndex < 0 || rlist.selectedIndex > rlist.options.length)return;
		 var i;
		
		 llist.options.length++;
		 llist.options[llist.options.length-1].value = rlist.options[rlist.selectedIndex].value;
		 llist.options[llist.options.length-1].text = rlist.options[rlist.selectedIndex].text;
		
		 for(i = rlist.selectedIndex; i < rlist.options.length - 1; i ++) {
		  rlist.options[i].value = rlist.options[i+1].value;
		  rlist.options[i].text = rlist.options[i+1].text;
	 }
	 rlist.length --;
}
/////////////////////////////////////////////
function strOverflow(str)
{
	if(str){
		var arr = str.split("\n");
		for(var i=0;i<arr.length;i++){
			var arrr = arr[i].split(" ");
			for(var j=0;j<arrr.length;j++){
				if(arrr[j].length > 25)	{
					alert('Syntax Error - Please make sure that you are not submitting any illegal characters.');
					return false;
				}
			}
		}
	}else{
		return false;
	}
	return true;
}

function wholeElection(target)
{
	for(var i=0;i<document.all.length;i++)
	{
		if(document.all[i].type == "checkbox"&&document.all[i] !=target)
		{
			document.all[i].checked = target.checked;	
		}
	}
}

function phresize(im,size) {
    if(im.width>im.height) {
        if(im.width>size) {
            im.width=size;
        }
    } else {
        if(im.height>size) {
            im.height=size;
        }
    }
}

function checkall(form, prefix, checkall) {
	var checkall = checkall ? checkall : 'chkall';
	for(var i = 0; i < form.elements.length; i++) {
		var e = form.elements[i];
		if(e.name != checkall && (!prefix || (prefix && e.name.match(prefix)))) {
			e.checked = form.elements[checkall].checked;
		}
	}
}

function setState(statestr, form, element){
	var state = form.operation;
	var _ids = document.getElementsByName(element);
	if(_ids == null)
		return false;
	var _id="";
	var num=0;
	for(var i=0;i<_ids.length;i++){
		if(_ids[i].checked==true)
			_id+=_ids[i].value+"id";
		else
			num++;
	}
	if(num == _ids.length){
		alert("Please select at least one item.");
		return; 
	}	
	state.value=statestr;
	if(statestr=="delete"){
		if(confirm("Are you sure you want to delete the selected item/items?")){
			form.submit();
		}
	}else{		
		form.submit();
	}
}

function textLimitCheck(thisArea,maxLength){
  if(document.getElementById("ErrorMessagePanel")!=undefined){
  	document.getElementById("ErrorMessagePanel").parentNode.removeChild(document.getElementById("ErrorMessagePanel"));
  }
  if(bytes(thisArea.value.trim()) > maxLength){
    alert("The maximum length is " + maxLength + " characters.");
    thisArea.value=thisArea.value.substring(0,maxLength);
    thisArea.focus();
    return false;
  }
  
  try{
      var span = document.createElement("SPAN");
      span.id = "ErrorMessagePanel";
      span.style.color = "red";
      span.style.display = "block";
      span.style.marginLeft = 140+"px";
      span.style.marginTop = 5+"px";
      thisArea.parentNode.appendChild(span);
      span.innerHTML = (maxLength-bytes(thisArea.value)) + " Characters Left";
  }catch(e){
  	alert(e.description);
  }
  
  return true;
}
