
//<![CDATA[

var geocoder = null;
var map = null;

function cancel()
{
alert("A");
	document.location = "#";
}

function load() {
 var main_div = document.getElementById("map_content");

 w=800
 h=600
 if (window.screen) {
  w = window.screen.availWidth;
  h = window.screen.availHeight;
 }

 main_div.width = w;


 //clearFields();
 if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("mash_map"));
    //map.setCenter(new GLatLng(37.4419, -122.1419), 13);
    //geocoder = new GClientGeocoder();

    //getLatLong("2020 K Street, 20006");
    //document.getElementById('address').value = '2020 K Street, 20006';
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    geoXml = new GGeoXml('http://mobilenewsfusion.com/MyKML.kml');
    map.addOverlay(geoXml);
    map.setCenter(new GLatLng(38.882239,-77.170983), 10);
  }

  getTags();
}

function getLatLong(address) {
  if (geocoder) {
     geocoder.getLatLng(address,
       function(point) {
	  if (!point) {
	    alert(address + " not found!");
	  } else {
	    map.setCenter(point, 13);
	    var marker = new GMarker(point, {draggable:true});
	    document.getElementById("lat").value = marker.getPoint().lat().toFixed(6);
	    document.getElementById("lng").value = marker.getPoint().lng().toFixed(6);
	    map.addOverlay(marker);
	    GEvent.addListener(marker, "dragend", function() {
	       document.getElementById("lat").value = marker.getPoint().lat().toFixed(6);
	       document.getElementById("lng").value = marker.getPoint().lng().toFixed(6);
	    });
	  }
	}
     ); 
  }
}

function postData()
{
  document.forms['rssnews'].submit();
  //window.location.replace("http://www.mobilenewsfusion.com/mobile_news.html",true);
  //alert("Thanks for adding some news.  Your news has been added to our RSS feed.");
}

function getTags()
{
  var response = "";
  new Ajax.Request('/cgi-bin/MobileNewsFusion.pl?handler=cloud',
     {
        method: 'get',
	onSuccess: function(transport) {
	   response = transport.responseText;
  	   var t = document.getElementById("TagCloud");
	   t.innerHTML = response;
        }
     }
  );
}

function addTag(name)
{
  var existing = document.getElementById('rss_tags').value;
  existing += (existing == "") ? "'" + name + "'" : ", '" + name + "'";
  document.getElementById('rss_tags').value = existing;

}

function buildRSSPipes()
{
  var tags = document.getElementById('rss_tags').value;
  if (tags == null || tags == '') {
    alert("You have not selected any tags.  Please select some tags before continuing.");
  } else {
    var tags = document.getElementById('rss_tags').value;
    var url = "http://www.mobilenewsfusion.com/cgi-bin/MobileNewsFusion.pl?handler=pipes&tags=" + tags;
    Effect.BlindUp('tag_cloud_select', {duration:1});
    Effect.Appear('rss_map_select');

    var rssDIV = document.getElementById('RSSDiv');
    rssDIV.onclick = function() { document.location.href = url };
  }

  //var tags = document.getElementById('rss_tags').value;
  //var url = "http://www.mobilenewsfusion.com/cgi-bin/MobileNewsFusion.pl?handler=pipes&tags=" + tags;
  //window.location = url;
}

function ShowMap()
{
  w=800
  h=600
  if (window.screen) {
   w = window.screen.availWidth;
   h = window.screen.availHeight;
  }
  window.open('map.html','newwin','width='+w+',height='+h+',top=0,left=0');
}

function clearFields()
{
  document.getElementById('rss_tags').value = "";
}
//]]>
