<!--
var ultimo_nLayerAdmin=-1;
var le, to;
// Muestra el menu de Administrador sobre las Sub/Categorias
function showAdmin(cual,capa, evt) {
	//cual es un tag A
	var e = evt || window.event;

	if(ultimo_nLayerAdmin>0) {
		mi_2_showHideLayers('LayerAdmin'+ultimo_nLayerAdmin,'','hide');
		//alert(ultimo_nLayerAdmin);
	};
	ultimo_nLayerAdmin=capa;
	cualDiv=capa='LayerAdmin'+capa;
	
	mi_2_showHideLayers(capa,'','show'); 
	capa=MM_findObj(capa,document);
	
	//le=event.x+10;
	//to=event.y-5;

	// scrollLeft : IE=>ok, MZ=>ok
	//alert(typeof e.srcElement );
	offsetX=(typeof e.offsetX=='undefined' ? 50 : e.offsetX);
	offsetY=(typeof e.offsetY=='undefined' ?  0 : e.offsetY);
	
	le=(document.body.scrollLeft + e.clientX - offsetX);
	to=(document.body.scrollTop  + e.clientY - offsetY);

	capa.style.left=le+152;//12
	capa.style.top=to-6;
	
	DivSetVisible(true, cualDiv);

}// end function showAdmin

function mi_2_showHideLayers(capa,nada,visibilidad) {
	MM_showHideLayers(capa, nada,visibilidad);

	if(visibilidad=='show') {
		//DivSetVisible(true, capa);
	} else {
		DivSetVisible(false, capa);
	}
	/*
	
	*/
	
}

function DivSetVisible(state, cualDiv)
{
	var DIV = document.getElementById(cualDiv);
	var Iframe = document.getElementById('DivShim');
	if(state)
	{
		Iframe.style.display = "block";
		//DIV.style.display = "block";
		Iframe.style.width = DIV.offsetWidth-20;
		Iframe.style.height = DIV.offsetHeight;
		Iframe.style.top = DIV.style.top;
		//window.status=DIV.style.top;
		//Iframe.style.top = to+'px';
		c=DIV.style.left.replace('px','');
		c=parseInt(c)+20;
		Iframe.style.left = c;
		//Iframe.style.left = le;
		Iframe.style.zIndex = DIV.style.zIndex - 1;
	}
	else
	{
		//DIV.style.display = "none";
		Iframe.style.display = "none";
		Iframe.style.width = '300px';
		Iframe.style.height = '300px';
	}
}


/*//Actualiza la vista de la imagen cuando de Agrega/Edita un Contenido
function actualizarImagen(fileinput) 
{	// fileinput es un <input type=file>
	if(fileinput.value.length>3) {
		//quiere decir que se ha elegido una nueva imagen
		imagenFoto=document.getElementById("imagenFoto");
		imagenFoto.src=fileinput.value;
		//if(document.all.imagenFoto.width>470) document.all.imagenFoto.width=470;	
		setTimeout("if(imagenFoto.width>450) imagenFoto.width=450;",1500);
	};
	//;document.all.imagenFoto.width=200;
};//End function actualizarImagen()
*/

// Funciones para cambiar el fondo de los labels de los forms
function moin(which){ 
	//which.style.background='bisque'; 
	which.className='onLabel'; 
};
function mout(which){ 
	which.className='outLabel';
};


function sacarBR(texto) {
	var regExp = new RegExp("\<br \/>","gi");
	//alert(texto.match("br").length);
	return texto.replace(regExp,String.fromCharCode(10, 13));
}

function ponerBR(texto) {
	var regExp = new RegExp("\r\n","gi");
	return texto.replace(regExp,"\<br \/>");
}

function myCustomCleanup(type, value) {
	switch (type) {
		case "get_from_editor": //alert("Value HTML string: \n"+type+"\n" + value);
			// Do custom cleanup code here
			value=sacarBR(value);
			break;
		case "insert_to_editor": //alert("Value HTML string: \n"+type+"\n" + value);
			value=ponerBR(value);
			// Do custom cleanup code here
			break;
		case "get_from_editor_dom": //alert("Value DOM Element \n"+type+"\n" + value);
			// Do custom cleanup code here
			break;
		case "insert_to_editor_dom": //alert("Value DOM Element: \n"+type+"\n" + value);
			// Do custom cleanup code here
			break;
	}

	return value;
}



/*
Control characters:
,    Separates element chunk definitions. 
/    Separates element synonymous. The first element is the one that will be output. 
|    Separates attribute definitions. 
[    Starts a new attribute list for an element definition. 
]    Ends an attribute list for an element definition. 
=    Makes the attribute default to the specified value. For example, "target=_blank" 
:    Forces the attribute to the specified value. For example, "border:0" 
<    Verifies the value of an attribute. For example, "target<_blank?_self" 
?    Separates attribute verification values. See above. 
+    Makes the element open if no child nodes exists. For example, "+a". 
-    Enables removal of empty elements such as <strong />. For example, "-strong". 
#    Enables padding of empty elements. This will pad with &nbsp; if they are empty. For example, "#p". 
!    Makes attributes required. If none of the required attributes are set, the element will be removed. For example, "!href". 

Wildcards such as *,+,? may be used in element or attribute name matching. 
*/

