<!--
var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;

var tempX = 0
var tempY = 0

var __url__ = "http://www.projectweightloss.com/index.php";
function HS_CheckStr(str)
{
	if (document.all)
	{
		return document.all[str];
	}
	else
	{
		return document.getElementById(str);
	}
}

function getMouseXY(e) 
{
  if (IE) 
  {
    tempX = event.clientX + document.body.scrollLeft;
    tempY = event.clientY + document.body.scrollTop;
  } 
  else 
  {
    tempX = e.pageX;
    tempY = e.pageY;
  }  
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  

  return true;
}


function HS_ShowToolTip(e,text)
{
	HS_CheckStr('ToolTip').innerHTML="<table><tr><td class=ToolTipTD>"+text+"</td></tr></table>";	
	HS_CheckStr('ToolTip').style.pixelLeft=(e.x+15+document.body.scrollLeft);
	HS_CheckStr('ToolTip').style.pixelTop=(e.y+document.body.scrollTop);
	HS_CheckStr('ToolTip').style.visibility="visible";
}
function HS_HideToolTip()
{
      HS_CheckStr('ToolTip').style.visibility="hidden";
}

function HS_CheckEmailInput(str,event) 
{

		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		var __email = document.getElementById('email');
		if(__email.value != '')
		{
			if (str.indexOf(at)==-1)
			{
			   HS_ShowToolTip(event,"Invalid E-mail ID");
			   __email.focus();
			   return false
			}
	
			if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			   HS_ShowToolTip(event,"Invalid E-mail ID");
			   __email.focus();		   
			   return false
			}
	
			if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
				HS_ShowToolTip(event,"Invalid E-mail ID");
			   __email.focus();			
				return false
			}
	
			 if (str.indexOf(at,(lat+1))!=-1){
				HS_ShowToolTip(event,"Invalid E-mail ID");
			   __email.focus();			
				return false
			 }
	
			 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
				HS_ShowToolTip(event,"Invalid E-mail ID");
			   __email.focus();			
				return false
			 }
	
			 if (str.indexOf(dot,(lat+2))==-1){
				HS_ShowToolTip(event,"Invalid E-mail ID");
			   __email.focus();			
				return false
			 }
			
			 if (str.indexOf(" ")!=-1){
				HS_ShowToolTip(event,"Invalid E-mail ID");
			   __email.focus();			
				return false
			 }
		}
		 HS_HideToolTip();
 		 return true					
	}


