
$.fn.bgResize = function (options)
{
	var obj = $(this);

	function doResize()
	{
		windowWidth = $(window).width();

		if (windowWidth <= options.minWidth)
		{
			obj.css("width", options.minWidth + "px");
		}
		else if (windowWidth >= options.maxWidth)
		{
			obj.css("width", options.maxWidth + "px");
		}
		else
		{
			obj.css("width", windowWidth + "px");
		}
	}

	$(window).resize(function()
	{
		doResize()
	});

	doResize();
	return this;

};

 $(document).ready(function()
 {
	$("#bgImages").bgResize({
		minWidth:990,
		maxWidth:1400
	});
	$("#bgImages-standalone").bgResize({
		minWidth:990,
		maxWidth:1400
	});


	$("#inner-bg").cycle(
	{ 
		fx:     "scrollHorz",
		speed:  "medium",
		timeout: 0,
		next:   "#next",
		prev:   "#prev",
		pager:  "#img-nav",
		pagerAnchorBuilder: function(idx, slide)
		{
		}
	});

	if ( !$("#inner-bg").length || $("#inner-bg div.img").length == 1 )
	{
		$("a#next,a#prev").css("display", "none");
	}

	if ( $("#gmap").length )
	{
		makeMap();
	}


	if ( $("div#gallery-wrapper ul li a").length )
	{
		$("div#gallery-wrapper ul li a").lightBox();
	}

});



	var map;

	function makeMap()
	{

		if (GBrowserIsCompatible())
		{
			var m = document.getElementById("gmap");
			m.style.height = "270px";
			m.style.width = "360px";

			map = new GMap(document.getElementById("gmap"));
			map.addControl(new GLargeMapControl());

			map.centerAndZoom(new GLatLng(52.949711, -1.298214), 3);
			
			var point = new GLatLng(52.949711, -1.298214);
			
			var marker = createMarker(point);
			map.addOverlay(marker);
			//marker.openInfoWindowHtml(mhtml);
		}
	}

	function createMarker(point)
	{
		var marker = new GMarker(point);
		return marker;	  
	}
