
/************************************************* Gadget Content *****************************************************************/
/**********************************************************************************************************************************/

//Global Variable for clearing timeout...
var CTO;
function CalculatorContent()
{
	var strBuilder="";
	
	strBuilder+='<iframe id="CalcIFrame" src="" frameborder="0" scrolling="no" style="width:278px;position: absolute;visibility: hidden; top: 203px;left: 830px;height:253px;"></iframe>'; 		
	strBuilder += '<div id="CalcMainDiv" onload="DisableSelect();AlignSettingsCalc();CalcForeScreen();" onclick="CalcForeScreen();" style="width: 276px; position: absolute; background-color:white; visibility:hidden; top: 203px;left: 830px; border: solid 2px #a7c7e7;height:250px;" >';
	strBuilder += '<table cellpadding="0" cellspacing="0" border="0" width="100%">';
	strBuilder += '<tr id="CalcTitleTR" title="Currency Gadget - Double Click here to Minimize/Expand CalculatorDiv" style="height: 23px; cursor:move; background: url(/images/bgMainMenuActive.gif) repeat-x;" onmousedown="dragOBJ(document.getElementById(\'CalcMainDiv\'),event,document.getElementById(\'CalcIFrame\'),document.getElementById(\'CalcTitleTR\')); return false;" ondblclick="MinimizeCalcWindow(\'CalculatorDiv\');">';
	strBuilder += '<td style="width: 55%;text-align: left; border-bottom: solid 1px #a7c7e7;padding-left: 6px;">';
	strBuilder += '<b style="color:White; font-size:12px;">Currency Gadget</b></td>';
	strBuilder += '<td style="text-align: right;width: 65%; padding: 0px 0px 0px 0px;margin: 5px 0px 5px 0px; border-bottom: solid 1px #a7c7e7;">';
	strBuilder += '<table width="100%" cellpadding="0" cellspacing="0"><tr>';
	strBuilder += '<td style="width:55%;">&nbsp;</td>';
	strBuilder += '<td style="cursor:pointer;width:15%;" title="Select your Mode of Operation" onmouseover="Shade(this)" onmouseout="RShade(this)" onclick="ShowMW()">';
	strBuilder += '&nbsp;<img alt="Select your Mode of Operation" src="/images/mode.gif"> &nbsp;';
	strBuilder += '</td>';
	strBuilder += '<td id="CMinimizeL" style="cursor:pointer; width:15%; font-weight:bold; font-size:16px; color:White;" title ="Minimize" onmouseover="Shade(this)" onmouseout="RShade(this)" onclick="MinimizeCalcWindow(\'CalculatorDiv\');">';
	strBuilder += '&nbsp;_&nbsp;';
	strBuilder += '</td> ';
	strBuilder += '<td style="cursor:pointer; font-weight:bold; width:15%; font-size:16px; color:White;" id="CloseL" title="Close" onmouseover="Shade(this)" onmouseout="RShade(this)" onclick="CloseCalc();">';
	strBuilder += '&nbsp;X&nbsp;';
	strBuilder += '</td></tr></table></td></tr></table>';
	
	//Creating Mode Menu
	strBuilder += '<div id="ModeWindowDiv" style="width:100px; position:absolute; display:block; background:white; visibility:hidden;">';
	strBuilder += '<table cellpadding="0" cellspacing="0" width="100%" style="background-color: #ECF1F9; display:block; border:1px solid #1A5083;">';
	strBuilder += '<tr><td onmouseover="MShade(this)"onmouseout="MRShade(this)"><input type="radio" id="StandardC" checked="checked" name="Mode" style="border:0px;width:15px;" value="SC" onclick="HideMW();ChangeMode();" />';
	strBuilder += '</td><td style="vertical-align:middle;" ><label for="StandardC">Standard Calc </label> </td> </tr>';
	strBuilder += '<tr><td onmouseover="MShade(this)" onmouseout="MRShade(this)"><input type="radio" id="ExchangeC" name="Mode" style="border:0px;width:15px;" value="EC" onclick="HideMW();ChangeMode();" />';
	strBuilder += '</td><td style="vertical-align:middle;" ><label for="ExchangeC">Exchange Calc </label> </td> </tr>';
	strBuilder += '</table></div>';
	
	//Creating Exchange Rate Calc
	strBuilder += '<div id="ExRateCalc" style="padding-right:1px;width:274px;background-color:white; visibility:hidden;position:absolute;padding-bottom:5px;">';
	strBuilder += '<table id="ExRateTable" cellpadding="0" cellspacing="0" width="100%" style="padding-top:5px;">'
	strBuilder += '<tr>';
	strBuilder += '<td colspan="5" style="padding-left:7px;">';
	strBuilder += '<input type="text" id="ExRateInputT" style="width:260px;text-align:right;" value="0" onkeypress="InitializeInput(this);return OnlyNumbers(event);" onkeyup="return CheckNull(event)" />';
	strBuilder += '</td></tr>';
	strBuilder += '<tr><td colspan="5" style="height:11px;"></td></tr>';
	strBuilder += '<tr>';
	strBuilder += '<td style="padding-left:7px;width:20%;">From</td>';
	strBuilder += '<td style="width:25%;">';
	strBuilder += '<span id="ExDate1L"></span>';
	strBuilder += '</td>';
	strBuilder += '<td style="width:10%;valign:middle;">';
	//strBuilder += '<script language="javascript" type="text/javascript">';
	strBuilder += DateInput('ExDate1T', true, 'DD-MON-YYYY','ExDate1L',TodayDate(),false);
	//strBuilder += '</script>';
	strBuilder += '</td>';
	strBuilder += '<td style="width:28%">';
	strBuilder += '<select id="ExFromDDL" name="ExFromDDL" style="height: 18px; width:70px;" onchange="CalculatorAjax();">';
	strBuilder += '<option value="" selected="selected">Currency</option>';
						for(var i=0;i<selectedCurrencies.length;i++)
						{
							strBuilder += '<option value="' + selectedCurrencies[i] + '">' + selectedCurrencies[i] + '</option>';
						}
	strBuilder += '</select>';
	strBuilder += '</td>';
	strBuilder += '<td style="valign:bottom;text-align:left; width:17%;" title="Use this value for Calculation">';
	strBuilder += '<Button style="width:40px;" onclick="MovetoSTD();return false;"><span class="buttonLeft"  ><span class="buttonRight">Use</span></span></Button>';
	strBuilder += '</td></tr>';
	strBuilder += '<tr><td colspan="5" style="height:3px;"></td></tr>';
	strBuilder += '<tr>';
	strBuilder += '<td style="padding-left:7px;">To</td>';
	strBuilder += '<td>';
	strBuilder += '<span id="ExDate2L"></span>';
	strBuilder += '</td>';
	strBuilder += '<td style="valign:middle;">';
//	strBuilder += '<script language="javascript" type="text/javascript">';
	strBuilder += DateInput('ExDate2T', true, 'DD-MON-YYYY','ExDate2L',TodayDate(),false);
	//strBuilder += '</script>';
	strBuilder += '</td>';
	strBuilder += '<td>';
	strBuilder += '<select id="ExToDDL" name="ExToDDL" style="height: 18px; width:70px;" onchange="CalculatorAjax();">';
	strBuilder += '<option value="" selected="selected">Currency</option>';
						for(var i=0;i<selectedCurrencies.length;i++)
						{
							strBuilder += '<option value="' + selectedCurrencies[i] + '">' + selectedCurrencies[i] + '</option>';
						}
	strBuilder += '</select>';
	strBuilder += '</td>';
	strBuilder += '<td></td>';
	strBuilder += '</tr>';
	strBuilder += '<tr><td colspan="5" style="padding-left:7px;">';
	strBuilder += '<span id="ExResultL" style="color:black;"></span>';
	strBuilder += '</tr>';
	strBuilder += '</table>';
	strBuilder += '</div>';
	
	/////////////////////////////////////////ExRate Mode End here ////////////////////////////////
	
	////////////////////////////////////////CalculatorDiv Content here //////////////////////////////
	
	strBuilder += '<div id="CalculatorDiv" style="visibility:hidden; background-color:White; width:274px; padding-right:2px;">';
	strBuilder += '<table cellpadding="0" style="padding-top: 5px; width:100%">';
	strBuilder += '<tr>';
	strBuilder += '<td colspan="2" style="width:190px;padding: 5px 0px 0px 8px;">';
	strBuilder += '<input type="text" name="CalcInputT" id="CalcInputT" style="width: 179px; text-align: right; cursor:text;" value="0" ';
	strBuilder += 'onSelectStart="return false;" onmousedown="return false;" tabindex="0"';
	strBuilder += ' onkeypress="InitializeInput(this);return OnlyNumbers(event);" onkeyup="return CheckNull(event)" />';
	strBuilder += '</td>';
	strBuilder += '<td style="padding: 5px 0px 0px 0px;width:80px;">';
	strBuilder += '<select id="FromDDL" name="FromDDL" style="height: 18px; width:70px;" onchange="CalculatorAjax();">';
	strBuilder += '<option value="" selected="selected">Currency</option>';
						for(var i=0;i<selectedCurrencies.length;i++)
						{
							strBuilder += '<option value="' + selectedCurrencies[i] + '">' + selectedCurrencies[i] + '</option>';
						}
	strBuilder += '</select>';
	strBuilder += '</td>';
	strBuilder += '</tr>';
	strBuilder += '<tr><td colspan="2" style="width:190px;padding-left: 8px;">';
//	strBuilder += '<select id="FromDDL" name="FromDDL" style="height: 18px;" onchange="CalculatorAjax();">';
//	strBuilder += '<option value="" selected="selected">Currency</option>';
//				for(var i=0;i<selectedCurrencies.length;i++)
//				{
//					strBuilder += '<option value="' + selectedCurrencies[i] + '">' + selectedCurrencies[i] + '</option>';
//				}
//	strBuilder += '</select>';
//<!--A Textbox to display Exchange Rate value. Read only. -->
	strBuilder += '<input type="text" name="ExRateT" id="ExRateT" value="0" title="Click here to Get this Value for Calculation" style="width: 179px; text-align: right;" readonly="readonly" onclick="ExNo()" />';
	strBuilder += '</td><td style="width:80px;">';
	strBuilder += '<select id="ToDDL" name="ToDDL" style="height: 18px; width:70px;" onchange="CalculatorAjax();">';
	strBuilder += '<option value="" selected="selected">Currency</option>';
						for(var i=0;i<selectedCurrencies.length;i++)
						{
							strBuilder += "<option value=" + selectedCurrencies[i] + ">" + selectedCurrencies[i] + "</option>";
						}
	strBuilder += '</select></td>';
	strBuilder += '</tr>';
	strBuilder += '<td colspan="3" style="margin:0px 0px 0px 0px; height:12px; padding: 0px 0px 0px 0px;">';
	strBuilder += '<span id="CalcResultL" style="color:Red; height:10px; padding-left:5px; font-size:10px; ">&nbsp;</span>';
	strBuilder += '</td></tr>';
//	strBuilder += '<tr><td colspan="3">';
//	strBuilder += '<table cellpadding="0" cellspacing="0" border="0" width="100%">';
//	strBuilder += '<tr><td valign="middle" style="width: 23%;"></td>';
//	strBuilder += '<td style="width: 5%; text-align: left;"></td><td style="width: 22%"></td>';
//	strBuilder += '<td style="width: 50%; text-align: right;">';
//	strBuilder += '<table cellpadding="0" cellspacing="0" border="0">';
//	strBuilder += '<tr align="right"><td style="text-align: right; width: 25%;"></td>';
//	strBuilder += '<td style="text-align: right; width: 25%;"></td><td style="text-align: right; width: 25%;"></td>';
//	strBuilder += '<td style="text-align: right; width: 25%;"></td></tr></table>';
//	strBuilder += '</td></tr></table></td></tr>';
	strBuilder += '<tr>';
	strBuilder += '<td colspan="3" style="text-align: right; padding-bottom: 3px;">';
	strBuilder += '<table cellpadding="2" cellspacing="2" border="0" width="100%" align="center" id="ContentTable">';
	strBuilder += '<tr>';
	strBuilder += '<td colspan="2" style="width: 23%; text-align: left;">';
		//<!-- Display Date Here -->
	strBuilder += '<span id="CalcDateL" style="padding-left:4px;"></span>';
	
	strBuilder += '</td>';
	strBuilder += '<td style="width: 11.5%; padding-left:5px;">';
	//strBuilder += '<script language="javascript" type="text/javascript">';
	strBuilder +=  DateInput('GadgetDate', true, 'DD-MON-YYYY','CalcDateL',TodayDate(),false);
	//strBuilder += '</script>';
	strBuilder += '</td>';
	
	//strBuilder += '<td style="width: 11.5%;"></td>';
//	strBuilder += '<td style="width: 11.5%;">';
//	strBuilder += '<span class="buttonLeft" title="Factorial" style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'NFACT\',\'1\')"><span class="buttonRight">n! </span></span>';
//	strBuilder += '</td><td style="width: 11.5%;">';
//	strBuilder += '<span class="buttonLeft" title="Mod Of" style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'MOD\',\'2\')"><span class="buttonRight">Mod </span></span>';
//	strBuilder += '</td>';
	strBuilder += '<td style="width: 11.5%" title="Percentage">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'PERCENT\',\'3\');return false;"><span class="buttonLeft"><span class="buttonRight">% </span></span></Button>';
	strBuilder += '</td>';
	strBuilder += '<td style="width: 11.5%" title="Backspace">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'BS\',\'0\');return false;"><span class="buttonLeft"  ><span class="buttonRight">BS </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%" title="Clear">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'CLEAR\',\'0\');return false;"><span class="buttonLeft" ><span class="buttonRight">C </span></span></Button>';
	strBuilder += '</td></tr><tr>';
//	strBuilder += '<td style="width: 11.5%; text-align: left;">';
//	strBuilder += '<span class="buttonLeft" title="X to the Power Y" style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'XPY\',\'2\')"><span class="buttonRight">X^Y </span></span>';
//	strBuilder += '</td>';
	strBuilder += '<td style="width: 11.5%;" title="Memory Clear">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'MC\',\'1\');return false;"><span class="buttonLeft" ><span class="buttonRight">MC </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 7">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'7\',\'0\');return false;"><span class="nButtonLeft" ><span class="nButtonRight">7 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 8" >';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'8\',\'0\');return false;"><span class="nButtonLeft" ><span class="nButtonRight">8 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 9">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'9\',\'0\');return false;"><span class="nButtonLeft" ><span class="nButtonRight">9 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Change Number\'s Sign">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'PM\',\'1\');return false;"><span class="buttonLeft" ><span class="buttonRight"> &plusmn; </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%" title="1 Divided by X">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'1/X\',\'1\');return false;"><span class="buttonLeft" ><span class="buttonRight">1/X </span></span></Button>';
	strBuilder += '</td>';
//	strBuilder += '<td style="width: 11.5%">';
//	strBuilder += '<span class="buttonLeft" title="Square Root" style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'SQRT\',\'1\')"><span class="buttonRight">SQRT </span></span>';
//	strBuilder += '</td>';
	strBuilder += '</tr><tr>';
//	strBuilder += '<td style="width: 11.5%; text-align: left;">';
//	strBuilder += '<span class="buttonLeft" title="X to the Power 4" style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'XP4\',\'1\')"><span class="buttonRight">X^4 </span></span>';
//	strBuilder += '</td>';
	strBuilder += '<td style="width: 11.5%;" title="Memory Store" > ';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'MS\',\'1\');return false;"><span class="buttonLeft" ><span class="buttonRight">MS </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 4">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'4\',\'0\');return false;"><span class="nButtonLeft"  ><span class="nButtonRight">4 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 5" >';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'5\',\'0\');return false;"><span class="nButtonLeft" ><span class="nButtonRight">5 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 6" >';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'6\',\'0\');return false;"><span class="nButtonLeft" ><span class="nButtonRight">6 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Addition" >';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'ADD\',\'2\');return false;"><span class="buttonLeft" ><span class="buttonRight">+ </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%" title="Multiplication" >';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'MUL\',\'2\');return false;"><span class="buttonLeft" ><span class="buttonRight">&times; </span></span></Button>';
	strBuilder += '</td>';
//	strBuilder += '<td style="width: 11.5%">';
//	strBuilder += '<span class="buttonLeft" title="Percentage" style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'PERCENT\',\'2\')"><span class="buttonRight">% </span></span>';
//	strBuilder += '</td>';
	strBuilder += '</tr><tr>';
//	strBuilder += '<td style="width: 11.5%; text-align: left;">';
//	strBuilder += '<span class="buttonLeft" title="X to the Power 3" style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'XP3\',\'1\')"><span class="buttonRight">X^3 </span></span>';
//	strBuilder += '</td>';
	strBuilder += '<td style="width: 11.5%;" title="Memory Recall" >';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'MR\',\'1\');return false;"><span class="buttonLeft" ><span class="buttonRight">MR </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 1" >';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'1\',\'0\');return false;"><span class="nButtonLeft" ><span class="nButtonRight">1 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 2" >';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'2\',\'0\');return false;"><span class="nButtonLeft" ><span class="nButtonRight">2 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 3">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'3\',\'0\');return false;"><span class="nButtonLeft" ><span class="nButtonRight">3 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Subtraction">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'SUB\',\'2\');return false;"><span class="buttonLeft" ><span class="buttonRight">- </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%" title="Division">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'DIV\',\'2\');return false;"><span class="buttonLeft" ><span class="buttonRight"> &divide; </span></span></Button>';
	strBuilder += '</td>';
//	strBuilder += '<td style="width: 11.5%">';
//	strBuilder += '<span class="buttonLeft" title="Log of" style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'LOG\',\'1\')"><span class="buttonRight">Log </span></span>';
//	strBuilder += '</td>';
	strBuilder += '</tr><tr>';
//	strBuilder += '<td style="width: 11.5%; text-align: left;">';
//	strBuilder += '<span class="buttonLeft" title="X to the Power 2" style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'XP2\',\'1\')"><span class="buttonRight">X^2 </span></span>';
//	strBuilder += '</td>';
	strBuilder += '<td style="width: 11.5%;" title="Memory Plus">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'MP\',\'1\');return false;"><span class="buttonLeft" ><span class="buttonRight">M+ </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 0">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'0\',\'0\');return false;"><span class="nButtonLeft"  ><span class="nButtonRight">0 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 00">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'00\',\'0\');return false;"><span class="nButtonLeft"  ><span class="nButtonRight">00 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Numeric 000">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'000\',\'0\');return false;"><span class="nButtonLeft"  ><span class="nButtonRight">000 </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%;" title="Decimal Point">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'DOT\',\'0\');return false;"><span class="buttonLeft"  ><span class="buttonRight">. </span></span></Button>';
	strBuilder += '</td><td style="width: 11.5%" title="View Result">';
	strBuilder += '<Button style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'=\',\'0\');return false;"><span class="buttonLeft"  ><span class="buttonRight">= </span></span></Button>';
	strBuilder += '</td>';
//	strBuilder += '<td style="width: 11.5%">';
//	strBuilder += '<span class="buttonLeft" title="PI Value" style="cursor: pointer; width: 35px;" onclick="CalcOperation(\'PI\',\'1\')"><span class="buttonRight">PI </span></span>';
//	strBuilder += '</td>';
	strBuilder += '</tr></table>';
	strBuilder += '</td></tr></table>';
	strBuilder += '</td> </tr> </table>';
	strBuilder += '</div>';
	strBuilder += '</div>';
	
	return strBuilder;
}

