/* Multiplica Chile, fecha modificaciÃ³n: 7 de Noviembre de 2011 */
var altura = 10;
var esIE6 = (jQuery.browser.msie && parseInt(jQuery.browser.version.substr(0, 1)) < 7);
var esIE7 = (jQuery.browser.msie && parseInt(jQuery.browser.version.substr(0, 1)) < 8);

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); };


$(document).ready(function(){

	$('.btn-add-list').attr('title','Agrega este producto a tu lista de compras').tipsy({gravity: 's'});
	$('.monitoring .save-items').val('Agregar toda la lista');
        
        //Add class electro para el pack virtual	
	if( $('#menu-food').hasClass('electro')){
	$('#cont-pack').addClass('electro');
	};

	$(' p.felicitaciones').append('<small>Recuerda que has acumulado Pesos Mi Club.</small>');
	$('.pedido .para-regalo').tipsy({live: true, opacity: 1, gravity: 's'});


	//$('.camino.now').wrap('<a onclick="Skembox(\'http://www.piamontelogistics.com/scd/index.php\', \'\',500, 880); return false;" href="box-seguiminento.html">').append('<img src="/dys/img/cnt/pestana-tool-despacho.png" class="pestana"/><a class="destacado activo" onclick="Skembox(\'http://www.piamontelogistics.com/scd/index.php\', \'\',500, 780); return false;" href="box-seguiminento.html">Haz seguimiento en detalle de tu despacho, haciendo clic aquÃ&iacute;</a>'); 
	
	//$('.camino:not(.ok, .now)').append('<img src="/dys/img/cnt/pestana-tool-despacho.png" class="pestana"/><a class="destacado" href="#">Una vez despachada tu compra podr&aacute;s hacer un seguimiento en detalle</a>'); 
 	
	
	bread = $('#navigation li:eq(1)').html();
	if(bread) bread = bread.slice(2,20).trim();
	if(bread == 'Supermercado'){
	
		//$('#suggestions').css({height: '310px'}).prepend('<a style="position:relative;" href="/dys/HTML/popup_listas.html" class="adfull" onClick="Skembox(\'/dys/HTML/popup_listas.html\',\'\',440,740); return false;"><img src="/dys/img/cnt/ico-aviso-food-listas.png" style="position:absolute;top:4px;left:115px;" />&iquest;Ya sabes crear tus <strong style="text-transform:none;color:#28C8FA;">listas de compra</strong>? Averigua como y comienza a organizar tu mes.</a>');
	}

	$('.btn-add-list').click(function(){
		
		if($(this).next().find('.tool-tip-product').text().trim() == '') $(this).next().find('.tool-tip-product').show().html('<div class="bgs"><a href="javascript:onclick=hideToolTip();" class="btn-close" title="enlace"><img src="/dys/img/icn/icn_tooltip_close.png" alt=""></a><p><br/>Cargando tus listas... </div>');
	});
	
	$('.info-principal .list .share-friend').click(function(){
		$tooltip = $(this).parent().next().find('.tool-tip-product');
		if($tooltip.html().trim() == '') $tooltip.show().html('<div class="bgs"><a href="javascript:onclick=hideToolTip();" class="btn-close" title="enlace"><img src="/dys/img/icn/icn_tooltip_close.png" alt=""></a><p><br/>Cargando tus listas... </div>');
	});
		   
	if($('.monitoring h3').text() == 'Mis listas de compra y compras anteriores') {
	 	var sabe = true;
	 	if($('.my-lists-created tr').length < 4){
	 	
	 		var texto1 = $('.my-lists-created tr:eq(1) td:eq(0)').text();
	 		texto1 = texto1.trim().replace('1.','').trim();
	 		
	 		var texto2 = $('.my-lists-created tr:eq(2) td:eq(0)').text();
	 		texto2 = texto2.trim().replace('2.','').trim();
	 		
	 		var cantidad = $('.my-lists-created tr:eq(1) td:eq(1)').text();
	 		if(cantidad) cantidad = cantidad.replace('items','').trim();
	 		
	 		if ((texto1 == 'Favoritos') && (cantidad == '0')){
	 			
	 			if ((texto2 == 'Lista Sugerida') || (texto2 == '')){
	 				sabe = false;
	 			}
	 		}
	 	}    	
	 	
	 	if(sabe) $('.monitoring h3').append('<a class="crea-lista" onClick="Skembox(\'/dys/HTML/popup_listas.html\',\'\',440,740); return false;" title="Â¿Como crear una lista?" href="/dys/HTML/popup_listas.html">C&oacute;mo crear mis listas</a>');
	 	else $('.monitoring h3').append('<a title="&iquest;Como crear una lista?" href="/dys/HTML/popup_listas.html" onClick="Skembox(\'/dys/HTML/popup_listas.html\',\'\',440,740); return false;"><p class="nueva-lista">Porque queremos ayudarte a organizar tus compras del mes...  Ent&eacute;rate aqu&iacute; sobre c&oacute;mo crear tus propias listas.</p></a>');
	}



$('.icn-food img[alt]').tipsy({live: true, opacity: 1, gravity: 's',title: 'alt'}); 
$(function() { $("ul.ul-tabs").tabs("div.panels > div.pan-tabs"); }); 

scrollables(); 
correccionesHTML(); 

$(".dateform select").change(function(){ 
var day = $(this).parent().parent().find("select[name='day']").attr('value'); 
var month = $(this).parent().parent().find("select[name='month']").attr('value'); 
var year = $(this).parent().parent().find("select[name='year']").attr('value'); 
var date_dad = $(this).parent().parent().find(".alert"); 
if (((day == 29) || (day == 30) || (day == 31)) && (month == 02) && (year % 4 != 0)){ 
$(date_dad).html('<img src="img/icn/icn_alert.png" alt="descripciÃ³n" /> La fecha ingresada no es correcta.'); 
} 
else if (((day == 30) || (day == 31)) && (month == 02) && (year % 4 == 0)){ 
$(date_dad).html('<img src="img/icn/icn_alert.png" alt="descripciÃ³n" /> La fecha ingresada no es correcta.'); 
} 
else if ((day == 31) && ((month == 04) || (month == 06) || (month == 09) || (month == 11))){ 
$(date_dad).html('<img src="img/icn/icn_alert.png" alt="descripciÃ³n" /> La fecha ingresada no es correcta.'); 
} 
else { 
$(date_dad).html(""); 
} 
}); 

$("#kids .dateform").hide(); 
$('select[name="kids_select"]').change(function(){ 
$("#kids .dateform").hide(); 
var cantidad = $(this).val(); 
for (i=1;i<=cantidad;i++){ 
$("#kids .dateform").eq(i).fadeIn(); 
} 
}); 

$('.btn.pay').html('Ver mi carro');

$('.promotions label').click(function(){ 
$('.promotions a.eliminar').hide(); 
$(this).parent().find('a.eliminar').show(); 
}); 
$('.promotions a.eliminar').click(function(){ 
$(this).parent().find('input').attr('checked',''); 
$(this).fadeOut(); 
return false; 
}); 

// Logo rollover 
$(".logo").hover(function(){ 
$(this).find(".img-logo").hide(); 
},function(){ 
$(this).find(".img-logo").show(); 
}); 

$("a.modal").overlay({ 
expose: 'white', 
opacity: 0, 
onBeforeLoad:function(){ 
$("#zoom .close").show(); 
} 
}); 

$("input[disabled='disabled']").addClass("disabled"); 

$("input").each(function(){ 
if( $(this).attr('type') == "button" ){ 
$(this).css({'cursor':'pointer'}); 
} 
}); 

$(".toggler").click(function(){ 
$(this).parent().find(".toggled").toggle(); 
$(this).toggleClass("open"); 
}); 

$(".calendario").click(function(){ 
$(".box .semanas").hide(); 
$(this).parent().parent().parent().parent().parent().find(".box").css({'zIndex':1}); 
$(this).parent().parent().parent().parent().css({'zIndex':10}); 
}); 

$("#ejemplo").append('<label for="birthdate">Fecha Ejemplo</label><input type="text" name="birthdate" value="22/03/2010" class="datepicker short" />'); 

// Super carro de compras 
$("#supercart a.toggle, #supercart .total, #ajaxCartQuantity .items").live('click',function(){ 
if($('#supercart').css('bottom') == '-114px'){ 
$('#supercart').animate({'bottom':'0px'}, 300); 
$('#supercart a.toggle').css({'backgroundPosition':'center -16px'}); 
altura = 124; 
} 
else{ 
$('#supercart').animate({'bottom':'-114px'}, 300); 
$('#supercart a.toggle').css({'backgroundPosition':'center 0px'}); 
altura = 10; 
} 

if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod'){ 
document.getElementById('supercart').style.top = (window.pageYOffset + window.innerHeight - altura) + 'px'; 
}; 
return false; 
}); 

$('.button').click(function(){ 
if($("#supercart").is(":hidden")) { 
$("#supercart").show("fast"); 
} 
}); 

$('.camara').click(function(){ 
$(".itemBase").clone(true).insertAfter(".items").addClass("duplicado"); 
$(".duplicado").removeClass("oculto"); 
$(".duplicado").removeClass("itemBase"); 
}); 

$('#supercart .eliminar').click(function(e){$(this).parent().remove(); $("#tultip").fadeOut(); e.preventDefault(); }); 

$('#supercart .item input.eliminar').hide(); 
$('#supercart .item').hover(function() { 
 var eliminar = $(this).find("input.eliminar") 
 var contenido = $(this).find("div.info").html(); 
 var papa = $(this).parent().position(); 
 var hijo = $(this).position(); 
 var posicion = papa.left + hijo.left + 50; 
 var t = setTimeout(function() { 
$(eliminar).show();
$("#sobretultip, #tultip").show(); 
$("#tultip").html(contenido); 
$("#sobretultip").css({"left":posicion}); 
}, 200); 
$(this).data('timeout', t); 
}, function() { 
clearTimeout($(this).data('timeout')); 
$(this).find("input.eliminar").hide(); 
$("#tultip").hide(); 
}); 

// Super carro de compras 

$("a.dialog").overlay({ 
expose: 'white', 
opacity: 1, 
close: '.cerrar' 
}); 
		$("img.calendario, .calendario-enlace, #horario2").click(function(e){
		$(".semanas").hide();
		$('.caja.super').removeAttr('style');
		$(this).parent().css({'z-index': 999999}).parent().find(".semanas").fadeIn();
		e.preventDefault();
	});
	
	$(".semanas label input").click(function(){
		var yay = $(this).val();
		$(".semanas").fadeOut();
		$(this).parents('.caja').removeAttr('style').find(".long").val(yay);
		
	});
	
	$(".semanas .cerrar").click(function(e){
		$(this).parent().parent().removeAttr('style');
		$(".semanas").fadeOut();
		e.preventDefault();
	});

$("#warning .btn-cerrar, #great .btn-cerrar").click(function(){ 
$(this).parent().fadeOut(); 
return false; 
}); 

$("a.close-warning").click(function(){ 
$("#error").fadeOut(); 
}); 

$(".friend .share-friend:last").click(function(e){ 
if( $(this).attr('class') == "share-friend abierto" ){ 
$(this).removeClass("abierto"); 
$("#share-friend").hide(); 
}else{ 
$(this).addClass("abierto"); 
$("#share-friend").fadeIn(); 
} 
e.preventDefault(); 
}); 


$("#share-friend .cerrar").click(function(){ 
$("#share-friend").hide(); 
$(".share-friend").removeClass("abierto"); 
return false; 
}); 

$(".despacho p").hide(); 
$(".despacho .first").show(); 
$(".despacho .first").toggle(function() { 
$(this).parent().find("p.item").fadeIn(); 
}, 
function () { 
$(this).parent().find("p.item").fadeOut(); 
}); 

$(".box-super table").hide(); 
$(".box-super table:first").show(); 
$(".box-super .btn-pas:first").addClass("sel"); 
$(".box-super .btn-pas").toggle(function() { 
$(this).addClass("sel"); 
$(this).parent().find("table").fadeIn(); 
}, 
function () { 
$(this).removeClass("sel"); 
$(this).parent().find("table").hide(); 
}); 

$(".box-super .btn-pas:first").toggle(function() { 
$(this).removeClass("sel"); 
$(this).parent().find("table").hide(); 
}, 
function () { 
$(this).addClass("sel"); 
$(this).parent().find("table").fadeIn(); 
}); 

$("input.clear").each(function(){ 
if( $(this).attr('type') != "radio" && $(this).attr('type') != "checkbox" && $(this).attr('type') != "button" ){ 
var value = $(this).val(); 
$(this).focusin(function(){ 
if( $(this).val() == value ){ 
$(this).val(""); 
}; 
$(this).css({'color':'#333'}); 
}); 
$(this).focusout(function(){ 
if( $(this).val() == '' ){ 
$(this).val(value); 
}; 
$(this).css({'color':'#999'}); 
}); 
} 
}); 

$("input").each(function(){ 
if( $(this).attr('type') == "checkbox" ){ 
$(this).addClass("cajacheck"); 
} 
}); 

$(".clean").each(function(){ 
var value = $(this).val(); 
$(this).focusin(function(){ 
if( $(this).val() == value ){ 
$(this).val(""); 
}; 
$(this).css({'color':'#333'}); 
}); 
$(this).focusout(function(){ 
if( $(this).val() == '' ){ 
$(this).val(value); 
}; 
$(this).css({'color':'#999'}); 
}); 
}); 


$(".despacho div.tienda").hide(); 
$(".despacho p.tienda").click(function(){ 
$(".despacho div.domicilio").hide(); 
$(".despacho div.tienda").show(); 
}); 
$(".despacho p.domicilio").click(function(){ 
$(".despacho div.domicilio").show(); 
$(".despacho div.tienda").hide(); 
}); 

$("#menu-productos").tabs("#box-products .category", { 
current: "sel" 
}); 

$("#menu-entertainment").tabs("#entertainment .category", { 
current: "sel" 
}); 

$("#sec-dad").tabs(".child", { 
current: "sel" 
}); 

$("#registry, #menu-product-category").tabs("div.panes > div", { 
current: "sel" 
}); 
$(function() { 
$("ul.tabs").tabs("div.panes > div"); 
}); 
$('#menu-product-category li:eq(0)').addClass('current');
$('#menu-product-category li').click(function(){
	$('#menu-product-category li').removeClass('current').find('a').removeClass('sel');
	$(this).addClass('current');
}).find('a').click(function(){
	$('#menu-product-category li').removeClass('current').find('a').removeClass('sel');
	$(this).parent().addClass('current');
});	
// Fin tabs 

$("a.fav").toggle(function(){ 
$(this).parent().append('<div class="fav_box"><a href="#" title="enlace" class="close">Cerrar</a><p>Para agregar este producto a una lista debes <a href="#" title="enlace">Ingresar â€º</a></p><p>Si no tienes cuenta <a href="#" title="enlace">RegÃ­strate ahora â€º</a></p></div>'); 
$(this).removeClass("add"); 
$(this).addClass("rem"); 

$(".close").click(function(){ 
$(this).parent().hide(); 
$(this).parent().parent().find("a.fav").removeClass("rem"); 
$(this).parent().parent().find("a.fav").addClass("add"); 
return false; 
}); 
},function(){ 
$(this).removeClass("rem"); 
$(this).addClass("add"); 
$(this).parent().find(".fav_box").hide(); 
}); 

$(".amount .operator").click(function(){ 
var val = $(this).parent().find(".number").val(); 
var operator = $(this).attr("class"); 
var minus = + val - 1; 
var plus = + val + 1; 

if( operator == "operator plus" && val < "999"){ 
$(this).parent().find(".number").val(plus); 
return false; 
} 
if( operator == "operator minus" && val > "0"){ 
$(this).parent().find(".number").val(minus); 
return false; 
}else{ 
return false; 
} 
}); 

/*FOOD*/ 
$(".shares-product .operator").click(function(){ 
var val = $(this).parent().find(".number").val(); 
var operator = $(this).attr("class"); 
var minus = + val - 1; 
var plus = + val + 1; 

if( operator == "operator plus" && val < "999"){ 
$(this).parent().find(".number").val(plus); 
return false; 
} 
if( operator == "operator minus" && val > "0"){ 
$(this).parent().find(".number").val(minus); 
return false; 
}else{ 
return false; 
} 
}); 

$("span.retiro").hover(function(){ 
$(this).find("span.tooltip").fadeIn(200); 
},function(){ 
$(this).find("span.tooltip").fadeOut(); 
}); 

$(".content-carro #select").change(function(){ 
var valor = ".info." + $(this).val(); 
$(this).parent().find(".info").hide(); 
$(this).parent().find(valor).fadeIn(); 
}); 

$(".content-carro .habilita").each(function(){ 
if( (this.tagName) == "INPUT" ){ 
$(this).change(function(){ 
var boton = $(this).parent().parent().parent().parent().find("input[value='Agregar']"); 
if( $(boton).attr('disabled') == ''){ 
$(boton).attr('disabled', 'disabled'); 
$(boton).addClass("disabled"); 
} else{ 
$(boton).attr('disabled', ''); 
$(boton).removeClass("disabled"); 
} 
});} else{ 
$(this).change(function(){ 
var boton = $(this).parent().parent().parent().parent().find("input[value='Agregar']"); 
if( $(this).val() == 'none'){ 
$(boton).attr('disabled', 'disabled'); 
$(boton).addClass("disabled"); 
} else{ 
$(boton).attr('disabled', ''); 
$(boton).removeClass("disabled"); 
} 
}); 
} 
}); 

// Tool tip store-retirement 
$(".tool-tip-store").hide(); 
$(".store-retirement").hover(function(){ 
$(".tool-tip-store").fadeIn(); 
},function(){ 
$(".tool-tip-store").fadeOut(); 
}); 

// Tool tip percentages 
$(".people .tool-tip-row, .people .close").hide(); 
$(".people .open").click(function(){ 
$(".people .tool-tip-row").fadeIn(); 
$(".people .open").fadeOut("fast", function(){ 
$(".people .close").fadeIn("slow"); 
} ); 
return false; 
}); 
$(".people .close").click(function(){ 
$(".people .tool-tip-row").fadeOut(); 
$(".people .close").fadeOut("fast", function(){ 
$(".people .open").fadeIn("slow"); 
} ); 
return false; 
}); 

// Tool tip 
$(".hidden").hide(); 
$(".item-more").hover(function(){ 
$(this).find(".hidden").fadeIn(); 
},function(){ 
$(".hidden").fadeOut(); 
}); 

// Photos product . In detail_product.html 
$("#carrousel-photos .product a").hover(function(){ 
$("#carrousel-photos .product").removeClass("selected"); 
$(this).parent().addClass("selected"); 
$("#photo-product img").remove(); 
var link_m = $(this).attr("href"); 
link = link_m.replace('/m/','/g/'); 
link = link.replace('ma.jpg','ga.jpg'); 
link = link.replace('mb.jpg','gb.jpg'); 
link = link.replace('mc.jpg','gc.jpg'); 
link = link.replace('md.jpg','gd.jpg'); 
link = link.replace('me.jpg','ge.jpg'); 
link = link.replace('mf.jpg','gf.jpg'); 
link = link.replace('mg.jpg','gg.jpg'); 
link = link.replace('mh.jpg','gh.jpg'); 
link = link.replace('mi.jpg','gi.jpg'); 
link = link.replace('mj.jpg','gj.jpg'); 
link = link.replace('mk.jpg','gk.jpg'); 
link = link.replace('ml.jpg','gl.jpg'); 
link = link.replace('mm.jpg','gm.jpg'); 
link = link.replace('mn.jpg','gn.jpg'); 
link = link.replace('mo.jpg','go.jpg'); 
link = link.replace('mp.jpg','gp.jpg'); 
link = link.replace('mq.jpg','gq.jpg'); 
link = link.replace('mr.jpg','gr.jpg'); 
link = link.replace('ms.jpg','gs.jpg'); 
link = link.replace('mt.jpg','gt.jpg'); 
link = link.replace('mu.jpg','gu.jpg'); 
link = link.replace('mv.jpg','gv.jpg'); 
link = link.replace('mw.jpg','gw.jpg'); 
link = link.replace('mx.jpg','gx.jpg'); 
link = link.replace('my.jpg','gy.jpg'); 
link = link.replace('mz.jpg','gz.jpg'); 

$("#zoom img").attr('src',link); 
var titulo = $(this).parent().index()+1+' de '+$('.right-info-principal h3:eq(0)').text(); 
$('<img src="'+link_m+'" alt="Foto '+titulo+'" />').click(function(){$('.zoom.modal').click();}).appendTo("#photo-product"); 
return false; 
}).click(function(){ return false; }); 

//Simple modal box-zoom 
$("#photo-product img").click(function(){ 
$('.zoom.modal').click(); 
return false; 
}); 
var numItems = $('#carrousel-photos li').size(); 
var primeraImagen = $('#carrousel-photos').find('.product:eq(0) a').attr('href'); 
if( numItems > 1){ 
$('#zoom').append('<a href="#" class="btn-back bton"></a><a href="#" class="btn-next bton"></a>'); 
$('#zoom img').wrap('<div class="box-zoom"></div>'); 
}else{ 
$('#zoom img').wrap('<div class="box-zoom"></div>'); 
}; 

var imgActual = null; 
$('#zoom .btn-back').click(function(e){ 
imgActual = $('#carrousel-photos .selected').index(); 
$('#carrousel-photos li').eq(imgActual-1).find('a').hover();
e.preventDefault();
}); 
$('#zoom .btn-next').click(function(e){ 
imgActual = $('#carrousel-photos .selected').index(); 

if(imgActual == ($('#carrousel-photos li').length - 1)) $('#carrousel-photos li:eq(0) a').hover(); 
else $('#carrousel-photos li').eq(imgActual+1).find('a').hover(); 
e.preventDefault();
}); 

	 
	if($('.monitoring h3').text() == 'Mis listas de compras'){
		$('a.btn-back').attr('href','/dys/catalog/categoryFood.jsp?id=CF_Nivel0_000001&navAction=jump').html(' &lt; Ver m&aacute;s productos').unbind('click');
	} 

// Tool tip .tool-tip-menu In resultados-rapidos.html 
$(".tool-tip-menu").hide(); 
$(".check").hover(function(){ 
$(this).parent().find(".tool-tip-menu").fadeIn(); 
},function(){ 
$(".tool-tip-menu").fadeOut(); 
}); 

// End Tool tips 

$('#more-option .all').hover(function() { 
var elemento = $(this); 
var t = setTimeout(function() { 
$(".option").css({'zIndex':9999}); 
$(elemento).parent().find('ul').show(); 
$(elemento).parent().css({'zIndex':999999}); 
}, 300); 
$(this).data('timeout', t); 
}, function() { 
clearTimeout($(this).data('timeout')); 
$('#more-option .all ul').parent().find('ul').hide(); 
}); 

// Tool tip 
$(".tool-pack-product").hide(); 
$(".pack li p").hover(function(){ 
$(this).parent().find(".tool-pack-product").fadeIn(); 
},function(){ 
$(".tool-pack-product").hide(); 
}); 

$(".tool-tip-state").hide(); 
$(".state ul li").hover(function(){ 
$(this).find(".tool-tip-state").fadeIn(); 
},function(){ 
$(".tool-tip-state").hide(); 
}); 

$(".tool-tip-despacho").hide(); 
$(".icn_despacho").hover(function(){ 
$(this).parent().parent().find(".tool-tip-despacho").fadeIn(); 
},function(){ 
$(".tool-tip-despacho").hide(); 
}); 

$(".tool-pack").hide(); 
$(".product img").hover(function(){ 
$(this).parent().parent().find(".tool-pack").fadeIn(); 
},function(){ 
$(".tool-pack").hide(); 
}); 
$("input:radio").css({'border':'none'}); 

$(".expandir-contraer").toggle(function() { 
$(this).parent().next().slideUp(); 
$(this).addClass("cerrar"); 
},function() { 
$(this).parent().next().slideDown(); 
$(this).removeClass("cerrar"); 
} 
); 

$("div.edit-list").hide(); 
$(".btn-edit").click(function(){ 
$(".name-list").hide(); 
$(".edit-list").fadeIn('slow'); 
return false; 
}); 

$(".edit-list .btn").click(function(){ 
$(".edit-list").hide(); 
$(".name-list").show(); 
return false; 
}); 

$(".product .tool-tip-product ").hide(); 
$(".product .btn-add-list").click(function(){ 
$(".product.list").css({'zIndex':0}); 
$("#list-product li").css({'zIndex':0}); 
$(".tool-tip-product").hide(); 
$(this).parent().css({'zIndex':9991}); 
$(this).parent().parent().css({'zIndex':9991}); 
$(this).parent().find(".tool-tip-product").show(); 
return false; 
}); 

$(".share-friend:first").click(function(){ 
$(".tool-tip-product").show(); 
return false; 
}); 

$(".shares-product .btn-close, .product .btn-close").click(function(){ 
$(".tool-tip-product").hide(); 
return false; 
}); 

$(".make-list-cont").hide(); 
$(".make-list a").click(function(){ 
$(this).remove(); 
$(".make-list-cont").show(); 
return false; 
}); 

$(".add-new-address").hide(); 
$(".formularios .edit").click(function(){ 
$(this).parent().parent().parent().find(".add-new-address").show(); 
return false; 
}); 
$(".formularios .btn-add, .formularios .btn-cancel").click(function(){ 
$(".add-new-address").hide(); 
return false; 
}); 

$(".tool-tip-secret").hide(); 
$(".secret a").hover(function(){ 
$(this).parent().find(".tool-tip-secret").fadeIn(); 
},function(){ 
$(".tool-tip-secret").hide(); 
}); 
$("input:radio").css({'border':'none'}); 

$(".checkout #left .formas label small").hide(); 
$(" .checkout #left .formas label img").hover(function(){ 
$(this).parent().find("small").fadeIn(); 
},function(){ 
$(this).parent().find("small").hide(); 
}); 

$(".checkout #left .formularios p input").focus(function(){ 
$(".checkout #left .formularios.pago .tool-pago1, .checkout #left .formularios.pago .tool-pago2").hide(); 
}); 
$(".checkout #left .formularios.pago .tool-pago1, .checkout #left .formularios.pago .tool-pago2").hide(); 
$(".checkout #left .formularios p .radio-pago:first").hover(function(){ 
$(".checkout #left .formularios.pago .tool-pago2").hide(); 
$(this).parent().find(".tool-pago1").fadeIn(); 
},function(){ 
$(this).parent().find(".tool-pago1").hide(); 
}); 
$(".checkout #left .formularios p .radio-pago:last").hover(function(){ 
$(".checkout #left .formularios.pago .tool-pago1").hide(); 
$(this).parent().find(".tool-pago2").fadeIn(); 
},function(){ 
$(this).parent().find(".tool-pago2").hide(); 
}); 

// Funcion actualizar carro de compras (ocultar mostrar) 
$(".amount a.operator").click(function(){ 
$(this).parent().parent().find(".actualizar").fadeIn(); 
$(".actualizar").click(function(){ 
$(this).fadeOut(); 
}); 
}); 
$(".amount .number").keydown(function(){ 
$(this).parent().parent().find(".actualizar").fadeIn(); 
$(".actualizar").click(function(){ 
$(this).fadeOut(); 
}); 
}); 

// ---- Function that add elements to create fancy buttons 
$("a.btn, .longcat").wrapInner("<span></span>"); 

$(".portion .caja").hide(); 
$(".portion .caja:first").show(); 
$('#ing-producto').change(function() { 
var pp = "."+$("#ing-producto").val(); 
$(".portion .caja").hide(); 
$(pp).show(); 
}); 
$(".prev-pfrecuentes").hide(); 
$(".expandir-contraer").addClass("cerrar"); 
$(".prev-pfrecuentes:first").show(); 
$("acordeon-pfrecuentes:first .expandir-contraer").removeClass("cerrar"); 


$(".expandir-contraer").toggle( 
function() { 
$(this).parent().parent().find(".prev-pfrecuentes").slideDown(); 
$(this).removeClass("cerrar"); 
},function() { 
$(this).parent().parent().find(".prev-pfrecuentes").hide(); 
$(this).addClass("cerrar"); 
} 
); 

$(".expandir-contraer:first").toggle( 
function() { 
$(this).parent().parent().find(".prev-pfrecuentes").hide(); 
$(this).removeClass("cerrar"); 
},function() { 
$(this).parent().parent().find(".prev-pfrecuentes").slideDown(); 
$(this).addClass("cerrar"); 
} 
); 

$("#acordeon-pfrecuentes").tabs("#acordeon-pfrecuentes .pre-pfrecuentes", {tabs: '.tit-acordeon-pfrecuentes', effect: 'slide'}); 

$(".aniversario").hide(); 
$(".estado_civil").change(function(){ 
var open = $(this).val(); 
if( open == 'Casado'){ 
$(".aniversario").show(); 
}else{ 
$(".aniversario").hide(); 
} 
}); 
// checkbox checkout 
$(".nombre-recibe").hide(); 
$(".ratio").change(function(){ 
if( $(this).attr('checked') == '' ){ 
$(this).parent().parent().parent().find(".nombre-recibe").hide(); 
}else{ 
$(this).parent().parent().parent().find(".nombre-recibe").show(); 
} 
}); 

if(jQuery().datepicker) { 
$.datepicker.setDefaults($.datepicker.regional['es']); 
$(".datepicker").datepicker({ defaultDate: '-109y', yearRange: '1901:2001' }, $.datepicker.regional['es']); 
$(".anypicker").datepicker({ yearRange: '1901:2011' }, $.datepicker.regional['es']); 
}; 

//Radio elegir promociÃ³n 
$('.radio-elegir input[type=radio]').change(function(){ 
$('.radio-elegir').parent().removeClass('promotions-free'); 
if( $(this).is(':checked') ){ 
$(this).parent().parent().addClass('promotions-free'); 
} 
$('.total-description').show(); 
img = $(this).parent().parent().parent().find('.image-product img').attr('src'); 
$('#img-promo').attr('src',img); 
}); 

$('#search').ejemploFz('Â¿QuÃ© estÃ¡s buscando?'); 

// acordeon 
$('.btn-secciones').click(function(){ 
if ($(this).parent().find('table').is(':visible')){ 
$(this).parent().find('table').slideUp(); 
$(this).removeClass('active'); 
} 
else{ 
$(this).parent().find('table').slideDown(); 
$(this).addClass('active'); 
} 
return false; 
}); 

	//seleccion de promocion
	$('.select-promo').click(function(){
    	if( $(this).is(':checked')){
			$(this).parent().parent().find('select').fadeIn();
		}
		else{
			$(this).parent().parent().find('select').hide();
		}
	});

	
//Tabs de los diferentes combos de electro
	$('.category.tabs-inter .combos-electro.description').hide();
	$('.category.tabs-inter .combos-electro.description:eq(0)').show();
	$('.lista-productos-combos .item-combo-small').click(function(){
		var eq = $(this).index();
		$('.item-combo-small').not(this).removeClass('active').find('img.flecha-blue').remove();
		$(this).addClass('active');
		$(this).append('<img src="/dys/img/cnt/flecha-blue-bottom.png"  class="flecha-blue"/>');
		$('.combos-electro.description').hide().eq(eq).fadeIn();
		
	});
	
	$('.image-left .btn-ver-mas').click(function(){
		$('#menu-productos li a:eq(1)').click();
		return false;
	});
	
	
 

}); 


