var xmlHttp;
var divObj;

function changeMeasurement(type)
{
	if (type == 1)
	{
		document.getElementById('weight').innerHTML = 'kg';
		document.getElementById('height').innerHTML = 'cm';
	}
	if (type == 2)
	{
		document.getElementById('weight').innerHTML = 'lbs';
		document.getElementById('height').innerHTML = 'inches';
	}
	document.getElementById('bmi').value = type;
}
function wo(page, xsize, ysize)
{
   w=window.open(page, "LBH", "menubar=no,scrollbars=auto,width=" + xsize + ",height=" + ysize + ",resizable=yes");
   w.focus();
} 
function tosChecked()
{
	if (document.getElementById("tos").checked == false)
	{
		alert("You have to agree to the Terms of Service in order to proceed");
		return false;
	}
	else
	{
		return true;
	}
};
function clearObjContents(obj)
{
	 document.getElementById(obj).innerHTML = "";
}
function showDiv(obj)
{
	if ($("#"+obj).attr("style") == "display: none;")
	{
		$("#"+obj).show("medium");
	}
	else
	{
		$("#"+obj).hide("fast");
	}
}
function getRequest(obj, url) 
{
	xmlHttp=GetXmlHttpObject();
	divObj = obj;
	$("#"+divObj).attr("style", "display: block; padding: 5px; margin-bottom: 10px;");
	document.getElementById(divObj).innerHTML = "<img src='img/ajax-loader.gif' border='0' /> Loading...";
	if (xmlHttp==null) 
	{
  		alert ("Your browser does not support AJAX!");
  		return;
  	}
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function stateChanged() 
{
	//alert(xmlHttp.responseText);
	if ((xmlHttp.readyState==4) || ( xmlHttp.readyState === "complete" )) 
	{
		$("#"+divObj).attr("style", "");
		document.getElementById(divObj).innerHTML = xmlHttp.responseText;
	}
}
function GetXmlHttpObject() 
{
	var xmlHttp=null;
	try 
	{
  		// Firefox, Opera 8.0+, Safari
  		xmlHttp=new XMLHttpRequest();
  	}
	catch (e) {
  		// Internet Explorer
  		try {
    		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    	}
  		catch (e) {
    		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    	}
  	}
	return xmlHttp;
}
function addLoadEvent(func)
{
	if(window.addEventListener)	
	{
		window.addEventListener("load",func,false);
	}
	else
	{
		window.attachEvent("onload",func);	
	}
	return true;	
}