function TodayDate()
{
	var today=new Date();
	return today.getDay()+ "-" + today.getMonth()-1 + "-" + today.getFullYear();
}

function ShowCalc()
{
	
	document.getElementById("CalcIFrame").style.visibility = 'visible';
	document.getElementById('CalcIFrame').style.height="251px";
	document.getElementById('CalcIFrame').style.top="218px";
	document.getElementById('CalcIFrame').style.left="830px";
	document.getElementById('CalcMainDiv').style.visibility='visible';
	document.getElementById('CalcMainDiv').style.top="218px";
	document.getElementById('CalcMainDiv').style.left="830px";
	
	if(document.getElementById("StandardC").checked)
		document.getElementById('CalculatorDiv').style.visibility='visible';
	else
		document.getElementById('ExRateCalc').style.visibility='hidden';
	
	ChangeMode();

	CalcForeScreen();
	StableHeader(document.getElementById('CalcTitleTR'));
}

//Getting window in to front than others.
function CalcForeScreen()
{	
	if(!document.all)
	{
		document.getElementById('ContentTable').style.height="150px";
	}
	document.getElementById('CalcIFrame').style.height=parseInt(document.getElementById("CalcMainDiv").style.height.replace("px",""))+2+"px";
	var eid=document.getElementById('MailDiv');	
	var id=document.getElementById('TimeZoneDiv');	
	var cid=document.getElementById('CalcMainDiv');
	
	cid.style.zIndex="2000";	
	if(eid){eid.style.zIndex="100";}	
	if(id){ id.style.zIndex="100";TZCTitleMouseOver();}
}

