$(function()
	{
	$('.moreinfo').hideInfo();
	$('.thumbnail').showLargeImage();
	setTall();
	});

(function($)
	{
	$.fn.hideInfo = function()
		{
		return this.each(function()
			{
			var self = $(this);
			var showtext = 'More info...';
			var hidetext = 'Hide info...';
			var title = self.attr('title');
			if (title)
				{
				showtext = 'Show ' + title;
				hidetext = 'Hide ' + title;
				}
			var lnk = $('<a class="minfo" href="#">' + showtext + '</a>');
			lnk.click(function()
				{
			  self.slideToggle('slow', function()
					{
					if ($(this).is(":visible"))
						lnk.text(hidetext);
			    else
						lnk.text(showtext);
					setTall();
			  	});
				return false;
				});
			var p = $('<p/>');
			p.append(lnk);
			p.insertAfter(self);
			self.hide();
			});
		}
	})(jQuery);

(function($)
	{
	$.fn.showLargeImage = function()
		{
		$(document).keypress(function(e)
			{
			if(e.keyCode==27)  
				removeLightbox();
			});
		return this.each(function()
			{
			var a = $('<a class="lightbox"/>');
			var src = $(this).attr('src');
			var dot = src.lastIndexOf('.');
			src = src.substr(0, dot) + '-large' + src.substr(dot);
			a.attr('href', src);
			a.click(function(e)
				{
				$('body').css('overflow-y', 'hidden');

				$('<div id="overlay"></div>')
					.css('top', $(document).scrollTop())
					.css('opacity', '0')
					.animate({'opacity': '0.5'}, 'slow')
					.appendTo('body');

				$('<div id="lightbox"></div>')
					.hide()
					.appendTo('body');

				$('<img title="Click here to close"/>')
					.attr('src', $(this).attr('href'))
					.load(function()
						{
						positionLightboxImage();
						})
					.click(function()
						{
						removeLightbox();
						})
					.appendTo('#lightbox');

				return false;
				});
			$(this).wrap(a);
			});
		function positionLightboxImage()
			{
			var top = ($(window).height() - $('#lightbox').height()) / 2;
			var left = ($(window).width() - $('#lightbox').width()) / 2;
			var closebutton = $('<img src="/images/close.png" width="30" height="30" alt="close" style="position: absolute; top: 0px; right: 0px;"/>');
			closebutton.click(function()
				{
				removeLightbox();
				});
			$('#lightbox')
				.append(closebutton)
				.css({'top': top + $(document).scrollTop(), 'left': left})
				.fadeIn();
			}
		function removeLightbox()
			{
			$('#overlay, #lightbox')
				.fadeOut('slow', function()
					{
					$(this).remove();
					$('body').css('overflow-y', 'auto');
					});
			}
		}
	})(jQuery);

function setTall()
	{
	var otherOuterHeight = $('#topbar').outerHeight(true) + $('#header').outerHeight(true) + $('#footer').outerHeight(true);

	var whitemain = $('#whitemain');
	whitemain.css("height", "auto");
	var whitemainHeight = $('#whitemain').outerHeight(true);
	var whitesidebarHeight = $('#whitesidebar').outerHeight(true);
	if (whitemain.height() < whitesidebarHeight)
		whitemain.height(whitesidebarHeight);
	}

function showWin()
  {
  var w = window.open('','popup',
      'width=500,height=400,resizable,scrollbars,status,left=80,top=80');
  w.document.clear();
  w.focus();
  return true;
  }
function showSearch()
	{
	window.name='origin';
	var w = window.open('','search',
		'width=250,height=550,resizable,scrollbars,status,top=0,left=0');
	w.document.clear();
	w.focus();
	return true;
	}

function mailIt()
	{
  var contact = "click here"
  var email = "enquiry"
  var emailHost = "awaywegotours.com.au"
  document.write("<a href=" + "mail" + "to:" + email + "@" + emailHost + ">'" + contact + "'</a>")
	}

