function validarEnvio()
{
	if(datosPedido.user_firstName&&datosPedido.user_firstName.value.length==0)
	{
		alert('Por favor, introduzca un nombre');
		return 0;
	}				
	
	if(datosPedido.user_documentId&&datosPedido.user_documentId.value.length==0)
	{
		alert('Por favor, introduzca DNI');
		return 0;
	}
	/*
	if(datosPedido.user_email&&datosPedido.user_email.value.length==0)
	{
		alert('Por favor, introduzca e-mail');
		return 0;
	}	
	if(datosPedido.user_email&&datosPedido.user_email.value.indexOf("@")==-1)
	{
		alert('Por favor, introduzca un e-mail correcto');
		return 0;
	}
	*/		
	if(datosPedido.user_phone&&datosPedido.user_phone.value.length==0)
	{
		alert('Por favor, introduzca un teléfono');
		return 0;
	}		

	
	if(!datosPedido.agreement.checked)
	{
		alert('Debe leer y aceptar las condiciones generales');
		return 0;
	}
	
	
	return 1;	

}

function DNI(n){
var d =(n/23)
d = Math.floor(d);
var e=d*23
var r=n-e
if (r==0)
return "T"
if (r==1)
return "R"
if (r==2)
return "W"
if (r==3)
return "A"
if (r==4)
return "G"
if (r==5)
return "M"
if (r==6)
return "Y"
if (r==7)
return "F"
if (r==8)
return "P"
if (r==9)
return "D"
if (r==10)
return "X"
if (r==11)
return "B"
if (r==12)
return "N"
if (r==13)
return "J"
if (r==14)
return "Z"
if (r==15)
return "S"
if (r==16)
return "Q"
if (r==17)
return "V"
if (r==18)
return "H"
if (r==19)
return "L"
if (r==20)
return "C"
if (r==21)
return "K"
if (r==22)
return "E"



}

function abrirVentana(dir)
{
	w=window.open(dir,"","width=710,height=600,location=no,status=yes");
}

function copySelect(x,y)
{
	//alert(x);
	//alert(x.options);
		var s=window.document.createElement('select');
		var i=0;
		if(x&&x.options)
		for(i=0;i<x.options.length;i++)
		{
			s.options[i]=new Option();
			s.options[i].value=x.options[i].value;
			s.options[i].text=x.options[i].text;
			if(y)
			{
					if(x.options[i].value==y)
					{
						s.options[i].selected='true';
					}
			}
		}
		return s;
}

function borrarCat(x)
{
	var prefix=document.getElementById('prefix').value;
		var s=null;
		if(x>0)s=document.getElementById(prefix+'_alternateCategory_'+x);
		else s=document.getElementById('alternateCategory0');
		if(s)
		{
			s.selectedIndex=-1;
	}
	if(x>0)
	{
		var t=document.getElementById('tdOtrasCategorias');
		t.removeChild(s);
		t.removeChild(document.getElementById('bc_'+x));	
		t.removeChild(document.getElementById('sl_'+x));	
	}
}

function addCat(ix)
{
		var t=document.getElementById('tdOtrasCategorias');
		var prefix=document.getElementById('prefix').value;
		var nueva=copySelect(document.getElementById('alternateCategory0'),ix);
		var numero=0;
		if(document.getElementById('numeroOtrasCategorias'))
		{numero=eval(document.getElementById('numeroOtrasCategorias').value);
		numero=eval(numero+1);
		document.getElementById('numeroOtrasCategorias').value=numero;
	}
		nueva.id=prefix+'_alternateCategory_'+numero;
		nueva.name=prefix+'_alternateCategory_'+numero;
		var boton=document.createElement('button');
		//<input type="button" value="X" onClick="borrarCat()">
		boton.appendChild(document.createTextNode('X'));
		//if(boton.type)boton.type='button';
		boton.id='bc_'+numero;
		boton.onclick=function(){borrarCat(numero);};
		var salto=document.createElement('br');
		salto.id='sl_'+numero;
		//t.appendChild(nueva);
		//t.appendChild(salto);
		if(t&&document.getElementById('botonMasCat'))
		{
		t.insertBefore(nueva,document.getElementById('botonMasCat'));
		t.insertBefore(boton,document.getElementById('botonMasCat'));
		t.insertBefore(salto,document.getElementById('botonMasCat'));
	}
}

function resetCat()
{
	if(document.getElementById("numeroOtrasCategorias"))
	{
	document.getElementById("numeroOtrasCategorias").value=0;
}
}

function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}


function d(x)
{
	document.write(x);
}
function sa()
{
	d('<');d('a');d(' ');d('h');d('r');d('e');d('f');d('=');d('"');d('m');d('a');d('i');d('l');d('t');d('o');d(':');
}

function dl()
{
	d('@');d('s');d('e');d('g');d('u');d('r');d('i');d('d');d('a');d('d');d('p');d('l');d('u');d('s');d('.');d('c');d('o');d('m');
	
}