function chkmaxlen(str){   
  sl=str.length;   
  strLen=0;   
    for(i=0;i<sl;i++){   
    if(str.charCodeAt(i)>255)   strLen+=2;   
    else   strLen++;   
    }   
  return strLen;   
  }   
 
function chkchar(str){     
  sl=str.length;   
  strLen=0;   
  strchar=0;
    for(i=0;i<sl && strLen<280;i++){   
    if(str.charCodeAt(i)>255)
	{
	   strLen+=2;  
	   strchar++;
	} 
	
    else
	{
	   strLen++; 
	   strchar++;
	} 
    }   
  return strchar;   
  }   

  function checkLength(which) { 
            var maxChars = 140; 
            var thisChars = chkmaxlen(which.value);
            if (thisChars > 2*maxChars) 
		{
                which.value = which.value.substring(0,chkchar(which.value)); 
		}
		var curr = Math.floor(maxChars - chkmaxlen(which.value)/2);
                document.getElementById("chLeft").innerHTML = curr.toString(); 
            } 

			function storeCaret (textEl) {
if (textEl.createTextRange) 
textEl.caretPos = document.selection.createRange().duplicate(); 
}

function insertAtCaret (textEl, text) {
if (textEl.createTextRange && textEl.caretPos) {
var caretPos = textEl.caretPos;
caretPos.text =caretPos.text.charAt(caretPos.text.length - 1) == ' ' ?text + ' ' : text; 
} 
else 
textEl.value = text;
} 
function deleteAtCaret (textEl) {
if (textEl.createTextRange && textEl.caretPos) {
var caretPos = textEl.caretPos;
document.selection.clear();
}
} 

function checkform(){
  if(document.aForm.acontent.value==""){
      alert("ÇëÊäÈëÄÚÈÝ!");
      aForm.acontent.focus();
      return false;
  }
  else 
	       
      return true;


}

	function show()
	{  var fn = "";
		
		var divtemp=document.getElementById("lspic");
		
		
		if (divtemp.style.display == "none") {
			
			divtemp.style.display = "block";
		}
		else
		{
		    
			divtemp.style.display = "none";
		}
		
	}


function updateStatusTextCharCounter(value, submitButton) {
    var len_max = getStatusTextCharLengthMax(value);
    var charCountLeftIndicator = G$('charCountLeft');

    //		if (submitButton!=null) {
    //			submitButton.disabled=true;
    //		}

    var len = getStringBytes(value);
    var len_remain = len_max - len;

    charCountLeftIndicator.value = len_remain;


    if (len_remain >= 20) {
        charCountLeftIndicator.style.color = "#828282";
    } else if (len_remain >= 10) {
        charCountLeftIndicator.style.color = "#2b2b2b";
    } else {
        charCountLeftIndicator.style.color = "#b30800";
    }

    //		if (submitButton!=null && len_remain>=0 && len_remain!=len_max) {
    //			submitButton.disabled=false;
    //		}
};


	
