$(function(){
/* Footer Report Card */
    if($("#footer > ul").length > 0){
     $.ajax({
       type: "GET",
       url: "/assets/ajax_pages/cs_report.html",
       success: function(html){
        $("#footer > ul").after(html);
        $(".btn-slide").click(function(){
            var currentDate = new Date()
            var months = ["January","February","March","April","May","June","July","August","September","October","November","December"]
            var month = currentDate.getMonth();
            var day = currentDate.getDate();
            var year = currentDate.getFullYear();
            var updatedDate = months[month] + " " + day + ", " + year;
            $("span.date","#cs-report").html(updatedDate);
            if( $("#cs-report").is(":hidden")){
                $("#footer-wrap").height(700);

            }
            $("#cs-report").slideToggle(1000, function(){
                if( $("#cs-report").is(":hidden")){
                    $("#footer-wrap").animate({height: "300px"}, "normal");
                }else{
                    $('html, body').animate({
                        scrollTop: $(".disclaimer")
                        .offset().top }, "normal");
                }
            });
            $(this).toggleClass("active");
            return false;
         });
        }
     });
    }
});

/* Shipping Countdown and Persistent Cart */
cartTimer = {
	/*Set the default widths to 0 initially*/
	countdownWidth: 0,
	cartWidth: 0,
	isCartOpen: false,
	/*
	  Open up the hover cart and set to display block, and give padding for text,
	  also set the width to auto for the container because if it was closed then there was a small width applied
	*/

	cartOpen: function(){
		$("#cart-total").animate({width: cartTimer.cartWidth},"fast",function(){
			$("#cart-total").width("");
		});
		$("#cart-total").css({
			display: "block",
			padding: "0 20px"
		});
		$("#global-cart").width("");
		cartTimer.isCartOpen = true;
	},
	/*
		Animate the cart total div to 0 setting, open the countdown, remove some of the styles, change the button image, set the container to
		the width of the button image and turn the hover cart to display none
	*/
	cartClose: function(){
		$("#cart-total").animate({width: 0},"fast", function(){
			cartTimer.countdownOpen();
			$("#cart-total").css("padding","0");
			$("#cart_corner").css("display","none");
			$("#cart-button img").attr("id","bug_cartIcon");
			fixPNG($(".png_ie"));
			$("#global-cart").width($("#cart-button").width());
			$('#hovercart-items').css("display","none");
		});
		cartTimer.isCartOpen = false;
	},
	/*
		Open the countdown by setting the width of the countdown time div to the original value when the page first loaded and set the
		container's width to auto because a previous width was set
	*/
	countdownOpen: function(){
		$("#countdown-time").animate({width: cartTimer.countdownWidth},"fast");
		$("#countdown-time").css("display","block");
		$("#countdown").width("");
	},
	/*
		Animate the countdown time div to 0, open the persistent cart and display the end rounded corner of the persistent cart,
		change the button to the one with a flat side and set the width of the container for the countdown to the size of the
		clock image and end corner combined
	*/
	countdownClose: function(){
		$("#countdown-time").animate({width: 0},"fast", function(){
			cartTimer.cartOpen();
			$("#cart_corner").css("display","inline");
			$("#cart-button img").attr("id","bug_cartIcon");
			fixPNG($(".png_ie"));
			$("#countdown").width($("#countdown_end").width() + $("#countdown-clock").width());
		});
	}
}
/* Get the initial width of the countdown time div */
cartTimer.countdownWidth = $("#countdown-time").width();

/* Get the persistent cart's total text div */
cartTimer.cartWidth = $("#cart-total").width();
	/*
	Set the  display of the cart total to none after we have got the width, since we had to get the width to apply it later
	we set the visibility to hidden in the style sheet, so we now give it visibility visible to set it back
*/
$("#cart-total").css({
	display: "none",
	visibility: "visible"
});
/* The click function that runs the the cartClose method,closing the cart after the user clicks the clock */
$("#countdown-clock").click(function(){
	cartTimer.cartClose();
	$(this).blur();
	return false;
});
/* The click function that runs the countdownClose method, closing the countdown after the user clicks the  cart button*/
$("#cart-button").click(function(){
	cartTimer.countdownClose();
	$(this).blur();
	return false;
});
	/* if the HTML in the element with the class of span inside the cart total div is greater then 0 open the cart and close the countdown */
