function textCounter(field, countfield, maxlimit)
{
   if (field.value.length > maxlimit)
	field.value = field.value.substring(0, maxlimit);
	else 	
	countfield.value = maxlimit - field.value.length;
}

function bookmarksite(title,url){
title = document.title

if (window.sidebar) // firefox
	window.sidebar.addPanel(title,url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url,title);
}

function IsNumeric(strString)
   //  check for valid numeric strings 
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }


function compute_weight(form)
{
    var weight = form.wt.value;
    if (weight > 0.0) {
        form.outputmrc.value = int_zero( 10 * weight * .378 ) / 10;
        form.outputvn.value = int_zero( 10 * weight * .907 ) / 10;
        form.outputmoon.value = int_zero( 10 * weight * .166 ) / 10;
        form.outputmars.value = int_zero( 10 * weight * .377 ) / 10;
        form.outputjp.value = int_zero( 10 * weight * 2.364 ) / 10;
        form.outputsat.value = int_zero( 10 * weight * 1.064 ) / 10;
        form.outputur.value = int_zero( 10 * weight * .889 ) / 10;
        form.outputnpt.value = int_zero( 10 * weight * 1.125 ) / 10;
        form.outputplt.value = int_zero( 10 * weight * .067 ) / 10;
        form.outputj2.value = int_zero( 100 * weight * .1264 ) / 100;
        form.outputj3.value = int_zero( 100 * weight * .13358 ) / 100;
        form.outputj4.value = int_zero( 100 * weight * .1448 ) / 100;
        form.outputj5.value = int_zero( 100 * weight * .18355 ) / 100;
        form.outputsun.value = int_zero( 10 * weight * 27.072 ) / 10;
        form.outputwd.value = int_zero( 10 * weight * 1.3E+6 ) / 10;
        form.outputns.value = weight * 1.4E+11;
    }

}

// Function to return 0 if result is <1
function int_zero(x)
{
	if ( x < 1 )
		return 0 ;
	else
		return parseInt( x ,10 );
}

