
$(document).ready(function(){ 

	$(".fancybox").fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});		
	


initialize();
	
});

function initialize() {


		$('#fn').bind('focus', function() {
	  		$('#fn').val("");
		});
		
		$('#ln').bind('focus', function() {
	  		$('#ln').val("");
		});
		
		$('#email').bind('focus', function() {
	  		$('#email').val("");
		});	

	
		var map = new GMap2(document.getElementById("map_canvas"));
		map.setMapType(G_NORMAL_MAP);    
		//map.setMapType(G_SATELLITE_MAP);  		
		map.setCenter(new GLatLng(38.619016, -90.43396), 10);
		map.setUIToDefault();
               
        
		
		G_PHYSICAL_MAP.getMinimumResolution = function () { return 10 }; 
        G_NORMAL_MAP.getMinimumResolution = function () { return 10 }; 
        G_SATELLITE_MAP.getMinimumResolution = function () { return 10 }; 
        G_HYBRID_MAP.getMinimumResolution = function () { return 10 }; 
        
        G_PHYSICAL_MAP.getMaximumResolution = function () { return 16 }; 
        G_NORMAL_MAP.getMaximumResolution = function () { return 16 }; 
        G_SATELLITE_MAP.getMaximumResolution = function () { return 16 }; 
        G_HYBRID_MAP.getMaximumResolution = function () { return 16 }; 	


		// Add 10 markers to the map at random locations
		var bounds = map.getBounds();
		var southWest = bounds.getSouthWest();
		var northEast = bounds.getNorthEast();
		var lngSpan = northEast.lng() - southWest.lng();
		var latSpan = northEast.lat() - southWest.lat();
		
		//change the param in the url to the swf to make the swf choose a new xml file. edit array in slideshow.fla to add more.
		var myMarkerHtml=new Array("<div style='height:170px; width:400px; text-align:left; padding-top:10px;'><div id='archssss' style='float:left; padding-right:10px;'><object width='200' height='160'><param name='movie' value='swf/slideshow.swf?show=arch'><embed src='swf/slideshow.swf?show=arch' width='200' height='160'></embed></object></div><p style='font-size:13px;'><a href='http://www.explorestlouis.com/myStl/memberDetails.asp?mID=67&pt=1&ic=2' target='_blank' style='color:#0000ff; font-weight:bold; text-decoration:underline;'>The Arch</a><br />630-feet tall. Wow. Gotta see this thing up close.</p><p><a onClick=\"callBoxFancy('arch');\" style='color:#0000ff; font-weight:bold; text-decoration:underline; font-size:10px'>Directions</a></p></div>",
		"<div style='height:170px; width:400px; text-align:left; padding-top:10px;'><div style='float:left; padding-right:10px;'><object width='200' height='160'><param name='movie' value='swf/slideshow.swf?show=arthill'><embed src='swf/slideshow.swf?show=arthill' width='200' height='160'></embed></object></div><p style='font-size:13px;'><a href='http://www.explorestlouis.com/itineraries/kids.asp' target='_blank' style='color:#0000ff; font-weight:bold; text-decoration:underline;'>Art Hill</a><br />'Dedicated to art and free to all.' That explains the museum, but evidently, that's the idea behind this entire 1,293-acre urban park.</p><p><a onClick=\"callBoxFancy('arthill');\" style='color:#0000ff; font-weight:bold; text-decoration:underline; font-size:10px'>Directions</a></p></div>",
		"<div style='height:170px; width:400px; text-align:left; padding-top:10px;'><div style='float:left; padding-right:10px;'><object width='200' height='160'><param name='movie' value='swf/slideshow.swf?show=boathouse'><embed src='swf/slideshow.swf?show=boathouse' width='200' height='160'></embed></object></div><p style='font-size:13px;'><a href='http://www.explorestlouis.com/visitors/25thingsOne.asp?pt=1' target='_blank' style='color:#0000ff; font-weight:bold; text-decoration:underline;'>Boat House</a><br />Note to self: paddleboats make lousy escape vehicles and great ways to spend an afternoon.</p><p><a onClick=\"callBoxFancy('boathouse');\" style='color:#0000ff; font-weight:bold; text-decoration:underline; font-size:10px'>Directions</a></p></div>",
		"<div style='height:170px; width:400px; text-align:left; padding-top:10px;'><div style='float:left; padding-right:10px;'><object width='200' height='160'><param name='movie' value='swf/slideshow.swf?show=zoo'><embed src='swf/slideshow.swf?show=zoo' width='200' height='160'></embed></object></div><p style='font-size:13px;'><a href='http://www.explorestlouis.com/myStl/memberDetails.asp?mID=52&pt=1' target='_blank' style='color:#0000ff; font-weight:bold; text-decoration:underline;'>Zoo</a><br />I could spend a whole day just at the zoo. But then I'd miss the Art Museum and those guys playing Frisbee.</p><p><a onClick=\"callBoxFancy('zoo');\" style='color:#0000ff; font-weight:bold; text-decoration:underline; font-size:10px'>Directions</a></p></div>",
		"<div style='height:170px; width:400px; text-align:left; padding-top:10px;'><div style='float:left; padding-right:10px;'><object width='200' height='160'><param name='movie' value='swf/slideshow.swf?show=citymuseum'><embed src='swf/slideshow.swf?show=citymuseum' width='200' height='160'></embed></object></div><p style='font-size:13px;'><a href='http://www.explorestlouis.com/members/directory/memberDetails.asp?mID=29&pt=4' target='_blank' style='color:#0000ff; font-weight:bold; text-decoration:underline;'>City Museum</a><br />This place is a kid haven. And if a kid tried to explain it to you, there's no way you'd believe him. </p><p><img src='images/playbtn.jpg' alt='Play Video'  />&nbsp;<a onClick=\"callBoxFancy2('cmvid');\" style='color:#0000ff; font-weight:bold; text-decoration:underline; font-size:10px' target='_blank'>Video Interview</a></p><p><a onClick=\"callBoxFancy('citymuseum');\" style='color:#0000ff; font-weight:bold; text-decoration:underline; font-size:10px'>Directions</a></p></div>",
		"<div style='height:170px; width:400px; text-align:left; padding-top:10px;'><div style='float:left; padding-right:10px;'><object width='200' height='160'><param name='movie' value='swf/slideshow.swf?show=loop'><embed src='swf/slideshow.swf?show=loop' width='200' height='160'></embed></object></div><p style='font-size:13px;'><a href='http://www.explorestlouis.com/myStl/memberDetails.asp?mID=848&pt=1' target='_blank' style='color:#0000ff; font-weight:bold; text-decoration:underline;'>Loop</a><br />Concert venues, restaurants, boutique hotel, bowling alley/movie theater, independent movie theatre, a walk of fame...</p><p><img src='images/playbtn.jpg' alt='Play Video'  />&nbsp;<a onClick=\"callBoxFancy2('loopvid');\" style='color:#0000ff; font-weight:bold; text-decoration:underline; font-size:10px' target='_blank'>Video Interview</a></p><p><a onClick=\"callBoxFancy('loop');\" style='color:#0000ff; font-weight:bold; text-decoration:underline; font-size:10px'>Directions</a></p></div>",
		"<div style='height:170px; width:400px; text-align:left; padding-top:10px;'><div style='float:left; padding-right:10px;'><object width='200' height='160'><param name='movie' value='swf/slideshow.swf?show=citygarden'><embed src='swf/slideshow.swf?show=citygarden' width='200' height='160'></embed></object></div><p style='font-size:13px;'><a href='http://www.explorestlouis.com/visitors/25thingsOne.asp?pt=1' target='_blank' style='color:#0000ff; font-weight:bold; text-decoration:underline;'>City Garden</a><br />Run through the fountains. Climb on the sculptures. All while surrounded by skyscrapers.</p><p><a onClick=\"callBoxFancy('citygarden');\" style='color:#0000ff; font-weight:bold; text-decoration:underline; font-size:10px'>Directions</a></p></div>",
		"<div style='height:170px; width:400px; text-align:left; padding-top:10px;'><div style='float:left; padding-right:10px;'><object width='200' height='160'><param name='movie' value='swf/slideshow.swf?show=buschstadium'><embed src='swf/slideshow.swf?show=buschstadium' width='200' height='160'></embed></object></div><p style='font-size:13px;'><a href='http://www.explorestlouis.com/members/directory/memberDetails.asp?mID=652&pt=5' target='_blank' style='color:#0000ff; font-weight:bold; text-decoration:underline;'>Busch Stadium</a><br />These're some pretty friendly confines, too.</p><p><img src='images/playbtn.jpg' alt='Play Video'  />&nbsp;<a onClick=\"callBoxFancy2('buschvid');\" style='color:#0000ff; font-weight:bold; text-decoration:underline; font-size:10px' target='_blank'>Video Interview</a></p><p><a onClick=\"callBoxFancy('buschstadium');\" style='color:#0000ff; font-weight:bold; text-decoration:underline; font-size:10px'>Directions</a></p></div>",
		"<div style='height:170px; width:400px; text-align:left; padding-top:10px;'><div style='float:left; padding-right:10px;'><object width='200' height='160'><param name='movie' value='swf/slideshow.swf?show=grantsfarm'><embed src='swf/slideshow.swf?show=grantsfarm' width='200' height='160'></embed></object></div><p style='font-size:13px;'><a href='http://www.explorestlouis.com/members/directory/memberDetails.asp?mID=242&pt=4' target='_blank' style='color:#0000ff; font-weight:bold; text-decoration:underline;'>Grant's Farm</a><br />Animals from different continents in one big pasture.</p><p><a onClick=\"callBoxFancy('grantsfarm');\" style='color:#0000ff; font-weight:bold; text-decoration:underline; font-size:10px'>Directions</a></p></div>",
		"<div style='height:170px; width:400px; text-align:left; padding-top:10px;'><div style='float:left; padding-right:10px;'><object width='200' height='160'><param name='movie' value='swf/slideshow.swf?show=sixflags'><embed src='swf/slideshow.swf?show=sixflags' width='200' height='160'></embed></object></div><p style='font-size:13px;'><a href='http://www.explorestlouis.com/myStl/memberDetails.asp?mID=54&pt=1' target='_blank' style='color:#0000ff; font-weight:bold; text-decoration:underline;'>Six Flags</a><br />Enough rides to wear out a nine year-old. And his dad.</p><p><a onClick=\"callBoxFancy('sixflags');\" style='color:#0000ff; font-weight:bold; text-decoration:underline; font-size:10px'>Directions</a></p></div>",
		"<div style='height:170px; width:400px; text-align:left; padding-top:10px;'><div style='float:left; padding-right:10px;'><object width='200' height='160'><param name='movie' value='swf/slideshow.swf?show=magichouse'><embed src='swf/slideshow.swf?show=magichouse' width='200' height='160'></embed></object></div><p style='font-size:13px;'><a href='http://www.explorestlouis.com/members/directory/memberDetails.asp?mID=63&pt=5' target='_blank' style='color:#0000ff; font-weight:bold; text-decoration:underline;'>Magic House</a><br />Having kids is a good excuse to come here.</p><p><img src='images/playbtn.jpg' alt='Play Video'  />&nbsp;<a onClick=\"callBoxFancy2('mhvid');\" style='color:#0000ff; font-weight:bold; text-decoration:underline; font-size:10px' target='_blank'>Video Interview</a></p><p><a onClick=\"callBoxFancy('magichouse');\" style='color:#0000ff; font-weight:bold; text-decoration:underline; font-size:10px'>Directions</a></p></div>",
		"<div style='height:170px; width:400px; text-align:left; padding-top:10px;'><div style='float:left; padding-right:10px;'><object width='200' height='160'><param name='movie' value='swf/slideshow.swf?show=anheuserbuschbrewery'><embed src='swf/slideshow.swf?show=anheuserbuschbrewery' width='200' height='160'></embed></object></div><p style='font-size:13px;'><a href='http://www.explorestlouis.com/myStl/memberDetails.asp?mID=86&pt=1&ic=2' target='_blank' style='color:#0000ff; font-weight:bold; text-decoration:underline;'>Anheuser-Busch Brewery</a><br />The world's largest brewery-luckily, it's walking distance from the hotel.</p><p><img src='images/playbtn.jpg' alt='Play Video'  />&nbsp;<a onClick=\"callBoxFancy2('abvid');\" style='color:#0000ff; font-weight:bold; text-decoration:underline; font-size:10px' target='_blank'>Video Interview</a></p><p><a onClick=\"callBoxFancy('anheuserbuschbrewery');\" style='color:#0000ff; font-weight:bold; text-decoration:underline; font-size:10px'>Directions</a></p></div>",
		"<div style='height:170px; width:400px; text-align:left; padding-top:10px;'><div style='float:left; padding-right:10px;'><object width='200' height='160'><param name='movie' value='swf/slideshow.swf?show=thehill'><embed src='swf/slideshow.swf?show=thehill' width='200' height='160'></embed></object></div><p style='font-size:13px;'><a href='http://www.explorestlouis.com/visitors/theHill.asp' target='_blank' style='color:#0000ff; font-weight:bold; text-decoration:underline;'>The Hill</a><br />Not a chain restaurant in-sight. But plenty of meatballs and toasted ravioli. Sounds like heaven. </p><p><a onClick=\"callBoxFancy('thehill');\" style='color:#0000ff; font-weight:bold; text-decoration:underline; font-size:10px'>Directions</a></p></div>"); 
		
		
		var myLat=new Array("38.62357641746295","38.639903","38.64007","38.633064270362155","38.6334", "38.656192", "38.62708", "38.622168", "38.551077", "38.51137", "38.573711", "38.596732", "38.617474"); 
		var myLng=new Array("-90.18573760986328","-90.294013","-90.284615","-90.293369","-90.201573", "-90.30663", "-90.193591", "-90.192862", "-90.35211", "-90.673256", "-90.405829", "-90.212581", "-90.278006"); 

		
		for (var i = 0; i < 13; i++) {
	
	        //var point = new GLatLng(southWest.lat() + latSpan * Math.random(), southWest.lng() + lngSpan * Math.random());
	       	var point = new GLatLng(myLat[i], myLng[i]);
	        var marker = new GMarker(point);
	        
			//weird fix for marker scope problem with loop making last item in array the content for all windows. 
			updateMarker(marker,myMarkerHtml[i], i); 	
	        map.addOverlay(marker);	
		}
		
			
		
		function updateMarker(marker, html, id) { 

	        GEvent.addListener(marker, "click", function() {	
	                this.openInfoWindowHtml(html);
	        });	
	        
	        if(id==4) {
	        	//trigger the loop
  				GEvent.trigger(marker,'click'); 
	        }	
	        
		} 	
		

	
}

