// Delay Plugin for jQuery - http://james.padolsey.com/javascript/jquery-delay-plugin/
$.fn.delay = function(time, callback){jQuery.fx.step.delay = function(){};return this.animate({delay:1}, time, callback);}

$(function() {
// Rounded Corners
	// $('#navsidebar').corners("50px transparent bottom-left top-right");
   	$('form#EmailForm fieldset, form#wlpeUserProfileForm fieldset').corners("10px");

	// Awesome Ambersands - http://justinhileman.info/articles/more-jquery-typography
	$("*:contains('&')", document.body).contents().each(function() {
		if( this.nodeType == 3 ) {
			$(this).replaceWith( 
				this.nodeValue.replace( /&/g, "<abbr title='and' class='amp'>&</abbr>" )
		);}});


	// Fancy Drop Caps
  	$('#basicContent p:first').each(function() { var text = $(this).html(); var first_letter = text.substr(0,1); if ( /[a-zA-Z]/.test(first_letter) ) { $(this).html('<span class="dropcap">' + first_letter + '</span>' + text.slice(1)); } });

	// img float fix (css margin)
	$("#basicContent img").each(function() {
		if($(this).css("float") == "left") {
			$(this).addClass("left");
		}
		else if ($(this).css("float") == "right") {
			$(this).addClass("right");
		}
	});

// jQuery Sliding Login Panel

	// Expand
	$("#panelopen").click(function(event){
		event.preventDefault();
		$("div#panel").slideDown("slow");
		$('#panelopen').hide();
		$('#panelclose').show();
	});	

	// Collapse
	$("#panelclose").click(function(event){
		event.preventDefault();
		$("div#panel").slideUp("slow");
		$('#panelclose').hide();
		$('#panelopen').show();
	});

// Links and Mainnav

	// FuNtastiC AniMation :{}  removed: a.B_currentCrumb, a.B_crumb
/*    $('ul.menu li a, #tabs a, a.quanttype, a.altlink, a.amountmini, a.minititle')
        .hover(function() {
            $(this).hoverFlow('mouseenter', { marginLeft: '+=0.7em' }, 'fast');
        }, function() {
            $(this).hoverFlow('mouseleave', { marginLeft: '-=0.7em' }, 'fast');
        });

    $('ul.menu li ul li')
        .hover(function() {
            $(this).hoverFlow('mouseenter', { borderLeftColor: "#300018" }, 'fast');
        }, function() {
            $(this).hoverFlow('mouseleave', { borderLeftColor: "white" }, 'fast');
        });

    $('a.type')
        .hover(function() {
            $(this).hoverFlow('mouseenter', { fontSize: '+=1px' }, 'fast');
        }, function() {
            $(this).hoverFlow('mouseenter', { fontSize: '-=1px' }, 'fast');
        });

*/

	// Breadcrumb: Top-Link disable
	$('#crumbs li span.B_firstCrumb a').click(function(event){
	 event.preventDefault();
	});
	/*
	$("#crumbs li span.B_firstCrumb a").toggle(function(){
		$('body').css("background", "#FFFFFF url(assets/images/backgrounds/circles07.jpg) no-repeat scroll center top");
		}, function () {
		$('body').css("background", "#FFFFFF url(assets/images/backgrounds/circles08.jpg) no-repeat scroll center top");
		}, function () {
		$('body').css("background", "#FFFFFF url(assets/images/backgrounds/circles09.jpg) no-repeat scroll center top");
		}, function () {
		$('body').css("background", "#FFFFFF");
		}, function () {
		$('body').css("background", "#FFFFFF url(assets/images/backgrounds/circles06.jpg) no-repeat scroll center top");
	}); */
	


// Product Page Code

	// Foxybox Dimensions
	fc_tb_WIDTH = 560;
	fc_tb_HEIGHT = 400;

	// Scrollable
	$("div.scrollable").scrollable({
		size: 1,
		speed: 700,
		interval: 0,
		navi: '#tabs',
		loop: true,
		keyboard: false
	});
		$("#tabs a").click(function(event){
	     event.preventDefault();
		});
	
	// Details Fix
	$("div.scrollable div.items div:eq(1) p").remove();		

	// Parings Check
	paringsContent = $('div.items div:last').html()
	if (!paringsContent) {
		$('#tabs a:last').hide();
	}

	// PriceCase Check    If(typeof myVar === ‘undefined’ || !myVar) 
	if (typeof priceCase === 'undefined' || !priceCase) {
		$('#casetype').hide();
		$('#bottletype').html("Bottles Only")
	}
	
	// quantity type toggle
	$("a#bottletype").click(function (event) {
		event.preventDefault();
		if ($("span#amount").text() == '$'+priceCase) {
			$("a#bottletype").addClass('active');
			$("a#casetype").removeClass('active');
			$("span#amount").fadeOut('normal',changePrice);
		}
		function changePrice() {
			$("span#amount").html('$'+priceBottle);
			$(".foxycart input[name=price]").attr("value","$"+priceBottle);
			$(".foxycart input[name=category]").attr("value", foxyCartCategoryPrefix+"Bottle");
			$("span#amount").fadeIn('normal');
		}
   });

	$("a#casetype").click(function (event) {
		event.preventDefault();
		if ($("span#amount").text() == '$'+priceBottle) {
			$("a#casetype").addClass('active');
			$("a#bottletype").removeClass('active');
			$("span#amount").fadeOut('normal',changePrice);
		}
		function changePrice() {
			$("span#amount").html('$'+priceCase);
			$(".foxycart input[name=price]").attr("value","$"+priceCase);
			$(".foxycart input[name=category]").attr("value", foxyCartCategoryPrefix+"Case");
			$("span#amount").fadeIn('normal');
		}
	});

	// quantity slider, numeric input only
	slideSet.init(document.getElementById("quantset"), 1, 18, 1, 99);
	$('#quantset').numeric();

}); // end jcode

