function keep_numeric(str) {
	var temp = new String(str);
	temp =  temp.replace(/[^. 0-9]+/g, '');

	return temp;
}

function keep_int(str) {
	var temp = new String(str);
	temp =  temp.replace(/[^0-9]+/g, '');

	return temp;
}

function calculate_bmi() {
	var bmi = 0;
	
	var wt = parseInt(document.form_bmi.wt.value);
	var ht = parseInt(document.form_bmi.ht.value);
	
	if ((wt) && (ht)) {
		bmi = (wt / (ht * ht)) * 703;
	}

	document.getElementById('bmi').innerHTML = bmi;
}

function getHTTPObject() {
	if (window.ActiveXObject)
		return new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest)
		return new XMLHttpRequest();
	else {      
		//alert("Your browser does not support AJAX.");
		return null;   
	}
}

function display_fg() {
	document.getElementById("div_fg").style.display = "block";
}

function forgot_password_user(email) {
	httpObject = getHTTPObject();
	
	if (httpObject != null) {
		if (email != "") {
			var now = new Date();

			var fullURL = '/optimal/wp-content/themes/optimal/ajax-forgot-password-user.php?e=' + escape(email) + 
				'&ts=' + now.getTime();
			
			httpObject.open("GET", fullURL, true);
			httpObject.send(null);
			httpObject.onreadystatechange = forgot_password_user_handler;
		}
	}
}

function forgot_password_user_handler() {
	if(httpObject.readyState == 4) {
		document.getElementById('div_fg_results').innerHTML = httpObject.responseText;
	}
}

function set_video(n) {
	switch(n) {
		case 2:
			document.getElementById('video_holder').innerHTML = '<object width="440" height="210"><param name="movie" value="http://www.youtube.com/v/bC4LqmDrSso?version=3&amp;hl=en_US&amp;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/bC4LqmDrSso?version=3&amp;hl=en_US&amp;rel=0" type="application/x-shockwave-flash" width="440" height="210" allowscriptaccess="always" allowfullscreen="true"></embed></object>';
			break;
		
		case 3:
			document.getElementById('video_holder').innerHTML = '<object width="440" height="210"><param name="movie" value="http://www.youtube.com/v/QByJiYdrgVU?version=3&amp;hl=en_US&amp;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/QByJiYdrgVU?version=3&amp;hl=en_US&amp;rel=0" type="application/x-shockwave-flash" width="440" height="210" allowscriptaccess="always" allowfullscreen="true"></embed></object>';
			break;
		
		case 4:
			document.getElementById('video_holder').innerHTML = '<object width="440" height="210"><param name="movie" value="http://www.youtube.com/v/AQZfg7lrI-g?version=3&amp;hl=en_US&amp;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/AQZfg7lrI-g?version=3&amp;hl=en_US&amp;rel=0" type="application/x-shockwave-flash" width="440" height="210" allowscriptaccess="always" allowfullscreen="true"></embed></object>';
			break;
		
		case 5:
			document.getElementById('video_holder').innerHTML = '<object width="440" height="210"><param name="movie" value="http://www.youtube.com/v/ghWDkTeSnwU?version=3&amp;hl=en_US&amp;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/ghWDkTeSnwU?version=3&amp;hl=en_US&amp;rel=0" type="application/x-shockwave-flash" width="440" height="210" allowscriptaccess="always" allowfullscreen="true"></embed></object>';
			break;
		
		default:
			document.getElementById('video_holder').innerHTML = '<object width="440" height="210"><param name="movie" value="http://www.youtube.com/v/MB6tcbtlTgQ?version=3&amp;hl=en_US&amp;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/MB6tcbtlTgQ?version=3&amp;hl=en_US&amp;rel=0" type="application/x-shockwave-flash" width="440" height="210" allowscriptaccess="always" allowfullscreen="true"></embed></object>';
	}
}


