function requestQuotation()
{
	ajax_submit_form("acceso_clientes","dopayment","php/presupuesto_clientes.php?cmd=clientquotation",null);
}


function addArticleToBasket(familia,nombre,inputName,subfamilia,relacionado)
{
	var cantidad = document.getElementById(inputName).value;
	if(cantidad>0) {
		ajax_call("quotationdebug","php/presupuesto_clientes.php?cmd=addarticle&comprar="+nombre + "&cantidad=" + cantidad,null);
	    //document.location="tienda.php?smenu="+familia+"&producto="+subfamilia+"&comprar="+nombre + "&cantidad=" + cantidad + "&enlace=" + subfamilia + "&relacionado="+relacionado;

	} else alert("Inavalid units number");
}

function addPanelToBasket(referencia){

	var panel = document.getElementsByName("paneles")[0].value;
	var cantidadPaneles = document.getElementsByName("unids")[0].value;
	var inversor = document.getElementsByName("inversores")[0].value;
	var cantidadInversores = document.getElementsByName("unidsInv")[0].value;
	if(cantidadPaneles>=0 && cantidadInversores>=0)
	document.location="tienda.php?smenu=Paneles Luminosos"+"&comprar="+referencia + "&cantidad=" + cantidadPaneles+"&pidpanel="+panel+"&cantp="+cantidadPaneles+"&pidinv="+inversor+"&canti="+cantidadInversores;
	else
	alert("Debe introducir una cantidad v�lida");	
	}
	

	
	
function addInversorToBasket(referencia){
	var panel = document.getElementsByName("paneles")[0].value;
	var cantidadPaneles = document.getElementsByName("unids")[0].value;
	var inversor = document.getElementsByName("inversores")[0].value;
	var cantidadInversores = document.getElementsByName("unidsInv")[0].value;
	if(cantidadPaneles>=0 && cantidadInversores>=0)
	document.location="tienda.php?smenu=Paneles Luminosos"+"&comprar="+referencia + "&cantidad=" + cantidadInversores+"&inv=set&pidpanel="+panel+"&cantp="+cantidadPaneles+"&pidinv="+inversor+"&canti="+cantidadInversores;
	else
	alert("Debe introducir una cantidad v�lida");		
	}
	
	function addAccesorioToBasket(nombre,inputName){
		var cantidad = document.getElementById(inputName).value;
		if(cantidad>0)
		document.location="tienda.php?accesorio=set&comprar="+nombre + "&cantidad=" + cantidad;
		else
		alert("Debe introducir una cantidad v�lida");	
		}

function modifyArticleBasket(idArticle,inputName){
	var direccion=document.location;
	var cantidad = document.getElementById(inputName).value;
	if(cantidad>0) {
		url = "tienda.php?action=modify&pid="+idArticle + "&cant=" + cantidad;
		document.location=url;
	} else {
		alert("Debe introducir una cantidad v�lida");	
		wait(1000);
		document.location=direccion;
	}
}


function doSelectionPanel(){
	
	 var indicePaneles = document.formpaneles.paneles.selectedIndex;
   var panel = document.formpaneles.paneles.options[indicePaneles].value;
	 var cantidadPaneles = document.getElementsByName("unids")[0].value;
 
   var indiceInversores = document.forminversores.inversores.selectedIndex;
   var inversor = document.forminversores.inversores.options[indiceInversores].value;
   var cantidadInversores = document.getElementsByName("unidsInv")[0].value;


if(cantidadPaneles>=0 && cantidadInversores>=0)
 	 document.location="tienda.php?smenu=Paneles Luminosos&pidpanel="+panel+"&cantp="+cantidadPaneles+"&pidinv="+inversor+"&canti="+cantidadInversores;
	else
		alert("Debe introducir una cantidad v�lida");
}



