jQuery(document).ready(function($){
	$('#slider1').tinycarousel({duration: 1000 });
	$('#slider2').tinycarousel({duration: 500 });
	$('#slider3').tinycarousel({duration: 500 });
		
	$('#slideshow1').cycle({ timeout: 6000, speed: 2000 });
	$('#slideshow2').cycle({ timeout: 5000, speed: 1500 });
	$('#slideshow3').cycle({ timeout: 6000,speed: 2000 });

//fade images in gallery	
  $("#photoGallery ul li a").hover( function () {$(this).fadeTo("fast", .8);}, function () { $(this).fadeTo("normal", 1);} );		
 	$("#slider3 ul li img").hover( function () {$(this).fadeTo("fast", .8);}, function () { $(this).fadeTo("normal", 1);} );		
 
 
 //Lightbox
  $(function() { $('#photoGallery ul li a').lightBox();});
   $(function() { $('.accomodation_result_right a').lightBox();});
     $(function() { $('.article_image a').lightBox();});
  
  //Calendar
  $(function() {
		$( '#datepicker' ).datepicker({
			showOn: "button",
			buttonImage: "http://cpnz.clients.blackfoot.net.nz/wp-content/themes/cpnz/_images/calendar-icon.gif",
			buttonImageOnly: true,
			dateFormat: 'yy-mm-dd'
		});
	});
	
	  $(function() {
		$( '#datepicker2' ).datepicker({
			showOn: "button",
			buttonImage: "http://cpnz.clients.blackfoot.net.nz/wp-content/themes/cpnz/_images/calendar-icon.gif",
			buttonImageOnly: true,
			dateFormat: 'yy-mm-dd'
		});
	});

//package form popup
$('#dialog1').jqm({
    trigger: '#package-trigger1'});
    
$('#dialog2').jqm({
    trigger: '#package-trigger2'});
    
$('#dialog3').jqm({
    trigger: '#package-trigger3'});
    
$('#dialog4').jqm({
    trigger: '#package-trigger4'});
    
    $('#dialog5').jqm({
    trigger: '#package-trigger5'});
	

	$("#trip-planner-form").submit(function() {
		
		//alert($("#accomodation-region").val());
	      if ($("#accomodation-region").val() != "") {
	       // $("span").text("Validated...").show();
	        return true;
	      }
			alert("Please choose a region");
	
	     // $("span").text("Not valid!").show().fadeOut(1000);
	     return false;
	    });
  
  
  //TABS
  //When page loads...

if ($("#showactivitytab").length) {
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:last").addClass("tab_active").show(); //Activate first tab
	$(".tab_content:last").show(); //Show last tab content
} else {
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("tab_active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show last tab content
	
	
}


	//On Click Event
	$("ul.tabs li").click(function() {

		$("ul.tabs li").removeClass("tab_active"); //Remove any "active" class
		$(this).addClass("tab_active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		

		
		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).show(); //Fade in the active ID content
		return false;
	});

  
  
  
});
