function showContent(divID){
	$("div.content").each(
		function(){
			$(this).hide();
		}
	)
	$("div#"+ divID).show();
}

function goPagina(pagina){
	$("#pg").val(pagina);
	document.frm.submit();
}

function TOLAfegirAlCarro(idarticulo,bug_ie6){
	var bug='';
	if (bug_ie6!='') bug='onclick="javascript:document.getElementById(\'' + bug_ie6  +'\').style.display=\'block\';"';
	
	//alert ("/index.php?resource=FTPX101559&idarticulo="+idarticulo);
	$.post('/index.php',	{
		resource: 	"FTPX101559",
		idarticulo: idarticulo, 
		bug_ie6: bug_ie6
		}, function(data) {
			$.modal(data,{	
				close       :true,
			    closeTitle  : 'Cerrar',
            	overlayId	: 'modalOverlay',
            	containerId	: 'modalContainer',
            	bug_ie6	    :  bug
            });
	});
}
	
function TOLSendToFriend(idarticulo){
	$.get('/index.php',{
		resource: "FTPX101540",
		idarticulo: idarticulo
		}, function(data) {
				$.modal(data,{	
					close       :true,
				    closeTitle  : 'Cerrar',
	            	overlayId	: 'modalOverlay',
	            	containerId	: 'modalContainer',
	            	bug_ie6	    : ''
	            });
	});
}


function TOLValidarSendToFriend(){
	if ($('#destinatario').val()==""){
		$('#destinatario').focus();
		alert(msgTOL["EnviarAmigoDestinatario"]);
	}else{
		if ($('#receptor').val()==""){
			$('#receptor').focus();
			alert(msgTOL["EnviarAmigoReceptor"]);
		}else{
			if ($('#email').val()==""){
				$('#email').focus();
				alert(msgTOL["EnviarAmigoEmail"]);
			}else{
				if ($('#emisor').val()==""){
					$('#emisor').focus();
					alert(msgTOL["EnviarAmigoEmisor"]);
				}else{
					if ($('#mensaje').val()==""){
						$('#mensaje').focus();
						alert(msgTOL["EnviarAmigoMensaje"]);
					}else{
						$.post('/index.php',{
							resource		: "FTPX101545",
							idarticulo		: $("#idarticulo").val(), 
							destinatario	: $("#destinatario").val(), 
							receptor		: $("#receptor").val(),
							email			: $("#email").val(),
							emisor			: $("#emisor").val(),
							mensaje			: $("#mensaje").val()
						},function(xml) {
							var status	="";
							var message	="";
							
							$(xml).find('response').each(function(){
								status=$(this).attr('status');
							});
							
							if (status=="OK"){
								$.modal.close();
							}else{
								$(xml).find('error').each(function(){
									message	=$(this).attr('message');
								});
								
								$("#error").html(message);
							}
						});
						
					}
				}
			}
		}
	}
}

function TOLCompararCarregarArticles(){
	$('#imgCmp').attr('src','/img/null.gif');
	
	$('span').each(function(){
		id=this.id;
		
		if (id.substr(0,2)=="at") $('#'+id).html("");
	});
	
	$('#idcomparar').empty();
	$('#idcomparar').append("<option value='0'>"+msgTOL["CompararCargandoArticulos"]+"</option>");
	$.post('/index.php',{
			resource	: "FTPX900060",
			idfamilia	: $("#idfamilia").val(), 
			idarticulo	: $("#idarticulo").val(), 
			idmarca		: $("#idmarca").val() 
		},function(xml) {
				var idarticulo	="";
				var modelo		="";
	
				$('#idcomparar').empty();
				$('#idcomparar').append("<option value=''>"+msgTOL["CompararSeleccionarModelo"]+"</option>");
				
				$(xml).find('articulo').each(function(){
		        		idarticulo	=$(this).attr('idarticulo');
		        		modelo		=$(this).attr('modelo');
	
		        		$('#idcomparar').append("<option value='"+idarticulo+"'>"+modelo+"</option>");
		        });
			
		});
}


function TOLCompararArticlesAtributs(){
	$.post('/index.php',{
			resource	: "FTPX900060",
			idfamilia	: $("#idfamilia").val(), 
			idarticulo	: $("#idarticulo").val(), 
			idmarca		: $("#idmarca").val(), 
			idcomparar	: $("#idcomparar").val()
		},function(xml) {
			var id		="";
			var valor	="";
			var img		="";
			
			$(xml).find('articulo').each(function(){
				img		=$(this).attr('img');
				
				$('#imgCmp').attr('src',img);
			});
			
			$(xml).find('atributo').each(function(){
				id		=$(this).attr('id');
		        valor	=$(this).attr('valor');
		        
				$('#at'+id).html(valor);
			});
		});
}


function TOLServeisTecnics(idmarca){
	$.post('/index.php',{
			resource	: "FTPX900070",
			idmarca		: idmarca
		},function(xml) {
			var nom			="";
			var url			="";
			var direccio	="";
			var telefon		="";
			var ContentST	="";
			
			$(xml).find('marca').each(function(){
				nom		=$(this).attr('nom');
				url		=$(this).attr('url');
			});
			
			$('#MarcaNom').html(nom);
			$('#HrefMarcaUrl').attr("href",url);
			$('#SpanMarcaUrl').html(url);
			
			
			$(xml).find('st').each(function(){
				nom		=$(this).attr('nom');
		        direccio=$(this).attr('direccio');
		        telefon	=$(this).attr('telefon');
		        
				ContentST+="<b>"+nom+"</b><br/>";
				ContentST+=direccio+"<br/>";
				ContentST+=telefon+"<br/><br/>";
			});
			
			$('#ContentST').html(ContentST);
		});
}