function compute_age(form)
{
    today = (new Date()).getTime();
    var birthyear = form.year.value;
    var birthmonth = form.month.value - 1;
    var birthday = form.day.value;
	birthdate = (new Date(birthyear, birthmonth, birthday)).getTime();
//		age is your age in days
		age = (today - birthdate) / (1000 * 3600 * 24);
    if (age > 0.0) {
//	Mercury
        form.outputmrcday.value = int_zero( 10 * age / 58.6 ) / 10;
        form.outputmrcyear.value = int_zero( 10 * age / 87.97 ) / 10;
        if ( (age / 87.97) > 1)
	        nextmrcbday = new Date(today + (( 1 - (( age / 87.97 ) - ( parseInt( age / 87.97 )))) * 87.97 * 24 * 3600 * 1000 ));
        else
	        nextmrcbday = new Date(today + ( 1 - ( age / 87.97 )) * 87.97 * 24 * 3600 * 1000 );
        form.outputmrcbday.value = getLongDate(nextmrcbday);
//	Venus
        form.outputvnday.value = int_zero( 10 * age / 243 ) / 10;
        form.outputvnyear.value = int_zero( 10 * age / 224.7 ) / 10;
        if ( (age / 224.7) > 1)
	        nextvnbday = new Date(today + (( 1 - (( age / 224.7 ) - ( parseInt( age / 224.7 )))) * 224.7 * 24 * 3600 * 1000 ));
        else
	        nextvnbday = new Date(today + ( 1 - ( age / 224.7 )) * 224.7 * 24 * 3600 * 1000 );
        form.outputvnbday.value = getLongDate(nextvnbday);
//	Earth
        form.outputearthday.value = int_zero( 10 * age ) / 10;
        form.outputearthyear.value = int_zero( 10 * age / 365.26 ) / 10;
        if ( (age / 365.26) > 1)
	        nextearthbday = new Date(today + (( 1 - (( age / 365.26 ) - ( parseInt( age / 365.26 )))) * 365.26 * 24 * 3600 * 1000 ));
        else
	        nextearthbday = new Date(today + ( 1 - ( age / 365.26 )) * 365.26 * 24 * 3600 * 1000 );
        form.outputearthbday.value = getLongDate(nextearthbday);
//	Mars
        form.outputmarsday.value = int_zero( 10 * age / 1.03 ) / 10;
        form.outputmarsyear.value = int_zero( 10 * age / 686.98 ) / 10;
        if ( (age / 686.98) > 1)
	        nextmarsbday = new Date(today + (( 1 - (( age / 686.98 ) - ( parseInt( age / 686.98 )))) * 686.98 * 24 * 3600 * 1000 ));
        else
	        nextmarsbday = new Date(today + ( 1 - ( age / 686.98 )) * 686.98 * 24 * 3600 * 1000 );
        form.outputmarsbday.value = getLongDate(nextmarsbday);
//	Jupiter
        form.outputjupday.value = int_zero( 10 * age / 0.41 ) / 10;
        form.outputjupyear.value = int_zero( 100 * age / 4332.71 ) / 100;
        if ( (age / 4332.71) > 1)
	        nextjupbday = new Date(today + (( 1 - (( age / 4332.71 ) - ( parseInt( age / 4332.71 )))) * 4332.71 * 24 * 3600 * 1000 ));
        else
	        nextjupbday = new Date(today + ( 1 - ( age / 4332.71 )) * 4332.71 * 24 * 3600 * 1000 );
        form.outputjupbday.value = getLongDate(nextjupbday);
//	Saturn
        form.outputsatday.value = int_zero( 10 * age / 0.45 ) / 10;
        form.outputsatyear.value = int_zero( 100 * age / 10759.5 ) / 100;
        if ( (age / 10759.5) > 1)
        	nextsatbday = new Date(today + (( 1 - (( age / 10759.5 ) - ( parseInt( age / 10759.5 )))) * 10759.5 * 24 * 3600 * 1000 ));
        else
        	nextsatbday = new Date(today + ( 1 - ( age / 10759.5 )) * 10759.5 * 24 * 3600 * 1000 );
		form.outputsatbday.value = getLongDate(nextsatbday);
//	Uranus
        form.outputurday.value = int_zero( 10 * age / 0.72 ) / 10;
        form.outputuryear.value = int_zero( 100 * age / 30685 ) / 100;
        if ( (age / 30685) > 1)
	        nexturbday = new Date(today + (( 1 - (( age / 30685 ) - ( parseInt( age / 30685 )))) * 30685 * 24 * 3600 * 1000 ));
        else
	        nexturbday = new Date(today + ( 1 - ( age / 30685 )) * 30685 * 24 * 3600 * 1000 );
        form.outputurbday.value = getLongDate(nexturbday);
//	Neptune
        form.outputnepday.value = int_zero( 10 * age / 0.67 ) / 10;
        form.outputnepyear.value = int_zero( 100 * age / 60190 ) / 100;
        if ( (age / 60190) > 1)
	        nextnepbday = new Date(today + (( 1 - (( age / 60190 ) - ( parseInt( age / 60190 )))) * 60190 * 24 * 3600 * 1000 ));
        else
	        nextnepbday = new Date(today + ( 1 - ( age / 60190 )) * 60190 * 24 * 3600 * 1000 );
        form.outputnepbday.value = getLongDate(nextnepbday);
//	Pluto
        form.outputpltday.value = int_zero( 10 * age / 6.39 ) / 10;
        form.outputpltyear.value = int_zero( 1000 * age / 90800 ) / 1000;
        if ( (age / 90800) > 1)
	        nextpltbday = new Date(today + (( 1 - (( age / 90800 ) - ( parseInt( age / 90800 )))) * 90800 * 24 * 3600 * 1000 ));
        else
	        nextpltbday = new Date(today + ( 1 - ( age / 90800 )) * 90800 * 24 * 3600 * 1000 );
        form.outputpltbday.value = getLongDate(nextpltbday);
    }

}

function getLongDate(dateObj)
{	
	theDay = dayNames[dateObj.getDay()+1]
	theMonth = monthNames[dateObj.getMonth()+1]
	theDate = dateObj.getDate()
	theYear = dateObj.getFullYear();
	
	return ""+theDay+", "+theMonth+" "+theDate+", "+theYear
}

monthNames = new Array(13)
monthNames[1]  = "Jan"
monthNames[2]  = "Feb"
monthNames[3]  = "Mar"
monthNames[4]  = "Apr"
monthNames[5]  = "May"
monthNames[6]  = "Jun"
monthNames[7]  = "Jul"
monthNames[8]  = "Aug"
monthNames[9]  = "Sep"
monthNames[10] = "Oct"
monthNames[11] = "Nov"
monthNames[12] = "Dec"
		 
dayNames = new Array(8)
dayNames[1]  = "Sun"
dayNames[2]  = "Mon"
dayNames[3]  = "Tues"
dayNames[4]  = "Wed"
dayNames[5]  = "Thur"
dayNames[6]  = "Fri"
dayNames[7]  = "Sat"

// Function to return 0 if result is <1
function int_zero(x)
{
	if ( x < 1 )
		return 0 ;
	else
		return parseInt( x ,10 );
}





 

