function _checkEmpty()
{
f=document.frmTop;
type="articles";
search_string=f.search_value.value;
if(f.search_value.value=="" || f.search_value.value=="eg. Seasonal Diseases, Clinical Tips, etc.")
{
alert("Please enter search criteria.");
return false;
}
f.action="http://www.homeorizon.com/homeopathic-hot-searches/"+type+"/"+search_string;
f.submit();
}
function click_button(e)
{ 
//var bt = document.getElementById("Button1"); 
//if (typeof bt == 'object')
//{ 
if (e.keyCode == 13)
{ 
//bt.click();
_checkEmpty();
return false; 
} 
//} 
}
function _clear()
{
if(document.frmTop.search_value.value=="eg. Seasonal Diseases, Clinical Tips, etc.")
{
document.getElementById("search_value").style.color="#000000";
document.frmTop.search_value.value="";
}
}
function _setvalue()
{
if(document.frmTop.search_value.value=="")
{
document.getElementById("search_value").style.color="#999999";
document.frmTop.search_value.value="eg. Seasonal Diseases, Clinical Tips, etc.";
}
}

function _cleartarea()
{
if(document.ask_ques.ques.value=="Enter your problem here.")
{
document.ask_ques.ques.value="";
}
}
function _settarea()
{
if(document.ask_ques.ques.value=="")
{
document.ask_ques.ques.value="Enter your problem here.";
}
}
function click_ques(e)
{ 
//var bt = document.getElementById("Button1"); 
//if (typeof bt == 'object')
//{ 
if (e.keyCode == 13)
{ 
//bt.click();
submit_ques();
return false; 
} 
//} 
}
function submit_ques()
{
	if(document.ask_ques.ques.value=="" || document.ask_ques.ques.value=="Enter your problem here.")
	{
	alert("Please enter your Question");
	document.ask_ques.ques.focus();
	return false;
	}
	if(document.ask_ques.email.value=="")
	{
	alert("Please enter your E-mail");
	document.ask_ques.email.focus();
	return false;
	}
	if(document.ask_ques.email.value.indexOf("@")<3)
	{
	alert("Sorry!. The e-mail address seems to be wrong. Please check the prefix and '@' sign.");
	document.ask_ques.email.focus();
	return false;
	}
	document.ask_ques.action="http://www.homeorizon.com/save-question.php";
	document.ask_ques.submit();
}
function samp_ques()
{
	window.open('http://www.homeorizon.com/sample-questions.php','ss',"scrollbars=no,width=550,height=400,left=240,top=180,toolbar=no,menubar=no,titlebar=no,scrollbar=yes");
}
function show_poll()
{
	window.open('http://www.homeorizon.com/pop-poll.php','ss',"scrollbars=no,width=400,height=300,left=302,top=234,toolbar=no,menubar=no,titlebar=no,scrollbar=yes");
}
function subscribe_me()
{
	window.open('http://www.homeorizon.com/subscribe-free-ezine.php','ss',"scrollbars=no,width=350,height=290,left=325,top=248,toolbar=no,menubar=no,titlebar=no,scrollbar=yes");
}
function pop_policy()
{
	window.open('http://www.homeorizon.com/pop-policy.php','ss',"scrollbars=yes,width=800,height=600,left=112,top=84,toolbar=no,menubar=no,titlebar=no,scrollbar=yes");
}
function pop_terms()
{
	window.open('http://www.homeorizon.com/pop-terms.php','ss',"scrollbars=yes,width=800,height=600,left=112,top=84,toolbar=no,menubar=no,titlebar=no,scrollbar=yes");
}
/*function show_userdetails()
{
	document.getElementById("commentForm").style.visibility="visible";
	document.getElementById("commentForm").style.display="block";
}*/
function getStar(stars)
{
	for(i=1; i<=5; i++)
	{
		if(document.getElementById("s"+i)==stars)
		{
			starSelected=i;
			document.getElementById("star_rate").value=i;
			break;
		}
	}
	for(i=1; i<=starSelected; i++)
	{
		document.getElementById("s"+i).src="http://www.homeorizon.com/images/star_fill.gif";
	}
	for(i=starSelected+1; i<=5; i++)
	{
		document.getElementById("s"+i).src="http://www.homeorizon.com/images/star_empty.gif";
	}
}
/*function  submit_rating(page_head)
{
	f=document.rate;
	if (window.XMLHttpRequest)
  	{// code for IE7+, Firefox, Chrome, Opera, Safari
  		xmlhttp=new XMLHttpRequest();
  	}
	else
  	{// code for IE6, IE5
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  	}
	xmlhttp.onreadystatechange=function()
  	{
  		if(xmlhttp.readyState==4 && xmlhttp.status==200)
    	{
    		document.getElementById("res_rate").innerHTML=xmlhttp.responseText;
   		}
  	}
xmlhttp.open("POST",page_head,true);
xmlhttp.send();
}*/
function click_star(e)
{ 
//var bt = document.getElementById("Button1"); 
//if (typeof bt == 'object')
//{ 
if (e.keyCode == 13)
{ 
//bt.click();
submit_rating();
return false; 
}
} 
function submit_rating(page_head)
{
	f=document.rate;
	if(isNaN(document.getElementById("star_rate").value) || document.getElementById("star_rate").value < 1 )
	{
		alert("Please enter valid star number.");
		f.star_rate.focus();
		return false;
	}
	else if(document.getElementById("star_rate").value > 5)
	{
		document.getElementById("star_rate").value=5;
	}
	f.action="http://www.homeorizon.com/homeopathic-services/"+page_head;
	f.submit();
}
function click_email_this(page_head)
{
	document.send_frnd.action="http://www.homeorizon.com/homeopathic-services/"+page_head;
	document.send_frnd.submit();
}
function chk_comment_frm(page_head)
{
	f=document.user_comment;
	if(f.star_rate.value)
	{
		if(isNaN(document.getElementById("star_rate").value) || document.getElementById("star_rate").value < 1 )
		{
			alert("Please enter valid star number.");
			f.star_rate.focus();
			return false;
		}
		else if(document.getElementById("star_rate").value > 5)
		{
			document.getElementById("star_rate").value=5;
		}
	}
	if(trim(f.comment.value)=="")
	{
		alert("Please enter your valuable comments");
		f.comment.focus();
		return false;
	}
	if(f.mcode.value!=1)
	{
		if(trim(f.email.value)=="")
		{
			alert("Please enter your registered email address.");
			f.email.focus();
			return false;
		}
		else
		{
			emailvalue=f.email.value;
			emailvalid=isValidEmail(emailvalue);	
			if(emailvalid!=true)
			{
				alert("Please check your provided e-mail address.");
				f.email.focus();
				return false;
			}
		}
		if(trim(f.password.value)=="")
		{
			alert("Please enter your registered password.");
			f.password.focus();
			return false;
		}
	}
	f.action="http://www.homeorizon.com/homeopathic-services/"+page_head;
	f.submit();
}
function changedval(obj,tstr,maxchars)
{
	var tobj = document.getElementById(tstr);
	//alert(tobj);
	if (obj.value.length > maxchars)
	{
		obj.value = obj.value.substring(0, maxchars);
		var valstr = 'Comment length : ' + maxchars +',   '  +'Remaining :  '+ 0;
		tobj.innerHTML = valstr;
	}	
	else
	{
		var nchars = obj.value.length;
		var rchars = maxchars - nchars;
		var valstr = 'Comment length : ' + nchars +',   '  +'Remaining :  ' + rchars;
		tobj.innerHTML = valstr;
	}
}
function trim(str)
{	
var s = str.replace(/^(\s)*/, '');
s = s.replace(/(\s)*$/, '');
return s;
}
function isValidEmail(str)
{
emailRe = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/;
if (!emailRe.test(str))	
return false;
else
return true;
}
function submit_agree(page_head, liking, comment)
{
	var f=document.commentAgree;
	if(liking=="report_abuse")
	{
		document.getElementById("comment_id").value=comment;
	}
	else
	{
		if(liking=="agree")
		{
			document.getElementById("agreed").value=1;
			document.getElementById("disagreed").value=0;
		}
		else
		{
			document.getElementById("agreed").value=0;
			document.getElementById("disagreed").value=1;
		}
		document.getElementById("comment_agree").value=comment;
	}
	f.action=page_head;
	f.submit();	
}
function chk_abuse_frm(article_id)
{
	f=document.report_abuse;
	if(f.reason_type.value=="")
	{
		alert("Please select a reason to report it abusive");
		f.comment.focus();
		return false;
	}
	if(f.mcode.value!=1)
	{
		if(trim(f.email.value)=="")
		{
			alert("Please enter your registered email address.");
			f.email.focus();
			return false;
		}
		else
		{
			emailvalue=f.email.value;
			emailvalid=isValidEmail(emailvalue);	
			if(emailvalid!=true)
			{
				alert("Please check your provided e-mail address.");
				f.email.focus();
				return false;
			}
		}
		if(trim(f.password.value)=="")
		{
			alert("Please enter your registered password.");
			f.password.focus();
			return false;
		}
	}
	f.action="http://www.homeorizon.com/homeopathic-services/"+article_id;
	f.submit();
}
function _send_article(article_id)
{
	f=document.frm_send;
	if(f.mcode.value!=1)
	{
		if(trim(f.email.value)=="")
		{
			alert("Please enter your registered email address.");
			f.email.focus();
			return false;
		}
		else
		{
			emailvalue=f.email.value;
			emailvalid=isValidEmail(emailvalue);	
			if(emailvalid!=true)
			{
				alert("Please check your provided e-mail address.");
				f.email.focus();
				return false;
			}
		}
		if(trim(f.password.value)=="")
		{
			alert("Please enter your registered password.");
			f.password.focus();
			return false;
		}
	}
	f.action="http://www.homeorizon.com/homeopathic-services/"+article_id;
	f.submit();
}
function pageHit(pgno, start, end)
{
	for(i=start; i<=end; i++)
	{
	if(document.getElementById("pagesLink"+i)==pgno || document.getElementById("pagesLink2"+i)==pgno)
	{
		document.getElementById("pages"+i).style.backgroundImage="url(http://www.homeorizon.com/images/current_pg.gif)";
		document.getElementById("pages2"+i).style.backgroundImage="url(http://www.homeorizon.com/images/current_pg.gif)";
	}
	}
}
function pageOut(pgno, start, end)
{
	for(i=start; i<=end; i++)
	{
	if(document.getElementById("pagesLink"+i)==pgno || document.getElementById("pagesLink2"+i)==pgno)
	{
		document.getElementById("pages"+i).style.backgroundImage="url(http://www.homeorizon.com/images/page.gif)";
		document.getElementById("pages2"+i).style.backgroundImage="url(http://www.homeorizon.com/images/page.gif)";
	}
	}
}
function increase_font()
{
	document.getElementById("control").style.fontSize="larger";
}
function decrease_font()
{
	document.getElementById("control").style.fontSize="smaller";
}
function submit_paging_form(pgno)
{
	f=document.paging_form;
	document.getElementById("cur_page").value=pgno;
	url=document.getElementById("url").value;
	f.action=url;
	f.submit();
}
