﻿function number_days(x_a, x_b){
	mins = (x_a - x_b);
	t_d = parseInt(mins / 86400);
	t_m = parseInt((mins % 86400 ) / 3600);
	ttt = parseInt(((mins % 86400 ) % 3600) / 60);
	t_s = (mins % 60);
	document.write('منذ '+t_d+' يوم, '+t_m+' ساعة, '+ttt+' دقيقة, '+t_s+' ثانية');

}

function limitcomment(field,counter,maxlimit,linecounter) {

	var fieldWidth =  parseInt(field.offsetWidth);
	var charcnt = field.value.length;        
	if (charcnt > maxlimit) { 
		field.value = field.value.substring(0, maxlimit);
	} else { 
		var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
		document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
		document.getElementById(counter).innerHTML="أقصى حد للكتابة: "+percentage+"%"
	}

}

var http = createRequestObject();
function createRequestObject(){
	var request_;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		request_ = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
        	request_ = new XMLHttpRequest();

	}
	return request_;
}

function report_comment(idg, idc, idh){	function lood(){
		if(http.readyState == 1){
			document.getElementById(idh).innerHTML = ' ... ';
		}
		if(http.readyState == 4){
			var response = http.responseText;
			document.getElementById(idh).innerHTML = response;
		}
	}

	http.open('GET', 'report-comment?act=comm&idg='+idg+'&idc='+idc);
	http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=UTF-8');
	http.onreadystatechange = lood;
	http.send(null);
}

