	$(document).ready(function() {
	
	$('#navigation li').each(function() {
		if($(this).hasClass('current')) {
			$(this).prev().addClass('current-prev');
		}
	});
	
	
//	$('.gallery-content .gal a:first-child').addClass('firsty');
//	$('.homepage .mast').cycle({
//		fx: 'fade'
//	});
	
	
	$('.spinner').cycle({
		fx: 'fade', 
		timeout: 3000,
		pause: 1
	});
	
	$("a[rel^='prettyPhoto']").prettyPhoto();
	
	//if($.browser.msie){
	if(false){
		$("a[rel='modalPDF']").click(function(){
			window.open ($(this).attr("href"),"mywindow","location=0,status=0,scrollbars=0,width=600,height=400");
		});
	}else{
		$("a[rel='modalPDF']").click(function(){
		$.prettyPhoto.open($(this).attr("href"));
			return false;
		});
	}
	
	
	$('.cycle-feature')
	.before('<div class="cycle-control">') 
	.cycle({ 
	    fx:     'fade',
		speed: 1000,
		timeout: 5000,
	    pager:  '.cycle-control' 
	});
	
	// contact us form date picker
	$('.contact_date')
		.datepicker({
			showOn: 'button',
			buttonImage: '/extension/cdev_base/design/cdev_base/images/calendar.png',
			buttonImageOnly: true,
			showOn: 'both',
			constrainInput: true,
			showAnim: 'slideDown',
			minDate: '+0',
			maxDate: '+1Y',
			dateFormat: 'MM d, yy'
		})
	$('.contact_date').datepicker('setDate', '+0');
	
	$('#calendar').fullCalendar({
		buttonText: {
	        prev: '&laquo;',
	        next: '&raquo;'
	    },
		header: {
			left: 'prev',
			center: 'title',
			right: 'next'
		},
		events: "/layout/set/popup/content/view/events/(category)/0",
		eventClick: function(event){
			loadModal(780, "/layout/set/modal/"+event.url);
			return false;
		},
		viewDisplay: function(view){
			var past   = new Date();
			past.setMonth(past.getMonth()-6);
			
			var future = new Date();
			future.setMonth(future.getMonth()+6);
			
			if(view.end > future)
				$("div.fc-button-next").hide();
			else
				$("div.fc-button-next").show();
			
			if(view.start < past)
				$("div.fc-button-prev").hide();
			else
				$("div.fc-button-prev").show();
			
		}
			
    });
	
/*
	$("form.quick-reservations").submit(function(){
		var arrival = $("input[name='arrDate']").val().split("/");
		
		$("input[name='arrivalMonth']").val(arrival[0]);
		$("input[name='arrivalDay']").val(arrival[1]);
		$("input[name='arrivalYear']").val(arrival[2]);
*/

		/*
		var departure = $("input[name='checkOut_date']").val().split("-");
		
		$("input[name='departureMonth']").val(departure[0]);
		$("input[name='departureDay']").val(departure[1]);
		$("input[name='departureYear']").val(departure[2]);
		*/	

	/*
		$("form.quick-reservations").attr("action","https://webrez.stjulien.com/v1web/Availability.ASP");
		$("input[name=WCI]").val('Reservations');
		$("input[name=WCE]").val('Dates');
		$("input[name=iRooms]").val($("select[name='rooms']").val());
		$("input[name=iNgts]").val($("select[name='nights']").val());
		$("input[name=ArvDD]").val($("input[name='arrivalDay']").val());
		$("input[name=ArvMM]").val($("input[name='arrivalMonth']").val());
		$("input[name=ArvYY]").val($("input[name='arrivalYear']").val());	
	});
	
*/

	// new subnav
	$('#navigation li ul').css({opacity: .8});
	$('#navigation>li').hover(function(){
			$(this)
				.addClass('on')
				.find('ul')
					.stop()
					.animate({width: 206})
		}, function(){
			$(this)
				.removeClass('on')
				.find('ul')
					.stop()
					.animate({width: 0});
			Cufon.refresh("#navigation li a, #navigation li span");
	});
	/*$('#navigation>li').mouseenter(function(){
		//alert('here');
		$(this)
			.addClass('on')
			.find('ul')
				.stop()
				.animate({width: 206})
	});
	$('#navigation>li').mouseleave(function(){
		$("#navigation>li.on")
			.removeClass('on')
			.find('ul')
				.stop()
				.animate({width: 0});
		Cufon.refresh();
	//});
	});*/
});

