function validate(form){
	//updateRTEs();
	if (form.title_news.value.length < 10) {
		alert("Bạn cần phải nhập Tiêu đề");
		form.title_news.focus();
		return false;
	}
	if (form.sabo_news.value.length < 10) {
		alert("Bạn cần phải nhập Tóm tắt");
		form.sabo_news.focus();
		return false;
	}
	if (document.frm_input_news.detail_news.value.length < 10) {
		alert("Bạn cần phải nhập nội dung bài viết");
		return false;
	}
	if(form.masoantoan.value.length == 0) { 
		alert("Hãy nhập vào mã an toàn bên dưới !");
		form.masoantoan.focus();
		return false;
	}
	if (form.masoantoan.value != form.cnum.value) {
		window.alert("Mã số an toàn nhập chưa đúng\nMã số này phân biệt chữ hoa thường\nNếu bạn đang sử dụng FireFox thì nhấp chuột phải vào hình và chọn Reload để load lại hình mã số !");
		form.masoantoan.focus();
		return false;
	}
	
} 

function emo(emo){
	AddText(emo);
}
function getActiveText(selectedtext) { 
	freeRTE = (document.all) ? document.selection.createRange().freeRTE : document.getSelection();
	if (selectedtext.createTextRange) {	
   		selectedtext.caretPos = document.selection.createRange().duplicate();	
  	}
	return true;
}

function AddText(NewCode) {

var formcontent=document.all.freeRTE.value;
formcontent=formcontent.split("[");
	
	if (document.all.freeRTE.createTextRange && document.all.freeRTE.caretPos) {
		var caretPos = document.all.freeRTE.caretPos;
		caretPos.freeRTE = caretPos.freeRTE.charAt(caretPos.freeRTE.length - 1) == ' ' ? NewCode + ' ' : NewCode;
		document.all.freeRTE.focus();
	}
	else {
		document.all.freeRTE.value+=NewCode;
	}
	
}

function show_prompt(text,kind,demo){

var y = window.prompt(text,demo);
var demo
	if ((y != null) && (y != "") && (y != 'http://')){
		switch (kind){
			case 'url':
			{
				z = window.prompt('Nhập chuỗi liên kết','Chuỗi liên kết');
				x = '[url='+y+']'+z+'[/url]';
				emo(x);
				return;
			}
			case 'img':
			{
				x = '[img]'+y+'[/img]';
				emo(x);
				return;
			}
			case 'google':
			{
				x = '[google]'+y+'[/google]';
				emo(x);
				return;
			}
			case 'youtube':
			{
				x = '[youtube]'+y+'[/youtube]';
				emo(x);
				return;
			}
			case 'media':
			{
				x = '[media]'+y+'[/media]';
				emo(x);
				return;
			}
			case 'clip':
			{
				x = '[clip]'+y+'[/clip]';
				emo(x);
				return;
			}
		}
	}
}

function showpicture(selectobj,name,w,h){
	var w, h;
	if (w=='') {w=80;}
	if (h=='') {h=80;}
	piccontainerobj=document.getElementById(name)
	piccontainerobj.innerHTML='<img src="'+selectobj.value+'" height="'+h+'" width="'+w+'" />'
	}


function show_hide(obj,is_close,element,str1,str2) {
	var str1, str2;
	var hideshow = document.getElementById(obj);
	if (is_close) {
		document.getElementById(obj).style.display = 'none';
	}
	else {
		if(hideshow.style.display != "none") {
					hideshow.style.display = "none";
					document.getElementById(element).innerHTML = '<img src="../img/open.gif" alt="'+str1+'" border="0" title="'+str1+'" align="absmiddle" /> '+str1;
		}
		else {
			hideshow.style.display = "block";
			document.getElementById(element).innerHTML = '<img src="../img/close.gif" alt="'+str2+'" border="0" title="'+str2+'" align="absmiddle" /> '+str2;
		}
	}
	return false;
}


function openurl(url,w,h,title){
	
	var url, title, w, h;
	var xwidth = w;	
	var xheight = h;
	var left = (screen.availWidth - xwidth) / 2 ;
	var top = ((screen.availHeight - xheight)-50) / 2 ;
	var windowOptions = 'history=no,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,width='+w+',height='+h+',left='+left+',top='+top;
	window.open(url, title, windowOptions);
	
	
	
}