
function getReseller()
{
		var o = $('order_number').value;
		if(o.length > 0){
		var url = 'jscalls/resellerjs.php?c=RO&o='+o;
		// notice the use of a proxy to circumvent the Same Origin Policy.
		
		new Ajax.Request(url, {
			  method: 'get',
			  onSuccess: function(transport) {
				$('order_number').value = transport.responseText;
			  }
			});
		}
}
function checkUpStatus(licid)
{
		var o = $(licid).value;
		if(o.length > 0)
		{
			var url = 'jscalls/handle_request.php?c_type=LICENSE_CHECK&key='+o;
		}
		else
		{
			$(licid).value = "License key not supplied";
			return false;
		}
		new Ajax.Request(url, {
		  method: 'get',
		  onSuccess: function(transport) {
			$(licid).value = transport.responseText;
			$(licid).style.border = "2px solid #790000";
			$(licid).style.padding = "2px";
		  },
		  onFailure: function(transport) {
			$(licid).value = "Can not handle request. Please try again later.";
			}
		});
}
// purchasing utilities
function updatePrice(q,i,ui,c,o,d,f)
{
		q = $('quantities'+i).value;
		if((q==0 || q.length==0) && f==0)
		{
			alert('Please input the quantity of BackupAssist licenses you require first.\nIf you are ordering add-ons only, upgrade protection does not apply');
			$('upgrade_protection'+i).checked = false;
		}
		var clicked = '';
		if(f==0 && $('upgrade_protection'+i).checked)
		{
			clicked='i';
		}
		else
		{
			clicked='u';
		}
		ui = document.getElementById('upgradeprotectionproduct').value;
		new Ajax.Request('jscalls/purchasing_updates.php?q='+q+'&i='+i+'&ui='+ui+'&c='+c+'&o='+o+'&ch='+clicked+'&d='+d, {
		    method: 'get',
		    onSuccess: function(transport) {
		 // alert(transport.responseText)
			$('i'+i).innerHTML = transport.responseText;
		  }
		});
}
function updatePriceDis(q,i,ui,c,o,d,f)
{
		q = $('quantities'+i).value;
		if((q==0 || q.length==0) && f==0)
		{
			alert('Please input the quantity of BackupAssist licenses you require first.\nIf you are ordering add-ons only, upgrade protection does not apply');
			$('upgrade_protection'+i).checked = false;
		}
		var clicked = '';
		if(f==0 && $('upgrade_protection'+i).checked)
		{
			clicked='i';
		}
		else
		{
			clicked='u';
		}
		ui = document.getElementById('upgradeprotectionproduct').value;
		new Ajax.Request('jscalls/purchasing_updates_dis.php?q='+q+'&i='+i+'&ui='+ui+'&c='+c+'&o='+o+'&ch='+clicked+'&d='+d, {
		    method: 'get',
		    onSuccess: function(transport) {
		 // alert(transport.responseText)
			$('Net'+i).innerHTML = transport.responseText;
		  }
		});
}


function toggleV3Table()
{
		if($('version4radio').checked)
		{
				$('v4table').show();
				$('v3table').hide();
		}
		if($('version3radio').checked)
		{
			$('v3table').show();
			$('v4table').hide();	
		}
		return true;
}

function CopyAccountsEmail()
{
		if ($('copy').checked)
		{
			if ($('accounts_email').value.length == 0)
			{
				alert ('Please enter an accounts\' email address');
				$('accounts_email').focus();
				$('copy').checked = false;
			}
			else
			{	
				$('tech_email').value = $('accounts_email').value;
				$('tech_email').readOnly = true;
				$('tech_email').style.color="#CCCCCC";				
			}
		}
		else 
		{
			$('tech_email').readOnly = false;
			$('tech_email').style.color="black";	
		}
		
}

function updateTotalPriceL()
{
		
		new Ajax.Request('jscalls/purchasing_price_updates.php', {
		  method: 'post',
		  parameters:$('licinfo').serialize(),
		  onSuccess: function(transport) {
			$('totalprice').innerHTML = transport.responseText;
		  }
		});
}
function getPrice(itemid)
{
		var url ='/services/prices.php?itemid='+itemid;
		var price = '';
		new Ajax.Request(url, {
		  onSuccess: function(transport) {
			$('price_'+itemid).innerHTML =  transport.responseText;
  }
		});
	
		
}
