$(document).ready(function() { 
	//$(document).pngFix(); 
	//find all elements containing cdquantity
	$("#catalog > ul").tabs();
	
	if(document.location.hash!='') {
        //console.log("we have a hash");
        //get the index from URL hash
      	tabSelect = document.location.hash.substr(1,document.location.hash.length);
		//console.log(tabSelect);
		$("#my-tabs").tabs('select',tabSelect-1);
	}
	
	var nextBtn = $('input.nextBtn');
	
	nextBtn.mouseover(function(){$(this).css("border", "2px solid #333");});
	nextBtn.mouseout(function(){$(this).css("border", "0px solid #333");});
	
	var addButtons = $("img.buy").each(function(){
		$(this).click(function(){
			var input = $(this).parents('div.cde').find('input[type="text"]');
			var currentValue = input.val();
			currentValue++;
			input.val(currentValue);
		});
	});
	
	var nextBtn = $("img.nextStep");
	
	var cancelBtn_inner = $("img.cancelBtn_inner");
	cancelBtn_inner.click(function(){
		$("#dialog").dialog("close");
	});
	
	var nextBtn_inner = $("img.nextBtn_inner");
	nextBtn_inner.click(function(){
		$("form").submit();
	});
	
	nextBtn.click(function(){
		$("form").submit();
	});
	
	var order_btn = $("img.order_btn");
	order_btn.click(function(){
		$("form").submit();
	});
	
	$("#dialog").dialog({ 
		modal: true, 
		overlay: {opacity: 0.5, background: "black"},
		resizable: false,
		draggable: false, 
		autoOpen: false
	});
	
	var cartButtons = $("img.cart").each(function(){
		$(this).click(function(){
			$("#dialog").dialog("open");
		});
	});
	
	var toolbars = $('#products').find('div.cde').each(function(){
		$(this).find('img.plus').mouseover(function(){
			//$(this).addClass("hover_btn");
		});
		
		$(this).find('img.plus').click(function(){
			var input = $(this).parents('div.cde').find('input[type="text"]');
			var currentValue = input.val();
			if(input.val() < 11){
				currentValue++;
				input.val(currentValue);	
			}
		});
		
		$(this).find('img.minus').click(function(){
			var input = $(this).parents('div.cde').find('input');
			var currentValue = input.val();
			
			if(input.val() > 0){
				currentValue--;
				input.val(currentValue);	
			}
	
		});
		
		$(this).find('img.minus').mouseover(function(){
			//$(this).addClass("hover_btn");
		});
		
		$(this).find('img.plus').mouseout(function(){
			//$(this).removeClass("hover_btn");
		});
		
		$(this).find('img.minus').mouseout(function(){
			//$(this).removeClass("hover_btn");
		});
			
	});
	/*
	plusButtons.click(function(){
		
	});
	
	plusButtons.mouseover(function(){
		$(this).addClass("hover_btn");
	});
	
	plusButtons.mouseout(function(){
		$(this).removeClass("hover_btn");
		
	});
	*/
	
	
	
});