var dot3="<font style='font-size:8px'> ...</font>";
var dot3_size=null;
function findSize(text,size){
	if(!text) return;
	var span=document.getElementById("FindStringLengthTool");
	if(!span) return;
	span.style.fontSize=size;
	span.innerHTML=text;
	var new_text=span.innerHTML;
	return span.offsetWidth;
}
function makeSize(text,size,limit){
	if(!text) return;
	if(!limit) return text;
	if(!size) size=11;
	if(!dot3_size) var dot3_size=findSize("...",8);
	limit=limit-11;
	var text_size=findSize(text,size);
	if(text_size>limit)
		return shortString(text,size,limit);
	else
		return text;
}
function shortString(text,size,limit,op){
	if(!text.length) return false;
	re=/([^\s\.,\(\)]+)/g;
	re2=/([\s\.,\(\)]+)/g;
	var words=text.match(re);
	var word_count=words.length;
	var seps=text.match(re2);
	var sep_count=seps.length;
	//
	if(word_count>=2){
		for(m=0;m<word_count;m++){
			var counter=word_count-1-m;
			if(counter==0)
				return words[0]+dot3;
			words[counter]="";
			new_text="";
			for(k=0;k<counter;k++)
				new_text+=words[k]+seps[k];
			var new_size=findSize(new_text,size)
			if(new_size<=limit)
				return new_text+dot3;
		}
	}
	else
		return text;
}
function getIt(url,w,wdth,hght){
	if(!url) return;
	switch(w){
		case "i":
			var block=document.getElementById("plzwait");
			if(!block) return;
			var delta=document.body.scrollTop;
			if(delta)
				block.style.top=(parseInt(block.style.top)+delta)+"px";
			block.style.display="";
			window.location=url;
			break;
		case "n":
		default:
			var sHTML="";
			var lwin=window.open('','','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,top=100,left=100,width='+wdth+',height='+hght);
			lwin.document.open();
			//
			sHTML+="<HTML><HEAD>";
			sHTML+="<style>.text{font-size:11px;font-family:tahoma;color:#ffffff}</style>";
			sHTML+="<scr"+"ipt language='javascript'>function getURL(u)\n{\nwindow.location=u;\n}\n</scr"+"ipt>";
			sHTML+="</HEAD><BODY onload=getURL('"+url+"') dir='rtl'><center>";
			sHTML+="<table width='150' height='50' style='border:1px dashed #870064' border='0' cellpading='0' cellspacing='0'><tr bgcolor='#870064' height='50'><td class='text' align='center'>&#1583;&#1585;&#1581;&#1575;&#1604; &#1583;&#1585;&#1610;&#1575;&#1601;&#1578; &#1575;&#1591;&#1604;&#1575;&#1593;&#1575;&#1578; ...</tr></table>";
			sHTML+="</center></BODY></HTML>";
			lwin.document.write(sHTML);
			//
			lwin.document.close();
	}
}
function initConversation(uid) {
	var init_win=window.open("/convs/init.php?uid="+uid ,"init" ,"width=600,height=300,status=0,resizable=0");
	init_win.focus();		
}
function mClk(src) {
  if (event.srcElement.tagName=='TD') {
     src.children.tags('A')[0].click();
    }
}
function openFarsiKeyboard(){
	var features="height=300, width=550";
	var keyWin=window.open("/keyboard.php","fw",features);
	keyWin.focus();
}

