function loginaction(evt){

	if (evt){
		var thisKey = (evt.which) ? evt.which : window.event.keyCode;
	}
	else{
		var thisKey = 13;
	}
	var error = false;
	if (thisKey == 13){
		username = document.getElementById("txtUserName").value;
		password = document.getElementById("txtPassword").value;
		if (username == ""){
			alert("Please enter valid username");
			document.getElementById("txtUserName").focus();
			error = true;
		}
		else if (password == ""){
			alert("Please enter password");
			document.getElementById("txtPassword").focus();
			error = true;
		}
		if (!error){
			var temp_pageurl=window.location.href.substring(window.location.href.indexOf("php"), window.location.href.length);
			var pageurl = temp_pageurl.substring(4,temp_pageurl.length); 
			document.getElementById("pageurl").value=pageurl;
			document.forms[0].method = "POST";
			document.forms[0].action = document.getElementById("hidURL").value;
			document.forms[0].submit();
		}
	}
}
		
		
function searchbars(){
	document.frmBars.action = document.getElementById("hidSearchbarsURL").value;
	document.frmBars.submit();
}

function searchdrinks(){
	
	document.frmDrinks.action = document.getElementById("hidSearchDrinksURL").value;
	document.frmDrinks.submit();
}

function drinks_page(drink_name){

	document.getElementById("drinkname").value = drink_name; 
	document.frmSpecialDrinks.action = document.getElementById("hidSearchDrinksURL").value;
	document.frmSpecialDrinks.submit();
}



function add_rating(barid){
	document.getElementById("barid").value = barid;
	doWork_Add(barid);
}

function sub_rating(barid){
	document.getElementById("barid").value = barid;
	doWork_Sub(barid);
}

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 setOutput(){
	if(httpObject.readyState == 4){
		barid = document.getElementById("barid").value;
		div_id = "div_agree" + barid
		base_url = document.getElementById("base_url").value; 
		base_url = base_url + "images/members_red.gif";
		//document.getElementById(div_id).innerHTML = httpObject.responseText; 
		responseText = "<img src=\""+ base_url + "\" align=\"absmiddle\"/> &nbsp; <strong> "+ httpObject.responseText + "</strong> MEMBERS AGREE</div>"; 
		document.getElementById(div_id).innerHTML = responseText;
	}
}

function doWork_Add(barid){
	httpObject = getHTTPObject();
	url = document.getElementById("site_url").value;
	if (httpObject != null) {
		httpObject.open("GET", url + "add_rating/" + barid, true);
		httpObject.send(null);
		httpObject.onreadystatechange = setOutput;
	}
}

function doWork_Sub(barid){
	httpObject = getHTTPObject();
	url = document.getElementById("site_url").value;
	if (httpObject != null) {
		httpObject.open("GET", url + "sub_rating/" + barid, true);
		httpObject.send(null);
		httpObject.onreadystatechange = setOutput;
	}
}

function get_auth(){
	document.forms[0].method = "POST";
	document.forms[0].action = document.getElementById("site_url").value + "/bar_auth";
	document.forms[0].submit();
}
var httpObject = null;


function get_auth_drinks(){
	document.forms[0].method = "POST";
	document.forms[0].action = document.getElementById("site_url").value + "/drinks_auth";
	document.forms[0].submit();
}

function add_rating_drinks(drinkid){
	document.getElementById("drinkid").value = drinkid;
	doWork_Add_drinks(drinkid);
}

function sub_rating_drinks(drinkid){
	document.getElementById("drinkid").value = drinkid;
	doWork_Sub_drinks(drinkid);
}

function doWork_Add_drinks(drinkid){
	httpObject = getHTTPObject();
	url = document.getElementById("site_url").value;
	if (httpObject != null) {
		httpObject.open("GET", url + "add_rating_drinks/" + drinkid, true);
		httpObject.send(null);
		httpObject.onreadystatechange = setDrinksOutput;
	}
}
function doWork_Sub_drinks(badrinkidrid){
	httpObject = getHTTPObject();
	url = document.getElementById("site_url").value;
	if (httpObject != null) {
		httpObject.open("GET", url + "sub_rating_drinks/" + drinkid, true);
		httpObject.send(null);
		httpObject.onreadystatechange = setDrinksOutput;
	}
}

