/****************************************
*	Pure Luxury JS
*
*	Created by: Adam Foster
*	Date Created: 2008-03-31
*
*	Copyright 2008 Lightmaker Manchester
*
****************************************/

$(document).ready(function(){
 
								 
	 // main navigation hover 
	 $('#destinationsMenu').hide();
	 $("#navigation li a:not(#itemActive a)").css({backgroundPosition: '0px 23px'});
	 
	$('#navigation li:not(.subMenuLink)').hoverIntent({sensitivity: 1,interval: 1,over: linkOver, timeout: 250, out: linkOut});
	 
	function linkOver(){
		//$(this).children('a').stop().animate({backgroundPosition: '(0px 19px)'}, 200, "easeOutQuad");
		$(this).children('#destinationsMenu').slideDown("fast",function(){
			var $menu = $('#destinationsMenu');
			$('li', $menu).each(function(){
				var $SubMenu = $('div',this);
					if($SubMenu.length > 0) {
						$(this).addClass('arrow');
					}
			});
			$('li', $menu).hover(
				function() {
					$(this).addClass('hover');
					var $SubMenu = $('div',this);
					$SubMenu.show();
				},
				function() {
					$(this).removeClass('hover');					
					var $SubMenu = $('div',this);
					$SubMenu.hide();
				}
			);
		});
	};
	 
	function linkOut(){
		$(this).children('a').stop().animate({backgroundPosition: '(0px 23px)'}, 200, "easeOutQuad");
		$(this).children('#destinationsMenu').slideUp("fast");
	}
	 
	// hotspot hover 
	/*$('.hotspot a').css({backgroundPosition: '0px 23px'});
	$(".hotspot a").hover(
		function(){$(this).stop().animate({backgroundPosition: '(0px 0px)'}, 200, "easeOutQuad");}, 
		function(){$(this).stop().animate({backgroundPosition: '(0px 23px)'}, 400, "easeOutQuad");}
	);*/
	
	
	//Resort Gallery
	$('#resortGallery a span').css({opacity: '0', border: '4px solid #deb45e'});
	$('#resortGallery .mainImage img').css({opacity: '1'});
	var currentImage = "image1";
	var potentialImage = "image1";
	$("#resortGallery ."+currentImage+" span").animate({opacity: 1},400, "easeInOutQuad");
	
	$('#resortGallery a').hover(
				function(){
						potentialImage = $(this).attr("class");
						if($(this).attr("class") != currentImage) {
							$(this).children('span').stop().animate({opacity: 1},400, "easeInOutQuad"); 
						}
					}, 
				function(){
					if($(this).attr("class") != currentImage) {
						$(this).children('span').stop().animate({opacity: 0},400, "easeInOutQuad");
					}
				}
	);
	
	$('#resortGallery a').click(function () { 
			$("#resortGallery ."+currentImage+" span").stop().animate({opacity: 0},400, "easeOutQuad");
			currentImage = potentialImage;
			$("#resortGallery ."+currentImage+" span").stop().animate({opacity: 1},400, "easeOutQuad");
			$("#resortGallery .mainImage img").stop().animate({opacity: 0},600, "easeOutQuad");
			$("#"+currentImage).stop().animate({opacity: 1},1000, "easeOutQuad");		
    });
	
	//resorts accordion 
	//var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
	
	//if(IE6==false){
		$("#resorts .rowHeader").click(function() { 
				$(this).children('span').toggleClass("activeAccordionItem");
				$(this).next().slideToggle("fast");
			}).next().hide();
		
		$("#showPrice").next().show();
	///}
	inputValueReplace();
	//Form field input value replace
	function inputValueReplace() {
	//From fields default value replace
  $('input.value-replace').each(function() {  var o = new valueReplace($(this)); });
	function valueReplace(e) {
		var o = {
		  init : function() {
				o.field = $(e); 
				o.isSet = false;
				o.defaultValue = o.field.val();
				o.monitor();
			},
			monitor : function() {
				o.field.focus(function() {
					if( $(this)[0].value == o.defaultValue) { $(this)[0].value = ''; }
				});
				o.field.blur(function() {
					if($(this)[0].value == '') { $(this)[0].value = o.defaultValue; }
				});
			}
		}
		o.init();
		return o;
	}
} 

});