function WeightCalc(WeightIn,WeightOut,WeightVal){
var weightArray = xmldata( 0, core + 'extend/ext_wsquery.php?swtype=object&objectName=weightArray' );
weightArray = weightArray.split(",")
var main;
var cara = weightArray[0];
var mili = weightArray[1];
var tone = weightArray[2];
var quin = weightArray[3];
var deni = weightArray[4];
var once = weightArray[5];
var poun = weightArray[6];
var quar = weightArray[7];

if(WeightIn == "CARA")
	main = WeightVal * cara;
if(WeightIn == "MILI")
	main = WeightVal * mili;
if(WeightIn == "TONE")
	main = WeightVal * tone;
if(WeightIn == "MAIN")
	main = WeightVal;
if(WeightIn == "QUIN")
	main = WeightVal * quin;
if(WeightIn == "DENI")
	main = WeightVal * deni;
if(WeightIn == "ONCE")
	main = WeightVal * once;
if(WeightIn == "POUN")
	main = WeightVal * poun;
if(WeightIn == "QUAR")
	main = WeightVal * quar;

if(WeightOut == "CARA")
	result = main / cara;
if(WeightOut == "MILI")
	result = main / mili;
if(WeightOut == "TONE")
	result = main / tone;
if(WeightOut == "MAIN")
	result = main;
if(WeightOut == "QUIN")
	result = main / quin;
if(WeightOut == "DENI")
	result = main / deni;
if(WeightOut == "ONCE")
	result = main / once;
if(WeightOut == "POUN")
	result = main / poun;
if(WeightOut == "QUAR")
	result = main / quar;

return result;	
}


function weightcara(){
Invalue = eval(document.weight.cara.value);

document.forms['weight'].elements['mili'].value=FormatCurrencies(WeightCalc("CARA","MILI",Invalue));
document.forms['weight'].elements['tone'].value=FormatCurrencies(WeightCalc("CARA","TONE",Invalue));
document.forms['weight'].elements['main'].value=FormatCurrencies(WeightCalc("CARA","MAIN",Invalue));
document.forms['weight'].elements['quin'].value=FormatCurrencies(WeightCalc("CARA","QUIN",Invalue));
document.forms['weight'].elements['deni'].value=FormatCurrencies(WeightCalc("CARA","DENI",Invalue));
document.forms['weight'].elements['once'].value=FormatCurrencies(WeightCalc("CARA","ONCE",Invalue));
document.forms['weight'].elements['poun'].value=FormatCurrencies(WeightCalc("CARA","POUN",Invalue));
document.forms['weight'].elements['quar'].value=FormatCurrencies(WeightCalc("CARA","QUAR",Invalue));
}

function weightmili(){
Invalue = eval(document.weight.mili.value);

document.forms['weight'].elements['cara'].value=FormatCurrencies(WeightCalc("MILI","CARA",Invalue));
document.forms['weight'].elements['tone'].value=FormatCurrencies(WeightCalc("MILI","TONE",Invalue));
document.forms['weight'].elements['main'].value=FormatCurrencies(WeightCalc("MILI","MAIN",Invalue));
document.forms['weight'].elements['quin'].value=FormatCurrencies(WeightCalc("MILI","QUIN",Invalue));
document.forms['weight'].elements['deni'].value=FormatCurrencies(WeightCalc("MILI","DENI",Invalue));
document.forms['weight'].elements['once'].value=FormatCurrencies(WeightCalc("MILI","ONCE",Invalue));
document.forms['weight'].elements['poun'].value=FormatCurrencies(WeightCalc("MILI","POUN",Invalue));
document.forms['weight'].elements['quar'].value=FormatCurrencies(WeightCalc("MILI","QUAR",Invalue));
}

function weighttone(){
Invalue = eval(document.weight.tone.value);

document.forms['weight'].elements['cara'].value=FormatCurrencies(WeightCalc("TONE","CARA",Invalue));
document.forms['weight'].elements['mili'].value=FormatCurrencies(WeightCalc("TONE","MILI",Invalue));
document.forms['weight'].elements['main'].value=FormatCurrencies(WeightCalc("TONE","MAIN",Invalue));
document.forms['weight'].elements['quin'].value=FormatCurrencies(WeightCalc("TONE","QUIN",Invalue));
document.forms['weight'].elements['deni'].value=FormatCurrencies(WeightCalc("TONE","DENI",Invalue));
document.forms['weight'].elements['once'].value=FormatCurrencies(WeightCalc("TONE","ONCE",Invalue));
document.forms['weight'].elements['poun'].value=FormatCurrencies(WeightCalc("TONE","POUN",Invalue));
document.forms['weight'].elements['quar'].value=FormatCurrencies(WeightCalc("TONE","QUAR",Invalue));
}

function weightmain(){
Invalue = eval(document.weight.main.value);

document.forms['weight'].elements['cara'].value=FormatCurrencies(WeightCalc("MAIN","CARA",Invalue));
document.forms['weight'].elements['mili'].value=FormatCurrencies(WeightCalc("MAIN","MILI",Invalue));
document.forms['weight'].elements['tone'].value=FormatCurrencies(WeightCalc("MAIN","TONE",Invalue));
document.forms['weight'].elements['quin'].value=FormatCurrencies(WeightCalc("MAIN","QUIN",Invalue));
document.forms['weight'].elements['deni'].value=FormatCurrencies(WeightCalc("MAIN","DENI",Invalue));
document.forms['weight'].elements['once'].value=FormatCurrencies(WeightCalc("MAIN","ONCE",Invalue));
document.forms['weight'].elements['poun'].value=FormatCurrencies(WeightCalc("MAIN","POUN",Invalue));
document.forms['weight'].elements['quar'].value=FormatCurrencies(WeightCalc("MAIN","QUAR",Invalue));
}

