(function($){
	//Custume style select box
 	$.fn.extend({
 	customStyle : function(options) {
	  if(!$.browser.msie || ($.browser.msie&&$.browser.version>6)){
	  return this.each(function() {	  
			var currentSelected = $(this).find(':selected');
			$(this).after('<span class="customStyleSelectBox"><span class="customStyleSelectBoxInner">'+currentSelected.text()+'</span></span>').css({position:'absolute', opacity:0,fontSize:$(this).next().css('font-size')});
			var selectBoxSpan = $(this).next();
			var selectBoxWidth = parseInt($(this).width()) - parseInt(selectBoxSpan.css('padding-left')) -parseInt(selectBoxSpan.css('padding-right'));			
			var selectBoxSpanInner = selectBoxSpan.find(':first-child');
			selectBoxSpan.css({display:'inline-block'});
			selectBoxSpanInner.css({width:selectBoxWidth, display:'inline-block'});
			var selectBoxHeight = parseInt(selectBoxSpan.height()) + parseInt(selectBoxSpan.css('padding-top')) + parseInt(selectBoxSpan.css('padding-bottom'));
			$(this).height(selectBoxHeight).change(function(){				
			selectBoxSpanInner.text($(this).find(':selected').text()).parent().addClass('changed');			
		});			
	  });
	  }
	}
 });
})(jQuery);
$(function(){
	$('.styled').customStyle();
});

