
function hide_others ( id, rid )
{
	object = document.getElementById(id);
	
	if(object.options[object.selectedIndex].value == 'Other')
	{
		document.getElementById(id+'_other').style.display = 'block';
	}
	else
	{
		document.getElementById(id+'_other').style.display = 'none';
		document.getElementById(id+'_other_txt').value = '';
	}
}

function check_postage ()
{
	object = document.getElementById('postage');
	
	if(object.options[object.selectedIndex].value=='')
	{
		alert("Please choose your postal area");
		return false;
	}
	return true;
}

function set_area(area)
{
	send_request(true,'set_area.php?area='+area, 'cart_postage');
	send_request(false,'total.php', 'cart_total');
}

function change_quantity(id, qty)
{
	if(qty <= 0)
	{
		// remove item
		send_request(true,'delete_product.php?id='+id);
		document.getElementById('product'+id).style.display = 'none';
	}
	else
	{
		send_request(true,'quantity.php?id='+id+'&qty='+qty);
	}
	// refresh displays
	send_request(false,"cart_display.php", 'shopping_basket');
	send_request(false,"basket_image.php", 'basket_image');
	send_request(false,"subtotal.php", 'subtotal');
	send_request(false,'total.php', 'cart_total');
	send_request(false,'subtotal.php', 'cart_total_nopostage');
	send_request(false,'total_items.php', 'total_items');
}



function send_request(xSync, xUrl, xId) {
// xSync param added to specify whether request should be synchronous (true) or asynchronous (false). 
// 21-05-07 Gareth Raw

  var xmlhttp = false;

  /*@cc_on @*/

  /*@if (@_jscript_version >= 5)

  // JScript gives us Conditional compilation, we can cope with old IE versions.
  // and security blocked creation of the objects.

  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
   } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
   }

  /*@end @*/

	if(!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	if(!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest();
		} catch (e) {
			xmlhttp = false;
		}
	}
	//sets asynchronous param to opposite of xSync param
	xmlhttp.open("GET", "/xmlhttp/"+xUrl, !xSync);
	//if asynchronous is required, set up the call back function.
	if ( !xSync ) {
		xmlhttp.onreadystatechange = function() {
			if(xmlhttp.readyState==4 && xId && xmlhttp.responseText) {
				document.getElementById(xId).innerHTML = xmlhttp.responseText;
			}
	  	}
	}

	xmlhttp.send(null);
	//if synchronous and something needs updating ... do the update
	if ( xSync && xId && xmlhttp.responseText) {
		document.getElementById(xId).innerHTML = xmlhttp.responseText;
	}
}

function popup(url, width, height, left, top)
{
	if(!width)
	{
		width = 850;
	}
	
	if(!height)
	{
		height = 600;
	}
	
	
	if(!left)
	{
		var left = (screen.width-width)/2;
	}
	
	if(!top)
	{
		var top = (screen.height-height)/2;
	}
	
	var settings ='height='+height+',';
	settings +='width='+width+',';
	settings +='top='+top+',';
	settings +='left='+left+',';
	settings +='scrollbars=yes,';
	settings +='resizable=yes';
	settings +=',location=yes,toolbar=yes';
	
	win = window.open(url, '', settings);
	
	if(parseInt(navigator.appVersion) >= 4)
	{
		win.window.focus();
	}
}