$.fn.clearForm = function() {
  return this.each(function() {
 var type = this.type, tag = this.tagName.toLowerCase();
 if (tag == 'form')
   return $(':input',this).clearForm();
 if (type == 'text' || type == 'password' || tag == 'textarea')
   this.value = '';
 else if (type == 'checkbox' || type == 'radio')
   this.checked = false;
 else if (tag == 'select')
   this.selectedIndex = -1;
  });
};
window.location.keyValue = function ( keyName )
	{
	// Check to see if we have already retrieved the key value pairs
	// if we haven't then we need to retrieve them
	if( window.location.variablePairs == null )
		{
		if( window.location.href.indexOf('?') == -1)
			{
			return false;	
			}
		window.location.variablePairs = window.location.href.substr( window.location.href.indexOf('?') + 1).split('&');
		}
	
	// Search for the key that matches the keyName supplied
	for( var x = 0; x < window.location.variablePairs.length; x++ )
		{
		// If we find the key name then we retun the value associated with it
		if( keyName == window.location.variablePairs[x].substr( 0, window.location.variablePairs[x].indexOf('=')))
			{
			return window.location.variablePairs[x].substr( window.location.variablePairs[x].indexOf('=') + 1);
			}
		}
	
	// If we couldn't find the key in the GET parameters
	// then we return false
	return false;
	}


$(document).ready(function() {
				// this initialises the demo scollpanes on the page.
				$('#pane').jScrollPane({showArrows:true});
				               
                // this initialises the scrollBy and scrollTo links.
                $('#cairnsBtn').bind(
                    'mouseenter',
                    function()
                    {
                        $('#pane')[0].scrollTo(405);
						$("#maplabel").removeClass();
						$("#maplabel").addClass("cityCairns");

						
                        return false;
                    }
                );
				 $('#airlieBtn').bind(
                    'mouseenter',
                    function()
                    {
                        $('#pane')[0].scrollTo(503);
						$("#maplabel").removeClass();
						$("#maplabel").addClass("cityAirlie");
                        return false;
                    }
                );
				  $('#goldcoastBtn').bind(
                    'mouseenter',
                    function()
                    {
                        $('#pane')[0].scrollTo(0);
						$("#maplabel").removeClass();
						$("#maplabel").addClass("cityGoldcoast");
                        return false;
                    }
                );
				    $('#byronBtn').bind(
                    'mouseenter',
                    function()
                    {
                        $('#pane')[0].scrollTo(450);
						$("#maplabel").removeClass();
						$("#maplabel").addClass("cityByron");
                        return false;
                    }
                );
				 $('#sydneyBtn').bind(
                    'mouseenter',
                    function()
                    {
                        $('#pane')[0].scrollTo(238);
						$("#maplabel").removeClass();
						$("#maplabel").addClass("citySydney");
						
                        return false;
                    }
                );
				$('#melbBtn').bind(
                    'mouseenter',
                    function()
                    {
                        $('#pane')[0].scrollTo(297);
						$("#maplabel").removeClass();
						$("#maplabel").addClass("cityMelb");
                        return false;
                    }
                );
							$('#adelBtn').bind(
                    'mouseenter',
                    function()
                    {
                        $('#pane')[0].scrollTo(557);
						$("#maplabel").removeClass();
						$("#maplabel").addClass("cityAdelaide");
                        return false;
                    }
                );
				$('#hobBtn').bind(
                    'mouseenter',
                    function()
                    {
                        $('#pane')[0].scrollTo(356);
						$("#maplabel").removeClass();
						$("#maplabel").addClass("cityHobart");
                        return false;
                    }
                );
				$('#perBtn').bind(
                    'mouseenter',
                    function()
                    {
                        $('#pane')[0].scrollTo(616);
						$("#maplabel").removeClass();
						$("#maplabel").addClass("cityPerth");
                        return false;
                    }
                );
				$('#baliBtn').bind(
                    'mouseenter',
                    function()
                    {
                        $('#pane')[0].scrollTo(612);
						$("#maplabel").removeClass();
						$("#maplabel").addClass("cityBali");
                        return false;
                    }
                );
					$('#thaiBtn').bind(
                    'mouseenter',
                    function()
                    {
                        $('#pane')[0].scrollTo(616);
						$("#maplabel").removeClass();
						$("#maplabel").addClass("cityThai");
                        return false;
                    }
                );
				$('#queenstownBtn').bind(
                    'mouseenter',
                    function()
                    {
                        $('#pane')[0].scrollTo(616);
						$("#maplabel").removeClass();
						$("#maplabel").addClass("cityQueenstown");
                        return false;
                    }
                );
                $("select").selectbox();
                $("#enquiryForm").validate();
				
				var formSubmit = window.location.keyValue('submit');
				if(formSubmit == "success"){
					showBox();
					setTimeout('hideBox()', 5000);
				}else{
					
				}
			});
function showBox(){
	$("#TB_window").show();
	$("#TB_overlay").show();
}
function hideBox(){
	$("#TB_window").fadeOut("slow");
	$("#TB_overlay").fadeOut("slow");
}