function setTabsOrder()
{
	document.getElementById('fname').tabIndex = 1;
	document.getElementById('lname').tabIndex = 2;
	document.getElementById('email').tabIndex = 3;
	document.getElementById('password').tabIndex = 4;
	document.getElementById('confirm_password').tabIndex = 5;
	document.getElementById('country').tabIndex = 6;
	document.getElementById('state').tabIndex = 7;
	document.getElementById('city').tabIndex = 8;
	document.getElementById('postal_code').tabIndex = 9;
	document.getElementById('gender_1').tabIndex = 10;
	document.getElementById('gender_2').tabIndex = 11;
	document.getElementById('birthdate[1]').tabIndex = 12;
	document.getElementById('birthdate[0]').tabIndex = 13;
	document.getElementById('birthdate[2]').tabIndex = 14;	
	document.getElementById('height_1').tabIndex = 15;	
	document.getElementById('height_2').tabIndex = 16;			
	document.getElementById('weight').tabIndex = 17;
	document.getElementById('target_weight').tabIndex = 18;
	document.getElementById('per_week').tabIndex = 19;
	document.getElementById('system_1').tabIndex = 20;
	document.getElementById('system_2').tabIndex = 21;
	document.getElementById('body_class').tabIndex = 22;
	document.getElementById('terms_agree').tabIndex = 24;
	document.getElementById('activity').tabIndex = 23;
	document.getElementById('join_code').tabIndex = 25;
	document.getElementById('submit_image').tabIndex = 26;	
	document.getElementById('join_code').value = "";			
}

	function HS_StatesPopulate(FormHandler,AllowEmpty){		
		for(var k = FormHandler.state.options.length-1; k>=0; k--){
			FormHandler.state.options[k] = null;
		}//for
		for(var k = FormHandler.city.options.length-1; k>=0; k--){
			FormHandler.city.options[k] = null;
		}//for
		FormHandler.state.options[0] = new Option("...loading...");
		FormHandler.city.options[0] = new Option("...loading...");
		var Country = FormHandler.country.options[FormHandler.country.selectedIndex].value;
		var xmlHttpReq = false;
    	var self = this;
    	// Mozilla/Safari
    	if (window.XMLHttpRequest) {
        	self.xmlHttpReq = new XMLHttpRequest();
    	}//if
    	// IE
    	else if (window.ActiveXObject) {
        	self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    	}//else if
    	self.xmlHttpReq.open('POST', __url__, true);
    	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    	self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200) {
	        HS_PullData(self.xmlHttpReq.responseXML,FormHandler.state,'state');
	        HS_PullData(self.xmlHttpReq.responseXML,FormHandler.city,'city');
    	}//if
        }//function
    	self.xmlHttpReq.send("handler=geo&action=states&country="+Country+"&allow_empty="+AllowEmpty);
	}//HS_StatesPopulate
	function HS_CitiesPopulate(FormHandler,AllowEmpty){
		for(var k = FormHandler.city.options.length-1; k>=0; k--){
			FormHandler.city.options[k] = null;
		}//for
		FormHandler.city.options[0] = new Option("...loading...");
		var Country = FormHandler.country.options[FormHandler.country.selectedIndex].value;
		var State = FormHandler.state.options[FormHandler.state.selectedIndex].value;
		var xmlHttpReq = false;
    	var self = this;
    	// Mozilla/Safari
    	if (window.XMLHttpRequest) {
        	self.xmlHttpReq = new XMLHttpRequest();
    	}//if
    	// IE
    	else if (window.ActiveXObject) {
        	self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    	}//else if
    	self.xmlHttpReq.open('POST', __url__, true);
    	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    	self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200) {
	        HS_PullData(self.xmlHttpReq.responseXML,FormHandler.city,'city');
    	}//if
        }//function
    	self.xmlHttpReq.send("handler=geo&action=cities&&country="+Country+"&state="+State+"&allow_empty="+AllowEmpty);
	}//HS_CitiesPopulate
	function HS_PullData(XMLData,FieldHandler,ItemName){
		for(var k = FieldHandler.options.length-1; k>=0; k--){
			FieldHandler.options[k] = null;
		}//for
		var Items = XMLData.getElementsByTagName(ItemName);
    	for(var i=0;i<Items.length;i++){
    		var ItemID = Items[i].firstChild.firstChild.nodeValue;
    		var ItemName = Items[i].firstChild.nextSibling.firstChild.nodeValue;
    		FieldHandler.options[i] = new Option(ItemName,ItemID);
    	}//for
	}//HS_PullData
    function HS_Us_Height()
	{
			var options = new Array();		
			options[0] = "3";
			options[1] = "4";
			options[2] = "5";
			options[3] = "6";
			options[4] = "7";
			options[5] = "8";
			
			var arrValues = new Array();
			arrValues[0] = "3";
			arrValues[1] = "4";
			arrValues[2] = "5";
			arrValues[3] = "6";
			arrValues[4] = "7";
			arrValues[5] = "8";
	
			var height_1 = document.getElementById('height_1');			
			height_1.length = 0;			
			for(i=0;i<options.length;i++)
			{
				height_1.options[i] = new Option(options[i],arrValues[i]);
			}
	}
    
      
	function HS_Switch_Simple_BMI()
	{
		switch (document.getElementById("current_val").value)
		{
			case "1":
				HS_Us_Height();
				document.getElementById("weight_unit_container").innerHTML = "lb";
				document.getElementById("target_weight_unit_container").innerHTML = "lb";
				document.getElementById("height_1_unit_container").innerHTML = "ft";
				document.getElementById("height_2_container").style.display = "inline";
				document.getElementById("height_2_unit_container").innerHTML = "in";
				document.getElementById("per_week_unit_container").innerHTML = "lb/week";
				break;
			case "2":
				HS_Metric_Height();
				document.getElementById("weight_unit_container").innerHTML = "kg";
				document.getElementById("target_weight_unit_container").innerHTML = "kg";
				document.getElementById("height_1_unit_container").innerHTML = "cm";
				document.getElementById("height_2_container").style.display = "none";
				document.getElementById("height_2_unit_container").innerHTML = "";
				document.getElementById("per_week_unit_container").innerHTML = "kg/week";
				break;
		}
	}


	function HS_Unit_Convert(val1, val2, type, sys)
	{
		var result = new Array();
		switch (type)
		{
			case "height":
				switch (sys)
				{
					case "metric_to_us":
						inch = val1 / 2.54;
						ft = parseInt(inch / 12);
						inch = Math.round(inch - (ft * 12));
						if (inch == 12)
						{
							ft = parseInt(ft) + 1;
							inch = 0;
						}
						result[0] = ft;
						result[1] = inch;
						break;
					case "us_to_metric":
						if (val2 == "")
						{
							val2 = 0;
						}
						cm = Math.round((parseInt(val1 * 12) + parseInt(val2)) * 2.54);
						result[0] = cm;
						result[1] = 0;
						break;
				}
				break;
			case "weight":
				switch (sys)
				{
					case "metric_to_us":
						lb = Math.round(val1 * 2.20462262);
						result[0] = lb;
						result[1] = 0;
						break;
					case "us_to_metric":
						kg = val1 * 0.45359237;
						result[0] = kg;
						result[1] = 0;
						break;
				}
				break;
		}
		return result;
	}

	function HS_Metric_Height()
	{
			var options = new Array();		
			options[0] = "122";
			options[1] = "124";
			options[2] = "127";
			options[3] = "130";
			options[4] = "132";
			options[5] = "135";
			options[6] = "137";
			options[7] = "140";
			options[8] = "142";
			options[9] = "145";
			options[10] = "147";
			options[11] = "150";
			options[12] = "152";
			options[13] = "155";
			options[14] = "157";
			options[15] = "160";
			options[16] = "163";
			options[17] = "165";
			options[18] = "168";
			options[19] = "170";
			options[20] = "173";
			options[21] = "175";
			options[22] = "178";
			options[23] = "180";
			options[24] = "183";
			options[25] = "185";
			options[26] = "188";
			options[27] = "191";
			options[28] = "193";
			options[29] = "196";
			options[30] = "198";
			options[31] = "201";
			options[32] = "203";
			options[33] = "206";
			options[34] = "208";
			options[35] = "211";
			options[36] = "213";
			options[37] = "216";
			options[38] = "218";
			options[39] = "221";
			options[40] = "224";
			options[41] = "226";
			options[42] = "229";
			options[43] = "231";
			options[44] = "234";
			options[45] = "236";
			options[46] = "239";
			options[47] = "241";
			options[48] = "244";
			
			var height_1 = document.getElementById('height_1');			
			height_1.length = 0;			
			for(i=0;i<options.length;i++)
			{
				height_1.options[i] = new Option(options[i],options[i]);
			}
	}


	function HS_Detect (thisValue)
	{
		if (document.getElementById("current_val").value != thisValue)
		{
			switch (thisValue)
			{
				case "1":
					if (document.getElementById("height_1").value != "")
					{
						
						result = HS_Unit_Convert(document.getElementById("height_1").value, document.getElementById("height_2").value, "height", "metric_to_us");
						document.getElementById("height_1").selectedIndex = result[0];
						document.getElementById("height_2").selectedIndex = result[1];
						//document.forms[0].height_1.options[height_1.selectedIndex] = result[0];
						//document.forms[0].height_2.options[height_2.selectedIndex] = result[1];
		
					}
					else
					{
						document.getElementById("height_2").value = "";
					}
					if (document.getElementById("weight").value != "")
					{
						result = HS_Unit_Convert(document.getElementById("real_weight").value, "0", "weight", "metric_to_us");
						document.getElementById("weight").value = result[0];
					}
					if (document.getElementById("target_weight").value != "")
					{
						result = HS_Unit_Convert(document.getElementById("real_target_weight").value, "0", "weight", "metric_to_us");
						document.getElementById("target_weight").value = result[0];
					}
					if (document.getElementById("per_week").value != "")
					{
						result = HS_Unit_Convert(document.getElementById("real_per_week").value, "0", "weight", "metric_to_us");
						document.getElementById("per_week").value = result[0];
					}
					break;
				case "2":
					if (document.getElementById("weight").value != "")
					{
						result = HS_Unit_Convert(document.getElementById("weight").value, "0", "weight", "us_to_metric");
						document.getElementById("weight").value = Math.round(result[0]);
						document.getElementById("real_weight").value = result[0];
					}
					if (document.getElementById("target_weight").value != "")
					{
						result = HS_Unit_Convert(document.getElementById("target_weight").value, "0", "weight", "us_to_metric");
						document.getElementById("target_weight").value = Math.round(result[0]);
						document.getElementById("real_target_weight").value = result[0];
					}
					if (document.getElementById("height_1").value != "")
					{
						
						result = HS_Unit_Convert(document.getElementById("height_1").value, document.getElementById("height_2"), "height", "us_to_metric");
						
						document.getElementById("height_1").selectedIndex = result[0];
						document.getElementById("height_2").selectedIndex = result[1];
					}
					else
					{
						document.getElementById("height_2").value = "0";
					}
					if (document.getElementById("per_week").value != "")
					{
						result = HS_Unit_Convert(document.getElementById("per_week").value, "0", "weight", "us_to_metric");
						document.getElementById("per_week").value = Math.round(result[0]);
						document.getElementById("real_per_week").value = result[0];
					}
					break;
			}
			document.getElementById("current_val").value = thisValue;
			HS_Switch_Simple_BMI();
			HS_Show_Perweek();
		}
	}

	function HS_Detect_Gender (thisValue){
		if (document.getElementById("gender_val").value != thisValue)
		{
			switch (thisValue)
			{
				case "1":
					document.getElementById("pregnant_label_container").style.display = "none";
					document.getElementById("pregnant_container").style.display = "none";
					document.getElementById("pregnant").checked = false;
					document.getElementById("pregnant_interval_container").style.display = "none";
					document.getElementById("pregnant_interval").value = "1";
					document.getElementById("lactating_label_container").style.display = "none";
					document.getElementById("lactating_container").style.display = "none";
					document.getElementById("lactating").checked = false;
					document.getElementById("lactating_interval_container").style.display = "none";
					document.getElementById("lactating_interval").value = "1";
					document.getElementById("pl_interval").style.display = "none";
					break;
				case "2":
					document.getElementById("pregnant_label_container").style.display = "block";
					document.getElementById("pregnant_container").style.display = "block";
					document.getElementById("lactating_label_container").style.display = "block";
					document.getElementById("lactating_container").style.display = "block";
					document.getElementById("pl_interval").style.display = "block";
					
					break;
			}
			document.getElementById("gender_val").value = thisValue;
		}
	}

	function HS_Show_Intervals (thisId)
	{
		if (document.getElementById(thisId).checked)
		{
			document.getElementById(thisId + "_interval_container").style.display = "block";
			document.getElementById(thisId + "_interval").value = "1";
		}
		else
		{
			document.getElementById(thisId + "_interval_container").style.display = "none";
		}
	}

	function HS_Display_Info (thisId)
	{
		if (timeoutIsSet)
		{
			clearTimeout(timeoutId);
			timeoutIsSet = false;
		}
		var iMargin;
		switch (thisId)
		{
			case 1:
				iMargin = "-240";
				txt = "Ectomorphs are typically slim, with long muscles and bones, and possibly underweight. While they can lose weight quickly, they usually have a hard time gaining weight and building muscle mass.";
				break;
			case 2:
				iMargin = "-160";			
				txt = "Mesomorphs are typically strong and athletic, with muscular bodies. They can generally develop muscle mass without difficulty, and eat without too much concern about gaining weight.";
				break;
			case 3:
				iMargin = "-40";			
				txt = "Endomorphs tend to be stocky, rounded and with big bones. They usually poses good natural strength and don't have difficulty building muscle, but have a difficult time losing weight and body fat.";
				break;
		}
		document.getElementById("info_container_txt").innerHTML = txt;
		document.getElementById("info_container").style.marginLeft = iMargin;
		document.getElementById("info_container").style.marginTop = "17px";
		document.getElementById("info_container").style.display = "block";
		timeoutId = setTimeout("document.getElementById(\"info_container\").style.display = \"none\";", 10000);
		timeoutIsSet = true;
	}

	function HS_Close_Info ()
	{
		document.getElementById('info_container').style.display = "none";
		clearTimeout(timeoutId);
		timeoutIsSet = false;
	}

	function HS_Show_Perweek()
	{
		if (document.getElementById('weight').value != "0" && document.getElementById('weight').value != "" && document.getElementById('target_weight').value != "0" && document.getElementById('target_weight').value != "" && document.getElementById('weight').value != document.getElementById('target_weight').value)
		{
			if (parseInt(document.getElementById('weight').value) > parseInt(document.getElementById('target_weight').value))
			{
				document.getElementById('per_week_label_container').innerHTML = "<b>Target Weight Loss Rate</b><font color=\"#FF0000\">*</font>";
			}
			else
			{
				document.getElementById('per_week_label_container').innerHTML = "<b>Target Weight Gain Rate</b><font color=\"#FF0000\">*</font>";
			}
			if (document.getElementById("current_val").value == "1")
			{
				document.getElementById('per_week_unit_container').innerHTML = "lb/week";
			}
			else
			{
				document.getElementById('per_week_unit_container').innerHTML = "kg/week";
			}
			document.getElementById('per_week_label_container').style.display = "block";
			document.getElementById('per_week_container').style.display = "block";
		}
		else
		{
			document.getElementById('per_week_label_container').style.display = "block";
			document.getElementById('per_week_container').style.display = "block";
			document.getElementById('per_week').value = "";
		}
	}

	timeoutIsSet = false;

//-->