function hide()
{document.getElementById('table0').style.display="none";
document.getElementById('table1').style.display="none";
document.getElementById('table2').style.display="none";
document.getElementById('table3').style.display="none";
document.getElementById('table4').style.display="none";
document.getElementById('table5').style.display="none";
document.getElementById('table6').style.display="none";
document.getElementById('table7').style.display="none";}
function gadget0(){document.getElementById('table0').style.display="block"; }
function gadget1(){document.getElementById('table1').style.display="block"; }
function gadget2(){document.getElementById('table2').style.display="block"; }
function gadget3(){document.getElementById('table3').style.display="block"; }
function gadget4(){document.getElementById('table4').style.display="block"; }
function gadget5(){document.getElementById('table5').style.display="block"; }
function gadget6(){document.getElementById('table6').style.display="block"; }
function gadget7(){document.getElementById('table7').style.display="block"; }

function tdm()
{
var principal = document.mvc.principal.value ;
var rate = document.mvc.rate.value ;
var ci = document.mvc.ci.options[document.mvc.ci.options.selectedIndex].value;
var time = document.mvc.time.value ;
var irate = rate/ci ;
var mv = document.mvc.mv.value ;
var decimal = 2 ;
document.mvc.mv.value = Math.round(document.mvc.principal.value*Math.pow((1 + irate/100),(time/12*ci))*100)/100 ;
}

var Result=0, Operator=0, Second=0, Ready=0, Done=1, Complete=0, Integer, CurrentValue;
function reset(value)
{ document.calculator.panel.value=value;
  Result=0, Operator=0, Second=0, Ready=0; Done=1; Complete=0;}
function SetValue(NewValue)
{  Integer=1;
  if(Second || Done)
  {Second=0;Done=0;CurrentValue=NewValue;  }
  for(var i=0; i<CurrentValue.length; i++)
if (CurrentValue[i]=='.')
  Integer=0;}

function Click(Caption)
{ CurrentValue=document.calculator.panel.value;
  if(Caption=='.')
  {SetValue('0');
if(Integer)
{  CurrentValue += Caption;
  document.calculator.panel.value=CurrentValue;
  Complete=0;}  }
  if (Caption.length == 1 && Caption>='0' && Caption<='9')
  { SetValue('');
if(CurrentValue=='0')
  CurrentValue='';
CurrentValue += Caption;
document.calculator.panel.value=CurrentValue;
Complete=1;  }

  if(Caption=='-' || Caption=='+' || Caption=='/' || Caption=='*' || Caption=='^' || Caption=='%')
  {  if(Second)
  Operator=Caption
else
{
  if(!Ready)
  { Operator=Caption;
Result=CurrentValue;
Ready=1;
  } else
  { if (Operator=='^')
Result=Math.pow(Result, CurrentValue);
else
Result=eval(Result + Operator + CurrentValue);
Operator=Caption; document.calculator.panel.value=Result;
  } Complete=0; Second=1;}  }
if(Caption=='x^2' )
  {Result=CurrentValue*CurrentValue; reset(Result);  }
  if(Caption=='1/x' )
  {Result=eval('1/' + CurrentValue) ; reset(Result);  }
  if(Caption=='sqrt')
  {Result=Math.sqrt(CurrentValue);
reset(Result);  }
  if(Caption=='+/-')
document.calculator.panel.value=eval(-CurrentValue);
  if(Caption=='=' && Complete && Operator!='0')  {
  if (Operator=='^')
{ Result=Math.pow(Result, CurrentValue);  reset(Result); }
 else if (Operator=='%')
{
  Result=(Result/ CurrentValue)*100;
  reset(Result);} 
else
  reset(eval(Result + Operator + CurrentValue));} 
  if (Caption =='CE')
  CurrentValue ==  0,  reset(Result);  
  if (Caption=='C')
reset(0);
  if(document.calculator.panel.value[0] == '.')
document.calculator.panel.value='0' + document.calculator.panel.value;}


