	var wheres='';
	

	
	function mostra_carro(div_id)
	{


		var url='ajax_carro_mostrar.php';
		//var parameters='';

		//ajaxPost(url,parameters,'GET',false);
		
		ajaxRequestResponseText= $.ajax({
		  								url: url,
		  								async: false
		 								}).responseText;		
		
		try
		{
			document.getElementById(div_id).innerHTML = ajaxRequestResponseText;
			document.getElementById(div_id).style.display = 'inline';
			document.getElementById('PRODUCTES').style.display = 'none';

		}
		catch(err)
		{
		}

	}	
	function tancar_carro(div_id)
	{
		
		try
		{
			document.getElementById(div_id).style.display = 'none';
			document.getElementById('PRODUCTES').style.display = 'inline';
		}
		catch(err)
		{
		}

	}	
	
	
	
	function elimina_tot_carro()
	{


		var url='ajax_carro_eliminar_tot.php';
		//var parameters='';

		//ajaxPost(url,parameters,'GET',false);
		
		ajaxRequestResponseText= $.ajax({
		  								url: url,
		  								async: false
		 								}).responseText;				
		mostra_carro('CARRO');

	}	
	
	
	function afegir_carro(codi,quantitat)
	{
		if (isNumeric(quantitat)==false)
		{
			alert ('La quantitat no és un número correcte');
			document.getElementById('txt_quantiat_'+codi).value='';
			comprovar_carro(codi);
			info_carro();			
			return false;
		}
		else
		{
			quantitat=quantitat*1;
			var url='ajax_afegir_carro.php?PAR_CODI_PRODUCTE='+codi+'&PAR_QUANTITAT='+quantitat;
			//var parameters='';
	
			//ajaxPost(url,parameters,'GET',false);
			
			 ajaxRequestResponseXML= $.ajax({
			  								url: url,
			  								async: false
			 								}).responseXML;			

			if (ajaxRequestResponseXML.getElementsByTagName('error_t')[0].childNodes[0].data!='0')
			{
				document.getElementById('txt_quantiat_'+codi).value='';
				alert (ajaxRequestResponseXML.getElementsByTagName('error_t')[0].childNodes[0].data);
				comprovar_carro(codi);
				info_carro();
				return false;
			}
			else
			{
				comprovar_carro(codi);
				info_carro();
				return true;
			}
		}

	}
	function comprovar_carro(codi)
	{	


			var url='ajax_carro_comprovar.php?PAR_CODI_PRODUCTE='+codi;
			//var parameters='';
	
			//ajaxPost(url,parameters,'GET',false);
			
			ajaxRequestResponseXML= $.ajax({
			  								url: url,
			  								async: false
			 								}).responseXML;			

			var quantitat=0;
			
			if (ajaxRequestResponseXML.getElementsByTagName('error_t')[0].childNodes[0].data=='0')
			{
				quantitat=ajaxRequestResponseXML.getElementsByTagName('quantitat')[0].childNodes[0].data;
			}

			if (quantitat*1 > 0)
			{
				try 
				{
					document.getElementById('img_botocomprar_'+codi).src='img/comprar3.gif';
					document.getElementById('txt_quantiat_'+codi).value=quantitat;
				}
				catch(err)
				{
				}
			}
			else
			{
				try 
				{
					document.getElementById('img_botocomprar_'+codi).src='img/comprar1.gif';
					document.getElementById('txt_quantiat_'+codi).value='';			
				}
				catch(err)
				{
				}
				
			}

	}
	
	

	

	

	
	
	// NOVES FUNCIONS
	
	function info_usuari()
	{	
			var url='ajax_usuari_info.php';
			//var parameters='';
	
			//ajaxPost(url,parameters,'GET',false);
			
			 ajaxRequestResponseText= $.ajax({
			  								url: url,
			  								async: false
			 								}).responseText;			

			document.getElementById('div_info_usuari').innerHTML=ajaxRequestResponseText;
	}	
	
	function info_carro()
	{	
			var url='ajax_carro_info.php';
			//var parameters='';
	
			//ajaxPost(url,parameters,'GET',false);
			
			 ajaxRequestResponseText= $.ajax({
			  								url: url,
			  								async: false
			 								}).responseText;


			document.getElementById('div_info_carro').innerHTML=ajaxRequestResponseText;
	}
	
	function veure_carro()
	{
			var url='ajax_carro_mostrar.php';
			//var parameters='';
			
			//ajaxPost(url,parameters,'GET',false);
			
			 ajaxRequestResponseText= $.ajax({
			  								url: url,
			  								async: false
			 								}).responseText;		
			
			try
			{
				document.getElementById('div_veure_carro').innerHTML = ajaxRequestResponseText;
				document.getElementById('div_veure_carro').style.display = 'inline';
			}
			catch(err)
			{
			}	
	}	
	
	function tancar_carro_compra()
	{
		
		try
		{
			document.getElementById('div_veure_carro').style.display = 'none';
		}
		catch(err)
		{
		}

	}
	
	function elimina_producte_carro(codi_producte)
	{


		var url='ajax_carro_eliminar_producte.php?PAR_CODI_PRODUCTE='+codi_producte;
		var parameters='';

		ajaxPost(url,parameters,'GET',false);

	}	
	
	function obre_div(div_id)	
	{
		
		if (div_id=='ROAD'		) { mostra_categoria('s_nombre','and tipo=\'ROAD\' and s_numero <> \'105\' and s_numero <> \'126\'','ROAD','s_nombre,serie,marca,modelo,color,talla','ROAD'); }
		if (div_id=='OFFROAD'	) { mostra_categoria('s_nombre','and tipo=\'OFF ROAD\' and s_numero <> \'105\' and s_numero <> \'126\'','OFFROAD','s_nombre,serie,marca,modelo,color,talla','OFF ROAD'); }
		//if (div_id=='CASUAL'	) { mostra_categoria('s_nombre','and tipo=\'CASUAL\'','CASUAL','s_nombre,tipomoto,modelo,serie,color,talla','CASUAL'); }
		if (div_id=='CASUAL'	) { mostra_categoria('s_nombre','and tipo=\'CASUAL\' and s_numero <> \'105\' and s_numero <> \'126\'','CASUAL','s_nombre,serie,marca,modelo,color,talla','CASUAL'); }
		
		if (div_id=='JUNIOR'	) { mostra_categoria('s_nombre','and serie=\'JUNIOR\'','JUNIOR','s_nombre,marca,modelo,color,talla','JUNIOR'); }
		if (div_id=='DONA'	) { mostra_categoria('s_nombre','and serie=\'MUJER\'','DONA','s_nombre,marca,modelo,color,talla','DONA'); }
		
		if (div_id=='CASCS'	) { mostra_categoria('tipo_ca_ac','and (s_numero=\'105\')','CASCS','tipo_ca_ac,marca,modelo,serie,color,talla','CASCS'); }
		if (div_id=='ACCCASCS'	) { mostra_categoria('tipo_ca_ac','and (s_numero=\'126\')','ACCCASCS','tipo_ca_ac,marca,modelo,serie,color,talla','ACCESSORIS CASCS'); }

		if (div_id=='FAMILIES'	) { mostra_categoria('s_nombre','and s_numero <> \'105\' and s_numero <> \'126\'','FAMILIES','s_nombre,serie,marca,marcamoto,modelo,color,talla','FAMILIES'); }
		if (div_id=='MARQUES'	) { mostra_categoria('marca','','MARQUES','marca,s_nombre,serie,marcamoto,modelo,color,talla','MARQUES'); }
		if (div_id=='ACCMOTORISTA'	) { mostra_categoria('s_nombre','and s_numero>=\'100\' and s_numero<=\'199\' ','ACCMOTORISTA','s_nombre,marca,modelo,serie,color,talla','ACCMOTORISTA'); }
		if (div_id=='ACCMOTO'	) { mostra_categoria('s_nombre','and s_numero>=\'300\' and s_numero<=\'399\' ','ACCMOTO','s_nombre,serie,marca,marcamoto,modelo,color,talla','ACCESSORIS MOTO'); }
		if (div_id=='RECANVIS'	) { mostra_categoria('s_nombre','and s_numero>=\'500\' and s_numero<=\'599\' ','RECANVIS','s_nombre,serie,marca,marcamoto,modelo,color,talla','RECANVIS'); }
		if (div_id=='MIMOTO'	) { mostra_categoria('marcamoto','','MIMOTO','marcamoto,modelo,s_nombre,serie,color,talla','LA MEVA MOTO'); }
		if (div_id=='TIPUSMIMOTO'	) { mostra_categoria('tipomoto','','TIPUSMIMOTO','tipomoto,marcamoto,modelo,s_nombre,serie,color,talla','TIPUS DE MOTO'); }
		if (div_id=='NOVETATS'	) { mostra_categoria('s_nombre',' and novedad=\'s\'','NOVETATS','s_nombre,marca,serie,marcamoto,modelo,color,talla','NOVETATS'); }
		if (div_id=='OFERTES'	) { mostra_categoria('s_nombre',' and oferta=\'s\'','OFERTES','s_nombre,marca,serie,marcamoto,modelo,color,talla','OFERTES'); }

	}	
	
	function mostra_productes(where,div_id,pagina,navegacio)
	{

		rpagina=9;
		//var url='ajax_mostra_productes.php?PAR_WHERE='+encodeURIComponent(where)+'&PAR_PAGINA='+encodeURIComponent(pagina)+'&PAR_REGISTRES_PER_PAGINA='+encodeURIComponent(rpagina)+'&PAR_NAVEGACIO='+encodeURIComponent(navegacio);
		var url='ajax_mostra_productes.php?PAR_WHERE='+where+'&PAR_PAGINA='+pagina+'&PAR_REGISTRES_PER_PAGINA='+rpagina+'&PAR_NAVEGACIO='+navegacio;
		var parameters='';

		//ajaxPost(url,parameters,'GET',false);
		
		ajaxRequestResponseText= $.ajax({
		  								url: url,
		  								async: false
		 								}).responseText;			
		
		try
		{
			document.getElementById(div_id).innerHTML = ajaxRequestResponseText;
			document.getElementById(div_id).style.display = 'inline';			
		}
		catch(err)
		{
		}

	}		
	
	function mostra_categoria(categoria,where,div_id,arbre,navegacio)
	{

	
		//var url='ajax_mostra_categories.php?PAR_CATEGORIA='+encodeURIComponent(categoria)+'&PAR_WHERE='+encodeURIComponent(where)+'&PAR_ARBRE='+encodeURIComponent(arbre)+'&PAR_DIVID='+div_id+'&PAR_NAVEGACIO='+encodeURIComponent(navegacio);
		var url='ajax_mostra_categories.php?PAR_CATEGORIA='+categoria+'&PAR_WHERE='+where+'&PAR_ARBRE='+arbre+'&PAR_DIVID='+div_id+'&PAR_NAVEGACIO='+navegacio;
		var parameters='';

		//ajaxPost(url,parameters,'GET',false);
		
		ajaxRequestResponseText= $.ajax({
		  								url: url,
		  								async: false
		 								}).responseText;			
		
		
		document.getElementById(div_id).innerHTML = ajaxRequestResponseText;
		document.getElementById(div_id).style.display='inline';


	}	
	
	function mostra_cercador_productes(cadena,div_id,pagina)
	{
		if (cadena!='')
		{
			rpagina=12;
			var url='ajax_cercador_productes.php?PAR_TEXTE='+cadena+'&PAR_PAGINA='+pagina+'&PAR_REGISTRES_PER_PAGINA='+rpagina;
			var parameters='';
	
			//ajaxPost(url,parameters,'GET',false);
			
			ajaxRequestResponseText= $.ajax({
			  								url: url,
			  								async: false
			 								}).responseText;			
			
			try
			{
				document.getElementById(div_id).innerHTML = ajaxRequestResponseText;
			}
			catch(err)
			{
			}
		}
		else
		{
			alert ('Cal entrar un text');
		}
	}	
	
	function mostra_destacats(div_id,pagina)
	{
		rpagina=10;
		var url='ajax_mostra_destacats.php?PAR_PAGINA='+pagina+'&PAR_REGISTRES_PER_PAGINA='+rpagina;
		var parameters='';

		//ajaxPost(url,parameters,'GET',false);
		ajaxRequestResponseText= $.ajax({
		  								url: url,
		  								async: false
		 								}).responseText;		
		
		try
		{
			document.getElementById(div_id).innerHTML = ajaxRequestResponseText;
		}
		catch(err)
		{
		}

	}		