function setDrinksOutput(){
	
	if(httpObject.readyState == 4){
		barid = document.getElementById("drinkid").value;
		div_id = "div_agree" + barid
		base_url = document.getElementById("base_url").value; 
		
		base_url = base_url + "images/members_red.gif";
		//document.getElementById(div_id).innerHTML = httpObject.responseText; 
		responseText = "<img src=\""+ base_url + "\" align=\"absmiddle\"/> &nbsp; <strong> "+ httpObject.responseText + "</strong> MEMBERS AGREE</div>";
		document.getElementById(div_id).innerHTML = responseText;
	}
}

function get_auth_submit_drinks(){
	document.forms[0].method = "POST";
	document.forms[0].action = document.getElementById("site_url").value + "/submit_drinks_auth";
	document.forms[0].submit();
}

function get_top_auth_drinks(){
	document.forms[0].method = "POST";
	document.forms[0].action = document.getElementById("site_url").value + "/topdrinks_auth";
	document.forms[0].submit();
}


function add_top_rating_drinks(drinkid){
	document.getElementById("drinkid").value = drinkid;
	doWork_top_Add_drinks(drinkid);
}

function doWork_top_Add_drinks(drinkid){
	httpObject = getHTTPObject();
	url = document.getElementById("site_url").value;
	if (httpObject != null) {
		httpObject.open("GET", url + "top_add_rating_drinks/" + drinkid, true);
		httpObject.send(null);
		httpObject.onreadystatechange = setTopDrinksOutput;
	}
}

function setTopDrinksOutput(){
	
	if(httpObject.readyState == 4){
		barid = document.getElementById("drinkid").value;
		div_id = "div_agree" + barid
		base_url = document.getElementById("base_url").value; 
		
		base_url = base_url + "images/members_red.gif";
		//document.getElementById(div_id).innerHTML = httpObject.responseText; 
		responseText = "<img src=\""+ base_url + "\" align=\"absmiddle\"/> &nbsp; <strong> "+ httpObject.responseText + "</strong> MEMBERS AGREE</div>";
		document.getElementById(div_id).innerHTML = responseText;
	}
}

function add_comments(barid){
	var comment=document.getElementById("comment_"+barid).value;
	httpObject = getHTTPObject();
	url = document.getElementById("site_url").value;
	//alert(url);
	if (httpObject != null) {
		httpObject.open("GET", url + "add_comments/" + barid+ "/" + comment, true);
		httpObject.send(null);
		httpObject.onreadystatechange = function (){
				if(httpObject.readyState == 4){
					div_id = "comments_"+barid;
					responseText = "<strong class=\"select\">Thanks for your comments...</strong>";
					document.getElementById(div_id).innerHTML = responseText;
					document.getElementById("comment_"+barid).value="";
					setTimeout("location.reload(true);",500);
				}
		};
	}
}

function add_drinkcomments(drinkid){
	var comment=document.getElementById("comment_"+drinkid).value;
	httpObject = getHTTPObject();
	url = document.getElementById("site_url").value;
	
	if (httpObject != null) {
		httpObject.open("GET", url + "add_drink_comments/" + drinkid+ "/" + comment, true);
		httpObject.send(null);
		httpObject.onreadystatechange = function (){
				if(httpObject.readyState == 4){
					div_id = "comments_"+drinkid;
					responseText = "<strong class=\"select\">Thanks for your comments...</strong>";
					document.getElementById(div_id).innerHTML = responseText;
					document.getElementById("comment_"+drinkid).value="";
					setTimeout("location.reload(true);",500);
				}
		};
	}
}

function get_bar_auth(barid){
	document.getElementById("comments_"+barid).innerHTML = "<strong style=\"padding-bottom:2px;padding-top:2px; color:#FF0000; font-size:11px\">Please login to give your comments...</strong>";
}