function CloseCalc()
{
	document.getElementById('CalcMainDiv').style.visibility='hidden';
	document.getElementById('CalcIFrame').style.visibility='hidden';
	document.getElementById('CalculatorDiv').style.visibility='hidden';
	document.getElementById('ModeWindowDiv').style.visibility='hidden';
	document.getElementById('ExRateCalc').style.visibility='hidden';
	
	if(GadgetDate_Object.isShowing())
	{
		GadgetDate_Object.show();
	}
	if(ExDate1T_Object.isShowing())
	{
		ExDate1T_Object.show();
	}
	if(ExDate2T_Object.isShowing())
	{
		ExDate2T_Object.show();
	}
}

function DisableSelect() 
{
	document.onselectstart = function() {return false;} // ie
	document.onmousedown = function() {return false;} // mozilla
}

function AlignSettingsCalc()
{
	if (!document.all)
	{
		document.getElementById("FromDDL").style.height="16px";
		document.getElementById("ToDDL").style.height="16px";
		document.getElementById("CalcInputT").style.width ="179px";
		document.getElementById("ExRateT").style.width ="179px";
	}
}

function HideMW()
{
	//setTimeout('document.getElementById("ModeWindowDiv").style.visibility="hidden"',3000);
	document.getElementById("ModeWindowDiv").style.visibility="hidden";
}

