$(document).ready(function(){


	$(function() {
	    $('a.lightbox').lightBox();
	});


	$('input[name="inquiry_Amount_other"]').focus( function() {
		$('input:radio[name="inquiry_Amount"]').filter('[value="other"]').attr('checked', true);
	});



	if(typeof GUnload == 'function') {
		updateMap(false, false);
	}


	$("a.question").addClass("closed");
	$(".answer").hide();

	 $("a.question").click(function () {

		if($(this).hasClass("closed") )
			$(this).removeClass("closed").addClass("open");
		else
			$(this).removeClass("open").addClass("closed");

		$(this).next(".answer").slideToggle("fast");

		return false;
	});

	$("ul.products li").equalHeights();
	$("ul.products h3").equalHeights();
	$("ul.products div.product_img_wrap").equalHeights();


	// jQuery SmoothScroll | Version 09-11-02
	$('a[href*=#]').click(function() {

		if($.browser.msie && $.browser.version<8) {
			return;

		} else {

	   // duration in ms
	   var duration=1000;

	   // easing values: swing | linear
	   var easing='swing';

	   // get / set parameters
	   var newHash=this.hash;
	   var target=$(this.hash).offset().top;
	   var oldLocation=window.location.href.replace(window.location.hash, '');
	   var newLocation=this;

	   // make sure it's the same location
	   if(oldLocation+newHash==newLocation)
	   {
		  // animate to target and set the hash to the window.location after the animation
		  $('html:not(:animated),body:not(:animated)').animate({ scrollTop: target }, duration, easing, function() {

		     // add new hash to the browser location
		     window.location.href=newLocation;
		  });

		  // cancel default click action
		  return false;
	   }

	}

	});




//if( $("#cart_summary").length  )
//{
//	if( !$("#cart_summary").hasClass("static"))
//	{
//		$("#cart_summary").makeFloat({x:"current",y:"current"});
//	}
//}

if( $("#calendar_block").length  )
{
	if( !$("#calendar_block").hasClass("static"))
	{
		if ($.browser.msie && $.browser.version<8) {
		return;
		} else {
		$("#calendar_block").makeFloat({x:"current",y:"current"});
		}
	}
}

});



function updateMap (geo, txt)
{

	if(!document.getElementById("map"))
		return false;


	if (GBrowserIsCompatible()) {

		var map = new GMap2(document.getElementById("map"));

		if(geo) {
			var tmp = geo.split(",");
			var map_lat = tmp[0];
			var map_long =  tmp[1];
		}
		else {
			var map_lat = 54.55853;
			var map_long =  -7.83188;



			//find first address
			//pull out geo


		}

		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(map_lat, map_long), 8);

		// Create our "tiny" marker icon
		var icon = new GIcon();
		icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
		icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		icon.iconSize = new GSize(12, 20);
		icon.shadowSize = new GSize(22, 20);
		icon.iconAnchor = new GPoint(6, 20);
		icon.infoWindowAnchor = new GPoint(5, 1);

		var bounds = map.getBounds();
		var southWest = bounds.getSouthWest();
		var northEast = bounds.getNorthEast();
		var lngSpan = northEast.lng() - southWest.lng();
		var latSpan = northEast.lat() - southWest.lat();
		var point = new GLatLng(map_lat,map_long);
		map.addOverlay(new GMarker(point, icon));


	}

}


/*--------------------------------------------------------------------
 * JQuery Plugin: "EqualHeights"
 * by:	Scott Jehl, Todd Parker, Maggie Costello Wachs (http://www.filamentgroup.com)
 *
 * Copyright (c) 2008 Filament Group
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 *
 * Description: Compares the heights or widths of the top-level children of a provided element
 		and sets their min-height to the tallest height (or width to widest width). Sets in em units
 		by default if pxToEm() method is available.
 * Dependencies: jQuery library, pxToEm method	(article:
		http://www.filamentgroup.com/lab/retaining_scalable_interfaces_with_pixel_to_em_conversion/)
 * Usage Example: $(element).equalHeights();
  		Optional: to set min-height in px, pass a true argument: $(element).equalHeights(true);
 * Version: 2.0, 08.01.2008


 * 29 May 09	- EDITED to work without dependencies & doesn't bother with children just the class passed to the fn
				- eoin@starfish.ie
--------------------------------------------------------------------*/

$.fn.equalHeights = function() {
	var currentTallest = 0;
	$(this).each(function(){

			if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
	});

	$(this).each(function(){

		$(this).css({'height': currentTallest});

	});

	return this;
};


