$(document).ready(function(){

//	$("#paragraphs").hide();
	$('#loading').hide();
//	$('#ajax-content').hide();
	
	// Get Kwicks running (homepage only)
	$('.kwicks').kwicks({  
	  max : 485  
	});  

	// Main navigation
	$("#navMain").superfish({
		speed:'fast',
		delay: 1, 
		autoArrows: false
	});

	$('ul#navMain li').hover(function(){
	    $(this).find('a:first').addClass('active');
	},
	function(){
	    $(this).find('a:first').removeClass('active');
	});



//  $("#toggle-ajax").click(function(event){  
//    if ($('#toggle-ajax').hasClass('hidden')) { // checks if the content is visible
//      $('#loading').show();
//      $("#ajax-content").load("ajax-response.html");
//      $('#loading').hide();
//    } else { 
//    }
//    return false;
//	});

	// Show / hide default stuff
  	$(".hidden,.visible").click(function(event){  
		if ($(this).hasClass('hidden')){
		  $(this).removeClass('hidden')
		  $(this).addClass('visible');
		} else {
		  $(this).removeClass('visible')
		  $(this).addClass('hidden');
		}
		$(this).parent().next().slideToggle();
		return false;
	});

	// Lightbox
	$(function() {
		$('a.lightbox').lightBox(); // Select all links with lightbox class
	});

	// Activate rounded corners
	//$('.rounded').corners();

	// Search box stuff
	var searchBoxes = $(".searchInput");
	var searchBox = $("#keywords");
	var searchBoxDefault = "Search our products...";
	
	// Effects for both searchbox
	searchBoxes.focus(function(e){
		$(this).addClass("active");
	});
	searchBoxes.blur(function(e){
		$(this).removeClass("active");
	});
	
	//searchBox show/hide default text if needed
	searchBox.focus(function(){
		if($(this).attr("value") == searchBoxDefault) $(this).attr("value", "");
	});
	searchBox.blur(function(){
		if($(this).attr("value") == "") $(this).attr("value", searchBoxDefault);
	});


	// Fitted plugin for big targets: http://www.trovster.com/lab/plugins/fitted/
	$(".clickable").fitted();

});

var addthis_config = {
	username: "lecafeshop"
}

// Quantity fix from rodney meyers
function qty_fix(elem,Increment,qMin,qMax) {
	var ev=elem.value;
	var permitted="1234567890";
	permitted += Increment<1 ? "." : "";
	ev=clean(ev,permitted);
	if(ev<qMin){ev=qMin;}
	else if(ev>qMax){ev=qMax;}
	else if( (ev-qMin)/Increment != Math.ceil((ev-qMin)/Increment)){ev=1*qMin+Math.ceil((ev-qMin)/Increment)*Increment;}
	elem.value=ev;
}
function clean(str,permitted){
str=""+str;
var nchar,n;var out="";
for(n=0;n<str.length;n++)
	{
	nchar=str.charAt(n);
	out+=permitted.indexOf(nchar)>-1?nchar:"";
	}
return(out);
}

// Equal height boxes/columns
function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}
$(document).ready(function() {
	equalHeight($(".column"));
});