function ShowMW()
{
	var wnd = document.getElementById("ModeWindowDiv");
	wnd.style.visibility = "visible";
	wnd.style.zIndex="3010";
	clearTimeout(CTO);
	CTO = setTimeout("HideMW()",5000);
	
	var versionInfo=navigator.appVersion;
	
	//Checking version 6.0
	if(versionInfo.substring(22,25) == "6.0")
	{
		wnd.style.left = "95px";
	}
	else
	{
		wnd.style.left = "175px";
	}
	
	wnd.style.top = "25px";	
}

function ChangeMode()
{
	if(document.getElementById("StandardC").checked)
	{
		document.getElementById("CalculatorDiv").style.visibility = 'visible';
	
		document.getElementById("ModeWindowDiv").style.visibility='hidden';
		document.getElementById("CalculatorDiv").style.position = 'relative';
		document.getElementById("ExRateCalc").style.position='absolute';
		document.getElementById("ExRateCalc").style.visibility='hidden';
		document.getElementById("CalcMainDiv").style.height = '250px';
	}
	else
	{
		document.getElementById("ExRateCalc").style.visibility = 'visible';
	
		document.getElementById("ModeWindowDiv").style.visibility='hidden';
		document.getElementById("CalculatorDiv").style.position = 'absolute';
		document.getElementById("CalculatorDiv").style.visibility='hidden';
		document.getElementById("ExRateCalc").style.position='relative';
		document.getElementById("CalcMainDiv").style.height = '157px';
	}
	CalcForeScreen();
	document.getElementById("CMinimizeL").innerHTML = "&nbsp;_&nbsp;";
	document.getElementById("CMinimizeL").style.border="0px";
	document.getElementById("CMinimizeL").title = "Minimize";
}