function weightquin(){
Invalue = eval(document.weight.quin.value);

document.forms['weight'].elements['cara'].value=FormatCurrencies(WeightCalc("QUIN","CARA",Invalue));
document.forms['weight'].elements['mili'].value=FormatCurrencies(WeightCalc("QUIN","MILI",Invalue));
document.forms['weight'].elements['tone'].value=FormatCurrencies(WeightCalc("QUIN","TONE",Invalue));
document.forms['weight'].elements['main'].value=FormatCurrencies(WeightCalc("QUIN","MAIN",Invalue));
document.forms['weight'].elements['deni'].value=FormatCurrencies(WeightCalc("QUIN","DENI",Invalue));
document.forms['weight'].elements['once'].value=FormatCurrencies(WeightCalc("QUIN","ONCE",Invalue));
document.forms['weight'].elements['poun'].value=FormatCurrencies(WeightCalc("QUIN","POUN",Invalue));
document.forms['weight'].elements['quar'].value=FormatCurrencies(WeightCalc("QUIN","QUAR",Invalue));
}

function weightdeni(){
Invalue = eval(document.weight.deni.value);

document.forms['weight'].elements['cara'].value=FormatCurrencies(WeightCalc("DENI","CARA",Invalue));
document.forms['weight'].elements['mili'].value=FormatCurrencies(WeightCalc("DENI","MILI",Invalue));
document.forms['weight'].elements['tone'].value=FormatCurrencies(WeightCalc("DENI","TONE",Invalue));
document.forms['weight'].elements['main'].value=FormatCurrencies(WeightCalc("DENI","MAIN",Invalue));
document.forms['weight'].elements['quin'].value=FormatCurrencies(WeightCalc("DENI","QUIN",Invalue));
document.forms['weight'].elements['once'].value=FormatCurrencies(WeightCalc("DENI","ONCE",Invalue));
document.forms['weight'].elements['poun'].value=FormatCurrencies(WeightCalc("DENI","POUN",Invalue));
document.forms['weight'].elements['quar'].value=FormatCurrencies(WeightCalc("DENI","QUAR",Invalue));
}

function weightonce(){
Invalue = eval(document.weight.once.value);

document.forms['weight'].elements['cara'].value=FormatCurrencies(WeightCalc("ONCE","CARA",Invalue));
document.forms['weight'].elements['mili'].value=FormatCurrencies(WeightCalc("ONCE","MILI",Invalue));
document.forms['weight'].elements['tone'].value=FormatCurrencies(WeightCalc("ONCE","TONE",Invalue));
document.forms['weight'].elements['main'].value=FormatCurrencies(WeightCalc("ONCE","MAIN",Invalue));
document.forms['weight'].elements['quin'].value=FormatCurrencies(WeightCalc("ONCE","QUIN",Invalue));
document.forms['weight'].elements['deni'].value=FormatCurrencies(WeightCalc("ONCE","DENI",Invalue));
document.forms['weight'].elements['poun'].value=FormatCurrencies(WeightCalc("ONCE","POUN",Invalue));
document.forms['weight'].elements['quar'].value=FormatCurrencies(WeightCalc("ONCE","QUAR",Invalue));
}

function weightpoun(){
Invalue = eval(document.weight.poun.value);

document.forms['weight'].elements['cara'].value=FormatCurrencies(WeightCalc("POUN","CARA",Invalue));
document.forms['weight'].elements['mili'].value=FormatCurrencies(WeightCalc("POUN","MILI",Invalue));
document.forms['weight'].elements['tone'].value=FormatCurrencies(WeightCalc("POUN","TONE",Invalue));
document.forms['weight'].elements['main'].value=FormatCurrencies(WeightCalc("POUN","MAIN",Invalue));
document.forms['weight'].elements['quin'].value=FormatCurrencies(WeightCalc("POUN","QUIN",Invalue));
document.forms['weight'].elements['deni'].value=FormatCurrencies(WeightCalc("POUN","DENI",Invalue));
document.forms['weight'].elements['once'].value=FormatCurrencies(WeightCalc("POUN","ONCE",Invalue));
document.forms['weight'].elements['quar'].value=FormatCurrencies(WeightCalc("POUN","QUAR",Invalue));
}

function weightquar(){
Invalue = eval(document.weight.quar.value);

document.forms['weight'].elements['cara'].value=FormatCurrencies(WeightCalc("QUAR","CARA",Invalue));
document.forms['weight'].elements['mili'].value=FormatCurrencies(WeightCalc("QUAR","MILI",Invalue));
document.forms['weight'].elements['tone'].value=FormatCurrencies(WeightCalc("QUAR","TONE",Invalue));
document.forms['weight'].elements['main'].value=FormatCurrencies(WeightCalc("QUAR","MAIN",Invalue));
document.forms['weight'].elements['quin'].value=FormatCurrencies(WeightCalc("QUAR","QUIN",Invalue));
document.forms['weight'].elements['deni'].value=FormatCurrencies(WeightCalc("QUAR","DENI",Invalue));
document.forms['weight'].elements['once'].value=FormatCurrencies(WeightCalc("QUAR","ONCE",Invalue));
document.forms['weight'].elements['poun'].value=FormatCurrencies(WeightCalc("QUAR","POUN",Invalue));
}