jQuery(function($){ 
if(jQuery().datepicker) { 
$.datepicker.regional['es'] = { 
closeText: 'Cerrar', 
prevText: '&laquo;', 
nextText: '&raquo;', 
currentText: 'Hoy', 
monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio', 
'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'], 
monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun', 
'Jul','Ago','Sep','Oct','Nov','Dic'], 
dayNames: ['Domingo','Lunes','Martes','Mi&eacute;rcoles','Jueves','Viernes','S&aacute;bado'], 
dayNamesShort: ['Dom','Lun','Mar','Mi&eacute;','Juv','Vie','S&aacute;b'], 
dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','S&aacute;'], 
weekHeader: 'Sm', 
dateFormat: 'dd/mm/yy', 
firstDay: 1, 
isRTL: false, 
showMonthAfterYear: false, 
changeMonth: true, 
changeYear: true, 
yearSuffix: ''}; 
$.datepicker.setDefaults($.datepicker.regional['es']); 
}; 
}); 

function agregarUrlaCarroRapido(){
         if(esIE7) return true;
         $('#superproducts .item img, .content-carro .a_2 img').each(function(e){
		id = $(this).attr('src').replace('http://www.lider.cl','').replace('http://lider.cl','').replace('/dys/productImages/t/','').replace('ta.jpg','').replace('tb.jpg','').replace('tc.jpg','');
		if($(this).parent().attr('href')){ return true;  }
		if(isNaN(id)){ return true;  }
		$(this).wrap('<a href="http://www.lider.cl/dys/catalog/product/productDetails.jsp?productId=PROD_'+id+'&skuId='+id+'" />');
	});
}

