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)+"%)";
}