function mortgageloan() {
 if ((document.mortgage.principal.value == null || document.mortgage.principal.value.length == 0) ||
 (document.mortgage.years.value == null || document.mortgage.years.value.length == 0)
||(document.mortgage.rate.value == null || document.mortgage.rate.value.length == 0))
 { document.mortgage.inst.value=document.mortgage.tinst.value="Enter Data"; }
 else
 {var inst='';  var princ=document.mortgage.principal.value; var term =document.mortgage.years.value * 12;
 var intr  =document.mortgage.rate.value/1200;  var tax =document.mortgage.tax.value; var tintt="";
 var gt='';
 document.mortgage.inst.value =Math.round((princ * intr/(1 - (Math.pow(1/(1 + intr), term))))*100)/100;
 document.mortgage.mtax.value=Math.round((tax/12 )*100)/100;
  document.mortgage.tinst.value= Math.round((document.mortgage.inst.value*1 + document.mortgage.mtax.value*1)*100)/100;
 }}

function rdmaturity()
{var principal=document.rdm.principal.value ;var rate=document.rdm.rate.value ;
var ci=document.rdm.ci.options[document.rdm.ci.options.selectedIndex].value ;var timerd=document.rdm.timerd.value ;
var irate=rate/ci ;var mv=document.rdm.mv.value ;
document.rdm.mv.value=Math.round(document.rdm.principal.value * (Math.pow((1 + irate/100),(timerd/12)*ci)-1)/(1-Math.pow((1+irate/100),-ci/12))*100)/100;}

function ytmcalc()
{var principal=document.ytm.principal.value;var mvalue=document.ytm.mvalue.value;
var rate=document.ytm.rate.value;var ci=document.ytm.ci.options[document.ytm.ci.options.selectedIndex].value;
var time=document.ytm.time.value;var irate=document.ytm.rate.value  /(ci*100);var pvalue;
if (time < 12/ci) pvalue=0
else
pvalue=document.ytm.principal.value *irate;
var yield;
yield=((pvalue) * (1)* (Math.pow((1+irate),((time)*ci/12))-1*1)/(irate))+document.ytm.principal.value*1-mvalue * 1;
document.ytm.yield.value=Math.round (yield*100)/100;
document.ytm.mv.value=Math.round ((yield *12*100 /(time *mvalue))*100)/100+" %";
document.ytm.ayield.value=Math.round(((pvalue) * (1)* (Math.pow((1+irate),((12)*ci/12))-1*1)/(irate))*100)/100;
document.ytm.apyield.value=Math.round((((pvalue) * (1)* (Math.pow((1+irate),((12)*ci/12))-1*1)/(irate))*100/mvalue)*100)/100+" %";}



function setDate(str) {
 if (str == " ") {
  return; }
 mnth1=document.forms[0].month.value;
 mnth=mnth1;
 mnth++;
 year=document.forms[0].year.value;
 dateStr=mnth+"/"+str+"/"+year;
 dateStr=trim(dateStr);
 }//setDate()
/**
 * The function removes spaces from the selected date.
 */
function trim(str) {
 res="";
 for(var i=0; i< str.length; i++) {
if (str.charAt(i) != " ") {
 res +=str.charAt(i);  } }
  return res;
}//trim()
 /**
 * The method to get the Month name given the Month number of the year.
 */
function getMonthName(mnth) {
 if (mnth == 0) {  name="January"; }
 else if(mnth==1) {  name="February"; }
 else if(mnth==2) {  name="March"; }
 else if(mnth==3) {  name="April"; }
 else if(mnth==4) {  name="May"; } 
 else if(mnth==5) {  name="June"; } 
 else if(mnth==6) {  name="July"; } 
 else if(mnth==7) {  name="August"; } 
 else if(mnth==8) {  name="September"; } 
 else if(mnth==9) {  name="October"; } 
 else if(mnth==10) {  name="November"; } 
 else if(mnth==11) {  name="December"; }

 return name;
}//getMonthName()
/**
 * Get the number of days in the month based on the year.
 */
function getNoOfDaysInMnth(mnth,yr) {
 rem=yr % 4;
 if(rem ==0) {leap=1; } else {  leap=0; }
 noDays=0;

 if ( (mnth == 1) || (mnth == 3) || (mnth == 5) || (mnth == 7) || (mnth == 8) || (mnth == 10) ||(mnth == 12)) 
 {  noDays=31; } 
 else if (mnth == 2) 
 { noDays=28+leap;} 
 else { noDays=30; }
 //alert(noDays);
 return noDays;
 }//getNoOfDaysInMnth() 
