function callfocus()
{
	document.getElementById("searchfield").value = '';
}

function callweather()
{
	var place = document.getElementById("searchfield").value;
	if(place == '')
	{
		YAHOO.example.container2.fail.setHeader("Blanks not allowed");
		YAHOO.example.container2.fail.setBody('<h4>Please enter a search term for Molu to go</h4>');
		YAHOO.example.container2.fail.show();  
	}
	else
	{
		var qurl = "getweather.php?qsrch=" + escape(place);
		createRequest();
		request.open("GET", qurl, true);
	    request.onreadystatechange = updatepage;
		request.send(null);

	}

}

function getlivew(type, code)
{
		var qurl = "getlive.php?type=" + type + "&code=" + code;
		createRequest();
		request.open("GET", qurl, true);
	    request.onreadystatechange = updatepanel;
		request.send(null);

}

function getforew(type, code)
{
		var qurl = "getfore.php?type=" + type + "&code=" + code;
		createRequest();
		request.open("GET", qurl, true);
	    request.onreadystatechange = updatepanel;
		request.send(null);

}


function finddesc()
{
	if (addressflag == 0)
	{
			YAHOO.example.container2.fail.setHeader("Can not fetch description");
			YAHOO.example.container2.fail.setBody('<em>Molu can only fetch description for the mapped location.</em><b> Try mapping a place first and try again</b>');
			YAHOO.example.container2.fail.show();  
	}
	else
	{
		var place = document.getElementById("searchfield").value;
		var qurl = "getdesc.php?qsrch=" + escape(place);
		createRequest();
		request.open("GET", qurl, true);
	    request.onreadystatechange = updatepage;
		request.send(null);
	}
}



function pointmap()
{
	var place = document.getElementById("searchfield").value;
	if(place == '')
	{
		YAHOO.example.container2.fail.setHeader("Blanks not allowed");
		YAHOO.example.container2.fail.setBody('<h4>Please enter a search term for Molu to go</h4>');
		YAHOO.example.container2.fail.show();  
	}
	else
	{
		var qurl = "getlatlon.php?qsrch=" + escape(place);
		createRequest();
		request.open("GET", qurl, true);
	    request.onreadystatechange = updatemap;
		request.send(null);

	}
}



function findvideos()
{
	if (addressflag == 0)
	{
			YAHOO.example.container2.fail.setHeader("Can not fetch videos");
			YAHOO.example.container2.fail.setBody('<em>Molu can only fetch videos for the mapped location.</em><b> Try mapping a place first and try again</b>');
			YAHOO.example.container2.fail.show();  
	}
	else
	{
		var place = document.getElementById("searchfield").value;
		var qurl = "getvideo.php?qsrch=" + escape(place);
		createRequest();
		request.open("GET", qurl, true);
	    request.onreadystatechange = updatepage;
		request.send(null);
	}
}

function findphotos()
{
	if (addressflag == 0)
	{
			YAHOO.example.container2.fail.setHeader("Can not fetch photos");
			YAHOO.example.container2.fail.setBody('<em>Molu can only fetch photos for the mapped location.</em><b> Try mapping a place first and try again</b>');
			YAHOO.example.container2.fail.show();  
	}
	else
	{
		var place = document.getElementById("searchfield").value;
		var qurl = "getphoto.php?qsrch=" + escape(place);
		createRequest();
		request.open("GET", qurl, true);
	    request.onreadystatechange = updatepage;
		request.send(null);
	}

}

function showvideo(vidurl, showurl, title, description, ratecount, viewcount)
{
			YAHOO.example.container3.vid.setHeader(title);
			var purl = 'playvideo.php?showurl=' + showurl;
			mbody = '<iframe src="' + purl + '" width="434px" height="354px"></iframe>';
			mbody = mbody + '<br><small>Viewed: ' + viewcount + ' times</small>';
			mbody = mbody + '<br><small>Average User Rating: ' + ratecount + ' </small>';
			mbody = mbody + '<br><center><small><a href="' + vidurl + '" target="_blank"><img src="images/youtube.png" border="0px"/></a></small></center>';
//			mbody = mbody + '<br><br><small<em><a href="#" onClick="closevid();">Close this Window</a></em></small>';
			YAHOO.example.container3.vid.setBody("");
			YAHOO.example.container3.vid.setBody(mbody);
			YAHOO.example.container3.vid.setFooter('<small<em><a href="#" onClick="closevid();">Close this Window</a></em></small>');
			YAHOO.example.container3.vid.show();  

}

function closevid()
{
	YAHOO.example.container3.vid.setBody("");
	YAHOO.example.container3.vid.hide();
}

function showphoto(photourl, murl)
{
	var foot = '<small><a href="' + photourl + '" target=_blank">View at original size</a><br><em>Create Custom Goodies</em>';
	foot = foot + '<br><a href="http://www.zazzle.com/api/create?at=238344283874683022&pd=235026227041396843&image=' + photourl + '&text=Save%20the%20World" target="_blank">Print it on a t-shirt</a></small>';
	var photo = '<img src="' + murl + '" alt="Photo from FlickR"  />';
	YAHOO.example.container4.overlay1.setBody(photo);
	YAHOO.example.container4.overlay1.setFooter(foot);
	YAHOO.example.container4.overlay1.show();

}