function doRequest(){
	
	var empresa = document.getElementsByName("empresa")[0].value;//obligatorio
	var cif = document.getElementsByName("cif")[0].value;//obligatorio
	var direccion = document.getElementsByName("direccion")[0].value;//obligatorio
	var localidad = document.getElementsByName("localidad")[0].value;//obligatorio
	var cp = document.getElementsByName("cp")[0].value;//obligatorio
	var provincia = document.getElementsByName("provincia")[0].value;//obligatorio
	var pais = document.getElementsByName("pais")[0].value;//obligatorio
	var contacto =  document.getElementsByName("contacto")[0].value;//obligatorio
	var cargo = document.getElementsByName("cargo")[0].value;
	var email = document.getElementsByName("email")[0].value;//obligatorio
	var sector = document.getElementsByName("sector")[0].value;//obligatorio
	var tlf = document.getElementsByName("tlf")[0].value;//obligatorio
	var movil = document.getElementsByName("movil")[0].value;
	var fax = document.getElementsByName("fax")[0].value;

	ajax_submit_form("acceso_clientes","dopayment","php/presupuesto_clientes.php?cmd=anonimquotation",null);

	//var tarjeta = document.getElementById("tarjeta").value;
	//var fecha = document.getElementById("fecha").value;
	//var fecha2 = document.getElementById("fecha2").value;
	//var cvv = document.getElementById("cvv").value;
	
/*	
	var cadlocation="tienda.php?register=client&contacto="+contacto+"&empresa="+empresa+"&cargo="+cargo+"&sector="+sector+"&cif="+cif+
	"&direccion="+direccion+"&cp="+cp+"&provincia="+provincia+"&email="+email+"&pais="+pais+"&tlf="+tlf+
	"&movil="+movil+"&fax="+fax;
	
	
	var longTarjeta = tarjeta.length;
	//var longFecha = fecha.length;
	
	
	if(contacto=="" || cargo=="" || sector=="" || direccion=="" || cp=="" || provincia=="" || email=="" || tlf==""|| tarjeta=="" || fecha=="" || cvv=="")
	alert("Por favor, rellene todos los campos obligatorios.");
		else if(longTarjeta!=16){
	alert("La tarjeta introducida es incorrecta.");	
	}
			else{
	document.location=cadlocation;
	wait(5000);//Esperamos a que haga la escritura del pedido en la base de datos
	
	var xml = document.getElementsByName("peticion")[0].value;
	xml = xml.replace("<numtarjeta>xxxxx</numtarjeta>","<numtarjeta>"+tarjeta+"</numtarjeta>");
	
	
	xml = xml.replace("<cvv2>xxx</cvv2>","<cvv2>"+cvv+"</cvv2>");
	//<cvv2>xxx</cvv2>
	var fechatratada="20"+fecha2+fecha;
	xml = xml.replace("<fechacaducidad>xxxxx</fechacaducidad>","<fechacaducidad>"+fechatratada+"</fechacaducidad>");
	//alert(xml);
	document.getElementsByName("peticion")[0].value = xml;	
*/	
	//document.dopayment.submit();
}
	
	
function wait(milliseconds){
var now = new Date();
var exitTime = now.getTime() + milliseconds;
while(true){
now = new Date();
if(now.getTime() > exitTime) return;
}
}


function openWindowFlash(producto){
	
   ventana = document.open("flash/[600x500]"+producto+".swf","","width=600 ,height=500"); 
   
}

function showProductVideo(producto){
	
   ventana = document.open(producto,"","width=600 ,height=500"); 
   
}

function imprimir(){
	window.print(); 
	}
	
	
function cargarDatosCliente(){
		
		alert("Lo sentimos, esta opci�n a�n no est� disponible.");
}
	
function mostrarFAQ(){
		
		var direccion =""+document.location;
		var encontrado = direccion.indexOf('?');
		if(encontrado==-1)
		document.location=document.location+"?faq=show&main=1#arriba";
		else{
		var direccion = document.location+"&faq=show&main=0#arriba";
		document.location=direccion;
		}		
		
	/*if(caracter=='')
		document.location="";
		else if(caracter=='');
		document.location="";
	*/
			
			
		
		//document.location=document.location+"?faq=show";

		}
		
		
function borrarArticle(articulo){
	/*
	var direccion=""+document.location;
	wait(1000);
	var encontrado = direccion.indexOf('?');
	if(encontrado==-1) direccion = direccion+"?mantener=1";
	else direccion = direccion+"&mantener=1";
	direccion = direccion+"&idcompra="+articulo;
	document.location=direccion;
	*/
	ajax_call("quotationdebug","php/presupuesto_clientes.php?cmd=delarticle&article="+articulo,null);

}

function doConsulta(peticion){
	alert(peticion);
//document.doconsulta.submit();
}
	
function doSelectionLightBar(){
	var indicePaneles = document.formLightBar.paneles.selectedIndex;
	var panel = document.formLightBar.paneles.options[indicePaneles].value;
	document.location="tienda.php?smenu=Luces de emergencia&producto=BARRAS DE LUZ&pidpanel="+panel;
}