	var _editores=Array();
	var ie = (navigator.userAgent.toLowerCase().indexOf("msie")!=-1)?true:false;
  var cmds  =  ["bold","italic","underline","strikethrough","justifyleft","justifycenter","justifyright","justifyfull","insertorderedlist","insertunorderedlist"];


	var activo="";

	function parametros(_form)
		{
		alert(_form.titular.value);
		}
	function iniciaEditor(editor)
		{

		document.getElementById(editor).contentWindow.document.designMode = 'On';
		if (ie)
			{
			document.getElementById(editor).contentWindow.document.attachEvent("onclick",function(){actualizaBarra(editor);actualizaTextArea(editor);},true);
			document.getElementById(editor).contentWindow.document.attachEvent("onkeydown",function(){actualizaBarra(editor);},true);
			document.getElementById(editor).contentWindow.document.attachEvent("onkeyup",function(){actualizaTextArea(editor);},true);

			}
		else
			{
			document.getElementById(editor).contentWindow.document.addEventListener("click",function(){actualizaBarra(editor);actualizaTextArea(editor);},true);
			document.getElementById(editor).contentWindow.document.addEventListener("keydown",function(){actualizaBarra(editor);},true);
			document.getElementById(editor).contentWindow.document.addEventListener("keyup",function(){actualizaTextArea(editor);},true);
			}
		var ta=editor.substring(0,editor.length-4);
		if (document.getElementById(ta).value!="")
			document.getElementById(editor).contentWindow.document.body.innerHTML=document.getElementById(ta).value;
		}

	function actualizaBarra(ifr)
		{
		for (i=0;i<cmds.length ;i++ )
			{
			if (document.getElementById(ifr).contentWindow.document.queryCommandState(cmds[i]))
				document.getElementById("b"+cmds[i]+ifr).className='botonOn';
			else
				document.getElementById("b"+cmds[i]+ifr).className='botonOff';
			}
		}
	function actualizaTextArea(ifr)
		{
		var ta=ifr.substring(0,ifr.length-4);
		document.getElementById(ta).value=document.getElementById(ifr).contentWindow.document.body.innerHTML;
		}

	function cargaTextArea(editor)
		{
		document.getElementById(editor).value=document.getElementById(editor+'_ifr').contentWindow.document.body.innerHTML;
		}

	function dentroBoton(id)
		{
		if (document.getElementById(id).className!='botonOn')
			document.getElementById(id).className='botonEncima';
		}
	function fueraBoton(id)
		{
		if (document.getElementById(id).className=='botonEncima')
			document.getElementById(id).className='botonOff';
		}
	function pulsadoBoton(id,cmd,ifr)
		{
		switch(cmd)
			{
			case 'NEGRITA':		document.getElementById(ifr).contentWindow.document.execCommand('bold', false, null);break;
			case 'SUBRAYADO':	document.getElementById(ifr).contentWindow.document.execCommand('underline', false, null);break;
			case 'CURSIVA':		document.getElementById(ifr).contentWindow.document.execCommand('italic', false, null);break;
			case 'TACHADO':		document.getElementById(ifr).contentWindow.document.execCommand('strikethrough', false, null);break;
			case 'JUST_IZQ':	document.getElementById(ifr).contentWindow.document.execCommand('justifyleft', false, null);break;
			case 'JUST_DER':	document.getElementById(ifr).contentWindow.document.execCommand('justifyright', false, null);break;
			case 'JUST_CEN':	document.getElementById(ifr).contentWindow.document.execCommand('justifycenter', false, null);break;
			case 'JUST_FULL':	document.getElementById(ifr).contentWindow.document.execCommand('justifyfull', false, null);break;
			case 'LISTA_ORD':	document.getElementById(ifr).contentWindow.document.execCommand('insertorderedlist', false, null);break;
			case 'LISTA_DES':	document.getElementById(ifr).contentWindow.document.execCommand('insertunorderedlist', false, null);break;
			}
/*		
		if (document.getElementById(id).className=='botonOn')
			document.getElementById(id).className='botonOff';
		else
			document.getElementById(id).className='botonOn';
*/
		actualizaBarra(ifr);

//		document.getElementById(ifr).contentWindow.document.focus();
		var elemento = document.getElementById(ifr);
		elemento.contentWindow.focus();

		actualizaTextArea(ifr);
		}



/////////////////////////////////////////////////////////////////////
/////////////////////FUNCIONES ANTERIORES
/////////////////////////////////////////////////////////////////////
function cambia_color(src,color) { 

		celda=document.getElementById(src);
    celda.bgColor=color;
//		src.style.cursor="hand"; 
}
function ventanaSecundaria(URL)
	{ 
	popup=window.open(URL,"ventana1","left=200,top=50,width=440,height=550");//,scrollbars=NO");
	popup.focus();
	} 
function saltaURL()
	{
	param="?nombre="+document.form.nombre.value;
	param=param+"&nif="+document.form.nif.value;
	param=param+"&direccion="+document.form.direccion.value;
	param=param+"&poblacion="+document.form.poblacion.value;
	param=param+"&codpos="+document.form.codpos.value;
	param=param+"&provincia="+document.form.provincia.value;
	param=param+"&email="+document.form.email.value;
	param=param+"&telefono="+document.form.telefono.value;
	switch(document.form.formaPago.value)
		{
		case "0":
			break;
		case "1":
			param=param+"&formaPago=1";
			break;
		case "2":
			param=param+"&formaPago=2";
			break;
		}
	param=param+"&error=1";
	window.location="formAltaPedidos.php"+param;
	}