// Cufon
Cufon.replace('#navigation li a, #navigation li span', {fontFamily: 'Gotham HTF', hover: true});
Cufon.replace('.crown a', {fontFamily: 'Gotham HTF'});
Cufon.replace('.preCrown', {fontFamily: 'Gotham HTF'});

Cufon.replace('#quick-reservations label', {fontFamily: 'Gotham HTF'});
Cufon.replace('.col1 h1, .gallery-content h1, #modal-content h1', {fontFamily: 'Gotham Rounded Light', textShadow: '1px 1px #6a6964'});
Cufon.replace('.homepage .col1 h2', {fontFamily: 'Gotham Rounded Light', textShadow: '1px 1px #6a6964'});
Cufon.replace('.gallery-content h3', {fontFamily: 'Gotham Rounded Light'});
Cufon.replace('.feature h3', {fontFamily: 'Gotham HTF'});
Cufon.replace('.nl h4', {fontFamily: 'Gotham HTF'});
Cufon.replace('.subnav li', {fontFamily: 'Gotham HTF'});
Cufon.replace('.specials h3', {fontFamily: 'Gotham HTF'});
Cufon.replace('.specials .price', {fontFamily: 'Gotham HTF'});
Cufon.replace('.quick-reserve h3', {fontFamily: 'Gotham HTF', textShadow: '0px 0px #6a6964'});
Cufon.replace('.quick-reserve label', {fontFamily: 'Gotham HTF', textShadow: '0px 0px #6a6964'});
Cufon.replace('.sub-tools .social-tools .fb a');


// Custom select button
function selectReplacement(obj) {
	// append a class to the select
	obj.className += ' replaced';
	// create list for styling
	var ul = document.createElement('ul');
	ul.className = 'selectReplacement';
	var opts = obj.options;
	for (var i=0; i<opts.length; i++) {
		var selectedOpt;
		if (opts[i].selected) {
			selectedOpt = i;
			break;
		} else {
			selectedOpt = 0;
		}
	}
	for (var i=0; i<opts.length; i++) {
		var li = document.createElement('li');
		var txt = document.createTextNode(opts[i].text);
		li.appendChild(txt);
		li.selIndex = opts[i].index;
		li.selectID = obj.id;
		li.onclick = function() {
			selectMe(this);
		}
		if (i == selectedOpt) {
			li.className = 'selected';
			li.onclick = function() {
				this.parentNode.className += ' selectOpen';
				this.onclick = function() {
					selectMe(this);
				}
			}
		}
		if (window.attachEvent) {
			li.onmouseover = function() {
				this.className += ' hover';
			}
			li.onmouseout = function() {
				this.className = 
				this.className.replace(new RegExp(" hover\\b"), '');
			}
		}
		ul.appendChild(li);
	}
	// add the input and the ul
	obj.parentNode.appendChild(ul);
	}
    function selectMe(obj) {
      var lis = obj.parentNode.getElementsByTagName('li');
      for (var i=0; i<lis.length; i++) {
        if (lis[i] != obj) { // not the selected list item
          lis[i].className='';
          lis[i].onclick = function() {
            selectMe(this);
          }
       } else {
          setVal(obj.selectID, obj.selIndex);
          obj.className='selected';
          obj.parentNode.className = 
            obj.parentNode.className.replace(new RegExp(" selectOpen\\b"), '');
          obj.onclick = function() {
            obj.parentNode.className += ' selectOpen';
            this.onclick = function() {
              selectMe(this);
            }
          }
        }
      }
    }
    function setVal(objID, selIndex) {
      var obj = document.getElementById(objID);
      obj.selectedIndex = selIndex;
    }
    
    //function setForm() {
    //		var s = document.getElementsByTagName('select');
    //		for (var i=0; i<s.length; i++) {
    //			selectReplacement(s[i]);
    //		}
    //}
    function closeSel(obj) {
      // close the ul
    }
 //   window.onload = function() {
 //     (document.all && !window.print) ? null : setForm();
 //   }

