var urlAddress = "http://www.180DegreeHealth.com"; var pageName = "180 Degree Health";



$(document).ready(function(){



	

		$("#tell-link").click(function(event) {

		event.preventDefault();

		$("#tell-box").slideToggle();

		});





	})

	

function addToFavorites() { if (window.external) { window.external.AddFavorite(urlAddress,pageName) 

} else { alert("Sorry! Your browser doesn't support this function."); 

} } 


var baseText = null;

var xmlhttp;



function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
	}
	if (window.ActiveXObject)
	{
		// code for IE6, IE5
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}
//remove the white sapces from the beginning & end of the string
function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

//This is the JS function to validate whether the input is not a empty, 
//if the input is non empty then it will passed to further process else the required input will be ask to the end user
function fieldBlank(fieldName,msg)
{	
	if(trim(fieldName.value)=="")
	{
		alert(msg);
		fieldName.focus();
		return false;
	}
	else
	{
		return true;
	}	
}
//This is the JS function to validate whether the input is a valid email format, 
//if the input is valid it will be passed to further process else the required input will be ask to the end user
function validEmail(fieldName,msg)
{
	if(trim(fieldName.value)!="")
	{	
		var email = fieldName.value;
		var matcharray = email.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z]+)*\.[A-Za-z]+$/) 
		if(matcharray == null)
		{	
			alert(msg);
			fieldName.select();
			return false;
		}
		else 
		{
			return true;
		}
	}
	return true;		
}
function showPopup()
{
	var popUp = document.getElementById("pop1_b");
	popUp.style.display = "block";	
}
function hidePopup()
{
	var popUp = document.getElementById("pop1_b");  
	popUp.style.display = "none";
}

function hide180Member()
{
	var popUp = document.getElementById("member180");  
	popUp.style.display = "none";
}

function validateNewsletter()
{
	var email = document.frmnewsletter.email;
	if(!fieldBlank(email, 'Please enter the email address'))
	{
		return false;	
	}
	if(!validEmail(email, 'Please enter the valid email address'))
	{
		return false;	
	}
	var popUp = document.getElementById("member180");  
	popUp.style.display = "none";
	var popUp = document.getElementById("pop1_b");  
	popUp.style.display = "none";
	var news_status = document.getElementById("newsletter_status").value;
	if(news_status == 0)
	{
		xmlhttp=GetXmlHttpObject();
		if (xmlhttp==null)
		{
			alert ("Browser does not support HTTP Request");
			return;
		}
		var url="update_session.php";
		xmlhttp.onreadystatechange=newsletterStatusChanged;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
	}
	return true;	
}

function newsletterStatus()
{
	var news_status = document.getElementById("newsletter_status").value;
	if(news_status == 1)
	{
		var popUp = document.getElementById("pop1_b");  
		popUp.style.display = "none";
		var popUp = document.getElementById("member180");  
		popUp.style.display = "none";
	}
}

function newsletterStatusChanged()
{
	if (xmlhttp.readyState==4)
	{
		
	}
}