function OpenPopup(B,D,A,C){if(!A){A=screen.width*(3/4)}if(!C){C=screen.height*(3/4)}l=(screen.width-A)/2;t=(screen.height-C)/2;widthHeight="width="+A+",height="+C+",left="+l+",top="+t+",menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,location=no";window.open(B,D,widthHeight);return true}var checkflag="false";window.status="";
function textCounter(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+"%"
	setcolor(document.getElementById(counter),percentage,"background-color");
	}
}
function clickclear(thisfield, defaulttext) {
if (thisfield.value == defaulttext) {
thisfield.value = "";
}
}
function clickrecall(thisfield, defaulttext) {
if (thisfield.value == "") {
thisfield.value = defaulttext;
}
}
$(document).ready(function(){
	$('a.poplight[href^=#]').click(function() {
		var popID = $(this).attr('rel');
		var popURL = $(this).attr('href');
		var query= popURL.split('?');
		var dim= query[1].split('&');
		var popWidth = dim[0].split('=')[1];
		$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="/templates/images/close_pop.png" class="btn_close" title="غلق النافذه" alt="غلق" /></a>');
		var popMargTop = ($('#' + popID).height() + 80) / 2;
		var popMargLeft = ($('#' + popID).width() + 80) / 2;
		$('#' + popID).css({ 
			'margin-top' : -popMargTop,
			'margin-left' : -popMargLeft
		});
		$('body').append('<div id="fade"></div>');
		$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();
		return false;
	});
	$('a.close, #fade').live('click', function() {
	  	$('#fade , .popup_block').fadeOut(function() {
			$('#fade, a.close').remove();  
	});
		return false;
	});
});

