$(document).ready(function(){
	// TOP MENU //
	$('ul.sf-menu').superfish();
	$("#language").sexyCombo();
	
	// SEARCH //
	$('input[type="text"]').addClass("idleField");
	$('input[type="text"]').focus(function() {
		$(this).removeClass("idleField").addClass("focusField");
		if (this.value == this.defaultValue){ 
		this.value = '';
	}
	if(this.value != this.defaultValue){
		this.select();
	}});
	$('input[type="text"]').blur(function() {
		$(this).removeClass("focusField").addClass("idleField");
		if ($.trim(this.value) == ''){
		this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});
	
	// JCAROUSEL //
    $('#mycarousel').jcarousel({
		auto: 5,
		wrap: 'circular',
		scroll: 1,
		animation: 1000
	});
	function random_num() {
		return parseInt(1*(0+Math.random()*5))
	}
	/// HOME
	$('#home_carousel_01').jcarousel({
		wrap: 'circular',
		scroll: 1,
		animation: 1000
	});
	$('#home_carousel_02').jcarousel({
		wrap: 'circular',
		scroll: 1,
		animation: 1000
	});
	$('#home_carousel_3').jcarousel({
		wrap: 'circular',
		scroll: 1,
		animation: 1000
	});
	$('#home_carousel_04').jcarousel({
		wrap: 'circular',
		scroll: 1,
		animation: 1000
	});
	//// SIDEBAR
	$('#side_caousel_01').jcarousel({
		wrap: 'circular',
		scroll: 1,
		animation: 1000
	});
	$('#side_caousel_02').jcarousel({
		wrap: 'circular',
		scroll: 1,
		animation: 1000
	});
	$('#side_caousel_03').jcarousel({
		wrap: 'circular',
		scroll: 1,
		animation: 1000
	});
	$('#side_caousel_04').jcarousel({
		wrap: 'circular',
		scroll: 1,
		animation: 1000
	});
	
	// HOME PAGE //
	//$("#home a img, #sidebar a img").wrap('<div class="effect" />');
	//$("#home a img, #sidebar a img").hover(
	//function() {
		//$(this).stop().animate({"opacity": ".5"}, "slow");
	//},
	//function() {
		//$(this).stop().animate({"opacity": "1"}, "slow");
	//});
	
	
	// VALIDATION //
	var validator = $('#contact-form, #application-form, #account-form').validate();
	$('.numeric').numeric();
	$('button[type="reset"]').click(function() {
       $('#contact-form, #application-form, #account-form');
       validator.resetForm();
    });
	
	// COLORBOX //
	//$('#cboxTitle').remove();
	//$('#cboxPrevious').remove();
	//$('#cboxNext').remove();
	//$('#cboxCurrent').remove();
	$("a[rel='colorbox']").colorbox({transition:"fade"});
	$("a[rel='promo']").colorbox({
		rel: "nofollow"
	});
	$(".login").colorbox({
		iframe:false,
		onLoad: function() {
			//$('#cboxClose').css('top','0px');
		}
	});
	$('.press').click(function(e) {
		$(this).colorbox({
			iframe:false,
			innerWidth: '810px',
			innerHeight: '360px',
			onOpen: function() {
				//$('#cboxClose').css('bottom','0px');
			},
			onComplete: function() {
				$("div#galleria").slideViewerPro({
					thumbs: 4, 
					autoslide: false, 
					asTimer: 3500, 
					typo: true,
					galBorderWidth: 0,
					thumbsBorderOpacity: 0, 
					buttonsTextColor: "#aa6617",
					buttonsWidth: 19,
					thumbsActiveBorderOpacity: 0.8,
					thumbsActiveBorderColor: "#aa6617",
					shuffle: false,
					leftButtonInner: "<img src='images/arrow-l.png' />",
					rightButtonInner: "<img src='images/arrow-r.png' />",
					thumbsPercentReduction: 18,
					thumbsRightMargin: 12,
					thumbsTopMargin: 5
				});
			}});
	});
	$('.press_old').click(function(e) {
		$(this).colorbox({
			iframe:false,
			innerWidth: '900px',
			innerHeight: '410px',
			onOpen: function() {
			//$('#cboxClose').css('bottom','0px');
		},
			onComplete: function() {
				$("div#galleria").slideViewerPro({
					thumbs: 4, 
					autoslide: false, 
					asTimer: 3500, 
					typo: true,
					galBorderWidth: 0,
					thumbsBorderOpacity: 0, 
					buttonsTextColor: "#707070",
					buttonsWidth: 15,
					thumbsActiveBorderOpacity: 0.8,
					thumbsActiveBorderColor: "aqua",
					shuffle: true,
					leftButtonInner: "<img src='images/arrow-l.png' />",
					rightButtonInner: "<img src='images/arrow-r.png' />",
					thumbsPercentReduction: 20,
					thumbsRightMargin: 15,
					thumbsTopMargin: 15
				});
			}
	});
    });
	
	
	// ITEMS //
	//$('#container .main #items .item:eq(2)').css('margin-right','0px');
	//$('#container .main #items .item:eq(5)').css('margin-right','0px');
	//$('#container .main #items .item:eq(8)').css('margin-right','0px');
	//$('#container .main #items .item:eq(11)').css('margin-right','0px');
	
	/// TABS ///
	$("#usual ul").idTabs();
	
	// TABLE //
	$('.data-shuttle tr:even').addClass('td-alt');
	//$('.accommodation tr:eq(0)').addClass('tr1');
	$('.accommodation tr:eq(1)').addClass('tr1');
	$('.accommodation tr:eq(2)').addClass('tr1');
	$('.accommodation tr:eq(5)').addClass('tr1');
	$('.accommodation tr:eq(6)').addClass('tr1');
	//$('.accommodation tr:eq(7)').addClass('tr1');
	$('.accommodation tr:eq(9)').addClass('tr1');
	$('.accommodation tr:eq(10)').addClass('tr1');
	
	// REDEEM //
	$('#redeem tr:odd').addClass('red-odd');
	// MESSAGES //
	$('#messages tr:even').addClass('alt');
	
	// PRESS ROOM //
	$('.main #content .press-title h3').addClass('press-arrow1');
	$('.press-title h3').click(function(){
		//alert('haha');
		$(this).parent('.press-title').children('.press-content').slideToggle();
		$(this).parent('.press-title').children('h3').toggleClass('press-arrow2');
	});
	
	$('.main #content .press-title .press-content ul.year li a').click(function(e){
		e.preventDefault();
		$(this).next('ul.month').slideToggle();
	})
	$('.main #content .press-title .press-content ul.year li ul.month li a').click(function(e){
		e.preventDefault();
		$(this).next('ul').slideToggle();
	});
	
	// FAQ //
	$('.main #content .faq-title h3').addClass('press-arrow1');
	$('.faq-title h3').click(function(){
		//alert('haha');
		$(this).parent('.faq-title').children('.faq-content').slideToggle();
		$(this).parent('.faq-title').children('h3').toggleClass('press-arrow2');
	});
	
	$( "#birthday" ).datepicker({
		maxDate: '-22Y',						
	});
	
});
