var time=new Date();
var hour,min,sec;
var d=document;

function showDate(){
  
  var dayOfWeek=time.getDay();
    if(dayOfWeek==0) dayOfWeek="Sunday  ";
    if(dayOfWeek==1) dayOfWeek="Monday  ";
    if(dayOfWeek==2) dayOfWeek="Tuesday  ";
    if(dayOfWeek==3) dayOfWeek="Wednsday  ";
    if(dayOfWeek==4) dayOfWeek="Thursday  ";
    if(dayOfWeek==5) dayOfWeek="Friday  ";
    if(dayOfWeek==6) dayOfWeek="Saturday  ";
    

    var day=time.getDate();
    if(day<10) day="0"+day;
    day+=", ";
    
    var mon=time.getMonth();
      if(mon==0) mon="Jan. ";
      if(mon==1) mon="Feb. ";
      if(mon==2) mon="Mar. ";
      if(mon==3) mon="Apr. ";
      if(mon==4) mon="May ";
      if(mon==5) mon="June ";
      if(mon==6) mon="July ";
      if(mon==7) mon="Aug. ";
      if(mon==8) mon="Sep. ";
      if(mon==9) mon="Oct. ";
      if(mon==10) mon="Nov. ";
      if(mon==11) mon="Dec. ";
    
    var year=time.getYear()+1900;

    d.write(dayOfWeek+mon+day+year);
  
}


function openWindow(theURL,winName,features) {window.open(theURL,winName,features);}
function launch(newURL, newName, newFeatures, orgName) {
  var remote = open(newURL, newName, newFeatures);
  if (remote.opener == null)
    remote.opener = window;
  remote.opener.name = orgName;
  return remote;
}

function cal() {
	var amount		= document.mortgage.amount.value;
	var rate			= document.mortgage.rate.value;
 	var term			= document.mortgage.term.options[document.mortgage.term.selectedIndex].value;
	var frequency			= document.mortgage.frequency.options[document.mortgage.frequency.selectedIndex].value;
 
	var periods = 54;
	if (frequency=="monthly") { periods=12; } 
     var payment = (amount*((rate/(periods*100))/(1-(Math.pow(1+(rate/(periods*100)),((term*periods)*-1))))));
    var interest = (( payment*( term*periods))-amount)
	document.mortgage.payment.value = calcRound(payment);
	document.mortgage.interest.value = calcRound(interest);
}
 
 function calcRound(num) {
   result="$"+Math.floor(num)+"." 
   n = result.length
   if (num>1000 && num<999999) {  
     result="$"+result.substring(1,n-4)+","+result.substring(n-4,n)
   }
   if (num>1000000) {  
     result = "$"+result.substring(1,n-7)+","+result.substring(n-7,n-4)+","+result.substring(n-4,n)
   }
   var cents=100*(num-Math.floor(num))+0.5
   result += Math.floor(cents/10)
   result += Math.floor(cents%10)
   return(result)
}


var winpopup= null;
function NewWindow(mypage,myname,w,h,scroll){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var settings  ='height='+h+',';
      settings +='width='+w+',';
      settings +='top='+wint+',';
      settings +='left='+winl+',';
      settings +='scrollbars='+scroll+',';
      settings +='resizable=no';
  winpopup=window.open(mypage,myname,settings);
  if(parseInt(navigator.appVersion) >= 4){winpopup.window.focus();}
}
 