var geocoder;
var mapArray = Array;

$(document).ready(
					function()
					{		
				  		$('input:checkbox').checkbox({cls:'jquery-cactus-checkbox'});  
						$('.statusCheckBox').click(function(){return false;	});
					}
				);
		
function initGmap(containerID,mapArrayID,address)
{
	var latlng = new google.maps.LatLng(-34.397, 150.644);
	var myOptions = {
						zoom: 15,
						center: latlng,
						mapTypeId: google.maps.MapTypeId.ROADMAP
						};
	mapArray[mapArrayID] = new google.maps.Map(document.getElementById(containerID), myOptions);

	codeAddress(address,mapArrayID);
}


function codeAddress(address,mapArrayID) 
{
	var map  = mapArray[mapArrayID];

	if(!geocoder)
		geocoder = new google.maps.Geocoder();

	geocoder.geocode(
		{ 'address': address}, 
		function(results, status)
		{
			if (status == google.maps.GeocoderStatus.OK) {
				if (status != google.maps.GeocoderStatus.ZERO_RESULTS) 
				{

					map.set_center(results[0].geometry.location);
					var marker = new google.maps.Marker({
						map: map,
				
						position: results[0].geometry.location
					});
				}
				else
					alert("No results found");
			}
			else 
				alert("Geocode was not successful for the following reason: " + status);
		}
  	);
}

function get_rss_feed(newsContainer,url) 
{
	//clear the content in the div for the next feed.
	//$(newsContainer).empty();
	
	//use the JQuery get to grab the URL from the selected item, put the results in to an argument for parsing in the inline function called when the feed retrieval is complete
	$.get('/DEV/rss_interface.php?url='+url, 
		function(d) 
		{
			
			//find each 'item' in the file and parse it
			$(d).find('item').each(
				function() 
				{
					//name the current found item this for this particular loop run
					var $item = $(this);
					// grab the post title
					var title = $item.find('title').text();
					// grab the post's URL
					var link = $item.find('link').text();
					// next, the description
					var description = $item.find('description').text();
					//don't forget the pubdate
					var pubDate = $item.find('blogDate').text();
					
					// now create a var 'html' to store the markup we're using to output the feed to the browser window
					var html = "<div class=\"entry\"><a href=\"" + link + "\" target=\"_blank\"><h2 class=\"postTitle\">" + title + "<\/h2></a>";
					html += "<em class=\"date\">" + pubDate + "</em>";
					html += "<p class=\"description\">" + description + "</p>";
					html += "<a href=\"" + link + "\" target=\"_blank\">Read More >><\/a><\/div>";
					
					//put that feed content on the screen!
					$(newsContainer).append($(html));  
				}
			);
		}
	);
	
};



