function updateCart($){
	var url="http://"+window.location.host+window.location.pathname+"?page_id=38";
	
	
	
   /* $('#cart #item_905_11').bind('keypress', function(e) {
    	  return ( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)) ? false : true ;
     });
      
      
	$('#cart input').change(function(){	
		
	});*/
	
	$('#cart .cart-item-remove').click(function(){
		$(this).parent().parent().fadeOut("fast", function(){
			$(this).find('.cart-item-name input').val(0);
			
			$.post(url, $("#cart form").serialize(), function(data) {
				$("#cart").html($("#cart", data).html());
				var itemcount=Number($("#cart .cart-item-count", data).html());
				if(itemcount>0){
					$("#nav .cart-item-count").html(itemcount);
				}else{
					$("#nav .cart-item-count").remove();
				}
				updateCart($);
			});
		});
	});
};
//
jQuery(function($) {
	
	$('ul.menu a').not(":only-child").each(function(index){	
		$(this).addClass('m'+index);
		$(this).addClass('closed');
	});
	$('ul.menu ul').hide();
	$.each($('ul.menu'), function(){
		var cookie = $.cookie(this.id);
		
		if(cookie === null || String(cookie).length < 1) {
			$('#' + this.id + '.expandfirst ul:first').show();
		} else {
			$('#' + this.id + ' .' + cookie).next().show();
			$('#' + this.id + ' .' + cookie).addClass('open');
		}
	});
	$('ul.menu li a').click(
	function() {
		var checkElement = $(this).next();
		var parent = this.parentNode.parentNode.id;
		if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
			$('#' + parent + ' ul:visible').slideUp('fast');
			$('#' + parent + ' ul:visible').prev().removeClass('open');
			if((String(parent).length > 0) && (String(this.className).length > 0)) {
				$.cookie(parent, this.className.split(' ')[0]);
			}
			checkElement.slideDown('fast');
			$(this).addClass('open');
			return false;
		}
	});

	/*$('.jewelry-category a').not(":only-child").addClass('open').click(function(event, instant){
		if(instant){
			$(this).parent().find('ul').toggle();
		}else{
			$(this).parent().find('ul').slideToggle( 'fast');
		}
		$(this).toggleClass('open');
		$(this).toggleClass('closed');
	});
	
	$('.jewelry-category .open').not(":first").trigger('click', [true]);*/
	
	
	$("h3:contains('Leave a Reply')").addClass('open').css({cursor:'pointer'}).click(function(event, instant){
		if(instant){
			$(this).parent().find('form').toggle();
		}else{
			$(this).parent().find('form').slideToggle('fast');
		}
		$(this).toggleClass('open');
		$(this).toggleClass('closed');
	}).trigger('click', [true]);
	
	
	$('#content .gallery a').lightBox({
		fixedNavigation: false,	
		imageLoading: 'http://www.knotstudio.com/wp-content/themes/knotstudio2009/images/lightbox-ico-loading.gif',
		imageBtnPrev: 'http://www.knotstudio.com/wp-content/themes/knotstudio2009/images/lightbox-btn-prev.gif',
		imageBtnNext: 'http://www.knotstudio.com/wp-content/themes/knotstudio2009/images/lightbox-btn-next.gif',
		imageBtnClose: 'http://www.knotstudio.com/wp-content/themes/knotstudio2009/images/lightbox-btn-close.gif',
		imageBlank: 'http://www.knotstudio.com/wp-content/themes/knotstudio2009/images/lightbox-blank.gif'
	});
	

	updateCart($);
	
/*	$('.jewelry-category li a').click(function(){
		$('#content').load(this.href+' #content .post');
		return false;
	});*/

}); 

