// INIT FOR MENU //
	
	var sRoot = 'http://casacaribe.ky';
	var sPath = window.location.pathname;
	var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
		
	function cookieSwap(m) {
		
		var n = readCookie(m);
		
		if (n == 'visible'){
			createCookie(m,'hidden',1);
			document.getElementById('arrow-'+m).src= sRoot + "/imgs/menu/arrow_ex.gif";
		} else if (n == 'hidden'){
			createCookie(m,'visible',1);
			document.getElementById('arrow-'+m).src= sRoot + "/imgs/menu/arrow_co.gif";
		} else {
			createCookie(m,'hidden',1);
			document.getElementById('arrow-'+m).src= sRoot + "/imgs/menu/arrow_ex.gif";};

	}
		
	function initMenu() {
		$('#menu ul').hide();
		
		var x = readCookie('why_stay');
			//alert(x);
			if (x == 'hidden'){
				$('#menu ul.why_stay').hide();
				document.getElementById('arrow-why_stay').src= sRoot + "/imgs/menu/arrow_ex.gif";
			} else if (x == 'visible') {
				$('#menu ul.why_stay').show();
				document.getElementById('arrow-why_stay').src= sRoot + "/imgs/menu/arrow_co.gif";
			} else {
				$('#menu ul.why_stay').hide();
				document.getElementById('arrow-why_stay').src= sRoot + "/imgs/menu/arrow_ex.gif";
			};
		
			if (sPage == 'why-stay-at-casa-caribe.php'){
				$('#menu ul.why_stay').show();
				createCookie('why_stay','visible',1);
				document.getElementById('arrow-why_stay').src= sRoot + "/imgs/menu/arrow_co.gif";};			
			
		var y = readCookie('things_to_do');
			//alert(y);
			if (y == 'hidden'){
				$('#menu ul.things_to_do').hide();
				document.getElementById('arrow-things_to_do').src= sRoot + "/imgs/menu/arrow_ex.gif";
			} else if (y == 'visible') {
				$('#menu ul.things_to_do').show();
				document.getElementById('arrow-things_to_do').src= sRoot + "/imgs/menu/arrow_co.gif";
			} else {
				$('#menu ul.things_to_do').hide();
				document.getElementById('arrow-things_to_do').src= sRoot + "/imgs/menu/arrow_ex.gif";
			};
		
			if (sPage == 'cayman-islands-things-to-do.php'){
				$('#menu ul.things_to_do').show();
				createCookie('things_to_do','visible',1);
				document.getElementById('arrow-things_to_do').src= sRoot + "/imgs/menu/arrow_co.gif";};
		
		var z = readCookie('about');
			//alert(z);
			if (z == 'hidden'){
				$('#menu ul.about').hide();
				document.getElementById('arrow-about').src= sRoot + "/imgs/menu/arrow_ex.gif";
			} else if (z == 'visible') {
				$('#menu ul.about').show();
				document.getElementById('arrow-about').src= sRoot + "/imgs/menu/arrow_co.gif";
			} else {
				$('#menu ul.about').hide();
				document.getElementById('arrow-about').src= sRoot + "/imgs/menu/arrow_ex.gif";};
				
			if (sPage == 'about-casa-caribe.php'){
				$('#menu ul.about').show();
				createCookie('about','visible',1);
				document.getElementById('arrow-about').src= sRoot + "/imgs/menu/arrow_co.gif";};
			
	  $('#menu li a').click(
		function() {
		  var checkElement = $(this).next();
		  
		  if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
			checkElement.slideUp('normal');
			}
		  if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
			checkElement.slideDown('normal');
			}
		  }
		);
	  }
	  
	$(document).ready(function() {initMenu();});

	function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
	}
	
	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
	
	function eraseCookie(name) {
		createCookie(name,"",-1);
	}

// CODE FOR FANCY BOX //

$(document).ready(function() { 
	$("a#fb").fancybox({ 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': false, 'imageScale': true });
	$("a.fb").fancybox({ 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': false, 'imageScale': true });
	$("a.villas").fancybox({ 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': false, 'imageScale': true });
	$("a.gallery").fancybox({ 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': false, 'imageScale': true }); 
});
