// ========================== //
// ===== Health Section ===== //
// ========================== //
function jumpHealthNotes(pageUrl)
{  
	if (pageUrl.length > 0) 
	{				
		window.location.href = pageUrl;
	}		
}
// Paging Javascript
function loadPage(pageno,action)
{
	document.getElementById('page').value=''+pageno;		
	document.loadPageing.action=action;
	document.loadPageing.submit();
}
// Comment Post
function ValidateHealthSection(a) {
    if (isWhitespace(a.name.value)) {
        alert("Please enter your name.");
        a.name.focus();
        return false;
    } else if (!isCharsInBag(a.name.value, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ")) {
        alert("Your name contains invalid characters.");
        a.name.focus();
        return false;
    }
    var b = trimAll(a.email.value);
    if (isWhitespace(b)) {
        alert("Please enter your e-mail address.");
        a.email.focus();
        return false;
    } else if (!isEmail(b)) {
        alert("Please enter your e-mail address in the correct format.");
        a.email.focus();
        return false;
    } else if (!isCharsInBag(b, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@._-")) {
        alert("Your e-mail address contains invalid characters.");
        a.email.focus();
        return false;
    }
    if (isWhitespace(a.comments.value)) {
        alert("Please enter your comments.");
        a.comments.focus();
        return false;
    }
    if (isWhitespace(a.name2.value)) {
        alert("Please enter characters in the image below.");
        a.name2.focus();
        return false;
    }
    return true
}
function postCommentHealth() {	
    if (!ValidateHealthSection(document.blog_comment_form)) {
        return false;
    }else{
    	document.getElementById('secured').value = 'secured';    
    	return true;
	}
}

// Rating Javascripts
function GetBrowserHealth()
{
	var xmlHTTP =null;
	try {
		//firefox ,sarfari,opera;
		xmlHTTP   = new XMLHttpRequest();
	}
	catch (e)
	{
		//FOR IE
		try
		{
			xmlHTTP = new ActiveXObject("Msxml2.XMLHTTP");	
		}
		catch (E)
		{
			xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");			
		}
	}
	return xmlHTTP;
} 
function showOverRatingHealth(imgId){
	var im=1;
	for(im = 1; im<=imgId; im++){
		document.getElementById("img"+im).src='images/yellow_star_17_16.gif';
	}
}
function showOutRatingHealth(imgId,ratingId){
	var im=1;
	//alert(ratingId);
	for(im = 1; im<=5; im++){
		if(im <= ratingId)
			document.getElementById("img"+im).src='images/orange_star_17_16.gif';
		else
			document.getElementById("img"+im).src='images/grey_star_17_16.gif';
	}
}
function doUpdateRatingHealth(type, id, vote)
{	
	var url = "rating_update_health.php";
	var param ="id="+id+"&type="+type+"&vote="+vote;
	//alert(param);
	var xmlhttp =  new GetBrowserHealth();
	xmlhttp.open('POST', url, true);                      
	
	/* The callback function */
	document.getElementById('div_rating_health').style.display='';
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4) {
		
		var objDetails = xmlhttp.responseText;
		//alert(objDetails);
		if(objDetails != null){
			
				document.getElementById("div_rating_health").innerHTML=""
				document.getElementById("div_rating_health").innerHTML = objDetails;
		}
				
		}
	}                  
	
	/* Send the POST request */
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlhttp.send(param);	
}

