      globalEditor = 1;  

      function validateEdit(){
        if(document.ec.editcontents.value == 0){
          return false;
        }
        return true;
      }
      
      function deleteContent(){
        selectedid = document.ec.editcontents.value;
        if(selectedid != 0){
          window.location = '?delete=' + selectedid;
        }
      }
      
      function makeFormat(sFormatString){
        if(sFormatString == "CreateLink"){
          eval("oDiv"+globalEditor+".focus()");
          var newLink = eval("oDiv"+globalEditor+".document.execCommand('CreateLink', true, null)");
          newLink.target = "_blank";
        }
        else{
          eval("oDiv"+globalEditor+".focus()");
          document.execCommand(sFormatString);
        }
      }
      
      function putFontSize(sdiv){
        eval("oDiv"+globalEditor+".focus()");
        if(document.getElementById('sizer_'+sdiv).value == "N"){
        	document.execCommand('fontsize','','11px');
        }
        else{
          document.execCommand('fontsize','',document.getElementById('sizer_'+sdiv).value);
        }
      }
      
      function saveContent(){
        if(formato == "Text"){
          viewHTML();
        }
        document.contentform.content.value = eval("oDiv"+globalEditor+".innerHTML");
        if(document.getElementById('concaption')){
          document.contentform.caption.value = document.getElementById('concaption').value;
        }
        if(document.getElementById('idstatus')){
          if(document.getElementById('idstatus').checked == true){
            document.contentform.status.value = 1;
          }
          else{
            document.contentform.status.value = 0;
          }
        }
        if(document.getElementById('setform').value != ""){
        	document.contentform.useform.value = document.getElementById('setform').value;
        }
        
        document.contentform.submit();
      }
      
      var sInitColor = null;
      function callColor(who){
        if (sInitColor == null) 
          var sColor = dlgHelper.ChooseColorDlg();
        else
          var sColor = dlgHelper.ChooseColorDlg(sInitColor);
        
        sColor = sColor.toString(16);
        
        if (sColor.length < 6) {
          var sTempString = "000000".substring(0,6-sColor.length);
          sColor = sTempString.concat(sColor);
        }
        
        document.execCommand(who, false, sColor);
        sInitColor = sColor;
      }
      
      var formato = "HTML"
      function viewHTML(){
        if(formato == "HTML"){
          if(document.getElementById('btn_html')){
            document.getElementById('btn_html').src = "../../images/content/UI_nohtml.gif";
          }
          else{
            document.getElementById('btn_html'+globalEditor).src = "../../images/content/UI_nohtml.gif";
          }
          eval("oDiv"+globalEditor+".innerText = oDiv"+globalEditor+".innerHTML");
          eval("oDiv"+globalEditor+".style.fontFamily = 'monospace'");
          eval("oDiv"+globalEditor+".style.fontSize = '10pt'");
          formato = "Text"
        }
        else{
          if(document.getElementById('btn_html')){
            document.getElementById('btn_html').src = "../../images/content/UI_html.gif";
          }
          else{
            document.getElementById('btn_html'+globalEditor).src = "../../images/content/UI_html.gif";
          }  
          eval("oDiv"+globalEditor+".innerHTML = oDiv"+globalEditor+".innerText");
          eval("oDiv"+globalEditor+".style.fontFamily = ''");
          eval("oDiv"+globalEditor+".style.fontSize = ''");
          formato = "HTML"
        }
      }
      
      function makeLink(){
        if(document.selection.createRange().htmlText == "" || document.selection.createRange().htmlText == undefined){
          alert("Please highlight the text or image.");
        }
        else{
          window.open('links.php','smallw','width=590,height=390,top=50,left=50,resizable=yes,scrollbars=no,status=no');
        }
      }
   /*  
      function putLink(linkurl,linktarget,typeurl){
	   
        kk  = document.selection.createRange();
        tt  = document.selection.createRange().htmlText;
        linkcap  = linkurl.split("/");
        if(typeurl == 'doc'){
          str = '<a href="' + linkurl + '" target="'+linktarget+'">' + tt + '</a>';
        }else if(typeurl = 'intern'){
          str = '<form name="link'+linkcap[(linkcap.length)-1]+'" method="POST" action=""> '; 
          str += '<a onClick="document.link'+linkcap[(linkcap.length)-1]+'.submit();">' + tt + '</a>';
          str += '</form>';
        }else{
          str = '<a href="' + linkurl + '">' + tt + '</a>';
        }
        
        kk.pasteHTML(str);
      }*/
      
      function makeImage(fld,openin){
      	if(openin){
          window.open(openin+'images2.php?folder='+fld,'smallw','width=690,height=450,top=50,left=50,resizable=yes,scrollbars=no,status=no');
        }
        else{
          window.open('images2.php?folder='+fld,'smallw','width=690,height=450,top=50,left=50,resizable=yes,scrollbars=no,status=no');
        }
      }
      
      function putImage(imagename){
        makeFormat('insertImage', false, imagename);
        changeimage = eval("oDiv"+globalEditor+".innerHTML");
        ext = imagename.substring(imagename.length-3,imagename.length);
		w = imagename.substring(imagename.length-11,imagename.length-8);
		h = imagename.substring(imagename.length-7,imagename.length-4);
		if(ext == "swf"){
		    flash = "<div style=\"z-index:0;\"><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\""+w+"\" height=\""+h+"\">";
			flash += "<param name=\"movie\" value=\""+imagename+"\" />";
			flash += "<param name=\"quality\" value=\"high\" />";
			flash += "<param name=\"wmode\" value=\"transparent\" />";
			flash += "<embed src=\""+imagename+"\" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+w+"\" height=\""+h+"\"></embed>";
			flash += "</object></div>";
			changeimage = changeimage.replace('<IMG>',flash);
		}else{
			changeimage = changeimage.replace('<IMG>','<img src="'+imagename+'" border="0">');
		}
        eval("oDiv"+globalEditor+".innerHTML = changeimage");
      }
      
      function makeLink2(formnumber){
        window.open('links.php?s='+formnumber,'smallw','width=590,height=390,top=50,left=50,resizable=yes,scrollbars=no,status=no');
      }
      
      function putLink2(linkurl,linktarget,formnumber){
        document.getElementById('linkto'+formnumber).value = linkurl;
        document.getElementById('linkta'+formnumber).value = linktarget;
        eval("document.form_"+formnumber+".submit()");
      }
      
      function makeLink3(menuid,table){
        window.open('links.php?s='+menuid+'&ptable='+table,'smallw','width=590,height=390,top=50,left=50,resizable=yes,scrollbars=no,status=yes');
      }
      
      function doLinkSelection(vURL,vTarg,vId,vTable){
      	if(!vTable || vTable == ""){
			var form0 = document.form0;
			form0.doLinkSelection.value = vId;
			form0.iValue.value = vURL;
			form0.vTar.value = vTarg;
			form0.obj.value = document.getElementById('groupname').value;
			form0.submit();
	    }else{
			var form0 = document.form0;
			form0.doLinkSelection.value = vId;
			form0.iValue.value = vURL;
			form0.vTar.value = vTarg;
			form0.obj.value = document.getElementById('groupname').value;
			form0.utable.value = vTable;
			form0.submit();
        }
      }
      
      function viewdesc(homeid){
        if(document.getElementById('desc'+homeid).style.display == "block"){
          document.getElementById('desc'+homeid).style.display = "none";
        }
        else{
          for(i=1;i<=100;i++){
            if(document.getElementById('desc'+i)){
              document.getElementById('desc'+i).style.display = "none";
            }
          }
          document.getElementById('desc'+homeid).style.display = "block";
          globalEditor = homeid;
        }
      }
      
      function sendhome(homeid){
        if(formato == "Text"){
          viewHTML();
        }
        eval("document.form_"+homeid+".description.value = oDiv"+homeid+".innerHTML");
        eval("document.form_"+homeid+".submit()");
      }
      
      function changeStatFile(s,t){
      	cf = confirm("Are you shure replace " + t + " for " + s + " file\nIf you confirm this action execute inmediatly and you can't rollback")
      	if(cf){
      		window.location = '?menu=stats&f1=' + s + '&f2=' + t;
      	}
      	else{
      		document.getElementById('scf1').value = 0;
      		document.getElementById('scf2').value = 0;
      		document.getElementById('scf3').value = 0;
      		document.getElementById('scf4').value = 0;
      	}
      }
      
      function validateform(formname){
      	formlist = document.getElementById("mandfields").value;
      	fields = formlist.split(";");
      	if(fields.length > 0){
      	  for(i=1;i<=fields.length-1;i++){
      	    if(eval("document." + formname + "." + fields[i-1] + ".value == ''")){
      	      alert("Plaese, complete all mandatory fields");
      	      return(false);
      	    }
      	  }
      	}
      }