/**
 * The function to reset the date values in the buttons of the 
 * slots.
 */
function fillDates(dayOfWeek1,noOfDaysInmnth) {
 for(var i=1; i<43; i++) {
str="s"+i;
document.forms[0].elements[str].value="";
 }
 startSlotIndx=dayOfWeek1;
 slotIndx=startSlotIndx;
 for(var i=1; i<(noOfDaysInmnth+1); i++) {
  slotName="s"+slotIndx;
  val="";
  if (i<10) {
val=" "+i+" ";
  } else {
val=i;
  }
  document.forms[0].elements[slotName].value=val;
  slotIndx++;
 }
 
}//fillDates()
 /**
 * The function that is called at the time of loading the page.
 * This function displays Today's date and also displays the 
 * the calendar of the current month.
 */
function thisMonth() {
  dt=new Date();
  mnth =dt.getMonth(); /* 0-11*/
  dayOfMnth=dt.getDate(); /* 1-31*/
  dayOfWeek=dt.getDay(); /*0-6*/
  yr=dt.getFullYear(); /*4-digit year*/
  //alert("month:"+(mnth+1)+":dayofMnth:"+dayOfMnth+":dayofweek:"+dayOfWeek+":year:"+yr);
  mnthName=getMonthName(mnth)+ " ";
  document.forms[0].month.value=mnth;
  document.forms[0].year.value=yr;
  document.forms[0].currMonth.value=mnth;
  document.forms[0].currYear.value=yr;
  document.forms[0].monthYear.value=mnthName+yr;
  startStr=(mnth+1)+"/1/"+yr;
  dt1=new Date(startStr);
  dayOfWeek1=dt1.getDay(); /*0-6*/
  noOfDaysInMnth=getNoOfDaysInMnth(mnth+1,yr);
  fillDates(dayOfWeek1+1,noOfDaysInMnth);
 }//thisMonth()
/**
 * The function that will be used to display the calendar of the next month.
 */
function nextMonth() {
 var currMnth=document.forms[0].month.value;
 currYr=document.forms[0].year.value;
 if (currMnth == "11") {
nextMnth=0;
nextYr=currYr;
nextYr++; } 
else {
nextMnth=currMnth;
nextMnth++;
nextYr=currYr; }
 mnthName=getMonthName(nextMnth);
 document.forms[0].month.value=nextMnth;
 document.forms[0].year.value=nextYr;
 document.forms[0].monthYear.value= mnthName+" "+nextYr;
 str=(nextMnth+1)+"/1/"+nextYr;
 dt=new Date(str);
 dayOfWeek=dt.getDay();
 noOfDays=getNoOfDaysInMnth(nextMnth+1,nextYr);
 fillDates(dayOfWeek+1,noOfDays);
 }//nextMonth()
/**
 * The method to display the calendar of the previous month.
 */

