
$(document).ready(function(){

		$(function() {
		// Homepage Tabs
			var intX = document.getElementById('showtab').value;
			$("#tabs").tabs({ fx: { opacity: '' } });
			$("#tabs").tabs( 'select' , intX );
		});
		
		$(function() {
		// Homepage Tabs
		
		$.hideAllExcept('#homepage-tabs', '#homepage-tabs ul.tab_navigation a', '#homepage-tabs div.tab');
		
//			var intX = document.getElementById('showtab').value;
//			$("#homepage-tabs").tabs({ fx: { 
//			height: 'toggle', 
//			opacity: 'toggle', 
//			duration:'slow' } });
		});
		
		
		// ======================= Homepage Contact form  =========================

	//$("div#enquiry_reveal").hide(); 

	$("a.call_us").click(function () {
		$("div#enquiry_reveal").slideToggle('1000', function() {
		// Animation complete.
	  });

	});  
			
		
		
		

		// Main Image Rotator
		$(function() {
			$('#main_slideshow').cycle({ 
				timeout: 10000,
				delay:  5000, 
				speed:  800
			}); 
			
			$('#slideshow2').cycle({ 
				timeout: 10000, 
				delay:  5000, 
				speed:  800
			}); 
			

			function onBefore() { 
				$('#title') 
				.html(this.alt); 
			}; 
		});
		
		$(function() {
		// FancyBox Pop Up
			$("#custom_1, #custom_2, #custom_3, #custom_4, #custom_5").fancybox({
				'zoomSpeedIn':	0, 
				'zoomSpeedOut':	0
			});
		});		
});



(function($){
  $.hideAllExcept = function(container, tabs,boxes){
    function init() {      
    // make it bookmarkable/refreshable. but, no history.
      var hash = window.location.hash;
      //(!hash) ? hideShow('#' + $(boxes+':first').attr('id')) : hideShow(window.location.hash);



      // add click handler.
      $(tabs).click(function(e) {
        
        //css('height','220px');
        e.preventDefault();
        var href = $(this).attr('href');
        //window.location.hash = href;
        if ($(this).hasClass('active')){

            $(tabs).removeClass('active');        
            $(boxes).hide();
            $(container).stop(true, true).animate({ height: 0}, 500 );
            $(href).stop(true, true).fadeOut('slow');
            
        } else {
            $(container).stop(true, true).animate({ height: 250}, 500 );
            hideShow(href);
        }
        
      });
      
      $(boxes).hide();
    }
    function hideShow(el) {
      $(boxes).css('position','absolute').hide();
      $(el).fadeIn('slow');
 
      $(tabs).removeClass('active');
      $('a[href="' + el + '"]').addClass('active');
    }
    init();
  };
})(jQuery);
