function func_txt(text,campo,form){
	var txtarea = eval('document.'+form+'.'+campo);
	txtarea.focus();

	selecao = document.selection.createRange().text; // Get text selection
	if (selecao) {
		// Add tags around selection
		document.selection.createRange().text = " <#IMG=\""+selecao+"\"#> ";
		txtarea.focus();
		selecao = '';
		return;
	}
}

function inserir_img(img,largura,altura){
	editor._CImage_Select(img,largura,altura);
}

function inserir_tag(text,campo,form) {
	var txtarea = eval('document.'+form+'.'+campo);
	text = ' ' + text + ' ';
	if (txtarea.createTextRange && txtarea.caretPos) {
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
		txtarea.focus();
	} else {
		txtarea.value = txtarea.value + text;
		txtarea.focus();
	}
}

function storeCaret(textEl) {
	if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}

function func_excluir(id,msg,subpag){
	if(id){
		if(confirm(msg)){
			document.location = 'index.php?pag=admin&sub='+subpag+'&excluir='+id;
		}
	}
	return false;
}

function func_janela(nome,url_destino,largura,altura){
	nome = window.open(url_destino,''+nome+'','scrollbars=yes,width='+largura+',height='+altura+',top='+(screen.availHeight/2-altura/2)+',left='+(screen.availWidth/2-largura/2));
	nome.focus();
}

function img_janela(valor,largura,altura){
	aux = valor.indexOf(",",valor);
	img = valor.substring(0,aux);
	valor = valor.replace(img+",","");
	largura = valor.substring(0,valor.indexOf(",",valor));
	altura = valor.substring(valor.indexOf(",",valor)+1,valor.lenght);
	
	alt = img.substring(img.indexOf("/",img)+1,img.length);
	
	
	posTop = (screen.availHeight/2-altura/2);
	posLeft = (screen.availWidth/2-largura/2);
	imagemJanela = window.open("","imagemJanela","width="+largura+",height="+altura+",left="+posLeft+",top="+posTop);
	imagemJanela.document.open();
	imagemJanela.document.write('<html><title>'+alt+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">');
	imagemJanela.document.write('<img src="'+img+'" width="'+largura+'" height="'+altura+'" alt="'+alt+'">');
	imagemJanela.document.write('</body></html>');
	imagemJanela.document.close();
	imagemJanela.focus();
}

ie =  document.all ? true : false;
if (document.all || document.layers) {
	IE4 = (document.all);
	NS4 = (document.layers);
	NS6 = false;
} else if (document.getElementById) {
	IE4 = false;
	NS4 = false;
	NS6 = (document.getElementById);
}
if ( navigator.userAgent.indexOf("Mozilla") != -1 ) {
	mozilla = true;
}
ver4 = (NS4 || IE4);
IE5 = (IE4 && navigator.appVersion.indexOf("5.")!=-1);
isMac = (navigator.appVersion.indexOf("Mac") != -1);
isMenu = (NS4 || (IE4 && !isMac) || (IE5 && isMac));

function getStyle(id){return NS4 ? document[id] : NS6 ? document.getElementById(id).style : document.all[id].style;}
function HideLayer(id){getStyle(id).visibility = NS4 ? "hide" : "hidden"; getStyle(id).display = "none";}
function ShowLayer(id){getStyle(id).visibility = NS4 ? "show" : "visible"; getStyle(id).display = "block";}

