/* this script handles the form behaviour in the pages. */
//jQuery.noConflict(); // no conflict is already done... 
(function($){
	$(document).ready(function() {
		//set up form submission links (cart system requires posts)
		$('a.form_submit').click(function() {
			$this = $(this);
			//$('~ form',$this.parents('ul')).submit();
			var action_form = $('~ form',$this.parents('ul'));
			$.facebox(function() {
				$.post(action_form.attr('action'),{
					product: action_form.find('input[type=hidden]').val(),
					qty: 1
				},function () {
					$.facebox('Added to favourites!');
					// *** robertv - 19/04/2010 - job 12823 - GA goals for add to favourites ***
					pageTracker._trackPageview('/favourites/' + $("body.interior div#body h2 span").html());
					// *** end robertv - 19/04/2010 - job 12823 ***
				});
			});
		});
		//now we fill the products field with products from the cart and hide the field
		if ( $('textarea[name=products]').length > 0 ) {
			var products = $('table.data.full tr td:nth-child(2)')
							.text()
							.replace(/\n+/g,', ')
							.replace(/^, |, $/g,'');
			$('textarea[name=products]').text(products).parents('div.row').hide();
		}
	});
})(jQuery);