//Make Shading while Cursor Moves over mode window..
function MShade(ctl)
{
	ctl.style.background="#a7c7e7";
}

// Remove Shading while Cursor Out for mode window.
function MRShade(ctl)
{
	ctl.style.background="";
}

//Load values to text box while click in value received.
function MovetoEx(val)
{
	document.getElementById("ExRateInputT").value = val;
}

//Function for Use button. This will swap mode and place the value in Standar mode for calculation.
function MovetoSTD()
{
	document.getElementById("StandardC").checked=true;
	ChangeMode();
	document.getElementById("CalcInputT").value=document.getElementById("ExRateInputT").value
}

/*****************************************************************************************************************************************/


/// Main functions to Execute Currency Gadjet with content..
/*
* Developed for Fedby Information Services.
*
*
*/
//Global Variables for Currencies.
//Hardcoded Value to Display selected Currencies.
var selectedCurrencies= new Array("EUR", "GBP", "CHF", "USD", "AUD", "CAD", "HKD", "INR", "JPY", "SAR", "SGD", "ZAR", "SEK", "AED" );
var CurrencyName=new Array("Euro",
									"Great Britain Pounds",
									"Swiss Franc",
									"United States of America Dollars",
									"Australian Dollar",
									"Canadian Dollar",
									"Hong Kong Dollars",
									"Indian Rupee",
									"Japan, Yen",
									"Saudi Riyal",
									"Singapore Dollar",
									"South African Rand",
									"Sweden Kronor",
									"United Arab Emirates Dirham");	
																			
//Global Variables for CalculatorDiv.
var AgainOpn=false;
var newOpn = false;
var strMemory="0";
var PrimaryNo=parseFloat("0");
var SecondNo=parseFloat("0");
var ThirdNo=parseFloat("0");
var CurrentOpn="";
var OpnSelected=false;
var againEqual=false;

//Minimize Window is the function to Minimise Currency Gadjet Window.
//To Minimise Current Window to Bottom.
//<params> Div Id  </params>
function MinimizeCalcWindow(divID)
{
	//Code here for Minimising Div.
	if(document.getElementById("StandardC").checked)
	{
		if(document.getElementById(divID).style.visibility == 'visible')
		{
			document.getElementById(divID).style.visibility = 'hidden';
		
			document.getElementById("ModeWindowDiv").style.visibility='hidden';
			document.getElementById("CalcMainDiv").style.height = '21px';
			document.getElementById("CMinimizeL").innerHTML = "<img src='/images/shape_square.png' style='border:#FFFFFF solid 1px; height:11px;' alt='Maximize'/>&nbsp;";
			document.getElementById("CMinimizeL").style.verticalAlign = "middle";
			document.getElementById("CMinimizeL").title ="Maximize";
		}
		else
		{
			document.getElementById(divID).style.visibility = 'visible';
		
			document.getElementById("ModeWindowDiv").style.visibility='hidden';
			document.getElementById("CalcMainDiv").style.height = '250px';
			document.getElementById("CMinimizeL").innerHTML = "&nbsp;_&nbsp;";
			document.getElementById("CMinimizeL").style.verticalAlign = "bottom";
			document.getElementById("CMinimizeL").style.border="0px";
			document.getElementById("CMinimizeL").title = "Minimize";
		}
	}
	else
	{
		if(document.getElementById("ExRateCalc").style.visibility == 'visible')
		{
			document.getElementById("ExRateCalc").style.visibility = 'hidden';
		
			document.getElementById("ModeWindowDiv").style.visibility='hidden';
			document.getElementById("CalcMainDiv").style.height = '21px';
			document.getElementById("CMinimizeL").innerHTML = "<img src='/images/shape_square.png' style='border:#FFFFFF solid 1px; height:16px;' alt='Maximize'/>";
			document.getElementById("CMinimizeL").style.verticalAlign = "bottom";
			document.getElementById("CMinimizeL").title ="Maximize";
		}
		else
		{
			document.getElementById("ExRateCalc").style.visibility = 'visible';
		
			document.getElementById("ModeWindowDiv").style.visibility='hidden';
			document.getElementById("CalcMainDiv").style.height = '174px';
			document.getElementById("CMinimizeL").innerHTML = "&nbsp;_&nbsp;";
			document.getElementById("CMinimizeL").style.border="0px";
			document.getElementById("CMinimizeL").title = "Minimize";
		}
	}
	CalcForeScreen();
}

//Make shading while Cursor Moves.

function Shade(ctl)
{
	ctl.style.background="#1A5083";
}

// Remove Shading while Cursor Out.
function RShade(ctl)
{
	ctl.style.background="";
}

//Ajax Function Starting Here....