function habilitaCombo(valor,comboFuente,comboDestino)
	{
//	var cb1 = eval('document.form.'+ comboFuente.name);
//	var cb2 = eval('document.form.'+ comboDestino.name);
//	alert(comboFuente.value);
	if (comboFuente.value!=valor)
		comboDestino.disabled=false;
	else
		{
		comboDestino.selectedIndex=0;
		comboDestino.disabled=true;
		}
	}
function abreCarpeta(id)
	{
	img=document.getElementById(id);
	img.src='/img/carpeta_on.jpg';
	}

function cambiaImagen(elemento)
	{
	var portada = document.getElementById("portada");
	var salvado = elemento.src;
	salvado = salvado.substring(salvado.indexOf("../../imagenes"));
	portada.src=salvado.replace("Mini","");
	elemento.src=activo;
	activo = salvado;
  }

/////////////////////////////////////////////
// MENU PROMOCIONES
/////////////////////////////////////////////
var propiedades;
var url;
var prop_actual;
var div;
function generaMenu(_propiedades,id,_url,_actual)
	{
//	alert(propiedades.length+"\r\n"+id+"\r\n"+url);
/*
	if (propiedades.length==0)
		return;

	generaPropiedades(propiedades,url,0);
	*/
	propiedades=_propiedades;
	url=_url;
	prop_actual=_actual;
	div=id;
	n=0;
	for(i=0;i<propiedades.length;i++)
		{
		if (prop_actual==propiedades[i][0])
			{
			n=i;
			break;
			}
		}
	generaPropiedades(n);
	}
function generaPropiedades(prop)
	{
	f1='<tr>\n';
	f2='<tr>\n';
	if (prop>0)
		{
		f1='<td></td>\n';
		f2+='<td><a href="#" onclick="generaPropiedades('+(prop-1)+');"><img src="/img/cuadrado_atras.jpg" border="0"></a></td>\n';
		}

	for(i=0;((i<3) && ((i+prop)<propiedades.length));i++)
		{
		f1+='<td width="25"></td>\n';
		f2+='<td width="25"></td>\n';
		f1+='<td width="25" align="center" class="textoGris">'+propiedades[i+prop][1]+'</td>\n';
		if (prop_actual==propiedades[i+prop][0])
			f2+='<td align="center"><img src="/img/cuadrado_gris.jpg"></td>\n';
		else
			{
			f2+='<form name="_formFichaProp'+i+'" action="'+url+'" method="post"><input type="hidden" name="clave" value="'+propiedades[i+prop][0]+'"><td align="center"> <a href="#" onclick="_formFichaProp'+i+'.submit()"> <img src="/img/cuadrado_rojo.jpg" border="0"></a></td></form>\n';
			}
		}

	if ((prop+3)<propiedades.length)
		{
		f1+='<td width="25"></td>\n';
		f2+='<td width="25"></td>\n';
		f1+='<td></td>';
//		cad='generaPropiedades(propiedades,url,'+(prop+1)+',actual)';
//		alert(cad);
		f2+='<td><a href="#" onclick="generaPropiedades('+(prop+1)+');"><img src="/img/cuadrado_adelante.jpg" border="0"></a></td>\n';
		}

	f1+='</tr>\n';
	f2+='</tr>\n';

	html='<table border="0">\n'+f1+f2+'\n</table>\n';
//	alert(html);
	document.getElementById(div).innerHTML=html;
	}
function muestraMapa()
	{
	obj=document.getElementById("icoMapa1");
	obj.style.display='none'
	obj=document.getElementById("icoMapa2");
	obj.style.display='none'
	obj=document.getElementById("MapaPromo");
	obj.style.display='block'
	obj=document.getElementById("icoFoto1");
	obj.style.display='block'
	obj=document.getElementById("icoFoto2");
	obj.style.display='block'
	obj=document.getElementById("FotoPromo");
	obj.style.display='none'
	}

function muestraFotos()
	{
	obj=document.getElementById("icoMapa1");
	obj.style.display='block'
	obj=document.getElementById("icoMapa2");
	obj.style.display='block'
	obj=document.getElementById("MapaPromo");
	obj.style.display='none'
	obj=document.getElementById("icoFoto1");
	obj.style.display='none';
	obj=document.getElementById("icoFoto2");
	obj.style.display='none';
	obj=document.getElementById("FotoPromo");
	obj.style.display='block';
	}

function muestraFotoPopup(foto)
	{ 
	url="popupFoto.php?IDPROMOCION=5dafdsfasdfsadf65656+asdfasfasdfsafasfsa134545465sdfsa646465445465sdfsa6464654s6dfsadf46s5ad4f56s4df564sad6f4sa65d4f65s4df6as4df&foto="+foto.replace("Mini","");
	popup=window.open(url,"ventana1","left=200,top=50,width=650,height=500");//,scrollbars=NO");
	popup.focus();
	} 