var popup_id = 0;

function popUp(a, c, d) {
    var b = '';
    b = a.href ? a.href : a;
    popup_id = popup_id + 1;
    if (c) c = c;
    else c = 590;
    if (d) d = d;
    else d = 400;
    var screenX = typeof window.screenX != 'undefined' ? window.screenX : window.screenLeft,
        screenY = typeof window.screenY != 'undefined' ? window.screenY : window.screenTop,
        outerWidth = typeof window.outerWidth != 'undefined' ? window.outerWidth : document.body.clientWidth,
        outerHeight = typeof window.outerHeight != 'undefined' ? window.outerHeight : (document.body.clientHeight - 22),
        width = c,
        height = d,
        left = parseInt(screenX + ((outerWidth - width) / 2), 10),
        top = parseInt(screenY + ((outerHeight - height) / 2.5), 10),
        features = ('width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',location = 0,resizable=0,scrollbars=1');
    newwindow = window.open(b, 'popupMundolider' + popup_id, features);
    if (window.focus) newwindow.focus();
    return false
}


function correccionesHTML(){
	agregarUrlaCarroRapido();
if(!esIE7){
    $(window).scroll( function() { 
      if($(document).scrollTop() > 280) $('#cont-pack-sub').addClass('fijo'); 
      else $('#cont-pack-sub').removeClass('fijo'); 
    });
} 
	
    //agrega clases para IE
    if(jQuery.browser.msie == true){
	$('#menu-food .mega').each(function(e){
	    $(this).addClass('nth-child-'+(e+1));
       });
    }

    //Mostrar mensajes de error y felicitaciones al cargar la pagina
    //***Manera antigua ****/if($('#errorDiv, #warning strong').text() != '') $("#warning").fadeIn();
    $('#errorDiv, #warning').each(function(e){
	    if($(this).find('strong').text() != '') $(this).fadeIn().parent().fadeIn();
    });

     if($('#successDiv, #great:eq(0) strong').not('#anchorDivFirstFood strong').text() != '') $("#great").fadeIn(); 

        //Imagen cerrar en tooltip de bÃºsqueda rÃ¡pida 
	$('<img src="/dys/img/icn/icn_delete.png" class="cerrar" />').click(function(){
		$(this).parent().hide();
	}).appendTo(".tool-tip-menu"); 

//Activa el boton para la nueva ficha de producto 
$('.see-specifications a.btn').click(function(){ 
$('#box-products #menu-productos li:eq(1) a').click(); 
return false; 
}); 

//elimina el icono de despacho en los formularios de pago 
$('.formularios.pago #retiro').hide(function(){ 
$(this).parent().find('span:eq(1)').hide().parent().find('.icn_despacho').hide(); 
}); 

	//agrega la funciÃ³n popup a FB y TW del home. Si! sÃ© que no es necesario el doble id pero el sitio es muy grande.
	$('#home_sA_centro #facebook, #home_sA_centro #twitter').click(function(e){
	    popUp(this);
		e.preventDefault();
	});


	//agrega la etiqueta visita al menu
	$('#menu-food.electro .ultimo').append('<span class="visita_outlet">Visita</span>');


    //agregamos la clase recuerda si no tiene precio presto en fichas de GM
    if($('.box-full-presto .item-presto select').length == 0 && $('.box-full-presto .item-presto .col-left em').length == 0) $('.box-full-presto').addClass('recuerda');

} 

function scrollables(){ 

$(".scrollable").scrollable({ 
circular: true 
}); 

$(".vertical-wrapper").scrollable({ 
vertical: true, 
prevPage: ".vertical-up", 
nextPage: ".vertical-down", 
size: 2 
}); 

$("#recent").scrollable({ 
items: ".pro-recent", 
item: ".item-recent", 
size: 5, 
clickable:false, 
keyboard:false, 
nextPage: ".nextPage.recent", 
prevPage: ".prevPage.recent" 
}).autoscroll({ 
autoplay: false, 
interval: 5000, 
steps: 5 
}).navigator({ 
navi:".pages-recent", 
indexed:true 
}); 

$("#pack-cont").scrollable({ 
items: ".pro-recent", 
item: ".item-recent", 
size: 5, 
clickable:false, 
keyboard:false, 
disabledClass: "disabled", 
nextPage: ".nextPage.recent", 
prevPage: ".prevPage.recent" 
}).navigator({ 
navi:".pages-recent", 
indexed:true 
}); 

$("#show-weeks").scrollable({
		items: "#weeks",
		item: "table",
		loop: false,
		size: 1,
		clickable:false,
		keyboard:false,
		nextPage: ".next-week",
		prevPage: ".prev-week"
	});	
	
	$("#show-weeks2, .show-weeks2").scrollable({
		items: "#weeks",
		item: "table",
		loop: false,
		size: 1,
		clickable:false,
		keyboard:false,
		nextPage: ".next-week",
		prevPage: ".prev-week"
	});

	$(".pagi-rece").scrollable({
		items: ".pag-rece",
		item: ".item-rece",
		loop: true,
		clickable:false,
		keyboard:false,
		nextPage: ".nextPage",
		prevPage: ".prevPage",
		speed:700,
		size: 1,
		circular: true
	}).navigator({
		navi:".pages-rece",
		indexed:true
	});	

	$(".muestra_semanas2").scrollable({ 
		items: ".tablas_semanas2", 
		item: "table", 
		loop: false, 
		clickable:false, 
		nextPage: ".next-week", 
		prevPage: ".prev-week" 
	}); 
	
	$(".muestra_semanas").scrollable({
		size: 1,
		nextPage: ".next-week",
		prevPage: ".prev-week"
          });
 
$("#prod-featured").scrollable({ 
items: ".prod-feat", 
item: ".page-feat", 
clickable:true, 
keyboard:false, 
loop:false, 
nextPage: ".nextPage-feat", 
prevPage: ".prevPage-feat", 
speed:700 
}).navigator({ 
navi:".pages-feat", 
indexed:true 
}); 

$("#prod-bestsellers").scrollable({ 
items: ".prod-best", 
item: ".page-best", 
loop: true, 
clickable:false, 
keyboard:false, 
nextPage: ".nextPage-best", 
prevPage: ".prevPage-best", 
speed:700 
}); 

if($("#prod-featured .page-feat").length == 1){ 
$('.nextPage-feat, .prevPage-feat').hide(); 
} 

$("#prod-most-viewed").scrollable({ 
items: ".prod-most-viewed", 
item: ".page-most-viewed", 
loop: true, 
clickable:false, 
keyboard:false, 
nextPage: ".nextPage-most", 
prevPage: ".prevPage-most", 
speed:700 
}); 

$("#prod-stock").scrollable({ 
items: ".prod-stock", 
item: ".page-stock", 
loop: true, 
clickable:false, 
keyboard:false, 
nextPage: ".nextPage-stock", 
prevPage: ".prevPage-stock", 
speed:700 
}); 

$("#prod-five").scrollable({ 
items: ".prod-five", 
item: ".page-five", 
loop: true, 
clickable:false, 
keyboard:false, 
nextPage: ".nextPage-five", 
prevPage: ".prevPage-five", 
speed:700 
}); 

$("#prod-books").scrollable({ 
items: ".products-boo", 
item: ".page-boo", 
loop: true, 
clickable:false, 
keyboard:false, 
nextPage: ".nextPage-boo", 
prevPage: ".prevPage-boo", 
speed:700 
}); 

$("#prod-games").scrollable({ 
items: ".products-gam", 
item: ".page-gam", 
loop: true, 
clickable:false, 
keyboard:false, 
nextPage: ".nextPage-gam", 
prevPage: ".prevPage-gam", 
speed:700 
}); 

$("#prod-mp3").scrollable({ 
items: ".products-mp3", 
item: ".page-mp3", 
loop: true, 
clickable:false, 
keyboard:false, 
nextPage: ".nextPage-mp3", 
prevPage: ".prevPage-mp3", 
speed:700 
}); 

$("#prod-movies").scrollable({ 
items: ".products-movies", 
item: ".page-movies", 
loop: true, 
clickable:false, 
keyboard:false, 
nextPage: ".nextPage-movies", 
prevPage: ".prevPage-movies", 
speed:700 
}); 

$("#special").scrollable({ 
items: ".products-special", 
item: ".product", 
loop: false, 
clickable:true, 
keyboard:false, 
nextPage: ".nextPage-special", 
prevPage: ".prevPage-special", 
speed:700, 
circular: false 
}).autoscroll({ autoplay:false }); 

$("#great-highlights").scrollable({ 
items: ".products", 
item: ".product", 
loop: true, 
clickable:false, 
keyboard:false, 
nextPage: "", 
prevPage: "", 
speed:700 
}); 

$("#slider").scrollable({ 
items: ".pro-slider", 
item: ".item-slider", 
loop: true, 
clickable:false, 
keyboard:false, 
nextPage: "", 
prevPage: "", 
speed:700 
}); 

$("#list-result").scrollable({ 
items: ".products", 
item: ".product", 
clickable:false, 
activeClass:"see", 
keyboard:true, 
hoverClass:"ss", 
speed:700 
});

$("#carrousel-photos").scrollable({
items: ".products",
item: ".product",
size: 3,
clickable:true,
activeClass:"see",
hoverClass:"ss",
vertical: true
});

$("#landing-promos, #list-four").scrollable({ 
items: ".products", 
item: ".product", 
loop: true, 
clickable:false, 
activeClass:"see", 
keyboard:true, 
hoverClass:"ss", 
speed:700 
}); 

$("#product-category-discs").scrollable({ 
items: ".pro-recent", 
item: ".item-recent", 
loop: true, 
clickable:false, 
keyboard:false, 
nextPage: ".nextPage-discs", 
prevPage: ".prevPage-discs", 
speed:700 
}); 
$("#product-category-printer").scrollable({ 
items: ".pro-printer", 
item: ".item-printer", 
loop: true, 
clickable:false, 
keyboard:false, 
nextPage: ".nextPage-printer", 
prevPage: ".prevPage-printer", 
speed:700 
}); 
$("#product-category-pendrives").scrollable({ 
items: ".pro-pendrives", 
item: ".item-pendrives", 
loop: true, 
clickable:false, 
keyboard:false, 
nextPage: ".nextPage-pendrives", 
prevPage: ".prevPage-pendrives", 
speed:700 
}); 
$("#product-category-webcam").scrollable({ 
items: ".pro-webcam", 
item: ".item-webcam", 
loop: true, 
clickable:false, 
keyboard:false, 
nextPage: ".nextPage-webcam", 
prevPage: ".prevPage-webcam", 
speed:700 
}); 
$("#product-category-speakers").scrollable({ 
items: ".pro-speakers", 
item: ".item-speakers", 
loop: true, 
clickable:false, 
keyboard:false, 
nextPage: ".nextPage-speakers", 
prevPage: ".prevPage-speakers", 
speed:700 
}); 

$("#product-category-office").scrollable({ 
items: ".pro-office", 
item: ".item-office", 
loop: true, 
clickable:false, 
keyboard:false, 
nextPage: ".nextPage-office", 
prevPage: ".prevPage-office", 
speed:700 
}); 

$("#accesorios").scrollable({ 
loop: true, 
speed:700 
}); 
$(".superscroll").scrollable();
/*
$(".superscroll").scrollable({
       size:8,
       clickable: false,
       keyboard:false,
       speed: 900,
       easing : 'rebote',
       nextPage: ".next",
       prevPage: ".prev"
});*/
} 

jQuery.easing.rebote = function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
};



