function comprar() {
	window.location = 'http://pcmdesign.es/index.php?/order-page/';
}

function ordernopcart() {
	if (document.getElementById('shipping_loc').checked ||
		document.getElementById('shipping_nat').checked ||
		document.getElementById('shipping_int').checked )
	{
		if (document.getElementById('shipping_loc').checked) { document.getElementById('shipping').value = document.getElementById('shipping_loc').value;}
		if (document.getElementById('shipping_nat').checked) { document.getElementById('shipping').value = document.getElementById('shipping_nat').value;}
		if (document.getElementById('shipping_int').checked) { document.getElementById('shipping').value = document.getElementById('shipping_int').value;}
	 // document.formulario.action="https://www.sandbox.paypal.com/row/cgi-bin/webscr";
	 //	document.formulario.action="https://www.paypal.com/cgi-bin/webscr";
		document.formulario.action="http://pcmdesign.es/ndxz-studio/site/pcmdesign/checkout.php";
		document.formulario.submit();
	} else {
		alert('Para continuar con el proceso de compra debe seleccionar el destino del pedido');
	}
}

function order() {
//  document.formulario.action="https://www.sandbox.paypal.com/row/cgi-bin/webscr";
	document.formulario.action="https://www.paypal.com/cgi-bin/webscr";
	document.formulario.submit();
}

function hacerpedido() {
	document.formulario.action="http://pcmdesign.es/index.php?/order-page/";
	document.formulario.submit();
}


function campoError(campo)
{
	campo.className="input-error";
	error=1;
}

function validaLongitud(valor, permiteVacio, minimo, maximo)
{
	var cantCar=valor.length;
	if(valor=="")
	{
		if(permiteVacio) return true;
		else return false;
	}
	else
	{
		if(cantCar>=minimo && cantCar<=maximo) return true;
		else return false;
	}
}

function limpiaForm()
{
	document.formulario.nombre.className="input-text"; 
	document.formulario.telefono.className="input-text"; 
	document.formulario.emilio.className="input-text"; 
	document.formulario.producto.className="input-text"; 
	document.formulario.cantidad.className="input-text"; 
	document.formulario.titulo.className="input-text"; 
	document.getElementById("mensaje").style.visibility = "hidden";

}

function validarForm() {
	limpiaForm();
	error=0;

//	if (document.formulario.politica.checked == false) {
//		alert("Es necesario aceptar la política de privacidad antes de enviar la solicitud de información");
//	} else {

		if (!validaLongitud(document.formulario.nombre.value,     0, 1, 200)) {campoError(document.formulario.nombre);}
		if (!validaLongitud(document.formulario.telefono.value, 1, 0, 200)) {campoError(document.formulario.telefono);}
		if (!validaLongitud(document.formulario.emilio.value,   0, 1, 200)) {campoError(document.formulario.emilio);}
		if (!validaLongitud(document.formulario.producto.value, 0, 1, 200)) {campoError(document.formulario.producto);}
		if (!validaLongitud(document.formulario.cantidad.value, 0, 1, 20)) {campoError(document.formulario.cantidad);}
		if (!validaLongitud(document.formulario.titulo.value,   0, 1, 200)) {campoError(document.titulo.cantidad);}

		if(error==0) {
			document.formulario.action="miemilio.php";
			document.formulario.submit();
/*			Modalbox.show('form_consulta.php?enviarFormulario=1'+
						    '&name='+document.formulario.name.value+
							'&telefono='+document.formulario.telefono.value+
							'&emilio='+document.formulario.emilio.value+
							'&producto='+document.formulario.producto.value+
							'&cantidad='+document.formulario.cantidad.value+
							'&titulo='+document.formulario.titulo.value+
							'&comentario='+document.formulario.comentario.value
			,{title: 'Solicitud enviada', width: 400}); 
			// php pone comillas a la cadena escapeshellarg(cadena)
*/
			return true;
		} else {
			document.getElementById("mensaje").style.visibility = "visible";
			alert("Los campos en rojo son obligatorios. Es necesario curbirlos antes de enviar el pedido");
		}
//	}
}


