/*-------------------------------------------------------------------------
=GLOBAL FUNCTIONS
-------------------------------------------------------------------------*/
$(document).ready(function() {
	var mainNavTags = '<li class="bottom"></li>';
	var bottomTags = '<div id="light"><span></span></div><span id="shadow"></span>';
	var specsContentTags = '<span></span>';
	
	$('div#bottom').append(bottomTags);
	$('ul#mainNav ul').append(mainNavTags);
	$('div.specsContent').append(specsContentTags);
	$('a#designfabrika').attr('target', '_blank');
	
	if ($.browser.msie) {
    	if ($.browser.version < 8.0) {
    		$('a.navHotels, ul#mainNav ul').hover(function(){
    			$('div#featuredTopics').css("zIndex", "-1");
    			$('ul#mainNav ul').css("display", "block");
    		}, function() {
    			$('div#featuredTopics').css("zIndex", "9");
    			$('ul#mainNav ul').css("display", "none");
    		});
    	}
 	}
 	
 	if ($('div.specsContent div').height() > $('div.specsContent.displayBlock').height()) {
 		$('div.specsContent.displayBlock').css('height', $('div.specsContent div').height());
	}
	
});



/*-------------------------------------------------------------------------
=FEATURED TOPICS
-------------------------------------------------------------------------*/
var topicIndex = 0;

function topicsCarousel(carousel) {
    $('ul#control li a').bind('click', function() {
    	carousel.startAuto(0);
        carousel.scroll($.jcarousel.intval($(this).text()));
		$('ul#control li').removeClass('activeTopic').hasClass('activeTopic');
		$(this).parent().addClass('activeTopic');
        return false;
    });

    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
    
    $('ul#control li a').hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });

};

function setTopicIndex(carousel) {
	if (topicIndex < $('ul#control li').length ) { 
		topicIndex++;
	}
	else {
		topicIndex = 1;
	}
	$('ul#control li').removeClass('activeTopic').hasClass('activeTopic');
	$("ul#control li a:contains(" + topicIndex + ")").parent().addClass('activeTopic');
};

$('div#featuredTopics').ready(function() {
    $('ul#topics').jcarousel({
        buttonNextHTML: '',
        buttonPrevHTML: '',
        auto: 6,
        wrap: 'last',
        animation: 'slow',
        scroll: 1,
        visible:1,
        initCallback: topicsCarousel,
        itemLoadCallback: { onBeforeAnimation: setTopicIndex }
    });
});



/*-------------------------------------------------------------------------
=SPECS
-------------------------------------------------------------------------*/
$(document).ready(function(){
	$('div#specs h4 a').click(function(){
		var activeThread = $('a.activeThread');
		activeThread.parent().next().removeClass('displayBlock');
		activeThread.removeClass('activeThread');
		$(this).addClass('activeThread');
		$(this).parent().next().addClass('displayBlock');
		return false;

		if ($('div.specsContent div').height() > $('div.specsContent.displayBlock').height()) {
			$('div.specsContent').css('height', $('div.specsContent div').height());
		}
		
	}); 
}); 



/*-------------------------------------------------------------------------
=SIFR CONFIGURATION
-------------------------------------------------------------------------*/
var rotis = {src: 'images/swf/rotissemiserifstd.swf' };
sIFR.activate(rotis);
sIFR.replace(rotis, {selector: 'div#aidaMagazine h1, div#agentLogin h1, div#hotels h1, div#sidebar h2, div#reservation h3, div#content h2', css: ['.sIFR-root { color: #ffffff }'], wmode: 'transparent', filters: { DropShadow: { knockout:false, distance:2, angle:120, alpha:.100,  color: '#000', strength:2 } }});
sIFR.replace(rotis, {selector: 'div#aidaMagazine p, div#hotels p', css: ['.sIFR-root { color: #ffffff; letter-spacing:-0.2 }'], wmode: 'transparent'});
sIFR.replace(rotis, {selector: 'div#footer ul li', css: ['.sIFR-root { color: #ffffff; letter-spacing:-0.2 }, a { color:#ffffff; text-decoration:none }, a:hover { color:#ffffff; text-decoration:underline }'], wmode: 'transparent'});
sIFR.replace(rotis, {selector: 'div#footer p, div#reservation p', css: ['.sIFR-root { color: #646464; letter-spacing:-0.2 }'], wmode: 'transparent'});
sIFR.replace(rotis, {selector: 'div#footer h2', css: ['.sIFR-root { color: #ffffff; letter-spacing:-0.2 }'], wmode: 'transparent'});
sIFR.replace(rotis, {selector: 'div#header div h1', css: ['.sIFR-root { color: #ffffff; text-align:right; letter-spacing:-1.5 }'], wmode: 'transparent'});
sIFR.replace(rotis, {selector: 'div#quickJump h3', css: ['.sIFR-root { color: #6C6C6C; letter-spacing:-0.2 }'], wmode: 'transparent'});
sIFR.replace(rotis, {selector: 'div#contactAddress h3, div#contactForm h3, div#googleMap h3, div#thumbs h3, div#specs h3', css: ['.sIFR-root { color: #ffffff; letter-spacing:-1 }'], wmode: 'transparent'});



/*-------------------------------------------------------------------------
=LIGHTBOX CONFIGURATION
-------------------------------------------------------------------------*/
$(function() {
  $('a[@rel*=lightbox]').lightBox({
      imageLoading: 'images/lightbox/loading.gif',
      imageBtnClose: 'images/lightbox/close.gif',
      imageBtnPrev: 'images/lightbox/prev.gif',
      imageBtnNext: 'images/lightbox/next.gif',
      imageBlank: 'images/lightbox/blank.gif',
      txtImage: 'Image:',
      txtOf: 'of',
      keyToClose: 'k',
      keyToPrev: 'o',
      keyToNext: 's'
  });  
  
  $('a.photo').lightBox({
      imageLoading: 'images/lightbox/loading.gif',
      imageBtnClose: 'images/lightbox/close.gif',
      imageBtnPrev: 'images/lightbox/prev.gif',
      imageBtnNext: 'images/lightbox/next.gif',
      imageBlank: 'images/lightbox/blank.gif',
      txtImage: 'Image:',
      txtOf: 'of',
      keyToClose: 'k',
      keyToPrev: 'o',
      keyToNext: 's'
  });
});
