function newTopic(forumURL,e){
	try{
		if(event!=undefined){
			e=event
		}
	}catch(ex){}
	this.e=e;
	m=getMouseIntXY(e);
	this.x=m[0];
	this.y=m[1];
	
	this.pageContainer=$('body');
	if(window.innerHeight){ 
		this.height=window.innerHeight;
		this.width=window.innerWidth;
		
	}else{
		this.height=document.body.clientHeight;
		this.width=document.body.clientWidth;
	}
	this.forumURL=forumURL;
	
	this.sessionCheck();
}

newTopic.prototype.sessionCheck=function(){
	this.xmlHttp_post = getXML();
	this.xmlHttp_post.obj=this;
	
	this.xmlHttp_post.onreadystatechange = this.handelSessionCheck;

	var send=Object();
	send.operation='sessionCheck';
	post= escape(prepearVar2(send));
	var string=base+"ajax/cms/forum/common/"+send.operation+"?js="+post;
	this.xmlHttp_post.open("GET",string,true);
	this.xmlHttp_post.send(post);
	return false;
}
newTopic.prototype.handelSessionCheck=function(){
		if(this.readyState==4){
		//alert(this.responseText);
		var jsonvar = Object();
		try{jsonvar=eval('(' + this.responseText + ')');
		}catch(ex){alert('Вътрешна грешка: Сървърът не отговаря!'+ex);return;}
		if(jsonvar.status!='ok'){alert('Транспортна грешка: Няма връзка със сървъра!');return;}
		
		if(jsonvar.loged==1){
			this.obj.win();
		}else{
			//alert(this.obj.e.clientX);
			new loginPan(this.obj.x,this.obj.y);
		}
	}
}
	
