function getHttp()
{  
	var Http;
	try
	{    
		// Firefox, Opera 8.0+, Safari    
		return Http=new XMLHttpRequest();    
	}
	catch (e)
	{    
		// Internet Explorer    
		try
		{      
			return Http=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{      
			try
			{        
			return Http=new ActiveXObject("Microsoft.XMLHTTP");        
			}
			catch (e)
			{        
				alert("Your browser does not support AJAX!");        
				return false;        
			}      
		}    
	}
	
}

function changCurr(crate)
{
	theForm = document.form1;
	var j = theForm.changeCurrBox.selectedIndex;
	var sym = theForm.changeCurrBox[j].text;
	
	var maxLimit = theForm.total_records.value;
	for(i=0;i<maxLimit;i++)
	{
		var jpy = 'price_local'+i;
		var curr = 'curr'+i;
		
		jpyVal = document.getElementById(jpy).value;
		if(jpyVal>0)
		{
			newVal = parseInt((jpyVal * crate)/100);
			newVal = sym+' '+addCommas(newVal);
			document.getElementById(curr).innerHTML = newVal;
		}
		else
			document.getElementById(curr).innerHTML = 'ASK';
	}
	
	// coding start for the price in similar vehicle box
	var foo = typeof document.forms['bot_form'] != 'undefined';
	if(foo)
	{
		theForm = document.bot_form;
		var maxLimit = theForm.total_records.value;
		for(i=1;i<maxLimit;i++)  // staring
		{
			var jpy = 'price_local'+i;
			var curr = 'curr'+i;
			
			jpyVal = document.getElementById(jpy).value;
			if(jpyVal>0)
			{
				newVal = parseInt((jpyVal * crate)/100);
				newVal = sym+' '+addCommas(newVal);
				document.getElementById(curr).innerHTML = newVal;
			}
			else
				document.getElementById(curr).innerHTML = 'ASK';
		}
	}
	// coding end for the price in similar vehicle box
	
	var xml_Http = getHttp();
	//xmlHttp1.onreadystatechange = showDesc;
	
	xml_Http.open("GET", "setCurrency.php?curr="+sym, true);
	xml_Http.send(null);
}


function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}