// these are custom CBS javascript functions

var $j = jQuery.noConflict();

function showForm(whatForm)
{
$j(whatForm).slideDown();
}

$j(document).ready(function(){
	$j(".question").click(function(){
		$j(this).next().slideToggle();
	});
	$j(".answer").hide();
	//$j(".answer").addClass("et-box et-shadow");
	//$j(".answer").children().addClass("et-box-content");
	$j("#bus-opp-form").hide();
	$j("#consignment-form").hide();
});


// these are the functions for the wishlist
$j(document).ready(function(){
	$j( "#wishlist-add" ).click(function(){
		iItems = $j( "#item-count" ).val();
		//alert(iItems);
		var itemRow = '<tr><td colspan="2"><h3 class="nice-titles">Item<span>Tell Us What You Need</span></h3></td></tr><tr><td>Item:</td><td><input type="text" name="item['+iItems+'][name]" /></td></tr><tr><td>Color:</td><td><input type="text" name="item['+iItems+'][color]" /></td></tr><tr><td>Size:</td><td><input type="text" name="item['+iItems+'][size]" /></td></tr><tr><td>Price Range:</td><td><input type="text" name="item['+iItems+'][price]" /></td></tr><tr><td>Style:</td><td><input type="text" name="item['+iItems+'][style]" /></td></tr><tr><td>Comments:</td><td><textarea name="item['+iItems+'][comments]" rows="3" cols="40"></textarea></td></tr>';
		$j( "#wishlist-items" ).append(itemRow);
		$j( "#item-count" ).val( parseInt(iItems) + 1 );
	});
	
	$j( "#submit-wishlist" ).click(function () {
		var serial = $j("#wishlist-form").serialize();
		$j.post("/bin/wishlist.php", serial, function(data) {
			if(data == 1){
				strOut = '<h3 class="nice-titles">Thank You<span>For Your Submission</span></h3><p>Thank you for sending us your Wish List. Our Staff will check our inventory and let you know as soon as we have your item in stock.</p><p>Want more? Forget to add something? <a href="">Submit another Wish List</a>';
				
			} else {
				strOut = '<h3 class="nice-titles">OOPS...<span>Something went wrong</span></h3><a href="">Please Try Again</a>';
			}
			$j( "#wishlist-div" ).html(strOut);
		});
	});
	
});





// these are legacy functions taken from the old shopterris.com
$j(document).ready(function(){
	$j( "#no_pictures" )
		.click(function() {
			$j( "#upload_table_tr" ).hide();
			$j( "#upload_table_tr2" ).hide();
	});
	$j( "#yes_pictures" )
		.click(function() {
			$j( "#upload_table_tr" ).show();
			$j( "#upload_table_tr2" ).show();
	});
	$j( "#add_file" )
		.click(function() {
			$j('#upload_table tr:last').after('<tr><td><input type="file" name="images[]" /></td></tr>');
	});

});


