	var eshare_ajax;
	
	var map = null;
	var geocoder = null;
	var a_ajax;

	
	function share_facebook(url)
	{
		window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(url),'sharer','toolbar=0,status=0,width=626,height=436');
	}
	
	function submit_email()
	{
		eshare_ajax = getAjax();
		var email = document.email_subscription.email_address.value;
	
		var business_id = document.email_subscription.business_id.value;

		if(eshare_ajax == null)
			{
				alert("Sorry! Please try again.");
			}
			
			var params="&op=subscribe_email&email="+email+"&business_id="+business_id;
				var template_path="../lib/ajax_caller.php";

		eshare_ajax.onreadystatechange=respond_email;
		eshare_ajax.open("POST",template_path,true);
			eshare_ajax.setRequestHeader("Content-type","application/x-www-form-urlencoded");
			eshare_ajax.setRequestHeader("Content-length",params.length);
			eshare_ajax.setRequestHeader("Connection","close");
		eshare_ajax.send(params);
	}

	function respond_email()
	{
		if(eshare_ajax.readyState == 4)
		{
			var update_msg = eshare_ajax.responseText;

			if(update_msg != "")
			{
				document.email_subscription.email_address.value = "";
				document.getElementById("email_response").innerHTML = update_msg;
			}
		}
	}
	
	function initialize_map()
	{
	  if (GBrowserIsCompatible()) {
	    map = new GMap2(document.getElementById("map_canvas"));
	    // map.setCenter(new GLatLng(37.4419, -122.1419), 13);
	    geocoder = new GClientGeocoder();
	  }
	}

	function display_map(address)
	{
		initialize_map();

		if (geocoder) 
		{
	    geocoder.getLatLng(
	      address,
	      function(point) {
	        if (!point) {
	          //alert(address + " not found");
	        } else {
	          map.setCenter(point, 15);
	          var marker = new GMarker(point);
	          map.addOverlay(marker);
	        }
	      }
	    );
	  }
	}

	function submit_answer()
	{
		a_ajax = getAjax();

		var user_email = document.business_question.user_email.value;
		var user_name = document.business_question.user_name.value;
		var answer_text = document.business_question.answer_text.value;
		var business_id = document.business_question.business_id.value;
		var question_id = document.business_question.question_id.value;
		var secret = document.business_question.secret.value;
		var sum = document.business_question.sum.value;
		
			if(answer_text == "Leave a Comment..." || answer_text == "")
			{
				document.getElementById("answer_status").innerHTML = "Please type your reply in the box. Thanks.";
			}
			else if(sum != secret)
			{
				document.getElementById("answer_status").innerHTML = "The answer to the math question is incorrect. Please try again.";
			}	
			else
			{
				if(a_ajax == null)
				{
					alert("Sorry! Please try again.");
				}
			
				var params="&op=submit_answer&user_name="+user_name+"&user_email="+user_email+"&business_id="+business_id+"&question_id="+question_id+"&secret="+secret+"&sum="+sum+"&answer_text="+answer_text;
					var template_path="../lib/ajax_caller.php";

				a_ajax.onreadystatechange=respond_answer;
				a_ajax.open("POST",template_path,true);
				a_ajax.setRequestHeader("Content-type","application/x-www-form-urlencoded");
				a_ajax.setRequestHeader("Content-length",params.length);
				a_ajax.setRequestHeader("Connection","close");
				a_ajax.send(params);
		}
	}

	function respond_answer()
	{
		if(a_ajax.readyState == 4)
		{
			var update_msg = a_ajax.responseText;

			if(update_msg != "" )
			{
				document.getElementById("answer_status").innerHTML = update_msg;

				if(update_msg == "Thanks for the Feedback!")
				{
					document.business_question.answer_text.value = "";
					document.business_question.user_email.value = "";
					document.business_question.user_name.value = "";
					document.business_question.secret.value = "";
				}
			}
		}
	}	

	function show_offer(net_id)
	{
		for(var id = 1; id < 7; id++)
		{
			 if (document.getElementById('net-'+id) != null)
			 {
				document.getElementById('net-'+id).style.display = "none";
			 }
		}

		if(document.getElementById("net-"+net_id).style.display == 'block')
		{
			document.getElementById("net-"+net_id).style.display = 'none';
		}
		else
		{
			document.getElementById("net-"+net_id).style.display = 'block';
		}
	}	
