var addressflag = 0;

function createRequest() {

     try {
       request = new XMLHttpRequest();
     } catch (trymicrosoft) {
       try {
         request = new ActiveXObject("Msxml2.XMLHTTP");
       } catch (othermicrosoft) {
         try {
           request = new ActiveXObject("Microsoft.XMLHTTP");
         } catch (failed) {
           request = null;
         }
       }
     }

     if (request == null)
	{      alert("Error creating request object!");}
	 else
	{
		YAHOO.example.container.wait.show();  
		
	}
   }

 function updatemap()
 {
    if (request.readyState == 4) {
		if (!request.responseText)
		{
			YAHOO.example.container.wait.hide();  
			YAHOO.example.container2.fail.setHeader("Could not parse location");
			YAHOO.example.container2.fail.setBody('<h4>Please correct the location and try again</h4>');
			YAHOO.example.container2.fail.show();  
			addressflag = 0;
		}
		else
		{
				YAHOO.example.container.wait.hide(); 

				function onSmartWinEvent1() {
					var word1 = '<div style="width:100px;height:40px;"><em>Your search place - </em><i>' + document.getElementById("searchfield").value + '</i></div>';
					marker1.openSmartWindow(word1);
					}
				
				addressflag = 1;

				document.getElementById("mapcontainer").innerHTML = '';
				// Create a lat/lon object
				var myPoint1 = document.getElementById("searchfield").value;
				// Set up map type in the constructor
				var map1 = new YMap(document.getElementById('mapcontainer'),YAHOO_MAP_REG);
				map1.removeMarkersAll;
				// Display the map centered on a lattitude and longitude
				map1.addTypeControl();
				map1.addPanControl(); 
				map1.addZoomLong(); 
				map1.enableDragMap;
				map1.drawZoomAndCenter(myPoint1, 13);
				map1.enableDragMap;

				// Create a marker positioned at a lat/lon
		
				var marker1 = new YMarker(myPoint1);
				marker1.setSmartWindowColor("blue");
				marker1.addLabel("MP");

				// Add auto expand
				var _txt1 = '<div style="width:160px;height:50px;"><b>This is the place you searched for. Zoom using the control to look for micro details of the place.</b><em> Use the options above to see other interesting details</em></div>';
				marker1.addAutoExpand(_txt1);

				// Call onSmartWinEvent when the user clicks on the marker
				YEvent.Capture(marker1, EventsList.MouseClick, onSmartWinEvent1);
				// Display the marker
				map1.addOverlay(marker1);




		}
	}
 }

 function updatepage()
 {
    if (request.readyState == 4) {
		if (!request.responseText)
		{
			YAHOO.example.container.wait.hide();  
			YAHOO.example.container2.fail.setHeader("Could not parse location");
			YAHOO.example.container2.fail.setBody('<h4>Please correct the location and try again</h4>');
			YAHOO.example.container2.fail.show();  
			addressflag = 0;
		}
		else
		{
			document.getElementById("headdata").innerHTML = request.responseText;
			YAHOO.example.container.wait.hide();  

		}
	}
 }


function updatepanel()
{
    if (request.readyState == 4) {
		if (!request.responseText)
		{
			YAHOO.example.container.wait.hide();  
			YAHOO.example.container2.fail.setHeader("Could not fetch live weather");
			YAHOO.example.container2.fail.setBody('<h4>Please correct the location and try again</h4>');
			YAHOO.example.container2.fail.show();  
			addressflag = 0;
		}
		else
		{
			YAHOO.example.container5.weather.setBody(request.responseText);
			YAHOO.example.container.wait.hide();  
			YAHOO.example.container5.weather.show();  
		}
	}
}