function iniciarEditor(estilo_css){ 
//var tinyMCE=document.getElementById(tinyMCE);
	// Notice: The simple theme does not use all options some of them are limited to the advanced theme
		tinyMCE.init({
			language : "es",
			mode : "none",
			//mode : "exact", elements : "descripcion,pie",
			
			content_css : estilo_css,
			
			//cleanup_callback : "myCustomCleanup",
			//cleanup : true, // esto en true ayuda a que no agregue atributo class=mceVisualAid
			//force_br_newlines: false, 
			convert_newlines_to_brs : false, //false
			entities :  "162,cent",//"160,nbsp,38,amp,34,quot,162,cent,8364",
			relative_urls : false, 
	
			//button_tile_map : true, // iconos con texto

			apply_source_formatting : true,
			
			valid_elements : "" +
				"a[name|href|target|title]," + 
				"object[classid|codebase|width|height],param,"+
				"embed[src|quality|pluginspage|type|width|height]," +
				"b/strong,i,u,"+
				"h1/h2/h3/h4,"+
				"table,tr,th,td,"+
				"ul,ol,li,span,font,blockquote,hr,br,em,strike,sub,sup",
			//"div",+
				
				
			verify_html : false, //con esto en false soluciono el problema de que quita los formularios y hace cagadas con TAGs, pero lo soluciono con lo de abajo:

			theme : "advanced",
			//plugins : "table,contextmenu,paste,-externalplugin,emotions,logos,flash",
			plugins : "table,contextmenu,paste,-externalplugin,flash",
			
			/*theme_advanced_valid_elements : "" +
				"a[name|href|target|title]," + 
				"object[classid|codebase|width|height],param,"+
				"embed[src|quality|pluginspage|type|width|height]," +
				"b/strong,i,u,"+
				"h1/h2/h3/h4,"+
				"table,tr,th,td,"+
				"ul,ol,li,span,font,blockquote,hr,br,em,strike,sub,sup",
			//"div",+*/
			//theme_advanced_disable : "formatselect,fontselect,fontsizeselect,styleselect,image,anchor",
			theme_advanced_layout_manager : "SimpleLayout", //SimpleLayout  , RowLayout , CustomLayout 
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_path_location : "bottom",
			
			//theme_advanced_buttons1_add_before : "bold,italic,underline,strikethrough,|",
			theme_advanced_buttons1 : "forecolor,backcolor,|,hr,charmap,|,removeformat,help,code,flash",
			//theme_advanced_buttons1 : "forecolor,backcolor,|,hr,charmap,logos,|,removeformat,help,code",
			//theme_advanced_buttons1_add : "formatselect,fontselect,fontsizeselect,styleselect,|",
			
			theme_advanced_buttons2 : "bold,italic,underline,strikethrough,sub,sup,|,link,unlink,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist, numlist, ,|,outdent, indent",
			theme_advanced_buttons3 : "",
			//theme_advanced_buttons3 : "table,row_before,row_after,delete_row,separator,rowseparator,col_before,col_after,delete_col",

			//theme_advanced_resize_horizontal : false,
			theme_advanced_resizing : true,
			height : "300",
			ask : false


		});
	toogleEditorMode('descripcion', tinyMCEmode); 
};//end function iniciarEditor


// Alterna el uso de editorMCE
function toogleEditorMode(sEditorID, visible) {
    try {
        if(!visible) {
            tinyMCE.removeMCEControl(tinyMCE.getEditorId(sEditorID));
            tinyMCEmode = false;
        } else {
            tinyMCE.addMCEControl(document.getElementById(sEditorID), sEditorID);
            tinyMCEmode = true;
        }
    } catch(e) {
        //error handling
    }
}


// para saber si el usuario elige el formato "normal" o "HTML"
function es_HTML()
{	
	return(document.nuevomensaje.htmlsi.checked);
};
	
// actualiza la "descripcion" cuando cambio en formato normal y HTML
function actualizarHTML() 
{
	es_html=es_HTML();
	if(es_html_option != es_html) 
	{
		es_html_option = (es_html?true:false);
		toogleEditorMode("descripcion", es_html);
	} else { 
		//alert("se ha elegido la opcion que ya está elegida");
	}
		$('textarea[name=descripcion]').focus();
};//end function



//muestra u oculta las capas de datos del contenido, segun el "tipo de contenido" clickeado
function actualizarCapas(option)
{
	tipo=option.value;

	ver=(tipos[tipo]["abierto"]!=0?"show":"hide");
	Mi_showHideLayers('Layer_abierto','',ver);
	if(ver=='hide') document.getElementById('abierto').checked=true;

	ver=(tipos[tipo]["titulo"]!=0?"show":"hide");
	Mi_showHideLayers('Layer_titulo','',ver);

	ver=(tipos[tipo]["descripcion"]!=0?"show":"hide");
	Mi_showHideLayers('Layer_descripcion','',ver);
	
	if(ver=='hide') {
		if(es_HTML() && tinyMCEmode ) toogleEditorMode('descripcion', false);
	} else {
		if(es_HTML() && !tinyMCEmode) toogleEditorMode('descripcion', true);
	}
	/*if(ver!='hide') {
		Mi_showHideLayers('formatoNormal','',es_HTML()?"hide":"show");
		//Mi_showHideLayers('formatoHTML','',es_HTML()?"show":"hide");
	} else {
		Mi_showHideLayers('formatoNormal','',"hide");
		//Mi_showHideLayers('formatoHTML','',"hide");
	}
	*/
	
	ver=(tipos[tipo]["imagen"]!=0?"show":"hide");
	Mi_showHideLayers('Layer_imagen','',ver);
	Mi_showHideLayers('Layer_imagenActual','',ver);
	
	
};

// 
function enviar_form(cual_form) 
{
	cual_form.elements['terminar'].value=" Espere ....";
	//alert(cual_form.elements['descripcion'].value);
	/*
	nf=document.getElementById('foto_nombre');
	 f=document.getElementById('foto');
	 nf.value=f.value;
	 f.value='D:\whm.jpg'; alert('viste');
	*/
	
};//end function


//-->
