﻿// JavaScript Document
$(document).ready(function(){	
	$(".cart a,div.module.offer ul li img, .limit.over").bt(BeautyCart);
	$(".module.offer li img").click(function(e){
		e.stopPropagation();
		var url = $(this).attr("data-url") || 'top';		
		document.location=$(this).parent().parent().parent().attr('href') + '#' + url;
		return false;
	})
	$('#slider').nivoSlider({
        effect:'fade', // Specify sets like: 'fold,fade,sliceDown'
        animSpeed:1000, // Slide transition speed
        pauseTime:8000, // How long each slide will show
        startSlide:0, // Set starting Slide (0 index)
        directionNav:true, // Next & Prev navigation
        directionNavHide:true, // Only show on hover
        controlNav:true, // 1,2,3... navigation
        controlNavThumbs:false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
        keyboardNav:true, // Use left & right arrows
        pauseOnHover:true, // Stop animation while hovering
        manualAdvance:false, // Force manual transitions
        captionOpacity:0.8, // Universal caption opacity
        prevText: 'Bakåt', // Prev directionNav text
        nextText: 'Framåt' // Next directionNav text        
    });
	Cart.init(Cart);		
	Cart.showCount();

/*
    var $sidebar   = $("#left"),
		$cart 	   = $("#cart"),
        $window    = $(window),
        offset     = $sidebar.offset(),
		cartoffset     = $cart.offset(),
        topPadding = 15;

    $window.scroll(function() {
        if ($window.scrollTop() > offset.top) {
            $sidebar.stop().animate({
                marginTop: $window.scrollTop() - offset.top + topPadding
            });			
        } else {
            $sidebar.stop().animate({
                marginTop: 0
            });			
        }
		if ($window.scrollTop() > cartoffset.top) {
			$cart.stop().animate({
                marginTop: $window.scrollTop() - cartoffset.top + topPadding
            });
		}else{
			$cart.stop().animate({
                marginTop: 0
            });
		}
    });
*/
	var tabs = $('dl.tabs');
		tabsContent = $('ul.tabs-content')
	
	tabs.each(function(i) {
		//Get all tabs
		var tab = $(this).children('dd').children('a');
		tab.click(function(e) {
			
			//Get Location of tab's content
			var contentLocation = $(this).attr("href")
			contentLocation = contentLocation + "Tab";
			
			//Let go if not a hashed one
			if(contentLocation.charAt(0)=="#") {
			
				e.preventDefault();
			
				//Make Tab Active
				tab.removeClass('active');
				$(this).addClass('active');
				
				//Show Tab Content
				$(contentLocation).parent('.tabs-content').children('li').css({"display":"none"});
				$(contentLocation).css({"display":"block"});
				
			} 
		});
	}); 
	$("a.buy").click(function(e){
		e.preventDefault();				
		//var options = { to: "#cart-count", className: 'ui-effects-transfer' };
		var id = $(this).attr("id");		
		Cart.add(id);
		//$(this).effect('transfer',options,400);					
		return false;
	});	
	//$("a.buybutton").bt(BeautyOptions);		

});
function toggleShoppingCart(d) {
    PerformAjax("com/cart.cfc?method=getCartProductList&extended=" + d, null, null, {
        expanded: d
    });
    var a = 400;
    if (jQuery.browser.msie && parseInt(jQuery.browser.version) < 8 && parseInt(jQuery.browser.version) > 4) {
        a = 0
    }
    var b = "blind",
        c = {},
        a;
    if (d == true) {
        $("#_NonExpandedShoppingCartContent").hide(b, c, a, function () {
            $("#_ShoppingCartContent").show(b, c, a);
        })
    } else {
        $("#_ShoppingCartContent").hide(b, c, a, function () {
            $("#_NonExpandedShoppingCartContent").show(b, c, a);
        })
    }
}
function PerformAjax(a, d, c, b) {
    if (b == null) {
        b = "{}"
    }
    $.ajax({
        type: "POST",
        contentType: "application/x-www-form-urlencoded",
        data: b,
        cache: false,
        url: a,
        dataType: "json",
        beforeSend: function (e) {
            e.setRequestHeader("connection", "close")
        },
        success: d,
        error: c
    })
}
