$(document).ready(function() {
	
	/* Cart */
	
	$(".cart_container").hide(); 
	
	$(".cart_trigger").click(function(event){
		event.preventDefault();
		$(".cart_container").slideToggle(500);
	});
	
	/* Categories */
	
	//$(".categories_container").hide();

	$('.categories_trigger').toggle(
		function() { // handlerEven
			$('.expand a').html('Expand [ + ]');
			$(".categories_container").slideUp(500);
		},
		function() { // handlerOdd
			$('.expand a').html('Collapse [ - ]');
			$(".categories_container").slideDown(500);
		}			
	);
	
	//setTimeout(display_categories, 2000);
	
});

$(function(){
	$("body").click(function(e){
		if(e.target.id=="clickMe" || $(e.target).parents("#clickMe").size()){ 
			//alert("inseide div");
			$("#results").toggle();
		} else {
			//alert("outside div"); 
			$('#results').hide(); //hide the button
		}
	});
})

function display_categories()
{
	$(".categories_container").slideDown(500, function(){
		$('.expand a').html('Collapse [ - ]');
		//setTimeout(display_categories_8, 2000);
	});	
}

function display_categories_8()
{
	$('.row.hidden').slideUp(500);
}

var swap_text_boxes = [];

function init_swap_text_boxes(){
  //Store the default value for each box
  $('input[type=text][value].swaptextbox').each(function() {
    swap_text_boxes[$(this).attr('id')] = $(this).attr('value');
  });
  //Add focus and blur events to set or clear the value
  $('input[type=text][value].swaptextbox').bind('focus', function() {
    if($(this).val() == swap_text_boxes[$(this).attr('id')]) {
      $(this).val('');
    }
  });
  $('input[type=text][value].swaptextbox').bind('blur', function() {
    if($(this).val() == '') {
      $(this).val(swap_text_boxes[$(this).attr('id')]);
    }
  });
}

$(document).ready(function(){ init_swap_text_boxes(); }); 


