function checkHover(){
	$('#cartBody').mouseleave(function(){
		$(this).fadeOut('fast');
		$(this).html('');
	});
}

eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(4($){k.9.7=5.9.7=4(a){3 b=p;2(b.j==5)b=d(b);2(!a)3 a=$(\'g\');2($(a).6()>0){3 c=b*(1/(d($(a).r("n-6"))))+\'m\';8 c}l 8\'i: o h q f s a e t\'}})(u);',31,31,'||if|var|function|String|size|pxToEm|return|prototype||||parseInt|DOM|is|body|scope|Error|constructor|Number|else|em|font|Provided|this|argument|css|not|element|jQuery'.split('|'),0,{}));

$.fn.equalHeights = function(px) {
	$(this).each(function(){
		var currentTallest = 0;
		$(this).children().each(function(i){
				if($(this).height() > currentTallest) { currentTallest = $(this).height(); }
		});
		if(!px || !Number.prototype.pxToEm) currentTallest = currentTallest.pxToEm($(this)); //use ems unless px is specified or 
		// for ie6, set height since min-height isn't supported
		var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
		if ($.browser.msie && (ie6)) { $(this).children().css({'height': currentTallest}); }
		$(this).children().css({'min-height': currentTallest}); 
	});
	return $(this);
};


$(document).ready(function(){ 
	$(document).pngFix(); 
	
	$('div.listado .item').equalHeights();
	
	$('#cart').hover(function(){
		$('#cartBody').load('processCart.php',null,function(){
			$('#cartBody').fadeIn('fast');
			$('a.cartDeleteProduct').click(function(e){
				e.preventDefault();
				$.ajax({
					type: "GET",
					url: 'axDelCart.php',
					data: "pID="+$(this).attr('id')
				});
				$(this).parent('p').parent('div').parent('li').fadeOut('fast');
			});
		});		
	},function(){
		setTimeout("checkHover()",400);
	});
	
	$('#frmBuscar #qry').focus(function(){
		if($(this).val()=='Buscar...'){
			$(this).val('');
		}
	});
	
	$('a.addProduct').click(function(e){
		e.preventDefault();
		$.ajax({
			type: "GET",
			url: 'axAddCart.php',
			data: "pID="+$(this).attr('id'),
			success: function(datos){
				jAlert(datos,"Estado del carrito");
			}
		});
		$(this).parent('p').html('Articulo Agregado');
	});
	
	$('a.cartDeleteProduct').click(function(e){
		e.preventDefault();
		$.ajax({
			type: "GET",
			url: 'axDelCart.php',
			data: "pID="+$(this).attr('id')
		});
		$(this).parent('p').parent('div').parent('li').fadeOut('fast');
	});
	
	$('input.btnCotizarIndividual').click(function(e){
		e.preventDefault();
		var pID = $(this).prev().prev().val();
		var email = $(this).prev().val();
		
		$.ajax({
			type: "GET",
			url: 'cotizarIndividualAction.php',
			data: "pID="+pID+"&email="+email,
			success:function(msg){
				jAlert(msg,'Envio de cotizacion');
			}
		});
		
	});
	
}); 