function debug (elemnt, str)
{	 var db = document.getElementById(elemnt);
	 if(db) db.innerHTML +=  str + '<br>';
}

function setHome(e) {
    var xMoz= (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined') && (typeof HTMLDocument!='undefined');
    var xSaf= navigator.userAgent.toLowerCase().indexOf("safari") != -1;
    var fIE = !xMoz && !xSaf;
    
    if (fIE) {
        e.style.behavior='url(#default#homepage)';
        e.setHomePage('http://health.ninemsn.com');
        return false;
    } else {
        return true;
    }
}

function onEnter(form, e, strParam)
{ var keycode;
  if (window.event) keycode = window.event.keyCode;
  else if (e) keycode = e.which;
  else return true;
  if (keycode == 13) {
    submit_form (form, strParam);
    return false;
  } else return true;
}

function focusOn(obj) 
{  if (obj.value == 'Search health') obj.value = '';
    return true;
}

function focusOut(obj) 
{  if (obj.value == '') obj.value = 'Search health';
    return true;
}

function submit_form()
{ var arrArgs = submit_form.arguments;
 var oForm = arrArgs[0];
 var strParam = arrArgs[1];
 var strInput, strType;

  if (strParam == 'HEALTH')
 { if ("[" + typeof(oForm.query.value) + "]"!="[undefined]")
  { strInput = oForm.query.value
  }else
  { strInput = '';
  }
  window.parent.location.href = "/search.aspx?query="+strInput;
 }
 return false;
}

function form_validator(theForm)
{	if (theForm.yourheight.value == "" || withinRange(theForm.yourheight.value)==false)
	{	alert("You must enter your height between 1 to 300!");
		theForm.yourheight.focus();
		return (false);
	} 
	else if (theForm.yourweight.value == "" || withinRange(theForm.yourweight.value)==false) 
	{	alert("You must enter your weight between 1 to 300!");
		theForm.yourweight.focus();
		return (false);
	}
	return (true);
}
 
function withinRange(input)
{	i = 0;
	if (isNumeric(input)==true) 
	{	i = parseInt(input);
		if (i>0 && i<300)
		{	return(true);
		}
	}
	return(false);
}
 
function isNumeric(szString)
{	nIdx = 0;
	szNumerics = "0123456789.";
	while (szString.substring(nIdx,nIdx+1)!="") 
	{	if (szNumerics.indexOf(szString.substring(nIdx,nIdx+1))==-1) 
		{	return(false);
		}
		nIdx++;
	}
	return(true);
}

function ImgError(source)
{
  source.style.display = "none";
  source.onerror = "";
  return true;
}




