$(function() {
	checkPrice();
});

function changePic(obj) {
	var c = $("#big_pic")[0].className.replace("img", "");
	
	if(typeof(obj) == "object") {
		var n = obj.id.replace("img_tb","");
	}
	else {
		var n = obj;
	}
	
	$("#img_spec"+c).css({ display:"none" });
	$("#img_spec"+n).css({ display:"inline" });
	
	var shown = $("#shown_in");
	
	if($("#img_spec"+n).html() == '') {
		shown.removeClass('shown_visible');
	}
	else if(!shown.hasClass('shown_visible')) {
		$("#shown_in").addClass('shown_visible');
	}
	
	$("#big_pic")[0].className = "img"+n;
}

function checkPrice() {
	var jQ = $;
	var sid = jQ("#option_species").val();
	var fid = jQ("#option_finish").val();
	
	var showprice = jQ("#product_price span[name="+sid+"-"+fid+"]");
	
	jQ("#product_price span").hide();
	
	if(showprice.length > 0 ) {
		showprice.show();
		jQ("#cart_actions input[name=s]").val(sid);
		jQ("#cart_actions input[name=f]").val(fid);
		
		$('.buttons_control').show();
	}
	else {
		jQ("#no_price").show();
		jQ("#cart_actions input[name=s],#cart_actions input[name=f]").val('0');
		
		//Hide the other buttons
		$('.buttons_control').hide();
	}
}

function addToCart() {
	var check = $("#cart_actions input[name=s], #cart_actions input[name=f]"); 
	if(check[0].value != 0 && check[1].value != 0) {
		$('#cart_actions')[0].submit();
	}
}