newTopic.prototype.win=function(){
	
tinyMCE.init({
		// General options
		//BASEURLIMG : "{BASEPATH}",
		mode : "specific_textareas",
		editor_selector : "tinyMCE",
		language : "bg",
		theme : "advanced",
		plugins : "safari,pagebreak,style,save,iespell,inlinepopups,insertdatetime,contextmenu,paste,directionality,noneditable,visualchars,nonbreaking,xhtmlxtras",
 
		width: "450",
		height: "230",
		// Theme options
		theme_advanced_buttons1 : "undo,redo,|,cut,copy,paste,pastetext,pasteword",
		theme_advanced_buttons2 : "fontsizeselect,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,outdent,indent,|,forecolor,backcolor",
		theme_advanced_buttons3 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : false,			
		
		entity_encoding : "numeric",
		encoding : "xml",
		cleanup : true,
		convert_urls : false,
		relative_urls : false,
		document_base_url : base,
		theme_advanced_resizing : false,
		verify_html : true,
		
		extended_valid_elements : "iframe[class|src|alt|title|width|height|onmouseover|onmouseout|frameborder|scrolling|marginheight|marginwidth],form[accept|accept-charset|action|class|enctype|id|lang"
  +"|method|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup"
  +"|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onreset|onsubmit"
  +"|style|title|target]"
		
	});
	
	if($('over')){
		over=$('over');
		over.innerHTML='';
	}else{
		over=document.createElement('div');
		over.id="over";
		over.style.position	="absolute";
		over.style.top		="0px";
		over.style.left		="0px";
		over.style.width	="100%";
		over.style.height	="100%";
	}
	
	this.pageContainer.appendChild(over);
	backgr=document.createElement('div');
	backgr.style.backgroundColor="#000000";
	backgr.style.position	="absolute";
	backgr.style.zIndex		="9";
	backgr.style.top		="0px";
	backgr.style.left		="0px";
	backgr.style.width		="100%";
	//backgr.style.height	="100%";
	backgr.style.height	=	"100%"; 
	backgr.style.opacity	="0.2";
	backgr.style.filter	="alpha(opacity=20)";
	over.appendChild(backgr);
	
	pan= document.createElement('div'); 
	over.appendChild(pan);
	pan.style.zIndex		="10";
	pan.style.backgroundColor="#ffffff";
	pan.style.border	="3px solid #888888";
	pan.style.position	="absolute";
	pan.style.top		=(this.y-100)+"px";
	pan.style.left		=(this.width/2-100)+"px";
	pan.style.width		="530px";
	pan.style.height	="400px";
	
	newpostForm= document.createElement('form'); 
	pan.appendChild(newpostForm);
	newpostForm.onupload=function(){return false;}
	newpostFormFieldset=document.createElement('fieldset');
	newpostForm.appendChild(newpostFormFieldset);
	newpostFormFieldset.style.padding="10px";
	newpostFormFieldset.style.margin="10px";
	
	newpostFormFieldsetLegend=document.createElement('legend');
	newpostFormFieldset.appendChild(newpostFormFieldsetLegend);
	newpostFormFieldsetLegend.innerHTML='<img src="'+imgpath+'icon_post_20.png" /> писане на отговор';
	
	newpostFormFieldsetLable1=newLabel('title','Заглавие:');
	newpostFormFieldset.appendChild(newpostFormFieldsetLable1);
	newpostFormFieldsetInput1=newInput('text','title','title','');
	newpostFormFieldset.appendChild(newpostFormFieldsetInput1);
	
	newpostFormFieldsetbr=document.createElement('br');
	newpostFormFieldset.appendChild(newpostFormFieldsetbr);
	
	newpostFormFieldsetLable2=newLabel('textContent','Текст:');
	newpostFormFieldset.appendChild(newpostFormFieldsetLable2);
	newpostFormFieldsetInput2=document.createElement('textarea');
	newpostFormFieldsetInput2.name='content';
	newpostFormFieldsetInput2.id='tinyMCE';
	newpostFormFieldset.appendChild(newpostFormFieldsetInput2);
	tinyMCE.execCommand('mceAddControl',false,'tinyMCE');
	
	ok=document.createElement('button');
	newpostFormFieldset.appendChild(ok);
	ok.style.styleFloat='right';
	ok.style.background="url('"+imgpath+"icon_right_20.png') no-repeat top left #f0fff0";
	ok.style.width='90px';
	ok.style.height='22px';
	ok.style.textAlign='left';
	ok.style.border='1px solid #f0f0f0';
	ok.style.padding='0px 0px 0px 25px';
	ok.style.margin='10px 10px 10px 0px';
	ok.innerHTML="Изпрати";
	ok.obj=this;
	ok.onclick=this.save;
	
	cancel=document.createElement('button');
	newpostFormFieldset.appendChild(cancel);
	cancel.style.styleFloat='right';
	cancel.style.background="url('"+imgpath+"icon_exit_20.png') no-repeat top left #fff0f0";
	cancel.style.width='90px';
	cancel.style.height='22px';
	cancel.style.textAlign='left';
	cancel.style.border='1px solid #f0f0f0';
	cancel.style.padding='0px 0px 0px 25px';
	cancel.style.margin='10px 10px 10px 0px';
	cancel.innerHTML="Отмени";
	cancel.onclick=this.closeWindow;
}
newTopic.prototype.closeWindow=function(){
	tinyMCE.execCommand('mceRemoveControl',false,'tinyMCE');
	try{
		over=$('over');
		over.parentNode.removeChild(over);
	}catch(ex){
		alert(ex);
	}
	return false;
}

newTopic.prototype.save=function(){
	if($('title').value==''){
		alert('Въведете заглавие на темата!');
		return false;
	}
	tinyMCE.triggerSave();
	this.xmlHttp_save = getXML();
	this.xmlHttp_save.obj=this.obj;
	this.xmlHttp_save.onreadystatechange = this.obj.handelSave;

	var send=Object();
	send.operation='saveNewTopic';
	send.forum_url=this.obj.forumURL;
	send.title=$('title').value;
	send.content=$('tinyMCE').value;
	post= escape(prepearVar2(send));
	//post= prepearVar2(send);
	var string=base+"ajax/cms/forum/common/"+send.operation+"?js="+post;
	this.xmlHttp_save.open("GET",string,true);
	this.xmlHttp_save.send(post);
	return false;
}
newTopic.prototype.handelSave=function (){
	if(this.readyState==4){
		//alert(this.responseText);
		var jsonvar = Object();
		try{jsonvar=eval('(' + this.responseText + ')');
		}catch(ex){alert('Вътрешна грешка: Сървърът не отговаря!'+ex); this.obj.closeWindow; return;}
		if(jsonvar.status!='ok'){alert('Транспортна грешка: Няма връзка със сървъра!'); this.obj.closeWindow; return;}
		//this.obj.closeWindow();
		//window.location=window.location;
		window.location.reload(true)

	}
}
