jQuery(function($){
	
	function colheight()
	{
		$('#content-wrap').height($(document).height());	
	}

	
		colheight();
	
	
	window.onresize = function(event) {
  		
		
			colheight();
		
	}
	
	if($('.show-form').length > 0 || $('.successTextBook').length > 0)
	{
		$('#book-now').animate({
				width: '230px'
			}, 500, function() {
			$('#book-now form').fadeIn(1000);
		 	 });
	}

	
	
	var $scrollingDiv = $("#book-now-container");
 
		$(window).scroll(function(){			
			$scrollingDiv
				.stop()
				.animate({"marginTop": ($(window).scrollTop()) + "px"}, "slow" );			
		});
		
	/*
	var $scrollingDiv2 = $("header");
 
		$(window).scroll(function(){			
			$scrollingDiv2
				.stop()
				.animate({"marginTop": ($(window).scrollTop()) + "px"}, "slow" );			
		});
	*/


	//controls for full screen image
	$("#full-screen-image").fullSizeImage({ 
		 overlayLine: true,
		 repositionImage : true,
		 offset : "260,0",
		 position : "fixed"
	});

	$('#book-now-btn').click(function(e)
	{
		e.preventDefault();
		var width = $('#book-now').width();
		if(width > 0)
		{
			$('#book-now form').fadeOut(1000);
			  $('#book-now').delay(1000).animate({ width: 0 }, // what we are animating
			{
				duration: 'slow', // how fast we are animating
				easing: 'easeOutQuad', // the type of easing
				complete: function() { // the callback
			}
		  });


		}
		else
		{
			
			var contentwidth = $('#content').width();
			if(contentwidth > 0)
			{
				 $('#copy').fadeOut(1000);
			  	 $('#content').delay(1000).animate({ width: 0 }, // what we are animating
				 {
				duration: 'slow', // how fast we are animating
				easing: 'easeOutQuad', // the type of easing
				complete: function() { // the callback
				$('img.close').hide();
				$('img.open').show();
				}
		  		});
				 
				$('#book-now').delay(2000).animate({
					width: '230px'
				}, 1000, function() {
					$('#book-now form').fadeIn(1000); 
		 		 });
				

 
			 }
			 
			 else
			 {
				 $('#book-now').animate({
				width: '230px'
			}, 1000, function() {
			// Animation complete.
		 	 });
			$('#book-now form').delay(1000).fadeIn(1000);
			 }
			
			
			
		}
	});
	
	var cOpen = false;
	
	$('.button-container img').click(function(e)
	{
		
		
			if (cOpen == true)
			{
				
				$(this).parent().next().slideUp(500, function() {
					colheight();
				});
				cOpen = false;
				
		
			}
			else
			{
				//$('.text').slideUp();
				$(this).parent().next().slideDown(100, function() {
					colheight();
				});
				cOpen = true;	
			}
		
		
	});
	
	$('#content-tab img').click(function(e)
	{
		e.preventDefault();
		var width = $('#content').width();
		if(width > 0)
		{
		
		 
		 
		 $('#copy').fadeOut(1000);
			  $('#content').delay(1000).animate({ width: 0 }, // what we are animating
			{
				duration: 'slow', // how fast we are animating
				easing: 'easeOutQuad', // the type of easing
				complete: function() { // the callback
				$('img.close').hide();
				$('img.open').show();
			}
		  });


		}
		else
		{
			
			var width = $('#book-now').width();
	    	if(width > 0)
			{
				$('#book-now form').fadeOut(1000);
			    $('#book-now').delay(1000).animate({ width: 0 }, // what we are animating
				{
					duration: 'slow', // how fast we are animating
					easing: 'easeOutQuad', // the type of easing
					complete: function() { // the callback
				}
			    });
				
				$('#content').delay(2000).animate({
					width: '604px'
					}, 1000, function() {
						$('img.open').hide();
						$('img.close').show();
		 	 	});
				
				$('#copy').delay(3000).fadeIn(1000);


			}
			
			else
			{
			
				$('#content').animate({
					width: '604px'
					}, 1000, function() {
						$('img.open').hide();
						$('img.close').show();
		 	 	});
				
				$('#copy').delay(1000).fadeIn(1000);
			}
		}
	});

});//end jquery

