	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 muestraImagen(id,img)
	{
	i=document.getElementById(id);
	i.src='/img/'+img;
	}
	
function muestraTallas(tabla1,tabla2)
	{
	t1=document.getElementById(tabla1);
	t2=document.getElementById(tabla2);

	t1.style.display='block';
	t2.style.display='none';
	}
function muestraTextoFormaPago()
	{

	switch(document.form.formaPago.selectedIndex)
		{
		case 0:
			document.getElementById("ttextoPaypal").style.display='none';
			document.getElementById("ttextoTransferencia").style.display='none';
			document.getElementById("ttextoContrarrembolso").style.display='none';
			break;
		case 1:
			document.getElementById("ttextoPaypal").style.display='block';
			document.getElementById("ttextoTransferencia").style.display='none';
			document.getElementById("ttextoContrarrembolso").style.display='none';
			break;
		case 2:
			document.getElementById("ttextoPaypal").style.display='none';
			document.getElementById("ttextoTransferencia").style.display='block';
			document.getElementById("ttextoContrarrembolso").style.display='none';
			break;
		case 3:
			document.getElementById("ttextoPaypal").style.display='none';
			document.getElementById("ttextoTransferencia").style.display='none';
			document.getElementById("ttextoContrarrembolso").style.display='block';
			break;
		}
	}