function prevMonth() {
 var currMnth=document.forms[0].month.value;
 currYr=document.forms[0].year.value;
 if (currMnth == "0") {
prevMnth=11;
prevYr=currYr;
prevYr--; } 
else {
prevMnth=currMnth;
prevMnth--;
prevYr=currYr; }
 str=(prevMnth+1)+"/1/"+prevYr;
 dt=new Date(str);
 dayOfWeek=dt.getDay();

 /***********************************************
  * Remove the comment if do not want the user to 
  * go to any previous month than this current month.
  ***********************************************/
 /*
 runningMonth=document.forms[0].currMonth.value;
 rMonth=runningMonth;
 rMonth++;
 runningYear=document.forms[0].currYear.value;
 rYear=runningYear;
 str=(rMonth)+"/1/"+rYear;
 dt1=new Date(str);
  if (dt.valueOf() < dt1.valueOf()) {
alert('Cannot Go Before Current Month');
return;
 }
*/
 /**************************************************
 * End of comment
 **************************************************/

 mnthName=getMonthName(prevMnth);
 document.forms[0].month.value=prevMnth;
 document.forms[0].year.value=prevYr;
 document.forms[0].monthYear.value= mnthName+" "+prevYr;
 noOfDays=getNoOfDaysInMnth(prevMnth+1,prevYr);
 fillDates(dayOfWeek+1,noOfDays); 
}//prevMonth()
function clock() {
var date=new Date()
var year=date.getYear()
var month=date.getMonth()
var day=date.getDate()
var hour=date.getHours()
var minute=date.getMinutes()
var second=date.getSeconds()
var months=new Array("Jan.", "Feb.", "Mar.", "Apr.", "May", "June", "July", "Aug.", "Sept.", "Oct.", "Nov.", "Dec.")
var monthname=months[month]
var ap  ;
if (year < 1000) {
year= year + 1900 }
if (hour > 12 )
hour=hour - 12 ;
if (hour >= 12 ) {
ap='PM';}
else
{ap='AM';}
if (minute < 10) 
{minute="0" + minute}
if (second < 10) {
second="0" + second }
document.getElementById('time').innerHTML=" " + monthname + " " + day + ", " + year + " - " + hour + ":" + minute + ":" +second + ' ' + ap ;
setTimeout("clock()", 1000)}

