
// 'stacks' is the Stacks global object.
// All of the other Stacks related Javascript will 
// be attatched to it.
var stacks = {};


// this call to jQuery gives us access to the globaal
// jQuery object. 
// 'noConflict' removes the '$' variable.
// 'true' removes the 'jQuery' variable.
// removing these globals reduces conflicts with other 
// jQuery versions that might be running on this page.
stacks.jQuery = jQuery.noConflict(true);

// Javascript for stacks_in_13_page12
// ---------------------------------------------------------------------

// Each stack has its own object with its own namespace.  The name of
// that object is the same as the stack's id.
stacks.stacks_in_13_page12 = {};

// A closure is defined and assigned to the stack's object.  The object
// is also passed in as 'stack' which gives you a shorthand for referring
// to this object from elsewhere.
stacks.stacks_in_13_page12 = (function(stack) {

	// When jQuery is used it will be available as $ and jQuery but only
	// inside the closure.
	var jQuery = stacks.jQuery;
	var $ = jQuery;
	
//-- Google Maps Stack v1.0.5 by Joe Workman --//

function clean_location(str) {
	str = str ? str : 'San Francisco,CA';
	str = str.replace(/\<\s*br\s*\/\>/g,',');
	str = str.replace(/[\s]+/g,'+');
	str = str.replace(/\s*\,+\s*/g,',');
	return $.trim(str);
}
$(document).ready(function() {	
	var map_height = 500;
	var map_width = 500;
	var map_zoom = 17;
	var map_center = ''; 
	var map_type = 'roadmap'; //roadmap, satellite, hybrid, and terrain
	var marker_size = 'large';
	var marker_color = 'FF6357';
	var map_url = 'http://maps.google.com/maps/api/staticmap?sensor=false&size='+ map_width +'x'+ map_height +'&maptype='+ map_type +'&zoom='+ map_zoom;
	
	if ( 'true' == 'true' ) {
		// foreach marker add the following data to the map_url: &markers=size:mid|label:S|color:red|San+Jose,CA
		$('#marker_data_stacks_in_13_page12 li').each(function(index) {
		    var marker_url = '&markers=size:'+ marker_size +'|color:0x'+ marker_color +'|';
			var label = $.trim($(this).attr('data-label'));
			if (label != '') { marker_url += 'label:'+ label.substr(0,1) +'|'; }
			marker_url += clean_location($(this).attr('data-location'));
			map_url += marker_url;
		});
	}
	else {
		map_url += '&center='+ clean_location(map_center);
	}
	// Add the map to the page
	$('#stacks_in_13_page12').append('<img src="'+ map_url +'" id="map_stacks_in_13_page12" alt=""/>');
});

//-- End Google Maps Stack --//
	return stack;
})(stacks.stacks_in_13_page12);



