	function finoPipCalcCalculate()
	{
		$("#finoPipCalc #pipResult")[0].innerHTML = "Please wait";
		var dd;
		var basePair;
		var to;
		var lotFloat; 

		basePair  = $("#finoPipCalc #basePair")[0].options[$("#finoPipCalc #basePair")[0].selectedIndex].value;
		to = $("#finoPipCalc #showIn")[0].options[$("#finoPipCalc #showIn")[0].selectedIndex].value;
		lotFloat = parseFloat($("#finoPipCalc #lot")[0].value);
		
		if(!(lotFloat>0))
		{
			$("#finoPipCalc #pipResult")[0].innerHTML = "<font color=Red>lot has to be greater than 0</font>";
			return true;
		}

		$.get("/FXQuotes.xml", function(data){
		
			$("/xml/product/name", data).each(
			function (i)
			{

				if(this.firstChild.nodeValue == basePair)
				{
					var rate;
					var pipValue;
					var rateCurrency;
					var pipBase = 0.0001;
					rateCurrency = basePair.substr(0,3);
					rate = parseFloat(this.parentNode.getElementsByTagName("ASK")[0].firstChild.nodeValue);
					$('#curPrice')[0].value=rate;
					if(basePair.substr(4,3) == 'JPY')
						pipBase = 0.01;
					if(basePair.substr(4,3) == 'CZK')
						pipBase = 0.001;
					if(basePair == 'JPY/ILS')
						pipBase = 0.000001;
					pipValue = (pipBase / rate) * 100000;

					if(rateCurrency == to)
					{
						$("#finoPipCalc #pipResult")[0].innerHTML = ((pipValue * lotFloat)).toFixed(2) + ' '+to;						
					}
					else{
						$("/xml/product/name", data).each(
						function (i)
						{
							var rate;
							if(this.firstChild.nodeValue == rateCurrency + '/' + to)
							{
								rate = parseFloat(this.parentNode.getElementsByTagName("ASK")[0].firstChild.nodeValue);
								$("#finoPipCalc #pipResult")[0].innerHTML = (rate*(pipValue * lotFloat)).toFixed(2) +  ' ' + to;
							}
							else if(this.firstChild.nodeValue == to + '/' + rateCurrency)
							{
								rate = parseFloat(this.parentNode.getElementsByTagName("ASK")[0].firstChild.nodeValue);
								$("#finoPipCalc #pipResult")[0].innerHTML = ((pipValue * lotFloat)/rate).toFixed(2) +  ' ' + to;
							}
						});	
						//We don't found the regular pair
						if($("#finoPipCalc #pipResult")[0].innerHTML == 'Please wait')
						{
							
							var rateFrom = 0;
							var rateTo = 0;
							$("/xml/product/name", data).each(
							function (i)
							{
								if(this.firstChild.nodeValue == rateCurrency + '/USD' || this.firstChild.nodeValue == 'USD/' + rateCurrency)
								{
									rateFrom = parseFloat(this.parentNode.getElementsByTagName("ASK")[0].firstChild.nodeValue);
								}
								else if(this.firstChild.nodeValue == to + '/USD' || this.firstChild.nodeValue == 'USD/' + to)
								{
									rateTo = parseFloat(this.parentNode.getElementsByTagName("ASK")[0].firstChild.nodeValue);
								}	
							});	
							var rate = rateTo/rateFrom;
							if(rateFrom != 0 && rateTo != 0)
							{
								$("#finoPipCalc #pipResult")[0].innerHTML = (rate*(pipValue * lotFloat)).toFixed(2) +  ' '+to;
			
							}
						}											
					}	
				}
			});	
		});
	}