var d=document;
var bkr=true;

function $(v){return(d.getElementById(v));}
function $s(v){return($(v).style);}

function sw(o){$s(o).display='block';}
function hd(o){$s(o).display='none';}
function tgl(o){$s(o).display=($s(o).display=='block')?'none':'block';}

function vv(o){$s(o).visibility='visible';}
function vh(o){$s(o).visibility='hidden';}
function tglv(o){$s(o).visibility=($s(o).visibility=='visible')?'hidden':'visible';}

function $t(o,t){$(o).innerHTML=t;}
function $v(o){return $(o).value;}
function of(tv,obj){if(obj.value==tv)obj.value='';obj.style.color='black'}
function ob(tv,obj){if(obj.value==''){obj.value=tv;obj.style.color='gray'}}
function w(u,s,w,h){window.open(u,s,'width='+w+',height='+h+',scrollbars=1');return false;}

function setOpacity(obj,opacityLevel){var eStyle=$s(obj);eStyle.opacity=opacityLevel/100;eStyle.filter='alpha(opacity="'+opacityLevel+'")';}
/*
	//exchange alpha with: progid:DXImageTransform.Microsoft.Alpha
	if(navigator.appName=='Microsoft Internet Explorer')
		obj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=\'" + value + "\')";
	else
		obj.style.opacity = value / 100;
//*/

function vE(e)
{
	r=true;
	if(!e.email.value.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/))
	{
		e.email.style.borderColor='red';
		alert('invalide email');
		e.email.focus();
		r=false;
	}
	else
		e.email.style.borderColor=e.esm.style.borderColor;
	if(trim(e.txt.value)=='')
	{
		e.txt.style.borderColor='red';
		e.txt.focus();
		r=false;
	}
	else
		e.txt.style.borderColor=e.esm.style.borderColor;
	return r;
}
function act_height(id){height=$(id).clientHeight;if(height==0)height=$(id).offsetHeight;return height;}
function trim (str){var whitespace,l=0,i=0;str+='';whitespace=" \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000";l=str.length;for(i=0;i<l;i++)if(whitespace.indexOf(str.charAt(i))===-1){str=str.substring(i);break;}l=str.length;for(i=l-1;i>=0;i--)if(whitespace.indexOf(str.charAt(i))===-1){str=str.substring(0,i+1);break;}return whitespace.indexOf(str.charAt(0))===-1?str:'';}
function add2f(){ttl='كتاب‌لينك - محرك‌البحث للكتب‌العربيةوالإسلامية';adrs='http://www.ketablink.com';if(window.sidebar)window.sidebar.addPanel(ttl,adrs,"");else if(window.external)window.external.AddFavorite(adrs,ttl);else if(window.opera && window.print)alert("إستخدم Ctrl+D")}
function add2b(ttl,adrs){if(window.sidebar)window.sidebar.addPanel(ttl,adrs,"");else if(window.external)window.external.AddFavorite(adrs,ttl);else if(window.opera && window.print)alert("اضغط بزر الفأرة الأيمن على الرابط ثم اختر\nBookmark Link");return false;}
function addEngine($xml)
{
	//if((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function"))
	//	window.sidebar.addSearchEngine ('http://www.ketablink.com','','هل تريد...',null);
	//else
	if(window.external.AddSearchProvider)
		window.external.AddSearchProvider($xml);
	else
		alert('Only Firefox and IE7+');
	return false;
}
function addqt(inp_id)
{
	S=$v(inp_id).toString().match(new RegExp('.{1}','g'));
	var s='';
	for(var i in S)
		if(S[i]!=='"')
			s+=S[i];
	$(inp_id).value='"'+s+'"';
	return false;
}
////////////////////////////////////////	AJAX_START
function createAjaxObj(){
	var httprequest=false
	if (window.XMLHttpRequest){ // if Mozilla, Safari etc
		httprequest=new XMLHttpRequest()
		if (httprequest.overrideMimeType)
			httprequest.overrideMimeType('text/xml')
	}
	else if (window.ActiveXObject){ // if IE
	try {httprequest=new ActiveXObject("Msxml2.XMLHTTP");} 
	catch (e){try{httprequest=new ActiveXObject("Microsoft.XMLHTTP");}
		catch (e){}}
	}
	return httprequest
}

var ajaxpack=new Object()
ajaxpack.basedomain="http://"+window.location.hostname
ajaxpack.ajaxobj=createAjaxObj()
ajaxpack.filetype="txt"
ajaxpack.addrandomnumber=0 //Set to 1 or 0. See documentation.
ajaxpack.getAjaxRequest=function(url, parameters, callbackfunc, filetype){
	ajaxpack.ajaxobj=createAjaxObj() //recreate ajax object to defeat cache problem in IE
	if (ajaxpack.addrandomnumber==1) //Further defeat caching problem in IE?
	var parameters=parameters+"&ajaxcachebust="+new Date().getTime()
	if (this.ajaxobj){
		this.filetype=filetype
		this.ajaxobj.onreadystatechange=callbackfunc
		this.ajaxobj.open('GET', url+"?"+parameters, true)
		this.ajaxobj.send(null)
	}
}
ajaxpack.postAjaxRequest=function(url, parameters, callbackfunc, filetype){
	ajaxpack.ajaxobj=createAjaxObj() //recreate ajax object to defeat cache problem in IE
	if(this.ajaxobj){
		this.filetype=filetype
		this.ajaxobj.onreadystatechange = callbackfunc;
		this.ajaxobj.open('POST', url, true);
		this.ajaxobj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		this.ajaxobj.setRequestHeader("Content-length", parameters.length);
		this.ajaxobj.setRequestHeader("Connection", "close");
		this.ajaxobj.send(parameters);
	}
}
function clk(id){ajaxpack.getAjaxRequest('/click.php',id,processGetPost,id);return false;}
function processGetPost(){}
////////////////////////////////////////	AJAX_END
function loadScript(url){var sC=document.createElement("script");sC.type="text/javascript";sC.src=url;document.getElementsByTagName("head")[0].appendChild(sC);}