if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod'){ 
window.onscroll = function abrirCerrar() { document.getElementById('supercart').style.top = (window.pageYOffset + window.innerHeight - altura) + 'px'; }; 
}; 

(function (a) { 
a.fn.ejemploFz = function (b) { 
return this.each(function () { 
a(this).focus(function () { 
a(this).val() == b && a(this).val("").removeClass("texto_info_input") 
}); 
a(this).blur(function () { 
a(this).val() == "" && a(this).val(b).addClass("texto_info_input") 
}); 
a(this).blur() 
}) 
} 
})(jQuery); 

(function($) { 
$.fn.tipsy = function(options) { 

options = $.extend({}, $.fn.tipsy.defaults, options); 

return this.each(function() { 

var opts = $.fn.tipsy.elementOptions(this, options); 

$(this).hover(function() { 

$.data(this, 'cancel.tipsy', true); 

var tip = $.data(this, 'active.tipsy'); 
if (!tip) { 
tip = $('<div class="tipsy"><div class="tipsy-inner"/></div>'); 
tip.css({position: 'absolute', zIndex: 100000}); 
$.data(this, 'active.tipsy', tip); 
} 

if ($(this).attr('title') || typeof($(this).attr('original-title')) != 'string') { 
$(this).attr('original-title', $(this).attr('title') || '').removeAttr('title'); 
} 

var title; 
if (typeof opts.title == 'string') { 
title = $(this).attr(opts.title == 'title' ? 'original-title' : opts.title); 
} else if (typeof opts.title == 'function') { 
title = opts.title.call(this); 
} 

tip.find('.tipsy-inner')[opts.html ? 'html' : 'text'](title || opts.fallback); 

var pos = $.extend({}, $(this).offset(), {width: this.offsetWidth, height: this.offsetHeight}); 
tip.get(0).className = 'tipsy'; // reset classname in case of dynamic gravity 
tip.remove().css({top: 0, left: 0, visibility: 'hidden', display: 'block'}).appendTo(document.body); 
var actualWidth = tip[0].offsetWidth, actualHeight = tip[0].offsetHeight; 
var gravity = (typeof opts.gravity == 'function') ? opts.gravity.call(this) : opts.gravity; 

switch (gravity.charAt(0)) { 
case 'n': 
tip.css({top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tipsy-north'); 
break; 
case 's': 
tip.css({top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tipsy-south'); 
break; 
case 'e': 
tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}).addClass('tipsy-east'); 
break; 
case 'w': 
tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}).addClass('tipsy-west'); 
break; 
} 

if (opts.fade) { 
tip.css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: 0.8}); 
} else { 
tip.css({visibility: 'visible'}); 
} 

}, function() { 
$.data(this, 'cancel.tipsy', false); 
var self = this; 
setTimeout(function() { 
if ($.data(this, 'cancel.tipsy')) return; 
var tip = $.data(self, 'active.tipsy'); 
if (opts.fade) { 
tip.stop().fadeOut(function() { $(this).remove(); }); 
} else { 
tip.remove(); 
} 
}, 100); 

}); 

}); 

}; 