function loader()
{
	YAHOO.example.container1.tt1 = new YAHOO.widget.Tooltip("tt1", 
				{ context:"menubar", 
				  text:"You may view various interesting details associated with the place using the links" });

			// Initialize the temporary Panel to display while waiting for external content to load
	YAHOO.example.container.wait = 
			new YAHOO.widget.Panel("wait",  
								{ width:"240px", 
								  fixedcenter:true, 
								  close:false, 
								  draggable:true, 
								  modal:true,
								  visible:false,
								  underlay:"shadow",
								  effect:{effect:YAHOO.widget.ContainerEffect.FADE, duration:1.0} 		
								} 
							);
	YAHOO.example.container.wait.setHeader("Fetching results, just for u ....");
    YAHOO.example.container.wait.setBody('<img src="images/loading.gif" />');
	YAHOO.example.container.wait.render(document.body);


	YAHOO.example.container2.fail = 
	new YAHOO.widget.Panel("fail",  
								{ width:"240px", 
								  fixedcenter:true, 
								  close:true, 
								  draggable:true, 
								  modal:true,
								  visible:false,
								  underlay:"shadow",
								  effect:{effect:YAHOO.widget.ContainerEffect.FADE, duration:1.0} 
		
								} 
							);
	YAHOO.example.container2.fail.setHeader("Error fetching the location");
    YAHOO.example.container2.fail.setBody('<h4>Please try to change the search terms and try again</h4>');
	YAHOO.example.container2.fail.render(document.body);

	YAHOO.example.container3.vid = 
	new YAHOO.widget.Panel("vid",  
								{ width:"442px", 
//								  height:"480px",
								  fixedcenter:true, 
								  close:false, 
								  draggable:true, 
								  modal:true,
								  visible:false,
								  underlay:"shadow",
								  effect:{effect:YAHOO.widget.ContainerEffect.FADE, duration:1.0} 
		
								} 
							);
	YAHOO.example.container3.vid.setHeader("Video");
    YAHOO.example.container3.vid.setBody('<h4>Please try to change the search terms and try again</h4>');
    YAHOO.example.container3.vid.setFooter("Molu");
	YAHOO.example.container3.vid.render(document.body);


	YAHOO.example.container5.weather = 
	new YAHOO.widget.Panel("weather",  
								{ width:"700px", 
								  fixedcenter:true, 
								  close:true, 
								  draggable:true, 
								  modal:true,
								  visible:false,
								  underlay:"matte",
								  effect:{effect:YAHOO.widget.ContainerEffect.FADE, duration:1.0} 
		
								} 
							);
	YAHOO.example.container5.weather.setHeader("Molu - Live Weather");
    YAHOO.example.container5.weather.setBody('<h4>sample</h4>');
	YAHOO.example.container5.weather.render(document.body);



	YAHOO.example.container4.overlay1 = new YAHOO.widget.Panel("overlay1",
										{ fixedcenter:true,    
                                          visible:false,
										  close:true, 
										  draggable:true, 
										  underlay:"shadow",
		                                  modal:true,
										  effect:{effect:YAHOO.widget.ContainerEffect.FADE, duration:1.5} 
										} );   

	YAHOO.example.container4.overlay1.setHeader('Welcome');   
	YAHOO.example.container4.overlay1.setBody('<img src="images/welcome.jpg" alt="Welcome to Molu Places" />');   
	YAHOO.example.container4.overlay1.setFooter('<center>Enjoy your stay</center>');   
	YAHOO.example.container4.overlay1.render(document.body); 
	
	YAHOO.example.container4.overlay1.show();



// Capture the user mouse-click and expand the SmartWindow
	function onSmartWinEvent() {
		var words = '<div style="width:100px;height:40px;"><em>This place is the home of Molu. Your location coming below</em><OBJECT DATA="http://www.hostip.info/map/frame.html"  TYPE="text/html" BORDER=0  WIDTH=610 HEIGHT=330 HSPACE=0 VSPACE=0></OBJECT></div>';
		marker.openSmartWindow(words);
		}
// Create a lat/lon object
//	var myPoint = new YGeoPoint(29.741001,-95.501159);
	var myPoint = "noida";
// Set up map type in the constructor
	var map = new YMap(document.getElementById('mapcontainer'),YAHOO_MAP_REG);

// Display the map centered on a lattitude and longitude
	map.addTypeControl();
	map.addPanControl(); 

	map.addZoomLong();
	map.drawZoomAndCenter(myPoint, 13);
// Create a marker positioned at a lat/lon




	var marker = new YMarker(myPoint);
	marker.setSmartWindowColor("blue");
	marker.disableAutoContain;
// Add a label to the marker
//marker.addLabel("<blink>Noida</blink>");

// Add auto expand
	var _txt = '<div style="width:160px;height:50px;"><b>Click for more</b></div>';
	marker.addAutoExpand(_txt);

// Call onSmartWinEvent when the user clicks on the marker
	YEvent.Capture(marker, EventsList.MouseClick, onSmartWinEvent);
// Display the marker
	map.addOverlay(marker);



}

function wikipedia()
{
		var qurl = "http://api.futef.com/api/v1?query=Panagar&appid=7159a7061ab44fcfac015d8d4b8be5e27d9";
		createRequest();
		request.open("GET", qurl, true);
	    request.onreadystatechange = wiki;

}

function wiki()
{
		YAHOO.example.container.wait.hide(); 
		alert("Request Returned a value");
}

function showwthr(counter)
{
	if (counter == 1)
	{
		document.getElementById("wthr1").style.visibility = "visible";
		document.getElementById("wthr2").style.visibility = "hidden";
		document.getElementById("wthr3").style.visibility = "hidden";
		document.getElementById("wthr4").style.visibility = "hidden";
		document.getElementById("wthr5").style.visibility = "hidden";
		document.getElementById("wthr6").style.visibility = "hidden";
		document.getElementById("wthr7").style.visibility = "hidden";
	}
}

function presskey(){
	if (event.keyCode == 13)
	{
		pointmap();
	}

}
