var tooltip=function(){
	var id = 'tt';
	var top = 3;
	var left = 3;
	var maxw = 250;
	var speed = 10;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = 'block';
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();

function searchSoftDESK(form){
	if(form.search.value==form.search.defaultValue || form.search.value==''){
	}
	else{
		window.location='/softdesk/search/' + escape(form.search.value)+'/';
	}
	return false;
}
function focusSDSearch(obj){
	if(obj.value==obj.defaultValue)
		obj.value='';
	else
		obj.select();
}
function blurSDSearch(obj){
	if(obj.value=='')
		obj.value=obj.defaultValue;
}
function focusLogin(obj){
	if(obj.value==obj.defaultValue)
		obj.value='';
	else
		obj.select();
}
function blurLogin(obj){
	if(obj.value=='')
		obj.value=obj.defaultValue;
}
function login(){
	document.getElementById('login').submit();
}

var refresh=0;
function theight(){
	var d=document, b=d.body, e=d.documentElement;
	return Math.max(Math.max(b.scrollHeight,e.scrollHeight),Math.max(b.clientHeight,e.clientHeight))
}
function twidth(){
	var d=document, b=d.body, e=d.documentElement;
	return Math.max(Math.max(b.scrollWidth,e.scrollWidth),Math.max(b.clientWidth,e.clientWidth))
}
function move_box() {
	var offset = 50; // set offset (likely equal to your css top)
	var element = document.getElementById('box');
	element.style.top = (parent.document.documentElement.scrollTop + offset) + 'px';
}
function showBox(w, h, url, title,extraParam)
  { 
    var width = document.getElementsByTagName('body')[0].clientWidth;
    var layer = document.createElement('div');
    layer.style.zIndex = 200;
    layer.id = 'layer';
    layer.style.position = 'absolute';
    layer.style.top = '0px';
    layer.style.left = '0px';
    layer.style.height = theight() + 'px';
    layer.style.width = twidth() + 'px';
    layer.style.backgroundColor = 'black';
    layer.style.opacity = '.6';
    layer.style.filter += ("progid:DXImageTransform.Microsoft.Alpha(opacity=60)");
    document.body.appendChild(layer); 
   
    var div = document.createElement('div');
    div.style.zIndex = 201;
    div.id = 'box';
    div.style.position = (navigator.userAgent.indexOf('MSIE 6') > -1) ? 'absolute' : 'fixed';
    div.style.top = '50px';
    div.style.left = (twidth() / 2) - (w / 2) + 'px'; 
	//div.style.marginLeft = (width / 2) - (w / 2) + 'px'; 
    //div.style.height = h + 20+ 32+ 'px';
    div.style.width = w + 'px';
    //div.style.backgroundColor = '#000';
    //div.style.border = '10px solid #000';//silver';//#B5CFEF #bcd3ef #adcaed	b7cfed	
	div.style.padding='7px';
    document.body.appendChild(div); 
	
	var div1 = document.createElement('div');
    div1.style.zIndex = 202;
    div1.id = 'ibox';	
    //div1.style.height = h +20 + 'px';
    //div1.style.width = w - 24 +'px';
    div1.style.backgroundColor = '#fff';
	//    div1.style.padding = '12px';
    div.appendChild(div1); 
   
   var div_head = document.createElement('div');
	div_head.innerHTML='<div style="float:left;text-shadow:1px 1px 1px #000000;">' + title + '<img id="ajax-loader" src="/images/ajax.gif"  alt="Loading..." style="margin-left:10px; vertical-align:middle;"/></div><div style="float:right;padding-right:5px;padding-top:3px"><a href="javascript:void(0)" onclick="closePopup()"><img border="0" src="/images/fileclose.png"/></a></div><div style="clear:both;font-size:0px;height:0px"></div>'
	div_head.style.background="#333 url(/images/popup_title.jpg) repeat";//#C9DAEF #ddd
	div_head.style.fontFamily="arial,verdana";
	div_head.style.color="#f9f9f9";
	div_head.style.fontSize="19px";
	div_head.style.padding="5px 0px 6px 15px";
	div_head.style.fontWeight="bold";
	//div_head.style.marginBottom="12px";	
	div1.appendChild(div_head); 
	

    var p = document.createElement('div');	
	p.id='popup';
	p.style.width=w-30+'px';
	//p.style.height=h +'px';
	p.border='0';
	p.scrolling='no';
	p.style.border="0";
	p.style.color='#000';
	p.frameBorder="0";
	p.style.marginWidth='0px';
	p.style.padding='15px';
    div1.appendChild(p);
	
	showResult(url,'popup',extraParam);
	
	if(navigator.userAgent.indexOf('MSIE') > -1) {
		window.setInterval(move_box, 100);
	}
  }
  function closePopup(){
	if(document.getElementById('popup')!=null){
		document.getElementById('popup').src='';
		document.body.removeChild(document.getElementById('layer'));
		document.body.removeChild(document.getElementById('box'));
	}
	
	if(refresh==1){
		window.location.reload();
		refresh=0;
	}
};

function gotoLogin(){
	closePopup();
	showLogin();
}
var tedy;

function showResult(url,container,extraParam){
	ajaxLoader(1);
	var xmlhttp=GetXmlHttpObject()
	if (xmlhttp==null){
	  alert ("Your browser does not support XML HTTP Request");
	  return;
	}
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4 && xmlhttp.status==200){
			document.getElementById(container).innerHTML=xmlhttp.responseText;
			ajaxLoader(0);
			if(extraParam=='loadEditor'){
				tedy = new TINY.editor.edit('editor',{
					id:'desc',
					width:480,
					height:175,
					cssclass:'te',
					controlclass:'tecontrol',
					rowclass:'teheader',
					dividerclass:'tedivider',
					controls:['bold','italic','underline','strikethrough','|','subscript','superscript','|',
							  'orderedlist','unorderedlist','|','outdent','indent','|','leftalign',
							  'centeralign','rightalign','blockjustify','n','cut','copy','paste','|','unformat','|','undo','redo',
							  'style','|','image','hr','link','unlink'],
					footer:false,
					fonts:['Verdana','Arial','Georgia','Trebuchet MS'],
					xhtml:false,
					bodyid:'editor',
					footerclass:'tefooter',
					toggle:{text:'source',activetext:'wysiwyg',cssclass:'toggle'},
					resize:{cssclass:'resize'}
				});
			}
		}
	};
	xmlhttp.open("GET",url,true);	
	xmlhttp.send(null);
}