function callBoxFancy(targetId) {
			$("#"+targetId+"").trigger('click');
}


function callBoxFancy2(targetId) {
			$("#"+targetId+"").trigger('click');
}	

function goSubmitForm() { 
		
		
		
		var cityVal = $("#city").val();	
		var emailVal = $("#email").val();	
		var fnVal = $("#fn").val();	
		var lnVal = $("#ln").val();	
		var optinVal = $('#optin').attr('checked')?1:0;	
		
		
		if((!fnVal || !lnVal || !emailVal || cityVal == "selectloc") || (fnVal == "First Name" || lnVal == "Last Name" || emailVal == "Enter Email Address" || cityVal == "selectloc")) {
			alert("Make sure all fields are complete. And don't forget to opt-in for news and special offers.");
			return false;
		}
		
		cityVal = escape(cityVal);
		emailVal = escape(emailVal);
		fnVal = escape(fnVal);
		lnVal = escape(lnVal);
		
		var dataString = 'city='+ cityVal + 
		"&" + 'email='+ emailVal +
		"&" + 'fn='+ fnVal +
		"&" + 'ln='+ lnVal +
		"&" + 'optin='+ optinVal;


		$.ajax({
			type: "POST",
			url: "processGuess.php",
			data: dataString,
   			dataType: "json",						
			cache: false,

			success: function(data){
			
				alert("Ah, good call and thanks in advance for your help. Check your email for periodic updates.");		
				$("#email").val("");
				$("#fn").val("");									
				$("#ln").val("");									
									

			},	
			
		    error: function(request, errorType, errorThrown){
				alert("There was an error in processing your submission. Please try again later.");		
		    }					
			
			
			
		});


		return false;
} 