function CalculatorAjax()
{
	var xmlHttp;
	var dispContent;
	try
	  {  
		// Firefox, Opera 8.0+, Safari  
		xmlHttp=new XMLHttpRequest();  
	  }
	  catch (e)
	  {  // Internet Explorer  
		  try
			 {    
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");   
			 }
			catch (e)
			{    
				try
				{      
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
				}
				catch (e)
				{      
					alert("Your browser does not support AJAX!");      
					return false;     
				}    
			}		
		}
	  xmlHttp.onreadystatechange=function()
	  {
		 if(xmlHttp.readyState==4)
		 {
			var result=xmlHttp.responseText;
			var splitResult=new Array();
			
			if(document.getElementById("StandardC").checked)
			{
				splitResult=result.split(",");

				if(!isNaN(Math.round(splitResult[0] * 10000)/10000))
				{
					if(document.getElementById("CalcInputT").value != "" && document.getElementById("CalcInputT").value != "0")
					{
						document.getElementById("ExRateT").value= parseFloat(document.getElementById("CalcInputT").value) * Math.round(splitResult[0] * 10000)/10000;
					}
					else
					{
						document.getElementById("ExRateT").value= Math.round(splitResult[0] * 10000)/10000;
					}
						
				 dispContent="Rate of " + document.getElementById("ToDDL").value + " vs One " + document.getElementById("FromDDL").value + " is :" + Math.round(splitResult[0] * 10000)/10000;
				 	 							 
				  document.getElementById("CalcResultL").style.color="black";
				  document.getElementById("CalcResultL").innerHTML=dispContent;
				}
				else
					document.getElementById("ExRateT").value="Not Available!";
					
				if(splitResult[1] == "1")
				{
					document.getElementById("CalcDateL").style.color="red";
					document.getElementById("CalcDateL").innerHTML="<Marquee scrolldelay=150> History applicable for Past Dates only, so today date Considered. </Marquee>";
					document.getElementById("CalcDateL").style.color="#000000";
				}
			}
			else
			{
				splitResult=result.split(",");
				clearTimeout(CTO);
				document.getElementById("ExResultL").innerHTML=splitResult[0];
				
				if(!isNaN(parseFloat(splitResult[1])))
					document.getElementById("ExRateInputT").value=splitResult[1];
				else
					document.getElementById("ExRateInputT").value="Not Available!";
			}
		 }
	  }
		if(document.getElementById("StandardC").checked)
  		{
  			 if(document.getElementById("FromDDL") && document.getElementById("ToDDL"))
  			 {
  				 if(document.getElementById("FromDDL").value != "" && document.getElementById("ToDDL").value != "")
				 {
					  if(CheckCurrency())
					  {
  							if(document.getElementById("FromDDL").value == "AED" || document.getElementById("ToDDL").value == "AED")
							  {
								  document.getElementById("CalcResultL").innerHTML="Currently this Currency type is Not Available!";
								  document.getElementById("ExRateT").value="0";
								  xmlHttp=false;
							  }
							  else
							  {
  								  document.getElementById("ExRateT").value="Loading......";
  								  document.getElementById("CalcResultL").innerHTML="";
  								  xmlHttp.open("POST","/Tools/GetForExRate.aspx",true);
								  xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
								  xmlHttp.send(getQueryString());
								  document.getElementById("CalcResultL").style.color="#000000";
								  document.getElementById("CalcResultL").innerHTML="Click this, to do Calculations with it <b>^</b>";
								  setTimeout('DisplayCurrencyName(document.getElementById("FromDDL"),document.getElementById("ToDDL"))',2000);
								  CTO=setTimeout('document.getElementById("CalcResultL").innerHTML="";document.getElementById("CalcResultL").style.color="red"',5000);
							
							  }
						
					  }
					  else
					  {
						  document.getElementById("CalcResultL").style.color = "red";
						  clearTimeout(CTO);
						  document.getElementById("CalcResultL").innerHTML="Selected Currencies are Same!";
						  document.getElementById("ExRateT").value="0";
						  xmlHttp=false;
					  }
				 }
				 else 
				 {	
						DisplayCurrencyName(document.getElementById("FromDDL"),document.getElementById("ToDDL"));
				}
			}
		}
		else
		{
			if(document.getElementById("ExFromDDL") && document.getElementById("ExToDDL"))
			 {	
				if(document.getElementById("ExFromDDL").value != "" && document.getElementById("ExToDDL").value != "")
				 {
					  if(CheckCurrency())
					  {
						  if(document.getElementById("ExFromDDL").value == "AED" || document.getElementById("ExToDDL").value == "AED")
						  {
							  document.getElementById("ExResultL").innerHTML="Currently this Currency type is Not Available!";
							  xmlHttp=false;
						  }
						  else
						  {
							  document.getElementById("ExResultL").style.color = "black";
							  document.getElementById("ExResultL").innerHTML="Loading....";
							  document.getElementById("CalcResultL").innerHTML="";
							  xmlHttp.open("POST","/Tools/GetForExRate.aspx",true);
							  xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
							  xmlHttp.send(getQueryString());
						  }
						}
					  else
					  {
						  document.getElementById("ExResultL").style.color = "red";
						  document.getElementById("ExResultL").innerHTML="Selected Currencies are Same!";
						  xmlHttp=false;
					  }
				 }
				 else 
				 {	
						DisplayCurrencyName(document.getElementById("ExFromDDL"),document.getElementById("ExToDDL"));
						CTO=setTimeout('document.getElementById("ExResultL").innerHTML="";',5000);
				 }
			}
		}
  }
 
 function DisplayCurrencyName(ctl,ctl1)
 {
	var curr1="",curr2="";
	
	for(var i=0; i < selectedCurrencies.length ; i++)
	{
		if(ctl.value == selectedCurrencies[i])
		{
			curr1=CurrencyName[i];
		}
		if(ctl1.value == selectedCurrencies[i])
		{
			curr2=CurrencyName[i];
		}
	}
	if(document.getElementById("StandardC").checked)
	{
		document.getElementById("CalcResultL").style.color="#000000";
		document.getElementById("CalcResultL").innerHTML=curr1;
		if(curr1 == "" || curr2 == "")
		 document.getElementById("CalcResultL").innerHTML=curr1 + curr2 
		else
		 document.getElementById("CalcResultL").innerHTML=curr1 + ", " + curr2;
	}
	else
	{
		document.getElementById("ExResultL").style.color="#000000";
		document.getElementById("ExResultL").innerHTML=curr1;
		if(curr1 == "" || curr2 == "")
		 document.getElementById("ExResultL").innerHTML=curr1 + curr2 
		else
		 document.getElementById("ExResultL").innerHTML=curr1 + ", " + curr2;
	}
 } 	
 
 function ExNo()
 {
	if(document.getElementById("ExRateT").value != "0" && ! isNaN(document.getElementById("ExRateT").value))
	{
		document.getElementById("CalcInputT").value=document.getElementById("ExRateT").value;
	}
 } 
 
 function CheckCurrency()
 {
	var returnVal=false;
	var fromC=document.getElementById("FromDDL").value;
	var toC=document.getElementById("ToDDL").value;
	var ExfromC=document.getElementById("ExFromDDL").value;
	var ExtoC=document.getElementById("ExToDDL").value;
	
	if(fromC != toC && document.getElementById("StandardC").checked)
	{
		returnVal=true;
	}
	if(ExfromC != ExtoC)
	{
		returnVal=true;
	}
	
	return returnVal;
 }
  
  function getQueryString()
  {
	 
		var strPass="";
		
		if(document.getElementById("StandardC").checked)
		{
			strPass="FromDDL=" + document.getElementById("FromDDL").value;
			strPass+="&ToDDL="+document.getElementById("ToDDL").value;
			strPass += "&GivenDate1=" + document.getElementById("CalcDateL").innerHTML;
			strPass += "&Mode=0";
		}
		else
		{
			strPass="FromDDL=" + document.getElementById("ExFromDDL").value;
			strPass+="&ToDDL="+document.getElementById("ExToDDL").value;
			strPass += "&GivenDate1=" + document.getElementById("ExDate1L").innerHTML;
			strPass += "&GivenDate2=" + document.getElementById("ExDate2L").innerHTML;
			strPass += "&Mode=1";
		}
		
		return strPass;
	
  }
  
 function OnlyNumbers(e)
 {
	var keycode= (e.keyCode) ? e.keyCode : e.which;
	
	if(keycode==27)
	{
		document.getElementById("CalcInputT").value="0";
		return true;
	}
	if(keycode==8 || keycode==9 || keycode==37 || keycode==46 || (keycode>= 48 && keycode<=57))
	{
		if(keycode==46 && !CheckDot())
		{
			return true;
		}
		else if(keycode >= 48 && keycode <=57)
		{
			InitializeInput(document.getElementById('CalcInputT'));
			CalcOperation(String.fromCharCode(keycode),'0');
			return false;
		}
		else
		{
			return false;
		}
	}
	else if(keycode==43)
	{
		//Addition operation
		CalcOperation("ADD",2); 
		return false;	
	}
	else if(keycode==45)
	{
		//Multiplication operation
		CalcOperation("SUB",2);
		return false;	 	
	}
	else if(keycode==42)
	{
		//Multiplication operation
		CalcOperation("MUL",2); 
		return false;		
	}
	else if(keycode==47)
	{
		//Division operation
		CalcOperation("DIV",2); 
		return false;		
	}
	else if(keycode==61 || keycode == 13)
	{
		//Either Enter or Equal to Pressed, View Result operation
		CalcOperation("=",1); 
		return false;		
	}
	else
	{
		return false;
	}
 }

 function InitializeInput(InputCtl)
 {
	if(InputCtl.value == "0")
	{
		InputCtl.value="";		
	}
	else if(InputCtl.value == "Infinity" || InputCtl.value == "NaN")
	{
		OpnSelected=false;
		CurrentOpn="";
		newOpn=true;
	}
	else if(InputCtl.value=="")
	{
		InputCtl.value="0";
	}
 }


