// JavaScript Document
$.noConflict();
jQuery(document).ready(function($) {
	$('#conditionsNav li').click(function() {
		$ccontent = '#' + $(this).attr('id') + 'Content';
		$(this).addClass('selected').siblings().removeClass('selected');
		$($ccontent).addClass('current').siblings().removeClass('current');
	});
	
	$('.ctBox .boxAnchor').click(function() {
		thisBox = $(this).siblings('.boxContent');
		if (thisBox.hasClass('open')) {
			thisBox.stop(true,true).animate({
				height:0,
				top:'0'
			},250,function() {
				thisBox.css('display','none').toggleClass('open')
			});
		}
		else {
			thisBox.css('display','block').stop(true,true).animate({
				height:240,
				top:'-237'
			},250).toggleClass('open');
		}
	});
	$('.ctBox .close').click(function() {
		thisBox = $(this).closest('.boxContent');
		thisBox.stop(true,true).animate({
			height:0,
			top:'0'
		},250,function() {
			thisBox.css('display','none').toggleClass('open')
		});
		
	});

	$('#topNav>ul>li').hover(function() {
		$(this).toggleClass('hover');
	},
	function() {
		$(this).toggleClass('hover');
	});

	$(".mapPop").fancybox({
		'width' : 760,
		'height': 460,
		'autoScale': false,
		'type': 'iframe'
	});
	
	$(".videoPop").fancybox({
		'width' : 640,
		'height': 360,
		'autoScale': false,
		'type': 'iframe'
	});

	$('#bookDatesQuery').click(function() {
		var jarrivaldate = $('[name=arrivaldate]').val();
		var jdeparturedate = $('[name=departuredate]').val();
		var jnumadults = 2;
		var jnumchildren = 0;
		window.open('https://book.okemo.com/WorldXA/LaunchApp/Booking.aspx?view=okemo&section=lodging&imagegallerytimeout=30&lock=&startdate=' + jarrivaldate + '&enddate=' + jdeparturedate + '&adults=' + jnumadults + '&children=' + jnumchildren +'&others=0&rooms=1','bookdateQuery');
	});
	$('.buttonOne').click(function() {
		$('#panelOne').css('display', 'block');
		$('#panelOne').siblings().css('display', 'none');
	});
	$('.buttonTwo').click(function() {
		$('#panelTwo').css('display', 'block');
		$('#panelTwo').siblings().css('display', 'none');
	});
	$('.buttonThree').click(function() {
		$('#panelThree').css('display', 'block');
		$('#panelThree').siblings().css('display', 'none');
	});	
	$('.contentExpander h3').click(function() {
		$(this).siblings().slideToggle('normal');
		//alert($(this).children('span').html());
		if ($(this).children('span').html() == "-")
		{
			$(this).children('span').html('+');
		}
			
		else
		{
			$(this).children('span').html('-');
		}
	});
	$('.restore').each(function() {
		var def_string = $(this).val();
		$(this).focus( function(){ 
			$(this).val('');
		});
		$(this).blur(function() {
			if ($(this).val() == '') {
				$(this).val(def_string);
			}
		});
	});

	function setCookie(c_name, value, expiredays) {
	var exdate = new Date();
	exdate.setDate(exdate.getDate() + expiredays);
	document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString()) + ";path=/";
	}
	// This functions reads & returns the cookie value of the specified cookie (by cookie name)
	function getCookie(c_name) {
		if (document.cookie.length > 0) {
			c_start = document.cookie.indexOf(c_name + "=");
			if (c_start != -1) {
				c_start = c_start + c_name.length + 1;
				c_end = document.cookie.indexOf(";", c_start);
				if (c_end == -1) c_end = document.cookie.length;
				return unescape(document.cookie.substring(c_start, c_end));
			}
		}
		return "";
	}
	
	if(stormAlert == 'True'){
		$('#alertContainer').css('display','block');
		if (getCookie("AlertVisited") == "") {
			setCookie("AlertVisited", "true", 1);
		}
		else {	
			$('#alertOpened').css('display','none');
			$('#alertClosed').css('display','block');
		}
	}

	$('#close a').click(function() {
		$('#alertOpened').slideToggle('fast', function() {
			$('#alertClosed').slideToggle('fast');
		});
	});
	$('#alertClosed').click(function() {
		$('#alertClosed').slideToggle('fast', function() {
			$('#alertOpened').slideToggle('fast');
		});
	});
});
jQuery(function($) {
	$("#arrivaldate").datepicker({dateFormat: 'mm/dd/yy'});
	$("#departuredate").datepicker({dateFormat: 'mm/dd/yy'});
});
function gsQuery() {
	document.forms["searchbar"].submit();
}

