
/////////////////////////////////////////////////////////
// On load
/////////////////////////////////////////////////////////
$(document).ready(function(){
	if ($("#google_map").length) { googleInit(); }   // Google maps API
	if ($("#cs_videos").length) { crusaderVideo(); } // Video demos
});

/////////////////////////////////////////////////////////
// Video page
/////////////////////////////////////////////////////////
function crusaderVideo() {
	
	$("#cs_list a").bind("click",function(e){
		var rel = $(this).attr("rel");
		if (rel=="clear") {
			$("#cs_vid").html("");
		} else {
			$("#cs_vid").html(vid(rel));
		}
		e.preventDefault();
	});
	
	function vid(code) {
		var vid_html = "";
		vid_html += "<object width='450' height='300'>";
		vid_html += "<param name='movie' value='http://www.youtube.com/v/" + code + "&hl=en_GB&fs=1&rel=0&color1=0x2b405b&color2=0x6b8ab6&border=1'></param>";
		vid_html += "<param name='allowFullScreen' value='true'></param>";
		vid_html += "<param name='allowscriptaccess' value='always'></param>";
		vid_html += "<embed src='http://www.youtube.com/v/" + code + "&hl=en_GB&fs=1&rel=0&color1=0x2b405b&color2=0x6b8ab6&border=1' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='450' height='300'></embed>";
		vid_html += "</object>";
		return vid_html;
	}
	
}

/////////////////////////////////////////////////////////
// Google maps API
/////////////////////////////////////////////////////////
function googleInit() {
//	$("#google_map").googleMap(52.892889, -1.147164, 10, {
//		controls: ["GSmallMapControl", "GMapTypeControl"],
//		markers: $(".geo")
//	});
	
	
    var myLatlng = new google.maps.LatLng(52.892889,-1.147164);
    var myOptions = {
      zoom: 10,
      center: myLatlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(document.getElementById("google_map"), myOptions);
    
    var marker = new google.maps.Marker({
        position: myLatlng, 
        map: map,
        title:"Oxford House, Easthorpe Street, Rudd NG11 6LA"
    }); 
	
	
	
	
}

/////////////////////////////////////////////////////////
// jQuery googleMap Copyright Dylan Verheul <dylan@dyve.net>
// * Licensed like jQuery, see http://docs.jquery.com/License
/////////////////////////////////////////////////////////
//$.googleMap = {
//	maps: {},
//	marker: function(m) {
//		if (!m) {
//			return null;
//		} else if (m.lat == null && m.lng == null) {
//			return $.googleMap.marker($.googleMap.readFromGeo(m));
//		} else {
//			var marker = new GMarker(new GLatLng(m.lat, m.lng));
//			if (m.txt) {
//				GEvent.addListener(marker, "click", function() {
//    				marker.openInfoWindowHtml(m.txt);
//  				});
//			}
//			return marker;
//		}
//	},
//	readFromGeo: function(elem) {
//		var latElem = $(".latitude", elem)[0];
//		var lngElem = $(".longitude", elem)[0];
//		if (latElem && lngElem) {
//			return { lat:parseFloat($(latElem).attr("title")), lng:parseFloat($(lngElem).attr("title")), txt:$(elem).attr("title") }
//		} else {
//			return null;
//		}
//	},
//	mapNum: 1
//};
//$.fn.googleMap = function(lat, lng, zoom, options) {
//
//	// If we aren't supported, we're done
//	if (!window.GBrowserIsCompatible || !GBrowserIsCompatible()) return this;
//
//	// Default values make for easy debugging
//	if (lat == null) lat = 37.4419;
//	if (lng == null) lng = -122.1419;
//	if (!zoom) zoom = 13;
//
//	// Sanitize options
//	if (!options || typeof options != 'object')	options = {};
//	options.mapOptions = options.mapOptions || {};
//	options.markers = options.markers || [];
//	options.controls = options.controls || {};
//
//	// Map all our elements
//	return this.each(function() {
//		// Make sure we have a valid id
//		if (!this.id) this.id = "gMap" + $.googleMap.mapNum++;
//		// Create a map and a shortcut to it at the same time
//		var map = $.googleMap.maps[this.id] = new GMap2(this, options.mapOptions);
//		// Center and zoom the map
//       	map.setCenter(new GLatLng(lat, lng), zoom);
//       	// Add controls to our map
//       	for (var i = 0; i < options.controls.length; i++) {
//	       	var c = options.controls[i];
//	       	eval("map.addControl(new " + c + "());");
//       	}
//       	// If we have markers, put them on the map
//       	var marker = null;
//       	for (var i = 0; i < options.markers.length; i++) {
//	       	if (marker = $.googleMap.marker(options.markers[i])) map.addOverlay(marker);
//       	}
//    });
//
//};





