if (window.jQuery && jQuery.noConflict && (typeof $('body') == 'object')) {
	jQuery.noConflict();
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); };

function menuFistLastItem () {
	if ((menu = $('nav')) && (children = menu.childElements()) && (children.length)) {
		children[0].addClassName ('first');
		children[children.length-1].addClassName ('last');
	}
}
toggleMenu = function (el, over) {
	  var iS = false;
    if (Element.childElements(el) && Element.childElements(el).length > 1) {
	    var uL = Element.childElements(el)[1];
			iS = true;
		}
    if (over) {
        Element.addClassName(el, 'over');
				Element.addClassName (el.down('a'), 'over');
        if(iS){ uL.addClassName('shown-sub')};
    }
    else {
        Element.removeClassName(el, 'over');
				Element.removeClassName (el.down('a'), 'over');
        if(iS){ uL.removeClassName('shown-sub')};
    }
}

function makeEqualHeight(divs, offset) {
	if (!offset) offset = 0;
	if(!divs || divs.length < 2) return;
	var maxh = 0;
	divs.each(function(el){
		var ch = el.getHeight();
		maxh = (maxh < ch) ? ch : maxh;
	});
	maxh += offset;
	divs.each(function(el){
		el.setStyle({height: (maxh-parseInt(el.getStyle('padding-top'))-parseInt(el.getStyle('padding-bottom'))) + 'px'});
	});
}
jQuery(document).ready(function($){
	$('#banners').aviaSlider({
		blockSize: {height: 3, width:'full'},
		display: 'topleft',
		transition: 'fade',
		betweenBlockDelay:10,
		animationSpeed: 4000,
		switchMovement: true
	});
	var aperturas = $("p.despliegame a");
	aperturas.live("click",function(event){	
	event.preventDefault();
	var cierres = $(".cerrar, #aw_acp_continue");
		$(this).toggle(
			function(){
        		$(".contenedor-anadidos").fadeIn("slow");
			},
			function(){
        		$(".contenedor-anadidos").fadeOut("slow");
		});
		cierres.click(function(){
			$(".contenedor-anadidos").fadeOut("slow");
		});
 	$(this).trigger('click');
	});
   if ($(".vacio")){
       $(".vacio").appendTo("#top-carrito-compra");
	}
//
	$(function () {
		var msie6 = $.browser == 'msie' && $.browser.version < 7;
		if (!msie6) {
			var top = $('#top-carrito-compra').offset().top +30;
			$(window).scroll(function (event) {
				var y = $(this).scrollTop();
				var z = $('#top-carrito-compra');
				if (y > top) {
					z.appendTo('.contenidos').addClass("fija");
				} else {
					z.prependTo('#topcarro').removeClass("fija");
				}
			});	
		}  
	});
	$(".contenidos #top-carrito-compra p").live('click',function(){
		var vinculo = $(this).find('a').attr('href');
		window.location = vinculo
	});
	$(".cambia-idioma, .telefono").hover(function(){
		$(this).find("ul").stop().fadeIn();
	}, function(){
		$(this).find("ul").stop().fadeOut();
	});
});
