function footerContactToggle(clickedItem, targetId)
{
	$(clickedItem).toggleClass('toggle_img');
	$('#'+targetId).slideToggle('fast');
	return false;
	
}
function cart_add(product_data, quantity)
{

	$('#shopping_cart_items').html($('#shopping_cart_loading').html());
	$.ajax({url: '/ajax-cart-add',
			method: 'post',
		    data: {data: product_data, quantity: quantity?quantity:1},
		    success: function(html){
		         $('#shopping_cart').html(html);
		    }
	});
	return false;
}
function cart_remove(product_data, product_name)
{
	if (!confirm("Are you sure you want to remove this item from your cart?"))
		return false;
	
	$('#shopping_cart_items').html($('#shopping_cart_loading').html());
	$.ajax({url: '/ajax-cart-remove',
			method: 'post',
		    data: {data: product_data},
		    success: function(html){
		         $('#shopping_cart').html(html);
		    }
	});

	return false;
}

function pop_return_policy()
{
	win = window.open('/return-policy', 'returnpolicy','scrollbars=1,width=700,height=336');
}

function toggleShipSameAsBilling(form, checkbox)
{
	if (checkbox.checked == true)
	{
		form.elements['shipping[first_name]'].value = form.elements['billing[first_name]'].value
		form.elements['shipping[last_name]'].value = form.elements['billing[last_name]'].value
		form.elements['shipping[address]'].value = form.elements['billing[address]'].value
		form.elements['shipping[address_cont]'].value = form.elements['billing[address_cont]'].value
		form.elements['shipping[city]'].value = form.elements['billing[city]'].value
		form.elements['shipping[state]'].selectedIndex = form.elements['billing[state]'].selectedIndex
		form.elements['shipping[zip]'].value = form.elements['billing[zip]'].value
		form.elements['shipping[phone]'].value = form.elements['billing[phone]'].value
	}
	else
	{
		form.elements['shipping[first_name]'].value = "";
		form.elements['shipping[last_name]'].value = "";
		form.elements['shipping[address]'].value = "";
		form.elements['shipping[address_cont]'].value = "";
		form.elements['shipping[city]'].value = "";
		form.elements['shipping[zip]'].value = "";
		form.elements['shipping[phone]'].value = "";
	}
}


/************
 SOCIAL BOOKMARK FUNCTIONS
 ************/

function social_digg()
{
	url = location.href;
	title = document.title;
	new_window = window.open('http://digg.com/submit?media=MEDIA&topic=TOPIC&url=?'+encodeURIComponent(url)+'&title='+encodeURIComponent(title),'digg');
	req = new Ajax.Request('/api-social-bm/digg/'+encodeURIComponent(url));
	return false;
}
	
function social_stumble()
{
	url = location.href;
	title = document.title;
	new_window = window.open('http://www.stumbleupon.com/submit?url='+encodeURIComponent(url));
	req = new Ajax.Request('/api-social-bm/stumbleupon/'+encodeURIComponent(url));
	return false;
}
	
function social_facebook() 
{
	url = location.href;
	title = document.title;
	new_window = window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(url)+'&t='+encodeURIComponent(title),'sharer','toolbar=0,status=0,width=626,height=436');
	req = new Ajax.Request('/api-social-bm/facebook/'+encodeURIComponent(url));
	return false;
}

function social_twitter(title) 
{
	url = location.href;
	
	if (title == undefined || title == "")
		title = "Bell Curves";
	
	new_window = window.open('http://twitter.com/home/?status='+encodeURIComponent(url)+' '+encodeURIComponent(title));
	req = new Ajax.Request('/api-social-bm/twitter/'+encodeURIComponent(url));
	
	return false;
}
	
function social_delicious() 
{
	url = location.href;
	
	title = document.title;
	
	new_window = window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(url)+'&title='+encodeURIComponent(title), 'delicious','toolbar=no,width=550,height=550');
	req = new Ajax.Request('/api-social-bm/delicious/'+encodeURIComponent(url));
	
	return false;
}
     