$(function(){
	// Main Menu Dropdown
	$("ul#nav li.active ul").addClass("hold");
	$("ul#nav li:not(ul#nav ul li)").hover(function()
	{
		if(!$(this).parent().hasClass("hold"))
			$(".hold").hide();
		
		$(this).addClass("active");
		$("ul", $(this)).show();
	}, function()
	{
		$(this).removeClass("active");
		$("ul", $(this)).hide();
		
		if($(this).parent().attr("id")=="nav")
			$(".hold").show();
	});	
	
	//home read more
	if ($('#collapse-more').length != 0){
   		$("#collapse-more").append("<br /><a href='#' class='btn-read-more-close'>&lt; Read Less</a>").hide();
	}
	$(".btn-read-more").click(function(){
		if ( $(this).next().is(":hidden") ) {
			$(this).next().slideDown("fast");
			$(this).hide();
		} else {
		$(".btn-read-more").next().hide();
			$(this).next().slideDown("fast");
			$(this).show();
		}
	return false;
	})
	$(".btn-read-more-close").click(function(){
		var btnReadMore = $(this).parent().prev()
			$(this).parent().slideUp("fast", function(){
			$(btnReadMore).fadeIn("fast")
	});
	return false;
	})
	     
	 // Date Picker
	$('.rescal')
		.datepicker({
		showOn: 'button',
		buttonImage: sitepath+'images/calender.gif',
		buttonText: 'Calendar',
		minDate:'0',
		buttonImageOnly: true,
		onSelect: function(dateText){
			var date = dateText.split("/");
			$("#selMonth").val(date[0]);
			$("#selDate").val(date[1]);
			$("#selYear").val(date[2]);
			$("#selMonth").next().children().text($("#selMonth")[0].options[$("#selMonth").attr("selectedIndex")].innerHTML);
			$("#selDate").next().children().text($("#selDate")[0].options[$("#selDate").attr("selectedIndex")].innerHTML);
			$("#selYear").next().children().text($("#selYear")[0].options[$("#selYear").attr("selectedIndex")].innerHTML);
			//$("#datepicker").hide();
		}
	});
	if ($('.datepicker_date_arrival').length != 0){
		$('.datepicker_date_arrival,.datepicker_date')
			.datepicker({
			showOn: 'button',
			minDate:'0',
			buttonImage: sitepath+'images/calender.gif',
			buttonText: 'Calendar',
			buttonImageOnly: true
		})
		//$('.datepicker_date_arrival').datepicker('setDate', '+0');
		//$('.datepicker_date_departure').datepicker('setDate', '+1');
		
		$(".datepicker_date_arrival").change(function(){
			var ci = $(this).datepicker("getDate");
			ci.setDate(ci.getDate()+1);			
				$($(this).parent().next().children('.datepicker_date_departure')).datepicker("setDate",ci);
			});
		}
	
		
		$('.datepicker_date_departure')
			.datepicker({
			showOn: 'button',
			beforeShow: minRange,
	        defaultDate: +0,
			buttonImage: sitepath+'images/calender.gif',
			buttonText: 'Calendar',
			buttonImageOnly: true
			});
		
		 function minRange(input) {
	           return {
	               minDate: (jQuery(($(this).parent().prev().children('.datepicker_date_arrival'))).datepicker("getDate") != null ? jQuery(($(this).parent().prev().children('.datepicker_date_arrival'))).datepicker("getDate") : 1)
	           };
	       }
						
	//res widget btncheck
	$(".btncheck").click(function() {
		  $('#selMonth').val();
		  $('#selDate').val();
		  $('#selYear').val();
		  var submitdate=$('#selMonth').val()+"/"+$('#selDate').val()+"/"+$('#selYear').val();
		  $('#dateIn').val(submitdate);
		  var today= new Date();
		  var today1= new Date(today.getMonth()+1+"/"+today.getDate()+"/"+today.getFullYear());
		  var datesubmitted= new Date(submitdate);
		  if(datesubmitted < today1)
		  {
		  	alert("Check-In date cannot be past date");
			return false;
		  }
		  $("form[name=omni_reservation_form]").submit();
	});
	
	//today function widget
	function fntoday()
	{
		var today= new Date();
		var mm=today.getMonth()+1;
		if(mm<10)mm="0"+mm;	else mm=mm;
		var dd=today.getDate();
		if(dd<10)dd="0"+dd; else dd=dd;
		var yy=today.getFullYear();
		$('#selMonth').val(mm);
		$('#selDate').val(dd);
		$('#selYear').val(yy);
		$("#selMonth").next().children().text($("#selMonth")[0].options[$("#selMonth").attr("selectedIndex")].innerHTML);
		$("#selDate").next().children().text($("#selDate")[0].options[$("#selDate").attr("selectedIndex")].innerHTML);
		$("#selYear").next().children().text($("#selYear")[0].options[$("#selYear").attr("selectedIndex")].innerHTML);
	}
	fntoday();
		
	
	//Photo Gallery
	if ($('.gallery').length != 0){
		$(".gallery a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'slow',slideshow:8000});
	}
	
	// Promo Banner
	$('.sidebar-slides .slide').cycle({ 
	    fx: 'fade',
		speed: 300,
	    timeout: 5000,
	    //pause: 1,
	    pager: '.slide-pager',
	  	pagerAnchorBuilder:	function(index, slide){return '<li><a href="#">'+index+'</a></li>';}		
	});	
	
	// Book Now Button
	Cufon('#promo .sidebar-slides .slide .item a',{hover: {color: '#ccba79'} });
	Cufon('#res_widget a.btncheck',{hover: {color: '#38180b'} });
	Cufon('#email_excl a.btnsign',{hover: {color: '#38180b'} });
	Cufon('a.btnview',{hover: {color: '#38180b'} });
	Cufon('a.cngbg',{hover: {color: '#ccba79'} });
	Cufon('.btn_check a',{hover: {color: '#38180b'} });	
	
	//Face Book 
	var isVisible = false;  
    function showLikeButton( visible ){         
        if( visible == true ){
            $('#fb-like').fadeIn( 'slow' );
			isVisible = true;
        }
        else if ( isVisible ){
            $('#fb-like').fadeOut( 'slow' );
            isVisible = false;
		}
    }
    var begOfUrl="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Fmorrisonclark";
    var endOfUrl="layout=button_count&amp;show_faces=false&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=21";
    function sendIdToLikeButton( title, id ){                   
        $( '#facebook-like' ).attr( 'src', begOfUrl + "%3Fid=" + id + endOfUrl );
    }
	
	//Email Signup
	$("#email").click(function(){
		if (this.value == this.defaultValue) this.value = '';
	});
	$("#email").blur(function(){
		if ( $(this).val().length==0) {
			$(this).val('Enter E-Mail Address');
		}
	});
	$('.btnsign').click(function() {
		if(checkEmail(document.Mjg3MTg5MTc6LTE.email.value))
		{$("#frmemail").submit();}
	});
});
