function keepFocus() {
  window.focus();
}

function openWindow(page, name, elements) {
  window.open(page, name, elements);
}

function SS_RemoveFormatTags(memo)
{
	// remover todos os tags de formatação de texto
	memo = memo.replace(/<span[\w\d\s'=:\.;#\-\/"%]*>|<\/span>/gi,"");
	memo = memo.replace(/<font[\w\d\s'=:\.;#\-\/"%]*>|<\/font>/gi,"");
	memo = memo.replace(/<b [\w\d\s'=:\.;#\-\/"%]*>/gi,"<b>");
	memo = memo.replace(/<\?[\w\d\s'=:\.;#\-\/"%]*>|<o:p>|<\/o:p>/gi, "");
	memo = memo.replace(/<\w\w\d:[\w\d\s'=:\.;#\-\/"%]*>|<\/\w\w\d:[\w\d\s'=:\.;#\-\/"%]*>/gi, "");
	memo = memo.replace(/<p[\w\d\s'=:\.;#\-\/"%]*>/gi,"<p>");
	memo = memo.replace(/<table[\w\d\s'=:\.;#\-\/"%]*>/gi,"<table bordercolor=\"#7C9DAD\" width=\"100%\" border=1 cellpadding=2 cellspacing=0>");
	memo = memo.replace(/<td[\w\d\s'=:\.;#\-\/"%]*>/gi,"<td class=\"normal\" valign=\"top\">");
	memo = memo.replace(/<ul[\w\d\s'=:\.;#\-\/"%]*>|<ul>/gi,"<ul class=\"normal\">");
	return(memo);
}

function FormatDataUS(formData) {
	var data = formData.value;
	/*if(String(data) != "") {
		var dia = data.substr(0,2);
		var mes = data.substr(3,2);
		var ano = data.substr(6,4);
		var res = mes + "-" + dia + "-" + ano;
		if(data.indexOf(":") != -1) {
			var h = data.substr(11,2);
			var m = data.substr(14,2);
			res += " " + h + ":" + m;
		}
		formData.value = res;
	}*/
	return(true);
}
function ConfRemocao_JS(PagRemover)
{
	var msg="Confirma a remoção?"
	
	if (confirm(msg))
		location.href = PagRemover;
}

/*************************/
/*************************/
var errorString = "Sorry but this web page needs\nWindows95 and Internet Explorer 5 or above to view."
  var Ok = "false";
  var name =  navigator.appName;
  var version =  parseFloat(navigator.appVersion);
  var platform = navigator.platform;

	if (platform == "Win32" && name == "Microsoft Internet Explorer" && version >= 4){
		Ok = "true";
	} else {
		Ok= "false";
	}

	if (Ok == "false") {
		//alert(errorString);
	}

function ColorPalette_OnClick(colorString){
	
	cpick.bgColor=colorString;
	document.all.colourp.value=colorString;
	doFormat('ForeColor',colorString);
}

function initToolBar(ed) {
    
	var eb = document.all.editbar;
	if (ed!=null) {
		eb._editor = window.frames['myEditor'];
	}
}

function doFormat(what) {

	var eb = document.all.editbar;
		
	if(what == "FontName"){
		if(arguments[1] != 1){
			eb._editor.execCommand(what, arguments[1]);
			document.all.font.selectedIndex = 0;
		} 
	} else if(what == "FontSize"){
    if(arguments[1] != 1){
      eb._editor.execCommand(what, arguments[1]);
      document.all.size.selectedIndex = 0;
    } 
	} else {
	   eb._editor.execCommand(what, arguments[1]);
	}
}

function swapMode() {

	var eb = document.all.editbar._editor;
  eb.swapModes();
}

function create() {

    var eb = document.all.editbar;
    eb._editor.newDocument();
}

function newFile(){

	create();
}

function makeUrl(){

	sUrl = document.all.what.value + document.all.url.value;
	doFormat('CreateLink',sUrl);
}

function copyValue() {

	var theHtml = "" + document.frames("myEditor").document.frames("textEdit").document.body.innerHTML + "";
	document.all.EditorValue.value = theHtml;
}

function SwapView_OnClick(){

  if(document.all.btnSwapView.value == "HTML"){
		var sMes = "WYSIWYG";
    var sStatusBarMes = "Current View Html";
	} else {
		var sMes = "HTML"
    var sStatusBarMes = "Current View Wysiwyg";
  }
	
	document.all.btnSwapView.value = sMes;
  window.status  = sStatusBarMes;
	swapMode();
}

function Help_OnClick(){
  window.open("editor_images/help_document.htm","wHelp", "toolbar=0, scrollbars=yes, width=640, height=480");
}

function OnFormSubmit(){

  if(confirm("This Document is about to be submitted\nAre you sure you have finished editing?")){
    copyValue();
    document.fHtmlEditor.submit();
  }
}