function ajaxLoader(opt){
	if(document.getElementById('ajax-loader')){
		if(opt==0)
			document.getElementById('ajax-loader').style.display='none';
		else
			document.getElementById('ajax-loader').style.display='inline';
	}
}

function send(url, params, container){
	ajaxLoader(1);
	var xmlhttp=GetXmlHttpObject()
	if (xmlhttp==null){
	  alert ("Your browser does not support XML HTTP Request");
	  return;
	}
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4){
			ajaxLoader(0);
			document.getElementById(container).innerHTML=xmlhttp.responseText;			
		}
	};
	xmlhttp.open("POST",url,true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(params);
}

function submit_qotw(url, params){
	var xmlhttp=GetXmlHttpObject()
	if (xmlhttp==null){
	  alert ("Your browser does not support XML HTTP Request");
	  return;
	}
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4){
			var ans=xmlhttp.responseText;
			if(ans=="error")
				alert("Please login or register to submit your answer.");
			else
				T$('qotw').innerHTML=xmlhttp.responseText;
			
		}
	};
	xmlhttp.open("POST",url,true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(params);
}

function GetXmlHttpObject(){
	if(window.XMLHttpRequest)
		return new XMLHttpRequest();
	if(window.ActiveXObject)
		return new ActiveXObject("Microsoft.XMLHTTP");
	return null;
}

