function cierra(element){
	var sku=$(element).attr("title");
    $(element).parentsUntil(".producto", ".popit").fadeToggle().html(sku); 
    }

function is_touch_device() {  
  try {  
    document.createEvent("TouchEvent");  
    return true;  
  } catch (e) {  
    return false;  
  }  
}

$(document).ready(function() {
	$("a.imgpop").mouseenter( function(){
		var sku=$(this).parent().siblings("div.popit").text();
		if(!is_touch_device()){
			$(this).parent().siblings("div.compare").fadeIn();	}
		else{
			url= "store.html?sku="+sku;
			window.location = url;
			}
			});
	$("div.producto").mouseleave( function(){	$(this).children("div.compare").fadeOut();	});
	$(".pop").click( function(){
		var poped;
		var sku=$(this).parent().siblings("div.popit").text();
		if(!is_touch_device()){
			$("#"+sku).fadeToggle().css({
									"top":"-=30px",
									"left":"-=30px"
									}).text("Cargando...").draggable({ dragPrevention: "a, a.pasear, a.popsale", containment: "window" });
			$.ajaxSetup({ 'beforeSend' : function(xhr) {	xhr.overrideMimeType('text/html; charset=ISO-8859-1'); },});
			$.get("mini.php", {"sku": sku}, function(results){
				$("#"+sku).html(results);
				});
		}
		else
		{
			url= "store.html?sku="+sku;
			window.location = url;
		}
		});
	
	$("div.popit").mouseenter(function(){
		$(this).css('z-index','2500');
		});
	
	$("div.popit").mouseleave(function(){
		$(this).css('z-index','2000');
		});
	});

function venta(vendido){
	var sku=$(vendido).attr("title");			
	$("div#shoppingtime").text("cargando..").fadeIn("slow");
	$.get("shopping.php", {"sku": sku}, function(results){
		$("div#shoppingtime").html(results).delay(1000).fadeOut();
		$(vendido).parentsUntil(".producto", ".popit").animate({
															   opacity: 0.25,
															   width:"150px",
															   height:"180px"
															   }, function(){
																   $(this).html(sku).css({
																						 opacity: 1,
																						 width:"330px",
																						 height:"auto"
																						 }).fadeToggle();
																   $("div#shoppingtime").fadeOut();
																   });
																});
	}	


