// JavaScript Document
var totalFeature = 0;
var grTotal = 0;
var xmlHttp = '';
var priceTextBox = '';
function createXMLHttpRequest() 
{
	if (window.ActiveXObject) 
	{
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	} 
	else if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
	}
	return xmlHttp;
}

function changePrice(totalAttributes)
{	
	var url = 'change_product_price.php';	
	xmlHttp = createXMLHttpRequest();
	var ids = '';
	for(var i=1;i<=totalAttributes;i++)
	{
		var tmpId = 'attr'+i;
		if(i == 1)
		{
			ids = ids+document.getElementById(tmpId).value;
		}
		else
		{
			ids = ids+','+document.getElementById(tmpId).value;
		}		
		
	}
	var pro_id = document.getElementById('pro_id').value;
	var tax_rate = document.getElementById('tax_rate').value;
	var cpath = document.getElementById('cpath').value;
	queryString = url+'?ids='+ids+'&pro_id='+pro_id+'&tax_rate='+tax_rate+'&cpath='+cpath+'&t='+Math.random();
	xmlHttp.onreadystatechange = parseResults;	
	xmlHttp.open("GET", queryString, true);
	xmlHttp.send(null);
}


function parseResults() 
{
	if (xmlHttp.readyState==4)
	{	
		var tmpVal = xmlHttp.responseText.split('|||');
		var attrPrice = parseFloat(tmpVal[1]);
		var attrPrice1 = parseFloat(tmpVal[2]);
		var orgPrice = parseFloat(document.getElementById('product_org_price').value);
		var orgPrice1 = parseFloat(document.getElementById('product_org_price_tax').value);
		totalPrice = attrPrice+orgPrice;
		totalPrice1 = attrPrice1+orgPrice1;
		//document.getElementById('span_pro_price').innerHTML = '<span class="currency_symbol">'+document.getElementById('cur_symbol').value+'</span>'+totalPrice.toFixed(2);
		//document.getElementById('span_pro_price_tax').innerHTML = '<span class="currency_symbol">'+document.getElementById('cur_symbol').value+'</span>'+totalPrice1.toFixed(2);
		document.getElementById('span_pro_price').innerHTML = '<span class="currency_symbol">&pound;</span>'+totalPrice.toFixed(2);
		document.getElementById('span_pro_price_tax').innerHTML = '<span class="currency_symbol">&pound;</span>'+totalPrice1.toFixed(2);                
	}
}