function CalcOperation(opn,key)
{
	ctl=document.getElementById("CalcInputT");
	
	if(opn != "=")
	{
		if(key != "3" && key != "1")
		{
			againEqual = false;
		}
		if (key == "2")
		{
			if(OpnSelected)
			{ 
				if(!newOpn)
				{
					DoOperation(ctl,CurrentOpn);
					PrimaryNo=parseFloat(ctl.value);
					CurrentOpn = opn;
				}
				else
				{
					PrimaryNo=parseFloat(ctl.value);
					CurrentOpn=opn;
				}
				newOpn = true;
			}
			else
			{
				OpnSelected=true;
				newOpn=true;
				PrimaryNo=parseFloat(ctl.value);
				CurrentOpn=opn;
			}
		}
		else if(key == "1")
		{
			DoOperation(ctl,opn);
			if(opn != "PM")
			{
				newOpn = true;
			}
		}
		else if(key == "0")
		{
			if(ctl.value == "Infinity" || ctl.value == "NaN")
			{
				InitializeInput(ctl);
			}
			if(opn != "BS")
			{	
				if(newOpn)
				{
					ctl.value="0";
					newOpn=false;
				}
			}
			DoOperation(ctl,opn);
		}
		else if(key == "3")
		{
			if(OpnSelected)
			{
				DoOperation(ctl,opn);
			}
			else if(againEqual)
			{
				PrimaryNo=parseFloat(ctl.value);
				DoOperation(ctl,opn);
				ThirdNo=parseFloat(ctl.value);
				OpnSelected=false;
				newOpn=true;
			}
			else
			{
				ctl.value= "0";
			}
		}
	}
	else
	{
		if(!againEqual)
			SecondNo=parseFloat(ctl.value);
		
		if(ThirdNo != 0)
		{
			SecondNo=ThirdNo;
			ThirdNo=parseFloat("0");
		}
		
		DoOperation(ctl,CurrentOpn);
		
		if(!againEqual)
			againEqual = true;
			
		OpnSelected=false;
		newOpn=true;
		
		PrimaryNo=SecondNo;
	}
}

