/***********************************************************\
||                     Duhok Forum 2.0                     ||
||                  =====================                  ||
|| +-----------------------------------------------------+ ||
|| |                                                     | ||
|| | DUHOK FORUM IS NOT FREE SOFTWARE AFTER THIS VERSION | ||
|| |                                                     | ||
|| | ============= Programming By Dilovan ============== | ||
|| | Copyright © 2007-2010 Dilovan. All Rights Reserved. | ||
|| +-----------------------------------------------------+ ||
|| | If you want any support vist down address:-         | ||
|| | Email: df@duhoktimes.com                            | ||
|| | Site: http://df.duhoktimes.com/index.php            | ||
|| +-----------------------------------------------------+ ||
\***********************************************************/
if(!DT) var DT={};
DT.checkRowClass=function(s,id,className,rowName){
	var row=$((rowName ? rowName : 'row')+id);
	row.className=(s.checked ? 'select' : (className ? className : 'fixed'));
};
DT.repClassByVal=function(val1,val2,el){
	var cell=$(el);
	if(cell){
		var cName=cell.className,findSel=(cName.indexOf('Sel')>=0?true:false);
		if(val1==val2){
			cell.className=(findSel?cName.substring(0,cName.length-3):cName);
		}
		else{
			cell.className=cell.className+(findSel?'':'Sel');
		}
	}
};
DT.checkSymbols=function(str){
	var bads=new Array("\"","@","'","|","\\",".","ـ","[","]","{","}","(",")","<",">","?","؟",",","~","!","#","$","%","^","&","*","=","+","_","-","`","/",":",";","،","‘","÷","×","؛","’");
	for(var x in bads){
		if(str.indexOf(bads[x])>=0){
			return bads[x];
		}
	}
	return 1;
};
DT.basicPagingGo=function(s){
	var pg=s.options[s.selectedIndex].value;
	document.location=link+"pg="+pg;
};
DT.getPhotoOver=function(el,ev,att){
	var img=document.createElement('img'),e=ev||window.event;
	img.style.position='absolute';
	img.style.top=e.clientY+document.body.scrollTop-5;
	img.style.left=e.clientX-10;
	img.style.border=0;
	img.src=(att?eval("el."+att):el.href);
	var errLoad=function(){
		img.style.width=0;
		img.style.height=0;
	}
	img.onerror=errLoad;
	el.appendChild(img);
};
DT.getPhotoOut=function(el){
	for(var x=0;x<el.children.length;x++){
		var child=el.children(x);
		if(child&&child.style.position=='absolute'){
			child.style.visibility='hidden';
			el.removeChild(child);
		}
	}
};
DT.zoomHeaderIcons=function(iconId,power){
	var icon=$(iconId),from=parseInt(icon.offsetWidth),to=(power==1?58:48),db=document.body,
	zoom=function(){
		if(power==1&&to>from||power==0&&from>to){
			if(power==1) from++;
			else from--;
			icon.style.width=from+"px";
			db.zoomIcon[iconId]=setTimeout(zoom,10);
		}
		else{
			clearTimeout(db.zoomIcon[iconId]);
			return;
		}
	};
	if(!db.zoomIcon){
		db.zoomIcon=new Array();
	}
	if(db.zoomIcon[iconId]){
		clearTimeout(db.zoomIcon[iconId]);
	}
	db.zoomIcon[iconId]=setTimeout(zoom,1);
};
DT.fillButtons=function(){
	var buttons=document.getElementsByTagName('input');
	for(var x=0;x<buttons.length;x++){
		if(buttons[x].type=='button'&&buttons[x].className=='dt-button'){
			this.setDetails(buttons[x]);
		}
	}
};
DT.setDetails=function(btn){
	btn.onmouseout=function(){
		this.className='dt-button';
	};
	btn.onmouseover=function(){
		this.className='dt-button-over';
	};
	btn.onmousedown=function(){
		this.className='dt-button-down';
	};
};
DT.hideElement=function(id){
	var el=$(id);
	if(el){
		el.style.visibility='hidden';
		el.style.position='absolute';
		el.style.top='2px';
		el.style.left='2px';
	}
};
DT.showElement=function(id){
	var el=$(id);
	if(el){
		el.style.visibility='visible';
		el.style.position='';
	}
};
DT.menu={
	obj:false,menuText:new Array(),objId:0,objType:false,
	load:function(other){
		this.menuText[1]=['رقم العضوية',''];
		this.menuText[2]=['عدد مشاركات',''];
		this.menuText[3]=['نقاط التميز',''];
		this.menuText[4]=['مراسلاتك مع العضو','pm.php?mail=u&u={u}'];
		this.menuText[5]=['مشاركات العضو','yourposts.php?auth={u}'];
		this.menuText[6]=['مواضيع العضو','yourtopics.php?auth={u}'];
		this.menuText[7]=['اضف العضو لقوائمك الخاصة','profile.php?type=lists&l=-1&u={u}'];
		this.menuText[8]=['امنع العضو من مراسلتك','profile.php?type=lists&l=-2&u={u}'];
		this.menuText[20]=['أضف موضوع جديد','editor.php?type=newtopic&f={f}&src='+escape(self)+''];
		this.menuText[21]=['ارسل رسالة للمنتدى','editor.php?type=sendpm&u=-{f}&src='+escape(self)+''];
		this.menuText[22]=['مواضيعك في المنتدى','forums.php?f={f}&auth='+userId+''];
		this.menuText[30]=['أضف رد للموضوع','editor.php?type=newpost&t={t}&src='+escape(self)+''];
		this.menuText[31]=['تعديل الموضوع','editor.php?type=edittopic&t={t}&src='+escape(self)+''];
		this.menuText[32]=['أرسل موضوع لصديقك','sendtopic.php?t={t}'];
		this.menuText[33]=['أضف موضوع للمفضلة','favorite.php?type=add&t={t}'];
		this.menuText[34]=['طباعة موضوع','print.php?t={t}'];
		this.menuText[35]=['ردودك فقط في الموضوع','topics.php?t={t}&u='+userId+''];
		this.menuText[36]=['أرسل رسالة لصاحب الموضوع','editor.php?type=sendpm&u={o}&t={t}&src='+escape(self)+''];
		if(other){
			for(var x=0;x<other.length;x++){
				this.menuText[other[x][0]]=eval(other[x][1]);
			}
		}
	},
	create:function(){
		if(!this.obj){
			var obj=document.createElement('div'),retFlase=function(){return false};
			obj.id='menubarObj';
			obj.className='menubarBox';
			obj.oncontextmenu=retFlase;
			obj.onselectstart=retFlase;
			document.body.appendChild(obj);
			this.obj=$('menubarObj');
		}
		DT.ajax.play({
			'send':'type=menubarContents&method='+this.objType+'&id='+this.objId,
			'func':function(){
				var obj=DT.ajax.oName,ac=DT.ajax.ac,code,rows,cells;
				if(obj.readyState==1||obj.readyState==2||obj.readyState==3){
					DT.menu.msgBox("<img src=\""+progressUrl+"\" vspace=\"4\" border=\"0\"><br>رجاءاً انتظر ...");
				}
				else if(obj.readyState==4){
					var rows=eval(obj.responseText);
					if(rows){
						code="<table dir=\"rtl\" width=\"155\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\">";
						for(var x=0;x<rows.length;x++){
							cells=rows[x];
							if(cells[0]==-1){
								code+="<tr><td class=\"menubarOut\" style=\"padding:0px\" colspan=\"2\"><hr style=\"width:96%;height:1px;\"></td></tr>";
							}
							else{
								code+=DT.menu.addField(cells[0],cells[1],cells[2],cells[3],cells[4]);
							}
						}
						code+="</table>";
						DT.menu.obj.innerHTML=code;
						DT.menu.setMenubarId(DT.menu.obj);
						DT.menu.hideSelectTag('hidden');
					}
					else{
						DT.menu.msgBox("<font color=\"red\"><img src=\""+errorUrl+"\" vspace=\"4\" border=\"0\"><br>حدث خطأ أثناء التحميل.</font>",2000);
					}
				}
			}
		});
	},
	msgBox:function(text,sec){
		this.obj.innerHTML="<table width=\"140\" cellspacing=\"0\" cellpadding=\"2\" border=\"0\"><tr><td class=\"menubarOut\" align=\"center\">"+text+"</td></tr></table>";
		DT.menu.setMenubarId(this.obj);
		if(sec) setTimeout("DT.menu.obj.style.visibility='hidden';",sec);
	},
	setMenubarId:function(obj){
		var children=(DT.browse().ie?'children':'childNodes');
		for(var x=0;x<obj[children].length;x++){
			obj[children][x].id='menubar';
			this.setMenubarId(obj[children][x]);
		}
	},
	addField:function(textId,otherText,highlight,disabled,o){
		var code,other,url,color,text=this.menuText[textId][0];
		url=this.menuText[textId][1].replace("{"+this.objType+"}",this.objId);
		if(o) url=url.replace("{o}",o);
		color=(disabled==1?'silver':'black');
		other=(url!=''&&disabled==0?" onClick=\"DT.menu.gotoLink('"+(this.menuText[textId][2]?this.menuText[textId][2]:'')+"','"+url+"')\"":"");
		if(highlight==1){
			other+=" onMouseOver=\"this.style.backgroundColor='"+menubarHighlight+"';\"  onMouseOut=\"this.style.backgroundColor='';\"";
		}
		code="<tr"+other+">"+
		"<td style=\"padding-right:5px;cursor:default;color:"+color+"\"><nobr><font class=\"small\">"+text+"</font></nobr></td>"+
		"<td style=\"width:10%;padding-right:5px;padding-left:5px;cursor:default;color:"+color+"\" align=\"center\"><nobr><font class=\"small\">"+otherText+"</font></nobr></td></tr>";
		return code;
	},
	gotoLink:function(msg,url){
		if(msg!=''){
			if(confirm(msg)){
				document.location=url;
			}
		}
		else{
			document.location=url;
		}
	},
	checkElements:function(){
		if(userLevel>0){
			var el=document.getElementsByTagName('a');
			for(var x=0;x<el.length;x++){
				if((/[u|f|t]+[0-9]/).test(el[x].id)){
					el[x].oncontextmenu=DT.menu.context;
				}
			}
		}
	},
	hideSelectTag:function(status){
		var el=document.getElementsByTagName('select');
		for(var x=0;x<el.length;x++){
			if(el[x].className=='dark'&&this.objType=='f'){
				el[x].style.visibility=status;
			}
		}
	},
	context:function(ev){
		var menu=DT.menu,e=ev||window.event,db=document.body,ie=DT.browse().ie,x=(ie?db.clientWidth:window.innerWidth)-e.clientX,y=(ie?db.clientHeight:window.innerHeight)-e.clientY;
		menu.objId=this.id.match(/([0-9]+)/g);
		menu.objType=this.id.substring(0,1);
 		menu.create();
		if(x<menu.obj.offsetWidth){
			menu.obj.style.left=(ie?db.scrollLeft:window.pageXOffset)+e.clientX-menu.obj.offsetWidth;
		}
		else{
			menu.obj.style.left=(ie?db.scrollLeft:window.pageXOffset)+e.clientX;
		}
		if(y<menu.obj.offsetHeight){
			menu.obj.style.top=(ie?db.scrollTop:window.pageYOffset)+e.clientY-menu.obj.offsetHeight;
		}
		else{
			menu.obj.style.top=(ie?db.scrollTop:window.pageYOffset)+e.clientY;
		}
		menu.obj.style.visibility='visible';
		return false;
	},
	click:function(ev){
		var menu=DT.menu,e=ev||window.event,ie=DT.browse().ie,obj=(ie?e.srcElement:e.target);
		if(obj&&!(/menubar+(.*)/).test(obj.id)&&menu.obj){
			menu.obj.style.visibility='hidden';
			DT.menu.hideSelectTag('visible');
		}
	}
};
DT.viewText=function(text){
	var el=document.createElement('textarea');
	el.style.width='500px';
	el.style.height='100px';
	el.style.direction='ltr';
	el.value=text;
	document.body.appendChild(el);
};
DT.msgBox=function(text,color,mp,width,logo,align){
	var colorsCode=new Array(),obj,mp=(mp?mp:10),code=textCode="",id="v"+Math.random().toString().substring(2,6)+"v";
	colorsCode['gray']=new Array('#666666','#ffffff','loading');
	colorsCode['yellow']=new Array('#666600','#fffaca','alert');
	colorsCode['blue']=new Array('#000066','#dce3fd','info');
	colorsCode['green']=new Array('#116600','#d5ffcd','succeed');
	colorsCode['red']=new Array('#660000','#ffced1','error');
	if(logo){
		if(color=='gray'){
			textCode=""+
			"<td dir=\"rtl\" style=\"padding:"+mp+"px;background-color:"+colorsCode[color][1]+"\">"+
			"<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">"+
			"	<tr>"+
			"		<td align=\"center\"><img src=\"images/icons/"+colorsCode[color][2]+".gif\" border=\"0\"></td>"+
			"	</tr>"+
			"	<tr>"+
			"		<td id=\""+id+"\" align=\"center\" style=\"padding-bottom:6px;color:"+colorsCode[color][0]+"\">"+text+"</td>"+
			"	</tr>"+
			"</table>"+
			"</td>";
		}
		else{
			textCode=""+
			"<td dir=\"rtl\" style=\"padding:"+mp+"px;background-color:"+colorsCode[color][1]+"\">"+
			"<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">"+
			"	<tr>"+
			"		<td><img src=\"images/icons/"+colorsCode[color][2]+".gif\" style=\"margin-left:"+(mp+2)+"px\" hspace=\"4\" border=\"0\"></td>"+
			"		<td id=\""+id+"\" style=\"color:"+colorsCode[color][0]+"\">"+text+"</td>"+
			"	</tr>"+
			"</table>"+
			"</td>";
		}
	}
	else{
		textCode="<td id=\""+id+"\" dir=\"rtl\" style=\"padding:"+mp+"px;background-color:"+colorsCode[color][1]+";color:"+colorsCode[color][0]+"\">"+text+"</td>";
	}
	code=""+
	"<table dir=\"ltr\""+(width&&width>0 ? " width=\""+width+"%\"" : "")+" cellpadding=\"0\" cellspacing=\"0\" style=\"margin:"+mp+"px;\" border=\"0\">"+
	"	<tr>"+
	"		<td style=\"background:url(images/boxes/"+color+"_top_left.gif) no-repeat 0px 0px;width:5px;height:5px;\"></td>"+
	"		<td style=\"background:url(images/boxes/"+color+"_top.gif) repeat-x 0px 0px;height:5px;\"></td>"+
	"		<td style=\"background:url(images/boxes/"+color+"_top_right.gif) no-repeat 0px 0px;width:5px;height:5px;\"></td>"+
	"	</tr>"+
	"	<tr>"+
	"		<td style=\"background:url(images/boxes/"+color+"_left.gif) repeat-y 0px 0px;width:5px;\"></td>"+
	textCode+
	"		<td style=\"background:url(images/boxes/"+color+"_right.gif) repeat-y 0px 0px;width:5px;\"></td>"+
	"	</tr>"+
	"	<tr>"+
	"		<td style=\"background:url(images/boxes/"+color+"_down_left.gif) no-repeat 0px 0px;width:5px;height:5px;\"></td>"+
	"		<td style=\"background:url(images/boxes/"+color+"_down.gif) repeat-x 0px 0px;height:5px;\"></td>"+
	"		<td style=\"background:url(images/boxes/"+color+"_down_right.gif) no-repeat 0px 0px;width:5px;height:5px;\"></td>"+
	"	</tr>"+
	"</table>"+
	"";
	if(align) code="<center>"+code+"</center>";
	obj={'id':id,'code':code};
	return obj;
};
DT.loadIcon=function(){
	var code="&nbsp;<img src=\"images/icons/loading.gif\" border=\"0\">&nbsp;";
	return code;
};
DT.checkAllByCheck=function(s,name){
	var el=s.form.elements,check=s.checked;
	for(var x=0;x<el.length;x++){
		if(el[x].type=='checkbox'){
			el[x].checked=check;
		}
	}
};
DT.fieldBox=function(text,width){
	var code=""+
	"<table dir=\"ltr\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">"+
	"	<tr>"+
	"		<td style=\"background:url(images/boxes/input1.gif) no-repeat 0px 0px;width:4px;height:30px;\"></td>"+
	"		<td style=\"background:url(images/boxes/input2.jpg) repeat-x 0px 0px;height:30px"+(width&&width>0 ? ";width:"+width+"px" : "")+"\" dir=\"rtl\">"+text+"</td>"+
	"		<td style=\"background:url(images/boxes/input3.gif) no-repeat 0px 0px;width:4px;height:30px;\"></td>"+
	"	</tr>"+
	"</table>";
	return code;
};
DT.input=function(size,att,ret){
	var input=code="";
	if(!att.inArray('type')){
		att.add('type','text');
	}
	for(var x=0;x<att.length;x+=2){
		input+=" "+att[x]+"=\""+att[x+1]+"\"";
	}
	code=this.fieldBox("<input"+input+" style=\"width:"+size+"px;border:gray 0px solid;background:none transparent scroll repeat 0% 0%\">");
	if(ret){
		return code;
	}
	else{
		document.write(code);
	}
};