var wino = false; 
include = function(url,method_,send_){ 
var ajax; 
if(!method_)method_ = "GET"; 
if(!send_)send_ = null; 
if (!url) return; 
try{ 
    ajax = new XMLHttpRequest (); 
    } 
    catch (e){ 
        try { 
            ajax = new ActiveXObject("Msxml2.XMLHTTP"); 
            } 
    catch (_e_) { 
        ajax = new ActiveXObject("Microsoft.XMLHTTP"); 
        } 
    } 
ajax.open (method_, url, false); 
ajax.send (send_); 
if (ajax.readyState==4) 
    return ajax.responseText; 
} 
function stopError() { return true; }
window.onerror = stopError;

function selectat(elemnt) {
document.getElementById(elemnt).select();
document.getElementById(elemnt).focus();
if (document.all) {
textRange = document.getElementById(elemnt).createTextRange();
textRange.execCommand('RemoveFormat');
textRange.execCommand('Copy');
alert('تم نسخ الرابط');
}
}

function textCounter(field,counter,maxlimit,linecounter) {
	// text width//
	var fieldWidth =  parseInt(field.offsetWidth);
	var charcnt = field.value.length;        

	// trim the extra text
	if (charcnt > maxlimit) { 
		field.value = field.value.substring(0, maxlimit);
	}

	else { 
	// progress bar percentage
	var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
	document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
	document.getElementById(counter).innerHTML="النسبة :"+percentage+"%"
	// color correction on style from CCFFF -> CC0000
	setcolor(document.getElementById(counter),percentage,"background-color");
	}
}

function setcolor(obj,percentage,prop){
	obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}

function emoticon(text) {
        text = ' ' + text + ' ';
        if (document.post.editor.createTextRange && document.post.editor.caretPos) {
        var caretPos = document.post.editor.caretPos;
        caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
        document.post.editor.focus();} else {
        document.post.editor.value  += text;
        document.post.editor.focus();}}
        function bbfontstyle(bbopen, bbclose) {
        if ((clientVer >= 4) && is_ie && is_win) {
        theSelection = document.selection.createRange().text;
        if (!theSelection) {
        document.post.editor.value += bbopen + bbclose;
        document.post.editor.focus();return;}
        document.selection.createRange().text = bbopen + theSelection + bbclose;
        document.post.editor.focus();
        return;} else {
        document.post.editor.value += bbopen + bbclose;
        document.post.editor.focus();
        return;}
        storeCaret(document.post.editor);}
        function bbstyle(bbnumber) {
        donotinsert = false;
        theSelection = false;
        bblast = 0;
        if (donotinsert) {while (bbcode[bblast]) {
        butnumber = arraypop(bbcode) - 1;
        document.post.editor.value += bbtags[butnumber + 1];
        imageTag = false;}
        document.post.editor.focus();
        return;}storeCaret(document.post.editor);}