
	$(function(){	
		  

	 
/*---- MAIN MENU DROPDOWNS ---*/
 if (jQuery.browser.msie && jQuery.browser.version == "6.0") {
	$('#nav li').hover(function(){
		$(this).addClass('currnav');
	},function(){
		$(this).removeClass('currnav');
	});	
}






/*---- OPEN .EXTERNAL LINKS IN NEW WINDOW ---*/
$('.external').click( function() {
 if (!$(this).hasClass('movie1')) {							   
	window.open($(this).attr('href'));					   
	return false;
	}
});
							   
function openSizedExternal(width,height,resize) {
}

/*---------- WHAT'S NEW SHOW/HIDE ---------*/
$('#whatsNew li').hover( function() {
	if ($(this).hasClass('more')) { return; 
	} else {
		$(this).siblings().removeClass('current');
		$(this).addClass('current');
	}
}, function () {return;});

$('#whatsNew li').click( function() {
	var thislink = $(this).find('a:first')	;
	if (thislink.hasClass('external')) {
		window.open(thislink.attr('href'));
	} else {
		window.location=thislink.attr('href');	
	}
	return false;
});

/*---------- PROMO LINKING ---------
$('#promos li').each( function() {
	$(this).find('p').wrap('<a href="'+ $(this).find('a:first').attr('href') + '"></a>');
});*/


/*---------- VIDEO SHOW/HIDE ---------*/

	var showmovie = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="480" height="280" codebase="http://www.apple.com/qtactivex/qtplugin.cab"><param name="src" value="http://mfile.akamai.com/17525/mov/colonialwil.download.akamai.com/17525/HanksPSA/TomHanksPSA_512k.mov"><param name="autoplay" value="true"><param name="controller" value="true"><param name="loop" value="false"><param name="bgcolor" value="#000000"><embed src="http://mfile.akamai.com/17525/mov/colonialwil.download.akamai.com/17525/HanksPSA/TomHanksPSA_512k.mov" width="480" height="280" bgcolor="#000000" autoplay="true" controller="true" loop="false" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>';

	
$('#aboutCW .movieThumb').click( function() {
if (jQuery.browser.msie && jQuery.browser.version == "6.0") {
	$('#movieSpot').replaceWith(showmovie);
 } 
	$('#movieLayer').toggle();
 
	return false;
/*	if ($('#movieLayer').css('left') != '150px') {
		$('#movieLayer').css('left','150px');	
	} else {
		$('#movieLayer').css('left','-9999px');
	}*/
});
$('#movieLayer a').click ( function() {
	if ($(this).hasClass('movieClose')) {
		$('#movieLayer').hide();
		//$('#movieLayer').css('left','-9999px');
		return false; 
	} 
});


/*---------- VISIT TOOLS SHOW/HIDE ---------*/
$('#visitlinks .cal').hover( function() {
	$('#calLayer').show();					  
},
function() {
	$('#calLayer').hide();
});

/*--------- SLIDESHOW FUNCTION FOR SPECIALS AND PACKAGES	----------*/

// create closure
(function($) {

  // plugin definition
  $.fn.inpageShow = function(options) {
   // debug(this);
   
    // build main options before element iteration
    var opts = $.extend({}, $.fn.inpageShow.defaults, options);
   
    // iterate and reformat each matched element
    return this.each(function() {
      $this = $(this);
      // build element specific options
      //var o = $.meta ? $.extend({}, opts, $this.data()) : opts;
	   var o = opts;
	   
		var numItems = $(o.wrapper).find(o.items).length;
	 // IF PLAYER, CREATE NUMBER_LINKS DIV
	  if (o.player) {
			var nums = '<div class="number_links">';
			o.arrows ? nums += '<a href="" class="prevbtn"><img src="/images_global/tips/sm_beigearrow_left.gif" alt="previous" width="5" height="7"></a>' : null;
				//console.log('numiitems = ' + numItems);
			for(i=0;i<numItems;i++) {
				i==0 ? nums += '<a href="" class="current">' + (i + 1) + '</a>' : nums += '<a href="">' + (i + 1) + '</a>';
				}
			o.arrows ? nums += '<a href="" class="nextbtn"><img src="/images_global/tips/sm_beigearrow_right.gif" alt="next" width="5" height="7"></a>' : null;
			o.pause ? nums += '<a href="" class="pausebtn">Pause</a>' : null;
			nums+='</div>';
			//determine where number_links goes relative to the showWrapper
			if (o.playerloc == "before") {
				$(o.wrapper).before(nums)
			} else if (o.playerloc == "after") {
				$(o.wrapper).after(nums);
			} else if (o.playerloc == "append") {
				$(o.wrapper).append(nums);
			} else if (o.playerloc == "prepend") {
				$(o.wrapper).prepend(nums);
			}
		}
		
		//IF TOOLTIPS, CREATE TOOLTIPS DIV
		if (o.tooltips) {
			$(o.wrapper).parent().find('.number_links').prepend('<div class="tooltip"><p></p><div class="tooltiparrow"></div></div>');
		}
		
		//set click functions for each button
		$(o.wrapper).parent().find('.number_links').find('a').each(function () {
			$(this).click(function() { 
				//get the current image number
				var curnum = (parseInt($(this).siblings('.current').text()));	
				
				// PAUSE BTN
				if ($(this).hasClass('pausebtn')) {
					$(this).removeClass('pausebtn').addClass('playbtn').text('Play');
					
				// PLAY BTN
				} else if ($(this).hasClass('playbtn')) {
					$(this).removeClass('playbtn').addClass('pausebtn').text('Pause');
					
				// NEXT BUTTON
				} else if ($(this).hasClass('nextbtn')) {
						
					if ( curnum == numItems ) {
					curnum = 0; 
					} 
					
					$(this).siblings('.current').removeClass('current');
					$(this).siblings('a:eq('+(curnum+1)+')').addClass('current');
					
		    		 var thisnum = curnum;
					 var thisli = o.items + ':eq('+thisnum+')';
					$(this).parent().parent().find(o.wrapper).find('li.current').removeClass('current').fadeOut('slow');
					$(this).parent().parent().find(o.wrapper).find(thisli).addClass('current').fadeIn('slow');
						
					
				// PREVIOUS BUTTON
				} else if ($(this).hasClass('prevbtn')) {
						
					if ( curnum == 1 ) {
					curnum = numItems+1; 
					} 
					$(this).siblings('.current').removeClass('current');
					$(this).parent().find('a:eq('+(curnum-1)+')').addClass('current');
					
					 var thisnum = curnum - 2;
					 var thisli = o.items + ':eq('+thisnum+')';
					$(this).parent().parent().find(o.wrapper).find('li.current').removeClass('current').fadeOut('slow');
					 $(this).parent().parent().find(o.wrapper).find(thisli).addClass('current').fadeIn('slow');
						
					
				// VIEW ALL BUTTON
				} else if ($(this).hasClass('viewall')) {
					window.open($(this).attr('href'));
						
				// NUMBER BTNS	
				} else {
					 
					if (o.pause){
					$(this).removeClass('pausebtn').addClass('playbtn').text('Play');
					}
					 $(this).siblings('.current').removeClass('current').end().addClass('current');
					 
					 var thisnum = (parseInt($(this).text())) - 1;
					 var thisli = o.items + ':eq('+thisnum+')';
					$(this).parent().parent().find(o.wrapper).find('li.current').removeClass('current').fadeOut('slow');
					 $(this).parent().parent().find(o.wrapper).find(thisli).addClass('current').fadeIn('slow');
				
				}
				
				
				return false;
			});						
			// NUMBER TOOLTIPS
			/*$(this).hover(function () {
				if($(this).hasClass('playbtn') || $(this).hasClass('pausebtn') || $(this).hasClass('prevbtn') || $(this).hasClass('nextbtn')) {
					return;
				} else {
					thisIndex = (parseInt($(this).text()))-1;
					$('body #container .tooltip p').text($(this).parents().find(o.items + ':eq(' + thisIndex + ') h4:eq(0)').text())
					
					var addwidth=0;
					var tipwidth = $('body #container .tooltip').width();
					
					for(i=1;i<(thisIndex+2);i++) {
						addwidth += $(this).parent().find('a:eq('+i+')').outerWidth();
						}
					//find center point to place pop up
					var targetX = (addwidth - (tipwidth/2))+($(this).outerWidth()/2-2);
					var targetY = -$(this).outerHeight()-($(this).outerHeight()/2 + 1);
					
					$('body #container .tooltip').css('left',targetX).css('top',targetY).show();
					$('body #container .tooltip .tooltiparrow').css('width',tipwidth);
				}
			  }, 
			  function () {
				$('body #container .tooltip').hide();
			  }); */
 
		});
		
    });
  };
 
  // private function for debugging
  /*function debug($obj) {
    if (window.console && window.console.log)
      window.console.log('hilight selection count: ' + $obj.size());
  };*/

 
  // define and expose our format function
/*  $.fn.inpageShow.format = function(txt) {
    return '<em>' + txt + '</em>';
  };*/
 
  // plugin defaults
  $.fn.inpageShow.defaults = {
    wrapper: '.inpageShow',
    items: 'li',
	player:true,
	pause:true,
	arrows:false,
	playerloc:'before',
	tooltips:true
  };
// end of closure
})(jQuery);

$('#specialsPackages').inpageShow({
										 		pause:false,
												arrows:true,
												playerloc:'after',
												tooltips:false
												 });
// to change an option: $('#myDiv').hilight({ foreground: 'blue' });
// to change a default: $.fn.hilight.defaults.foreground = 'blue';
});	  