// Tigra Calendar v4.0.3 (01/12/2009) American (mm/dd/yyyy)
// http://www.softcomplex.com/products/tigra_calendar/
// Public Domain Software... You're welcome.
// default settins
var A_TCALDEF={
'months' : ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
'weekdays' : ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
'yearscroll': true, // show year scroller
'weekstart': 0, // first day of week: 0-Su or 1-Mo
'centyear'  : 70, // 2 digit years less than 'centyear' are in 20xx, othewise in 19xx.
'imgpath' : 'http://multiutils.com/gadgets/tigra/img/' // directory with calendar images
}
// date parsing function
function f_tcalParseDate (s_date) {
var re_date=/^\s*(\d{1,2})\/(\d{1,2})\/(\d{2,4})\s*$/;
if (!re_date.exec(s_date))
return alert ("Invalid date: '" + s_date + "'.\nAccepted format is mm/dd/yyyy.")
var n_day=Number(RegExp.$2),
n_month=Number(RegExp.$1),
n_year=Number(RegExp.$3);

if (n_year < 100)
n_year += (n_year < this.a_tpl.centyear ? 2000 : 1900);
if (n_month < 1 || n_month > 12)
return alert ("Invalid month value: '" + n_month + "'.\nAllowed range is 01-12.");
var d_numdays=new Date(n_year, n_month, 0);
if (n_day > d_numdays.getDate())
return alert("Invalid day of month value: '" + n_day + "'.\nAllowed range for selected month is 01 - " + d_numdays.getDate() + ".");
return new Date (n_year, n_month - 1, n_day);}
// date generating function
function f_tcalGenerDate (d_date) {
return (
 (d_date.getMonth() < 9 ? '0' : '') + (d_date.getMonth() + 1) + "/"
+ (d_date.getDate() < 10 ? '0' : '') + d_date.getDate() + "/"
+ d_date.getFullYear()
);}
// implementation
function tcal (a_cfg, a_tpl) {
// apply default template if not specified
if (!a_tpl)
a_tpl=A_TCALDEF;
// register in global collections
if (!window.A_TCALS)
window.A_TCALS=[];
if (!window.A_TCALSIDX)
window.A_TCALSIDX=[];
this.s_id=a_cfg.id ? a_cfg.id : A_TCALS.length;
window.A_TCALS[this.s_id]=this;
window.A_TCALSIDX[window.A_TCALSIDX.length]=this;
// assign methods
this.f_show=f_tcalShow;
this.f_hide=f_tcalHide;
this.f_toggle=f_tcalToggle;
this.f_update=f_tcalUpdate;
this.f_relDate=f_tcalRelDate;
this.f_parseDate=f_tcalParseDate;
this.f_generDate=f_tcalGenerDate;
// create calendar icon
this.s_iconId='tcalico_' + this.s_id;
this.e_icon=f_getElement(this.s_iconId);
if (!this.e_icon) {
document.write('<img src="' + a_tpl.imgpath + 'cal.gif" id="' + this.s_iconId + '" onclick="A_TCALS[\'' + this.s_id + '\'].f_toggle()" class="tcalIcon" alt="Open Calendar"/>');
this.e_icon=f_getElement(this.s_iconId);}
// save received parameters
this.a_cfg=a_cfg;
this.a_tpl=a_tpl;}
function f_tcalShow (d_date) {
// find input field
if (!this.a_cfg.controlname)
throw("TC: control name is not specified");
if (this.a_cfg.formname) {
var e_form=document.forms[this.a_cfg.formname];
if (!e_form)
throw("TC: form '" + this.a_cfg.formname + "' can not be found");
this.e_input=e_form.elements[this.a_cfg.controlname];}
else
this.e_input=f_getElement(this.a_cfg.controlname);
if (!this.e_input || !this.e_input.tagName || this.e_input.tagName != 'INPUT')
throw("TC: element '" + this.a_cfg.controlname + "' does not exist in "
+ (this.a_cfg.formname ? "form '" + this.a_cfg.controlname + "'" : 'this document'));
// dynamically create HTML elements if needed
this.e_div=f_getElement('tcal');
if (!this.e_div) {
this.e_div=document.createElement("DIV");
this.e_div.id='tcal';
document.body.appendChild(this.e_div);}
this.e_shade=f_getElement('tcalShade');
if (!this.e_shade) {
this.e_shade=document.createElement("DIV");
this.e_shade.id='tcalShade';
document.body.appendChild(this.e_shade);}
this.e_iframe= f_getElement('tcalIF')
if (b_ieFix && !this.e_iframe) {
this.e_iframe=document.createElement("IFRAME");
this.e_iframe.style.filter='alpha(opacity=0)';
this.e_iframe.id='tcalIF';
this.e_iframe.src=this.a_tpl.imgpath + 'pixel.gif';
document.body.appendChild(this.e_iframe);}
// hide all calendars
f_tcalHideAll();
// generate HTML and show calendar
this.e_icon=f_getElement(this.s_iconId);
if (!this.f_update())
return;
this.e_div.style.visibility='visible';
this.e_shade.style.visibility='visible';
if (this.e_iframe)
this.e_iframe.style.visibility='visible';
// change icon and status
this.e_icon.src=this.a_tpl.imgpath + 'no_cal.gif';
this.e_icon.title='Close Calendar';
this.b_visible=true;}
function f_tcalHide (n_date) {
if (n_date)
this.e_input.value=this.f_generDate(new Date(n_date));
// no action if not visible
if (!this.b_visible)
return;
// hide elements
if (this.e_iframe)
this.e_iframe.style.visibility='hidden';
if (this.e_shade)
this.e_shade.style.visibility='hidden';
this.e_div.style.visibility='hidden';
// change icon and status
this.e_icon=f_getElement(this.s_iconId);
this.e_icon.src=this.a_tpl.imgpath + 'cal.gif';
this.e_icon.title='Open Calendar';
this.b_visible=false;}
function f_tcalToggle () {
return this.b_visible ? this.f_hide() : this.f_show();}
function f_tcalUpdate (d_date) {
var d_today=this.a_cfg.today ? this.f_parseDate(this.a_cfg.today) : f_tcalResetTime(new Date());
var d_selected=this.e_input.value == ''
? (this.a_cfg.selected ? this.f_parseDate(this.a_cfg.selected) : d_today)
: this.f_parseDate(this.e_input.value);
// figure out date to display
if (!d_date)
// selected by default
d_date=d_selected;
else if (typeof(d_date) == 'number')
// get from number
d_date=f_tcalResetTime(new Date(d_date));
else if (typeof(d_date) == 'string')
// parse from string
this.f_parseDate(d_date);
if (!d_date) return false;
// first date to display
var d_firstday=new Date(d_date);
d_firstday.setDate(1);
d_firstday.setDate(1 - (7 + d_firstday.getDay() - this.a_tpl.weekstart) % 7);
var a_class, s_html='<table class="ctrl"><tbody><tr>'
+ (this.a_tpl.yearscroll ? '<td' + this.f_relDate(d_date, -1, 'y') + ' title="Previous Year"><img src="' + this.a_tpl.imgpath + 'prev_year.gif"/></td>' : '')
+ '<td' + this.f_relDate(d_date, -1) + ' title="Previous Month"><img src="' + this.a_tpl.imgpath + 'prev_mon.gif"/></td><th>'
+ this.a_tpl.months[d_date.getMonth()] + ' ' + d_date.getFullYear()
+ '</th><td' + this.f_relDate(d_date, 1) + ' title="Next Month"><img src="' + this.a_tpl.imgpath + 'next_mon.gif"/></td>'
+ (this.a_tpl.yearscroll ? '<td' + this.f_relDate(d_date, 1, 'y') + ' title="Next Year"><img src="' + this.a_tpl.imgpath + 'next_year.gif"/></td></td>' : '')
+ '</tr></tbody></table><table><tbody><tr class="wd">';
// print weekdays titles
for (var i=0; i < 7; i++)
s_html += '<th>' + this.a_tpl.weekdays[(this.a_tpl.weekstart + i) % 7] + '</th>';
s_html += '</tr>' ;
// print calendar table
var n_date, n_month, d_current=new Date(d_firstday);
while (d_current.getMonth() == d_date.getMonth() ||
d_current.getMonth() == d_firstday.getMonth()) {
// print row heder
s_html +='<tr>';
for (var n_wday=0; n_wday < 7; n_wday++) {
a_class=[];
n_date =d_current.getDate();
n_month=d_current.getMonth();
// other month
if (d_current.getMonth() != d_date.getMonth())
a_class[a_class.length]='othermonth';
// weekend
if (d_current.getDay() == 0 || d_current.getDay() == 6)
a_class[a_class.length]='weekend';
// today
if (d_current.valueOf() == d_today.valueOf())
a_class[a_class.length]='today';
// selected
if (d_current.valueOf() == d_selected.valueOf())
a_class[a_class.length]='selected';
s_html += '<td onclick="A_TCALS[\'' + this.s_id + '\'].f_hide(' + d_current.valueOf() + ')"' + (a_class.length ? ' class="' + a_class.join(' ') + '">' : '>') + n_date + '</td>'
d_current.setDate(++n_date);
while (d_current.getDate() != n_date && d_current.getMonth() == n_month) {
d_current.setHours(d_current.getHours + 1);
d_current=f_tcalResetTime(d_current);}}
// print row footer
s_html +='</tr>';}
s_html +='</tbody></table>';
// update HTML, positions and sizes
this.e_div.innerHTML=s_html;
var n_width =this.e_div.offsetWidth;
var n_height=this.e_div.offsetHeight;
var n_top =f_getPosition (this.e_icon, 'Top') + this.e_icon.offsetHeight;
var n_left=f_getPosition (this.e_icon, 'Left') - n_width + this.e_icon.offsetWidth;
if (n_left < 0) n_left=0;
this.e_div.style.left=n_left + 'px';
this.e_div.style.top =n_top + 'px';
this.e_shade.style.width=(n_width + 8) + 'px';
this.e_shade.style.left=(n_left - 1) + 'px';
this.e_shade.style.top=(n_top - 1) + 'px';
this.e_shade.innerHTML=b_ieFix
? '<table><tbody><tr><td rowspan="2" colspan="2" width="6"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td width="7" height="7" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_tr.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td height="' + (n_height - 7) + '" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_mr.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td width="7" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_bl.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_bm.png\', sizingMethod=\'scale\');" height="7" align="left"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'' + this.a_tpl.imgpath + 'shade_br.png\', sizingMethod=\'scale\');"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tbody></table>'
: '<table><tbody><tr><td rowspan="2" width="6"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td rowspan="2"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td width="7" height="7"><img src="' + this.a_tpl.imgpath + 'shade_tr.png"></td></tr><tr><td background="' + this.a_tpl.imgpath + 'shade_mr.png" height="' + (n_height - 7) + '"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td></tr><tr><td><img src="' + this.a_tpl.imgpath + 'shade_bl.png"></td><td background="' + this.a_tpl.imgpath + 'shade_bm.png" height="7" align="left"><img src="' + this.a_tpl.imgpath + 'pixel.gif"></td><td><img src="' + this.a_tpl.imgpath + 'shade_br.png"></td></tr><tbody></table>';

if (this.e_iframe) {
this.e_iframe.style.left=n_left + 'px';
this.e_iframe.style.top =n_top + 'px';
this.e_iframe.style.width=(n_width + 6) + 'px';
this.e_iframe.style.height=(n_height + 6) +'px';}
return true;}

