/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| alteredCart.com
| All code developed by Bill Brewer
| Copyright (c)2009 alteredCart            
| Bill Brewer <bill@alteredcart.com> | All rights reserved.
| This code is licensed for use on a single server.
| This code is licensed for use by the original purchaser only.
| Full license :: www.alteredcart.com/license.php
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

function buyTogetherCheckOptions(){

	ac.$('buyTogetherLoading').style.display = '';
	ac.$('buyTogetherButton').style.display = 'none';

	// Loop through the elements //
	var poarr = document.forms['buy_together'].elements;
	var params = '';
		
	for (x=0; x < poarr.length; x++)
		params += poarr[x].name+'='+encodeURI(poarr[x].value)+'&';

	params = params.substr(0, params.length-1);

	params += '&bt_ajax=check_options';

	ac.update_prices = function(text){
	
	ac.$('buyTogetherLoading').style.display = 'none';
	ac.$('buyTogetherButton').style.display = '';
	
	text = ac.trim(text);
	
	var prices = text.split("\n");

	ac.$('buy_together_discounted_price').innerHTML = prices[0];
	ac.$('buy_together_discount').innerHTML = prices[1];
	ac.$('buy_together_price').innerHTML = prices[2];

		}
	
	// Check status and update prices //
	ac.ajax({url:'buy_together_cart.php', method:'POST', parameters:params, returned:'text', return_func:ac.update_prices});

	}


function buyTogetherAdd(){

	document.buy_together.submit();

	}