if ($(".quantity", "li#cart-total").html() > 0){
    cartTimer.countdownClose();
    cartTimer.cartOpen();
}

/*
	We set the initial visibility of the countdown container to hidden so that we can grab the initial width and since the persistent cart
	can be the first one open if there is something in the cart we had it to be set to hidden so there wouldn't be a flash of the full countdown,
	so now we set the div back to visible
*/

function showFormRedBag() {
document.getElementById('RedBag').style.display = 'block';
document.getElementById('InsideRedBag').style.classname = 'inactive';   

return false;
}

function hideFormRedBag() {
    document.getElementById('RedBag').style.display = 'none';
    return false;
}

function showFormInsideRedBag() {
    oDiv = document.getElementById('InsideRedBag');
    oDiv.style.display = 'block';
    return false;
}

function hideFormInsideRedBag() {
    oDiv = document.getElementById('InsideRedBag');
    oDiv.style.display = 'none';
    return false;
}

function showFormRedFlap() {
    oDiv = document.getElementById('RedFlap');
    oDiv.style.display = 'block';
    return false;
}

function hideFormRedFlap() {
    oDiv = document.getElementById('RedFlap');
    oDiv.style.display = 'none';
    return false;
}

function showFormSmallBag() {
    oDiv = document.getElementById('SmallBag');
    oDiv.style.display = 'block';
    return false;
}

function hideFormSmallBag() {
    oDiv = document.getElementById('SmallBag');
    oDiv.style.display = 'none';
    return false;
}

function showFormLongBag() {
    oDiv = document.getElementById('LongBag');
    oDiv.style.display = 'block';
    return false;
}

function hideFormLongBag() {
    oDiv = document.getElementById('LongBag');
    oDiv.style.display = 'none';
    return false;
}

function showFormCanvasBag() {
    oDiv = document.getElementById('CanvasBag');
    oDiv.style.display = 'block';
    return false;
}

function hideFormCanvasBag() {
    oDiv = document.getElementById('CanvasBag');
    oDiv.style.display = 'none';
    return false;
}

function showFormCanvasOpen() {
    oDiv = document.getElementById('CanvasOpen');
    oDiv.style.display = 'block';
    return false;
}

function hideFormCanvasOpen() {
    oDiv = document.getElementById('CanvasOpen');
    oDiv.style.display = 'none';
    return false;
}

function showFormBrownBag() {
    oDiv = document.getElementById('BrownBag');
    oDiv.style.display = 'block';
    return false;
}

function hideFormBrownBag() {
    oDiv = document.getElementById('BrownBag');
    oDiv.style.display = 'none';
    return false;
}

function showFormBrownOpen() {
    oDiv = document.getElementById('BrownOpen');
    oDiv.style.display = 'block';
    return false;
}

function hideFormBrownOpen() {
    oDiv = document.getElementById('BrownOpen');
    oDiv.style.display = 'none';
    return false;
}

function showFormLeatherBag() {
oDiv = document.getElementById('LeatherBag');
    oDiv.style.display = 'block';
    return false;
}

function hideFormLeatherBag() {
    oDiv = document.getElementById('LeatherBag');
    oDiv.style.display = 'none';
    return false;
}

function showFormOrangeFlap() {
oDiv = document.getElementById('OrangeFlap');
    oDiv.style.display = 'block';
return false;
}

function hideFormOrangeFlap() {
    oDiv = document.getElementById('OrangeFlap');
    oDiv.style.display = 'none';
    return false;
}

function showFormLeatherBB() {
oDiv = document.getElementById('LeatherBB');
    oDiv.style.display = 'block';
return false;
}

function hideFormLeatherBB() {
    oDiv = document.getElementById('LeatherBB');
    oDiv.style.display = 'none';
    return false;
}

function showFormLeatherOpen() {
oDiv = document.getElementById('LeatherOpen');
    oDiv.style.display = 'block';
return false;
}

function hideFormLeatherOpen() {
    oDiv = document.getElementById('LeatherOpen');
    oDiv.style.display = 'none';
    return false;
}

function showFormGreenFlap() {
oDiv = document.getElementById('GreenFlap');
    oDiv.style.display = 'block';
return false;
}

function hideFormGreenFlap() {
    oDiv = document.getElementById('GreenFlap');
    oDiv.style.display = 'none';
    return false;
}
    