function checkExists(url, params, container){
	var xmlhttp=GetXmlHttpObject()
	if (xmlhttp==null){
	  alert ("Your browser does not support XML HTTP Request");
	  return;
	}
	xmlhttp.onreadystatechange=function(){
		if (xmlhttp.readyState==4){
			document.getElementById(container).innerHTML=xmlhttp.responseText;
			if (document.getElementById(container).innerHTML=='Correct'){
				successClass(container);
				return true;
			}
			else{
				errorClass(container);
				return false;
			}
		}
	};
	xmlhttp.open("POST",url,true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", params.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(params);
}

function formValidate(){
	formCheck();
	if((document.getElementById("user_error").innerHTML=='Correct') && passError() && repassError() && (document.getElementById("email_error").innerHTML=='Correct') && (document.getElementById("verifn_error").innerHTML=='Correct') && (document.getElementById("tnc").checked==1)){
		//checkExists('register.php','username=' + document.getElementById("user").value + '&password=' + document.getElementById("pass").value + '&email=' + document.getElementById("email").value + '&tnc=1+&captcha='+document.register.verification.value,'reg-content');
		document.getElementById("user_error").style.display='none';
		document.getElementById("pass_error").style.display='none';
		document.getElementById("repass_error").style.display='none';
		document.getElementById("email_error").style.display='none';
		document.getElementById("verifn_error").style.display='none';	
		return true;
	}
	else{
		
		return false;
	}
}
function funcReset(){	
	document.register.username.focus();
	document.register.captcha_image.src=document.register.captcha_image.src + '&rand=' + Math.random();
	document.getElementById("user_error").style.display='none';
	document.getElementById("pass_error").style.display='none';
	document.getElementById("repass_error").style.display='none';
	document.getElementById("email_error").style.display='none';
	document.getElementById("verifn_error").style.display='none';	
}
function userError(){
	var msg='';
	if(document.register.username.value!=''){
		var i;
		var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>? ";
		var num="0123456789"
		j=document.register.username.value.length;
		if(j>0 && num.indexOf(document.register.username.value.charAt(0))!=-1){
			msg = "Cannot start with a digit.";
		}
		
		for (i = 0; i < j; i++) {
			if (iChars.indexOf(document.register.username.value.charAt(i)) != -1) {
				msg= "Cannot contain special characters. ";
				break;
			}
		}
	}
	if(document.register.username.value.length==0)
		msg = "Cannot be empty.";
	else if(document.register.username.value.length<6)
		msg= 'Minimum 6 letters';
	
	if(msg!=''){
		errorClass("user_error");
		document.getElementById("user_error").innerHTML=msg;
		return false;
	}
	else{
		successClass("user_error");
		checkExists("/checkExists.php", 'username='+document.register.username.value,"user_error");
	}
}


function passError(){
	var msg='';
	if(document.register.password.value.length==0)
		msg = "Cannot be empty.";
	else if(document.register.password.value.length<6)
		msg= 'Minimum 6 letters';
	
	if(msg!=''){
		errorClass("pass_error");
		document.getElementById("pass_error").innerHTML=msg;
		return false;
	}
	else{
		successClass("pass_error");
		document.getElementById("pass_error").innerHTML='Correct';
		return true;
	}
	
}

function repassError(){
	var msg='';
	if(document.register.repassword.value.length==0)
		msg = msg + "Cannot be empty. ";

	if(document.register.password.value!=document.register.repassword.value && document.register.repassword.value.length>0){
		msg = msg + "Passwords doesn't matches. ";
	}
	
	
	if(msg!=''){
		errorClass("repass_error");
		document.getElementById("repass_error").innerHTML=msg;					
		return false;
	}
	else{
		successClass("repass_error");
		document.getElementById("repass_error").innerHTML='Correct';
		return true;
	}
}

function emailError(){
	var msg='';
	if(document.register.email.value!=''){
		var emailReg = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
		if(!emailReg.test(document.register.email.value))
			msg = "Invalid E-Mail.";
	}
	else{
		msg = "Cannot be empty.";
	}
	
	if(msg!=''){
		errorClass("email_error");
		document.getElementById("email_error").innerHTML=msg;
		return false;
	}
	else{
		checkExists("/checkExists.php", 'email='+document.register.email.value,"email_error")
	}
}

function verifnError(){
	var msg='';
	if(document.register.verification.value.length==0)
		msg = msg + "Cannot be empty.";
	else if(document.register.verification.value.length<6)
		msg= msg+'6 letters word.';
		
	if(msg!=''){
		errorClass("verifn_error");
		document.getElementById("verifn_error").innerHTML=msg;
		document.getElementById("verifn_error").style.display='block';
		return false;
	}
	else{
		//successClass("verifn_error");
		//document.getElementById("verifn_error").style.display='none';
		successClass("verifn_error");
		checkExists("/captcha/captcha_check.php?"+'captcha='+document.register.verification.value,"","verifn_error");
		return true;
	}
}

function formCheck(){
	userError();
	passError();
	repassError();
	emailError();
	verifnError();
}

function errorClass(id){
	document.getElementById(id).setAttribute("className", "reg-error");
	document.getElementById(id).setAttribute("class", "reg-error");
	document.getElementById(id).style.display='block';
}

function successClass(id){
	document.getElementById(id).setAttribute("className", "reg-success");
	document.getElementById(id).setAttribute("class", "reg-success");
	document.getElementById(id).style.display='block';
}

//Slider
function T$(i){return document.getElementById(i)}
function T$$(e,p){return p.getElementsByTagName(e)}
slider=function(){
	function slide(n,p){this.n=n; this.init(p)}
	slide.prototype.init=function(p){
		var s=T$(p.id), u=this.u=T$$('ul',s)[0], c=T$$('li',u), l=c.length, i=this.l=this.c=0;
		if(p.navid&&p.activeclass){this.g=T$$('li',T$(p.navid)); this.s=p.activeclass}
		this.a=p.auto||0; this.p=p.resume||0; this.v=p.vertical||0; s.style.overflow='hidden';
		for(i;i<l;i++){if(c[i].parentNode==u){this.l++}}
		if(this.v){;
			u.style.top=0; this.h=p.height||c[0].offsetHeight; u.style.height=(this.l*this.h)+'px'
		}else{
			u.style.left=0; this.w=p.width||c[0].offsetWidth; u.style.width=(this.l*this.w)+'px'
		}
		this.pos(p.position||0,this.a?1:0)
	},
	slide.prototype.auto=function(){
		this.u.ai=setInterval(new Function(this.n+'.move(1,1)'),this.a*1000)
	},
	slide.prototype.move=function(d,a){
		var n=this.c+d, i=d==1?n==this.l?0:n:n<0?this.l-1:n; this.pos(i,a)
	},
	slide.prototype.pos=function(p,a){
		clearInterval(this.u.ai); clearInterval(this.u.si);
		var o=this.v?parseInt(this.u.style.top):parseInt(this.u.style.left),
		t=this.v?p*this.h:p*this.w, d=t>Math.abs(o)?1:-1; t=t*-1; this.c=p;		
		t=-p*878;
		if(this.g){for(var i=0;i<this.l;i++){this.g[i].className=i==p?this.s:''}}		
		this.u.si=setInterval(new Function(this.n+'.slide('+t+','+d+','+a+')'),20)
	},
	slide.prototype.slide=function(t,d,a){
		var o=this.v?parseInt(this.u.style.top):parseInt(this.u.style.left);
		if(o==t){
			clearInterval(this.u.si); if(a||(this.a&&this.p)){this.auto()}
		}else{
			var v=o-Math.ceil(Math.abs(t-o)*.15)*d+'px';
			this.v?this.u.style.top=v:this.u.style.left=v
		}
	};
	return{slide:slide}
}();

function showLogin(){
	T$('login-box').style.display="block";
	T$('login_username').focus();
	document.getElementById('dologin').setAttribute("className", "login");
	document.getElementById('dologin').setAttribute("class", "login");
}
function hideLogin(){
	T$('login-box').style.display="none";
	document.getElementById('dologin').setAttribute("className", "");
	document.getElementById('dologin').setAttribute("class", "");
}
document.onclick=checkClicked;
function checkClicked(e){
	if(T$('login-box').style.display!="none"){
		var target = (e && e.target) || (event && event.srcElement); 
		var obj = document.getElementById('dologin'); 
		var obj1 = document.getElementById('login-box'); 
		if(target==obj || checkParent(target))
			return;
		else
			hideLogin();
	}
}

function checkParent(t){ 
	while(t.parentNode){ 
		if(t==document.getElementById('login-box'))
			return true;
		t=t.parentNode;
	}
	return false;
}

function openLink(url){
	window.location = url;
}
var TINY={};function T$(i){return document.getElementById(i)}TINY.box=function(){var p,m,b,fn,ic,iu,iw,ih,ia,f=0;return{show:function(c,u,w,h,a,t){if(!f){p=document.createElement('div');p.id='tinybox';m=document.createElement('div');m.id='tinymask';b=document.createElement('div');b.id='tinycontent';document.body.appendChild(m);document.body.appendChild(p);p.appendChild(b);m.onclick=TINY.box.hide;window.onresize=TINY.box.resize;f=1}if(!a&&!u){p.style.width=w?w+'px':'auto';p.style.height=h?h+'px':'auto';p.style.backgroundImage='none';b.innerHTML=c}else{b.style.display='none';p.style.width=p.style.height='100px'}this.mask();ic=c;iu=u;iw=w;ih=h;ia=a;this.alpha(m,1,80,3);if(t){setTimeout(function(){TINY.box.hide()},1000*t)}},fill:function(c,u,w,h,a){if(u){p.style.backgroundImage='';var x=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject('Microsoft.XMLHTTP');x.onreadystatechange=function(){if(x.readyState==4&&x.status==200){TINY.box.psh(x.responseText,w,h,a)}};x.open('GET',c,1);x.send(null)}else{this.psh(c,w,h,a)}},psh:function(c,w,h,a){if(a){if(!w||!h){var x=p.style.width,y=p.style.height;b.innerHTML=c;p.style.width=w?w+'px':'';p.style.height=h?h+'px':'';b.style.display='';w=parseInt(b.offsetWidth);h=parseInt(b.offsetHeight);b.style.display='none';p.style.width=x;p.style.height=y}else{b.innerHTML=c}this.size(p,w,h,4)}else{p.style.backgroundImage='none'}},hide:function(){TINY.box.alpha(p,-1,0,3)},resize:function(){TINY.box.pos();TINY.box.mask()},mask:function(){m.style.height=TINY.page.theight()+'px';m.style.width='';m.style.width=TINY.page.twidth()+'px'},pos:function(){var t=(TINY.page.height()/2)-(p.offsetHeight/2);t=t<10?10:t;p.style.top=(t+TINY.page.top())+'px';p.style.left=(TINY.page.width()/2)-(p.offsetWidth/2)+'px'},alpha:function(e,d,a,s){clearInterval(e.ai);if(d==1){e.style.opacity=0;e.style.filter='alpha(opacity=0)';e.style.display='block';this.pos()}e.ai=setInterval(function(){TINY.box.twalpha(e,a,d,s)},20)},twalpha:function(e,a,d,s){var o=Math.round(e.style.opacity*100);if(o==a){clearInterval(e.ai);if(d==-1){e.style.display='none';e==p?TINY.box.alpha(m,-1,0,2):b.innerHTML=p.style.backgroundImage=''}else{e==m?this.alpha(p,1,100,5):TINY.box.fill(ic,iu,iw,ih,ia)}}else{var n=o+Math.ceil(Math.abs(a-o)/s)*d;e.style.opacity=n/100;e.style.filter='alpha(opacity='+n+')'}},size:function(e,w,h,s){e=typeof e=='object'?e:T$(e);clearInterval(e.si);var ow=e.offsetWidth,oh=e.offsetHeight,wo=ow-parseInt(e.style.width),ho=oh-parseInt(e.style.height);var wd=ow-wo>w?-1:1,hd=(oh-ho>h)?-1:1;e.si=setInterval(function(){TINY.box.twsize(e,w,wo,wd,h,ho,hd,s)},20)},twsize:function(e,w,wo,wd,h,ho,hd,s){var ow=e.offsetWidth-wo,oh=e.offsetHeight-ho;if(ow==w&&oh==h){clearInterval(e.si);p.style.backgroundImage='none';b.style.display='block'}else{if(ow!=w){e.style.width=ow+(Math.ceil(Math.abs(w-ow)/s)*wd)+'px'}if(oh!=h){e.style.height=oh+(Math.ceil(Math.abs(h-oh)/s)*hd)+'px'}this.pos()}}}}();TINY.page=function(){return{top:function(){return document.body.scrollTop||document.documentElement.scrollTop},width:function(){return self.innerWidth||document.documentElement.clientWidth},height:function(){return self.innerHeight||document.documentElement.clientHeight},theight:function(){var d=document,b=d.body,e=d.documentElement;return Math.max(Math.max(b.scrollHeight,e.scrollHeight),Math.max(b.clientHeight,e.clientHeight))},twidth:function(){var d=document,b=d.body,e=d.documentElement;return Math.max(Math.max(b.scrollWidth,e.scrollWidth),Math.max(b.clientWidth,e.clientWidth))}}}();

function changeClass(nowid, group, total){
	for(var i=1; i<=total;i++){
		var nextLink = group + i;
		document.getElementById(nextLink).setAttribute("class", "");
	}
	document.getElementById(group+nowid).setAttribute("class", "active");
	if(nowid==1)
		showResult('/prog_update.php?lang=java','home-prog-cont');
	else if(nowid==2)
		showResult('/prog_update.php?lang=cncpp','home-prog-cont');
}
function newTopicValidate(board,subcat_url){
	var sub=document.topic.subject.value;
	//var descr =desc.getContent({save : true});
	//var descr='abcd';
	tedy.post();
	var descr=document.getElementById('desc').value;
	descr= descr.replace(/<.*?>/g,'');
	if(document.topic.subject.value=='' && descr==''){
		alert("Subject & Description fields cannot be empty.");
		document.topic.subject.focus();
	
	}	
	else if(document.topic.subject.value=='' && descr!=''){
		alert("Subject field cannot be empty.");
		document.topic.subject.focus();
		
	}
	else if(document.topic.subject.value!='' && descr==''){
		alert("Description field cannot be empty.");
		
	}
	else{
		send('/probdesk/create_topic.php?board='+board+'&subcat_url='+subcat_url, 'subject='+ escape(document.getElementById('subject').value)+'&description='+escape(document.getElementById('desc').value),'popup');
		refresh=1;
	}
	return false;
}
function newMsgValidate(topic){
	var sub=document.message.subject.value;
	tedy.post();
	var descr=document.getElementById('desc').value;
	descr= descr.replace(/<.*?>/g,'');
	if(document.message.subject.value=='' && descr==''){
		alert("Subject & Description fields cannot be empty.");
		document.message.subject.focus();	
	}	
	else if(document.message.subject.value=='' && descr!=''){
		alert("Subject field cannot be empty.");
		document.message.subject.focus();
	}
	else if(document.message.subject.value!='' && descr==''){
		alert("Description field cannot be empty.");		
	}
	else{
		send('/probdesk/create_message.php?topic='+topic, 'subject='+ escape(document.getElementById('subject').value)+'&description='+escape(document.getElementById('desc').value),'popup');
		refresh=1;
	}
}

function modifyMsgValidate(msg){
	var sub=document.message.subject.value;
	tedy.post();
	var descr=document.getElementById('desc').value;
	descr= descr.replace(/<.*?>/g,'');
	if(document.message.subject.value=='' && descr==''){
		alert("Subject & Description fields cannot be empty.");
		document.message.subject.focus();
	
	}	
	else if(document.message.subject.value=='' && descr!=''){
		alert("Subject field cannot be empty.");
		document.message.subject.focus();
		
	}
	else if(document.message.subject.value!='' && descr==''){
		alert("Description field cannot be empty.");
		
	}
	else{		
		send('/probdesk/modify_message.php?msg='+msg, 'subject='+ escape(document.getElementById('subject').value)+'&description='+escape(document.getElementById('desc').value),'popup');
		refresh=1;
	}
}