$.fn.tipsy.elementOptions = function(ele, options) { 
return $.metadata ? $.extend({}, options, $(ele).metadata()) : options; 
}; 

$.fn.tipsy.defaults = { 
fade: false, 
fallback: '', 
gravity: 'n', 
html: false, 
title: 'title' 
}; 

$.fn.tipsy.autoNS = function() { 
return $(this).offset().top > ($(document).scrollTop() + $(window).height() / 2) ? 's' : 'n'; 
}; 

$.fn.tipsy.autoWE = function() { 
return $(this).offset().left > ($(document).scrollLeft() + $(window).width() / 2) ? 'e' : 'w'; 
}; 

})(jQuery);



/*
 * jQuery Skembox 0.3.1 - 19/10/09
 * (cc) 2009 Fabbian Alvarez (http://mrfabbianz.com)
 * Actualizado: 09/08/2011 para mundolider.com
*/

if(typeof jQuery=="undefined"){throw"Error: Skembox necesita jQuery"}
var skmX_ok = false, skm_actual = 0;
var esIE6 = (jQuery.browser.msie && parseInt(jQuery.browser.version.substr(0,1)) < 7);
var root = 'http://www.lider.cl/dys/';

(function($) {                              
	$.skmX = {
		mostrar: function(url, titulo, alto, ancho, tipo, respuesta) {

			if(titulo){ altoTitulo = 27, claseCerrar = ''; }
			else{ altoTitulo = 0, claseCerrar = ' sin_t'; }

	  		if(!skmX_ok){
	  			 $(document.body).append('<div id="Skembox_overlay" style="display: none;"></div><div id="skmX_c">&nbsp;</div><div id="skmX_v" style="display: none;"><div class="skmX_b"><div id="skmX_i"></div></div></div>');
				skmX_ok = true;
			}
	 		
			if(tipo == 'enlinea' || url.charAt(0) == '#') {
								
				skmXAlto = alto || $(url).height()+altoTitulo;
				skmXAncho = ancho || $(url).width(); 
				
				if(skmXAncho == 0){
					$(url).parent().show().css({visibility:'hidden'});
					skmXAncho =	$(url).width();	
					skmXAlto =	$(url).height();
					$(url).parent().hide().css({visibility:'visible'});	
				}
				
				
				$.skmX.reiniciar(skmXAlto,skmXAncho);

				$('#skmX_c').hide();
				$("#skmX_i").html('<div id="skmX_f">'+$(url).html()+'</div>');
				
				if(titulo != '') $("#skmX_i").prepend('<div id="skmX_t" style="display:none">'+titulo+'</div>');

				$('.skmX_b').before('<a class="skmX_bc '+claseCerrar+'" title="Cerrar">&nbsp;</a>');
		  		$("#skmX_v .skmX_bc").click($.skmX.ocultar);
		  		$('#skmX_f, #skmX_v').fadeIn();
				$.skmX.posicion();
			}
			else if(tipo == 'texto') {		 
				$("#skmX_c").html('<div id="skmX_f">'+url+'</div>');
				$('.skmX_b').before('<a class="skmX_bc'+claseCerrar+'" title="Cerrar">&nbsp;</a>');
		  		$("#skmX_v .skmX_bc").click($.skmX.ocultar);
		  		$('#skmX_f, #skmX_t, #skmX_v, #Skembox_overlay').fadeIn();
				$.skmX.posicion();
			}
			else if(url.match(/.(gif|png|jpg|jpeg)$/i)){ 
			
				$(document).unbind('keydown.skmX').bind('keydown.skmX', function(e) {
					if(e.keyCode == 27) $.skmX.ocultar();
					else if(e.keyCode == 37) $.skmX.anterior();
					else if(e.keyCode == 39) $.skmX.siguiente();
				});
			
				if(url == $('#skmX_f').attr('src')) return false;
	  			$.skmX.reiniciar(alto,ancho);  
	  		  	
				$('#skmX_c').show();
				var imagen = new Image();
				imagen.src = url;
				$imagen = $('<img src="'+url+'" id="skmX_f" border="0" style="display:none" />');
				$imagen.load(function(){
					$('#skmX_c').hide();
					imagenAlto = imagen.height;
					imagenAncho = imagen.width;
					$("#skmX_f, #skmX_t, .skmX_bc").remove();
					$(window).unbind("resize");
					$(window).resize($.skmX.tamanioImagen);
					$('.skmX_b').before('<a class="skmX_bc'+claseCerrar+'" title="Cerrar">&nbsp;</a>');
		  			$("#skmX_v .skmX_bc").click($.skmX.ocultar);
					if(titulo !== '') $("#skmX_i").prepend('<div id="skmX_t" style="display:none">'+titulo+'</div>');
					$('#skmX_f, #skmX_t').fadeIn();
					$(this).appendTo("#skmX_i").fadeIn();
					$.skmX.tamanioImagen();
					$("#skmX_v").fadeIn();
					$.skmX.posicion();
				});
			}
			else if(url.match(/.(flv|mp3)$/i)){
				$(document).unbind('keydown.skmX').bind('keydown.skmX', function(e) {
					if(e.keyCode == 27) $.skmX.ocultar();
					else if(e.keyCode == 37) $.skmX.anterior();
					else if(e.keyCode == 39) $.skmX.siguiente();
				});
				if(url.match(/.(mp3)$/i)){
					alto = 32;
					param = '&autostart=true';
				}
				else{
					param = '&controlbar=over';
				}
				$.skmX.reiniciar(alto,ancho);  
				$("#skmX_f, #skmX_t, .skmX_bc").remove();
				$("#skmX_i").html('<object height="'+alto+'" width="'+ancho+'" data="'+root+'/reproductor.swf" type="application/x-shockwave-flash" name="skmX_f" id="skmX_f" border="0"> <param value="file='+url+ '&displayheight='+alto+'&width='+alto+'&backcolor=0xC7E3F8&frontcolor=0x336699&lightcolor=0xFFFFFF&screencolor=0xFFFFFF&skin='+root+'/r.swf'+param+'" name="flashvars"/><param value="true" name="allowfullscreen"/></object> ');
				$('.skmX_b').before('<a class="skmX_bc'+claseCerrar+'" title="Cerrar">&nbsp;</a>');
		  		$("#skmX_v .skmX_bc").click($.skmX.ocultar);
				if(titulo !== '') $("#skmX_i").prepend('<div id="skmX_t" style="display:none">'+titulo+'</div>');

				$.skmX.posicion();
				$('#skmX_c').hide();
				$('#skmX_v, #skmX_t').fadeIn();
			}
			else  {
				$('#skmX_c').show();
				$(document).unbind('keydown.skmX').bind('keydown.skmX', function(e) {
					if(e.keyCode == 27) $.skmX.ocultar();
				});
			
	  			$.skmX.reiniciar(alto,ancho);  
				$("#skmX_f, #skmX_t, .skmX_bc").remove();
				$iframe = $('<iframe id="skmX_f" src="'+url+'" frameborder="0" scrolling="auto" hspace="0" style="display:none"></iframe>');
				$iframe.load(function(response, status, xhr){
					$('#skmX_c').hide();
					$("#skmX_v").fadeIn();
					$('.skmX_b').before('<a class="skmX_bc'+claseCerrar+'" title="Cerrar">&nbsp;</a>');
		  			$("#skmX_v .skmX_bc").click($.skmX.ocultar);
					if(titulo !== '' && ($('#skmX_t').length == 0)){ 
						$("#skmX_i").prepend('<div id="skmX_t" style="display:none">'+titulo+'</div>');
						$('#skmX_t').show();
					}
					$('#skmX_f').fadeIn();
					
				}
				).appendTo("#skmX_i").fadeIn();
				$.skmX.posicion();
	
			}
		},
		reiniciar: function(alto, ancho){
			$(window).unbind("resize");
	  		$("#skmX_v .skmX_bc").unbind("click");
			skmXAlto = alto || 400;
			skmXAncho = ancho || 650;
	  		$(window).resize($.skmX.posicion);
	  		if(!skmX_ok){ $.skmX.posicion(); skmX_ok = true;}
		},
		anterior: function(){
			if(skm_actual <= 0) skm_actual = 1;
			if($(skmXes).eq(skm_actual-1).parent().is('.skmC_visible') == false) $('.skmC_ant').click();
			$(skmXes).eq(skm_actual-1).click();
		},
		siguiente: function(){
			if($(skmXes).length == skm_actual) skm_actual = skm_actual-1;
			if($(skmXes).eq(skm_actual+1).parent().is('.skmC_visible') == false) $('.skmC_sig').click();
			$(skmXes).eq(skm_actual+1).click();
		},
		ocultar: function() {
  			abierto = false;
  			titulo = '';
  			$(document).unbind('keydown.skmX');
  			$('#skmX_c').hide();
  			$("#skmX_v, #Skembox_overlay").fadeOut(300,function(){
	  			$("#skmX_i").html(' '); 
	  			$("#skmX_f, #skmX_t, .skmX_bc").remove(); 
  			});
	  		$(window).unbind("resize");
		},
		posicion: function(an,al){
			if(an) skmXAncho = an;
			if(al) skmXAlto = al;
		  	var w = $(window).width(), h = $(window).height();
		  	$("#skmX_c").css({top: ((h - 50)/2 )+"px",left: ((w - 70)/2)+"px"  }); 
		
		  	$("#skmX_v").css({width:skmXAncho+"px",height:skmXAlto+altoTitulo+"px",left: ((w - skmXAncho-28)/2)+"px" });
		  	if(!(esIE6)){   	
		  		var ht = (h - skmXAlto)/2;
		   		if(ht < 0) ht = 0; 
		   		$("#skmX_v").css({top: ht+"px" }); 
		   	}
		  	$("#skmX_f").css({width:skmXAncho+"px",height:skmXAlto+"px"});
	  		$("#skmX_i").css({width:skmXAncho+"px",height:skmXAlto+altoTitulo+"px"});
		},
		tamanioImagen: function (){ // Redimensionar imagenes grandes - basado en original de Christian Montoya.
			var x = $(window).width() - 6, y = $(window).height() - (90+altoTitulo), an = imagenAncho, al = imagenAlto;
			if (an > x) {
				al = al * (x / an); 
				an = x; 
				if (al > y) { 
					an = an * (y / al); 
					al = y; 
				}
			} else if (al > y) { 
				an = an * (y / al); 
				al = y; 
				if (an > x) { 
					al = al * (x / an); 
					an = x;
				}
			}
			if(an < 50) an = 50;
			if(al < 50) al = 50;
			skmXAlto = al || 400;
  			skmXAncho = an || 650;
  			$.skmX.posicion(an,al);
		}
	}

	$.fn.skembox = function() {
		skmXes	= $(this);
		$(this).click(function(){  
			skm_actual	= skmXes.index(this);
			$(skmXes).removeClass('skm_actual');
			$(skmXes).eq(skm_actual).addClass('skm_actual');
			$.skmX.mostrar($(this).attr('href'), $(this).attr('title'));
			return false;
		});	
	};

})($);

function Skembox(url, tit, al, an,ti, re){
	jQuery.skmX.mostrar(url, tit, al, an,ti, re);
};

function skmbTexto(titulo,texto, al, an){
	jQuery.skmX.mostrar(texto, titulo, al, an, 'texto');
}

function skmbEnLinea(titulo,idClase, al, an){
	al = al || 190;
	an = an || 350;
	jQuery.skmX.mostrar(idClase, titulo, al, an, 'enlinea');
}

function skmbCerrar() {
		jQuery.skmX.ocultar();
};

	// Funcion Ventana Modal 	
$(document).ready(function(){
	if(typeof $.skmX != 'undefined'){
   			$(".lightbox").skembox();
	
			$(".lightbox_iframe").click(function() {
				var obj = this;
				var alto = 500; 
				var ancho = 800;
				if($(this).attr('data:width')) ancho = parseInt($(this).attr('data:width'));
				if($(this).attr('data:height')) alto = parseInt($(this).attr('data:height'));
 				$.skmX.mostrar(obj.href,'',alto,ancho);
				return false;
    		});
    	}// fin else de comprobaciÃ³n de carga de skembox	
    
  	});
	// fin lightbox 
