// JavaScript CRUISE TABS
	var currentTab = 1;
	var totalchildren;
	var $children;
	var portInfoWindow = 1;
	var heightHasChanged = false;
	var mapLoaded = false;
	var isClickable = true;
	var opened = new Array();
	var tHeight;
	var topHeight = new Array();
	var pageHeight = new Array();
	var ImagepoolLoaded = false;
	var imageWidth = 200;

	if(headerHeight == undefined)
	{
		var headerHeight = 437;
	}

	var params = {
	  menu: "false",
	  allowFullScreen: "true",
	  wmode: "transparent"
	};


    function setLightboxReady()
    {
        $("a[rel^='lightbox']").prettyPhoto({
                animationSpeed: 0, /* fast/slow/normal */
                padding: 3, /* padding for each side of the picture */
                opacity: 0.3, /* Value betwee 0 and 1 */
                showTitle: false, /* true/false */
                allowresize: false, /* true/false */
                counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
                theme: 'light_rounded', /* light_rounded / dark_rounded / light_square / dark_square */
                hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
                modal: false, /* If set to true, only the close button will close the window */
                changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
                callback: function(){} /* Called when prettyPhoto is closed */
        });
    }

	$(document).ready(function()
	{
        setLightboxReady();

		var i = 0;
		$('.tabimg .img').each(function(){
			$(this).children('.box1').find('.off').hide();
			i++;
		});
		i = 1;
		$children = $('.tabimg .list.tab1').children('li');
		totalchildren = $children.length;
		$children.each(function() {
			$(this).val(i);
			topHeight.push($(this).children('.box1').height());
			pageHeight.push($('#page'+i).height());
			if(i>1){
				$('.tabimg .img.tab'+$(this).attr('value')).hide();
				$('#page'+(i)).hide();
			}
			i++;
		});
		isClickable = true;
	
		$('.tabimg .list.tab1 li').click(function(event){
			event.preventDefault();
			if(!$(this).hasClass('on')){
			 if(isClickable){
				nr = $(this).attr('value');
				$(this).siblings().removeClass('on');
				$(this).addClass('on');
				isClickable = false;
				nextTab(nr,500);
				currentTab = nr;
			 }
			}
		});
                $("#pricetab").click(function(event){
                //getPrices();
               });
               $("#zoovertab").click(function(event){
                //getZoover();
               });
               //get_flight_price("#flight_price");

	});

    function nextTab(id,speed){
        $('.box3').fadeOut("fast");
        switch(id){
          case 6:
		  		if ($('.imagepool ul.list li.float_left').length>0)
	                setHeight(speed,headerHeight);
				else 
					setHeight(speed,1);
                break;
          default:

                  //$("#flightprice").hide();
              //$('.gmap').fadeOut(300);
                //$('.pricetag').hide();
                setHeight(speed,1);
                break;

        }
        fadePages(currentTab,id);
        for(var i=0;i<opened.length;i++){
                opened[i].hide();
        }
        opened = [];
    }

    function fadePages(old,nieuw)
    {
        $('#page'+old).fadeOut(300,function(){
        $('#page'+nieuw).fadeIn(300);
        isClickable = true;
        });
    }

    function setHeight(speed,newheight)
    {
		  $('.tabimg .img').animate({
				  height: newheight+"px"
		  }, speed);
		  if (newheight == 1) {
			  $('.tabimg .img .layer_left').hide();
			  $('.tabimg .img .layer_right').hide();
		  }
		  else {
			  $('.tabimg .img .layer_left').show();
			  $('.tabimg .img .layer_right').show();
		  }
    }
	
    function simpleSlider(target, clicked, txt){
        $(target).find('.off').each(function(i){
            $(this).show(200);
        });
        if(clicked != null){
            if(txt == null){
                $(clicked).hide(200);
            }else {
                $(clicked).text(txt);
            }
        }
        return false;
    }
	
	function gotoPage(pagename){
		i = 0;
		switch(pagename){
			case 'preturi':
                            $(this).scrollTo($('h2'),400);
			$('.tabimg .list.tab1 li').each(function() {
				i++;
				if('Preturi' == $(this).find('em').text()){
					$(this).addClass('on');
					id = i;
				}else {
					$(this).removeClass('on');
				}
			});
			nextTab(id,300);
			currentTab = id;
			break;
		}
                if(i == 0){

                    if(pagename == "first")
                    {
                        var first;
                        first = $('.tabimg .list.tab1 li:first');
                        first.addClass('on');
                        nr = first.attr('value');
                        first.siblings().removeClass('on');
                        first.addClass('on');
                        nextTab(nr,500);
                        currentTab = nr;
                    }
                    var i = 0;
                    var nr;
                    $('.tabimg .list.tab1 li').each(function() {
                            i++;
                            if(pagename == $(this).find('em').text()){
                                if(!$(this).hasClass('on')){
                                        $(this).addClass('on');
                                        nr = $(this).attr('value');
                                        $(this).siblings().removeClass('on');
                                        $(this).addClass('on');
                                        nextTab(nr,500);
                                        currentTab = nr;
                                }
                            }
                    });
                }
	}


