function MakeHomePage(){
if(document.all) {this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.datedial.com'}
}

function Send_To_A_Friend(){
var SubjectLine="Take a look at this web page I found. It's called : "+top.document.title; 
var BodyText='You can find this page at: '+top.location.href;

var Message=' <A CLASS=contact HREF="mailto:?SUBJECT='+escape(SubjectLine)+'&BODY='+escape(BodyText)+'" OnMouseOver="status=\'Send this page to your friends\'; return true;" TITLE="Send your friends e-mail about this page"><input type="text" value="Send This Page To A Friend" style="cursor:hand" size=25><\/A>';

var MessageIE=' <A CLASS=contact HREF="mailto:?SUBJECT='+(SubjectLine)+'&BODY='+(BodyText)+'" OnMouseOver="status=\'Send this page to your friends\'; return true;" TITLE="Send your friends e-mail about this page"><input type="text" value="Send This Page To A Friend" style="cursor:hand" size=25><\/A>';

if(document.all) { document.write(MessageIE); }

else { document.write(Message); }
}

function Comma(number) {
number = '' + number;
if (number.length > 3) {
var mod = number.length % 3;
var output = (mod > 0 ? (number.substring(0,mod)) : '');
for (i=0 ; i < Math.floor(number.length / 3); i++) {
if ((mod == 0) && (i == 0))
output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
else
output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
}
return (output);
}
else return number;
}

function addbookmark()
{
if (document.all)
{window.external.AddFavorite(document.location,document.title)}
}

var clockID=0
function UpdateClock()
{
if (clockID)
{clearTimeout(clockID);
clockID = 0;}

var H,M,S,Mth,Day,AMPM,Yr
var tDate = new Date();
Day=tDate.getDate()
if (Day<10)
{Day="0"+Day;}

Mth=tDate.getMonth()+1
if (Mth==1){Mth="Jan"}
if (Mth==2){Mth="Feb"}
if (Mth==3){Mth="Mar"}
if (Mth==4){Mth="Apr"}
if (Mth==5){Mth="May"}
if (Mth==6){Mth="Jun"}
if (Mth==7){Mth="Jul"}
if (Mth==8){Mth="Aug"}
if (Mth==9){Mth="Sep"}
if (Mth==10){Mth="Oct"}
if (Mth==11){Mth="Nov"}
if (Mth==12){Mth="Dec"}

Yr=tDate.getFullYear()

H=tDate.getHours();
if (H>11)
{AMPM="pm";}
else
{AMPM="am";}

if (H>12)
{H=H-12;}

if (H<10)
{H="0"+H;}

M=tDate.getMinutes()
if (M<10)
{M="0"+M;}

S=tDate.getSeconds()
if (S<10)
{S="0"+S;}

theTime.innerHTML = Mth + " " + Day + " " + Yr + "::" + H + ":" + M + ":" + S + AMPM;
clockID = setTimeout("UpdateClock()",1000);
}

function StartClock() {
clockID = setTimeout("UpdateClock()",500);
}

function KillClock() {
if (clockID)
 {clearTimeout(clockID);
 clockID = 0;}
}

var Feet,Result,Inches,Lbs,Cms,Kgs,Pinch,Peet,Metres,Height,Weight,x,active,gender,input,tot,carb,prot,fat,A1,A2,A3,A4,frac

function FeetConvert()
{
Result=TGrams.ft.value*30.48;
Result+=TGrams.ins.value*2.54;
decimal();
TGrams.cms.value=Result.toFixed(frac);
}

function InchConvert()
{
Peet=TGrams.ft.value;
Pinch=TGrams.ins.value;

if (Pinch >= 12)
	{FtInsConvert(Pinch);}
else
	{Feet=Peet*30.48;
	Inches=Pinch*2.54;
	Result=+Inches+Feet;
	decimal();
	TGrams.cms.value=Result.toFixed(frac);}
}

function FtInsConvert()
{
Inches=Pinch%12;
Feet=+Peet+parseInt(Pinch/12);
TGrams.ft.value=Feet;
decimal();
TGrams.ins.value=Inches.toFixed(frac);
Result=(Feet*30.48)+(Inches*2.54);
decimal();
TGrams.cms.value=Result.toFixed(frac);
}

function CmsConvert()
{
Cms=TGrams.cms.value;
Feet=Math.round(Cms/30.48);
Inches=(Cms % 30.48)/2.54;
TGrams.ft.value=Feet;
decimal();
TGrams.ins.value=Inches.toFixed(frac);
}

function LbsConvert()
{
Kgs=TGrams.lbs.value*0.45359;
decimal();
TGrams.kgs.value=Kgs.toFixed(frac);
}

function KgsConvert()
{
Lbs=TGrams.kgs.value*2.2;
decimal();
TGrams.lbs.value=Lbs.toFixed(frac);
}

function GramsCalculate()
{
decimal();FtInsConvert();LbsConvert();
carb=TGrams.carb.value;
prot=TGrams.prot.value;
fat=TGrams.fat.value;
tot=eval(parseInt(carb) + Math.round(prot) + Math.round(fat));
TGrams.carb.value=Math.round(carb/tot*100);
TGrams.prot.value=Math.round(prot/tot*100);
TGrams.fat.value=100-Math.round(carb/tot*100)-Math.round(prot/tot*100);

carb=TGrams.carb.value/100;
prot=TGrams.prot.value/100;
fat=TGrams.fat.value/100;
if (TGrams.radio3[1].checked)
	{Weight=TGrams.kgs.value*4.36/2.2046;
	Height=TGrams.cms.value*4.32*2.54;
	Age=TGrams.age.value*4.7;
	Result=655+Weight+Height-Age;}
else
	{Weight=TGrams.kgs.value*6.22/2.2046;
	Height=TGrams.cms.value*12.7*2.54;
	Age=TGrams.age.value*6.8;
	Result=66+Weight+Height-Age;}

if (TGrams.Activity[0].checked){
A1=(Result*carb/Protein).toFixed(frac);
A2=(Result*prot/Carbs).toFixed(frac);
A3=(Result*fat/Fats).toFixed(frac);
A4=Result.toFixed(frac);
active=TGrams.Activity[0].value;
for (x=0;x<=TGrams.radio3.length-1;x=x+1)
{if (TGrams.radio3[x].checked)
{gender=TGrams.radio3[x].value;}
}
}

else if (TGrams.Activity[1].checked){
A1=(Result*1.25*carb/Protein).toFixed(frac);
A2=(Result*1.25*prot/Carbs).toFixed(frac);
A3=(Result*1.25*fat/Fats).toFixed(frac);
A4=(Result*1.25).toFixed(frac);
active=TGrams.Activity[1].value;
for (x=0;x<=TGrams.radio3.length-1;x=x+1)
{if (TGrams.radio3[x].checked)
{gender=TGrams.radio3[x].value;}
}
}

else if (TGrams.Activity[2].checked){
A1=(Result*1.3*carb/Protein).toFixed(frac);
A2=(Result*1.3*prot/Carbs).toFixed(frac);
A3=(Result*1.3*fat/Fats).toFixed(frac);
A4=(Result*1.3).toFixed(frac);
active=TGrams.Activity[2].value;
for (x=0;x<=TGrams.radio3.length-1;x=x+1)
{if (TGrams.radio3[x].checked)
{gender=TGrams.radio3[x].value;}
}
}

else if (TGrams.Activity[3].checked){
A1=(Result*1.5*carb/Protein).toFixed(frac);
A2=(Result*1.5*prot/Carbs).toFixed(frac);
A3=(Result*1.5*fat/Fats).toFixed(frac);
A4=(Result*1.5).toFixed(frac);
active=TGrams.Activity[3].value;
for (x=0;x<=TGrams.radio3.length-1;x=x+1)
{if (TGrams.radio3[x].checked)
{gender=TGrams.radio3[x].value;}
}
}

else if (TGrams.Activity[4].checked){
A1=(Result*1.7*carb/Protein).toFixed(frac);
A2=(Result*1.7*prot/Carbs).toFixed(frac);
A3=(Result*1.7*fat/Fats).toFixed(frac);
A4=(Result*1.7).toFixed(frac);
active=TGrams.Activity[4].value;
for (x=0;x<=TGrams.radio3.length-1;x=x+1)
{if (TGrams.radio3[x].checked)
{gender=TGrams.radio3[x].value;}
}
}

else if (TGrams.Activity[5].checked){
A1=(Result*2*carb/Protein).toFixed(frac);
A2=(Result*2*prot/Carbs).toFixed(frac);
A3=(Result*2*fat/Fats).toFixed(frac);
A4=(Result*2).toFixed(frac);
active=TGrams.Activity[5].value;
for (x=0;x<=TGrams.radio3.length-1;x=x+1)
{if (TGrams.radio3[x].checked)
{gender=TGrams.radio3[x].value;}
}
}
TGrams.actgender.value=active+" for "+gender+"  : "+Comma(A4)+" Calories";
TGrams.carbs.value="Carbohydrates  : "+A1+" grams ("+(A1/28.35).toFixed(frac)+" ozs.)";
TGrams.protein.value="Protein                 : "+A2+" grams ("+(A2/28.35).toFixed(frac)+" ozs.)";
TGrams.fats.value="Fat                          :"+A3+" grams ("+(A3/28.35).toFixed(frac)+" ozs.)";
}

function decimal()
{
for (x=0;x<=TGrams.Decimal.length;x=x+1){
if (TGrams.Decimal[x].selected)
{frac=x;
return true;}
}
}

function WaistInchConvert()
{
Peet=BMI11.feet.value;
Pinch=BMI11.inches.value;

if (Pinch >= 12)
	{r=Pinch%12;
	Feet=Math.round(Pinch/12);
	Result=+Peet+Feet;
	BMI11.feet.value=Result;
	BMI11.inches.value=r;}
}

function InchConvert()
{
Peet=BMI1.feet.value;
Pinch=BMI1.inches.value;

if (Pinch >= 12)
	{r=Pinch%12;
	Feet=Math.round(Pinch/12);
	Result=+Peet+Feet;
	BMI1.feet.value=Result;
	BMI1.inches.value=r;}
}

function FarenheitConvert()
{CF.centigrade.value=(CF.farenheit.value-32)*5/9
}

function CentigradeConvert()
{CF.farenheit.value=(CF.centigrade.value*1.8)+32
}

function ValidInput()
{
		
		if (BMI1.feet.value.length<1)
			{alert("Please enter your height in feet");
			BMI1.feet.focus();
			return false;}

		else if (BMI1.inches.value>=12)
			{alert("Inches should be less than 12");
			BMI1.inches.focus();
			return false;}

		else if (BMI1.cms.value.length<1)
			{alert("Please enter your height in cms");
			BMI1.cms.focus();
			return false;}

		else
		{return true;}
}

function ValidComments(){
if (form2.name1.value==""){alert("Your name, please");form2.name1.focus();return false;}
if (form2.email1.value==""){alert("Your email, please");form2.email1.focus();return false;}
var goodEmail = form2.email1.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
if (goodEmail){}
 else
{alert ("Please enter a valid e-mail address.");
form2.email1.focus();
form2.email1.select();
return false;}
if (form2.comments1.value==""){alert("Your comments, please");form2.comments1.focus();return false;}

ToCheck = form2.comments1.value;
Checked = Del(ToCheck);
form2.comments1.value = Checked;
alert("Please notice that all HTML has been filtered from the text box's contents.");
}

function Del(Word) {
a = Word.indexOf("<");
b = Word.indexOf(">");
len = Word.length;
c = Word.substring(0, a);
if(b == -1)
b = a;
d = Word.substring((b + 1), len);
Word = c + d;
tagCheck = Word.indexOf("<");
if(tagCheck != -1)
Word = Del(Word);
return Word;
}