function DoOperation(control,COpn)
{
	document.getElementById("CalcResultL").style.color = "black";
	switch(COpn)
	{
		case "XPY":
			control.value=Math.pow(PrimaryNo,ctl.value);
			break;
		case "XP4":
			control.value=Math.pow(PrimaryNo,4);
			AgainOpn=true;
			break;
		case "XP3":
			control.value=Math.pow(PrimaryNo,3);
			AgainOpn=true;
			break;
		case "XP2":
			control.value=Math.pow(PrimaryNo,2);
			AgainOpn=true;
			break;
		case "MC":
			strMemory ="0";
			AgainOpn=true;
			break;
		case "MS":
			strMemory=control.value;
			AgainOpn=true;
			break;
		case "MR":
			control.value=strMemory;
			AgainOpn=true;
			break;
		case "MP":
			strMemory = parseFloat(strMemory)+parseFloat(control.value);
			AgainOpn=true;
			break;
		case "7":
			InitializeInput(control);
			control.value=control.value + "7";
			break;
		case "4":
			InitializeInput(control);
			control.value=control.value + "4";
			break;
		case "1":
			InitializeInput(control);
			control.value=control.value + "1";
			break;
		case "0":
			AddZero(control,"0");
			break;
		case "8":
			InitializeInput(control);
			control.value=control.value + "8";
			break;
		case "5":
			InitializeInput(control);
			control.value=control.value + "5";
			break;
		case "2":
			InitializeInput(control);
			control.value=control.value + "2";
			break;
		case "00":
			AddZero(control,"00");
			break;
		case "NFACT":
			control.value=NFactorial(parseFloat(control.value));
			AgainOpn=true;
			break;
		case "9":
			InitializeInput(control);
			control.value=control.value + "9";
			break;
		case "6":
			InitializeInput(control);
			control.value=control.value + "6";
			break;
		case "3":
			InitializeInput(control);
			control.value=control.value + "3";
			break;
		case "000":
			AddZero(control,"000");
			break;
		case "MOD":
			control.value=Mod(parseFloat(control.value));
			AgainOpn=true;
			break;
		case "PM":
			if(parseFloat(control.value) > 0)
			{
				var temp=parseFloat(control.value);
				temp=temp - (temp * 2);
				control.value=temp;
			}
			else if(parseFloat(control.value) < 0)
			{
				var temp=parseFloat(control.value);
				temp=(-temp * 2)+ temp;
				control.value=temp;
			}
			else
			{
				control.value="0";
			}
			break;
		case "ADD":
			control.value = PrimaryNo + parseFloat(control.value);
			break;
		case "SUB":
			if(!againEqual)
				control.value = PrimaryNo - parseFloat(control.value);
			else
				control.value = parseFloat(control.value) - PrimaryNo  ;
			break;
		case "DOT":
			if(!CheckDot())
				control.value=control.value + ".";
			break;
		case "BS":
			if(!OpnSelected)
			{
				BackSpace(control);
			}
			document.getElementById("CalcResultL").innerHTML = "";
			break;
		case "DIV":
			if(!againEqual)
				control.value = parseFloat(PrimaryNo / control.value);
			else
				control.value = parseFloat(control.value /PrimaryNo );
			break;
		case "MUL":
			sc=parseFloat(control.value);
			control.value = PrimaryNo * parseFloat(control.value);
			break;
		case "1/X":
			control.value=(1/parseFloat(control.value));
			AgainOpn=true;
			break;
		case "CLEAR":
			ClearTextField();
			document.getElementById("CalcResultL").innerHTML = "";
			break;
		case "SQRT":
			control.value=Math.sqrt(parseFloat(control.value));
			AgainOpn=true;
			break;
		case "PERCENT":
			sc=parseFloat(control.value);
			control.value=Percentage(PrimaryNo, parseFloat(control.value));
			break;
		case "LOG":
			control.value=Math.log(parseFloat(control.value));
			AgainOpn=true;
			break;
		case "PI":
			control.value=Math.PI;
			break;
	}
}

function ClearTextField()
{
	CurrentOpn="";
	PrimaryNo=parseFloat("0");
	SecondNo=parseFloat("0");
	ThirdNo=parseFloat("0");
	OpnSelected=false;
	CurrentOpn="";
	newOpn=true;
	document.getElementById("CalcInputT").value="0";
	document.getElementById("ExRateInputT").value="0";
	document.getElementById("ExRateT").value="0";
	document.getElementById("FromDDL").value="";
	document.getElementById("ToDDL").value="";
	document.getElementById("ExFromDDL").value="";
	document.getElementById("ExToDDL").value="";
}

function BackSpace(control)
{
	if(control.value != "Infinity")
	{
		control.value=control.value.substring(0,control.value.length-1);
		if(control.value.length <=0)
			control.value="0";
	}
	else
	{
		control.value = "0";
	}
}

function AddZero(control,val)
{
	if(CheckDot() || (parseFloat(control.value) != 0) )
		control.value = control.value + val;
}

function NFactorial (n)
{ 
    if(n==0) return(1);

    return (n * NFactorial (n-1) );
}

function Mod(n)
{
	return (PrimaryNo - (parseInt(PrimaryNo / n) * parseInt(n)));
}

function Percentage(a,b)
{
	var temp;
	temp = parseFloat(a/100);
	temp = temp * b;
	return temp;
}

function CheckDot()
{
	var temp=document.getElementById("CalcInputT").value;
		for(var i=0; i<temp.length; i++)
		{
			if(temp.substring(i,i+1) == ".")
			{
				return true;
			}
		}
		return false;
}

function CheckNull(e)
{
	if(e.keyCode == 46 || e.keyCode == 8)
	{
		var temp=document.getElementById("CalcInputT");
		if(temp.value.length == 0)
		{
			temp.value="0";
			return false;
		}
		return true; 
	}
}