function f_getPosition (e_elemRef, s_coord) {
var n_pos=0, n_offset,
e_elem=e_elemRef;
while (e_elem) {
n_offset=e_elem["offset" + s_coord];
n_pos += n_offset;
e_elem=e_elem.offsetParent;}
// margin correction in some browsers
if (b_ieMac)
n_pos += parseInt(document.body[s_coord.toLowerCase() + 'Margin']);
else if (b_safari)
n_pos -= n_offset;
e_elem=e_elemRef;
while (e_elem != document.body) {
n_offset=e_elem["scroll" + s_coord];
if (n_offset && e_elem.style.overflow == 'scroll')
n_pos -= n_offset;
e_elem=e_elem.parentNode;}
return n_pos;}

function f_tcalRelDate (d_date, d_diff, s_units) {
var s_units=(s_units == 'y' ? 'FullYear' : 'Month');
var d_result=new Date(d_date);
d_result['set' + s_units](d_date['get' + s_units]() + d_diff);
if (d_result.getDate() != d_date.getDate())
d_result.setDate(0);
return ' onclick="A_TCALS[\'' + this.s_id + '\'].f_update(' + d_result.valueOf() + ')"';}
function f_tcalHideAll () {
for (var i=0; i < window.A_TCALSIDX.length; i++)
window.A_TCALSIDX[i].f_hide();}
function f_tcalResetTime (d_date) {
d_date.setHours(0);
d_date.setMinutes(0);
d_date.setSeconds(0);
d_date.setMilliseconds(0);
return d_date;}
f_getElement=document.all ?
function (s_id) { return document.all[s_id] } :
function (s_id) { return document.getElementById(s_id) };
if (document.addEventListener)
window.addEventListener('scroll', f_tcalHideAll, false);
if (window.attachEvent)
window.attachEvent('onscroll', f_tcalHideAll);
// global variables
var s_userAgent=navigator.userAgent.toLowerCase(),
re_webkit=/WebKit\/(\d+)/i;
var b_mac=s_userAgent.indexOf('mac') != -1,
b_ie5=s_userAgent.indexOf('msie 5') != -1,
b_ie6=s_userAgent.indexOf('msie 6') != -1 && s_userAgent.indexOf('opera') == -1;
var b_ieFix=b_ie5 || b_ie6,
b_ieMac =b_mac && b_ie5,
b_safari=b_mac && re_webkit.exec(s_userAgent) && Number(RegExp.$1) < 500;

function stock () {var num=document.tstest.num.value;var div=document.tstest.div.value;
var purprice=document.tstest.purprice.value;var saleprice=document.tstest.saleprice.value;
var stt=document.tstest.stt.value;var purcost=purprice * num ;var salecost=saleprice * num ;
var date1=document.getElementById("d1").value ;var date2=document.getElementById("d2").value ;
var pdate=Date.parse(date1);var sdate=Date.parse(date2);
var msPerDay=24 * 60 * 60 * 1000 ;
days=Math.round((sdate*1 - pdate*1 )/msPerDay);
if ( sdate >= pdate )
{document.tstest.nroi.value=(salecost*1 + div*1) - purcost*1 - stt*1  ;
document.tstest.arr.value=Math.round((document.tstest.nroi.value/purcost )*( 365/days )*10000)/100 + " %";}
else if ( sdate < pdate )
{document.tstest.arr.value="Incorrect date" ;
document.tstest.nroi.value="Incorrect date" ;
alert ("<strong>Error</strong> : The Sale Date is prior to the Purchase Date. \n Please enter correct dates and recalculate.");}}

window.onload=function(){clock(); thisMonth();}
