var jcar = null;
var jcar_index = 0;
var pcount = 0;
var pidx = 0;
var parsed = [];
var promos_timeout = 4;
var dom =document.domain;

var t = n = count = 0;


function checkEmail(email) {

	var re = new
	RegExp("^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$");

	if (!email.match(re)) {

	alert('Please provide a valid email address');

	return false;

	}

}

function check(){
	var  username = $("#id1").val();
	var  password= $("#id2").val();
	
	if(!username || !password){
		alert('Please provide message complete');
		return false;
	}else{
		return true;
	}

}











$(function(){
	

	for(var i=0; i<document.links.length; i++) 
	{
		document.links[i].onfocus=function(){this.blur()}
	}

	
	$('#hero_images').cycle({
        timeout: 4000
    });
	//	Cufon font's fixing
	Cufon.set('fontFamily', 'Avenir LT 55 Roman');
	Cufon.replace('.avenir', {
		fontStyle: 'Avenir LT 55 Roman',
	
		hover: true
	});
	
	Cufon.set('fontFamily', 'Avenir LT 55 Roman');
	Cufon.replace('.wavenir', {
		fontStyle: 'Avenir LT 55 Roman',
		color:'#746b78',
		hover: true
	});
	
	Cufon.set('fontFamily', 'Avenir LT Std');
	Cufon.replace('.xavenir', {
		fontStyle: 'Avenir LT Std',
		fontSize:'11px',
		hover: true
	});
	
	Cufon.set('fontFamily', 'Avenir LT Std');
	Cufon.replace('.txavenir', {
		fontStyle: 'Avenir LT Std',
		fontSize:'9px',
		color:'#ffffff',
		hover: true
	});
	
	Cufon.set('fontFamily', 'Helvetica Neue');
	Cufon.replace('.hel', {
		fontStyle: 'Helvetica Neue',
		fontSize:'18px',
		color: '#FFFFFF',
		hover: true
	});
	
	Cufon.set('fontFamily', 'Avenir LT 55 Roman');
	Cufon.replace('.aavenir', {
		fontStyle: 'Avenir LT 55 Roman',
		fontSize:'11px',
		hover: true
	});
	
	Cufon.set('fontFamily', 'Helvetica Neue');
	Cufon.replace('.hhel', {
		fontStyle: 'Helvetica Neue',
		fontWeight: 'bold',
		hover: true
	});
	
	Cufon.set('fontFamily', 'Avenir LT Std');
	Cufon.replace('.hhhel', {
		fontStyle: 'Avenir LT Std',
		fontSize:'14px',
		color:'#3d3d3f',
		hover: true
	});
	
	
	Cufon.set('fontFamily', 'Avenir LT Std');
	Cufon.replace('#maincontent h3', {
		fontStyle: 'Avenir LT Std',
		fontSize:'14px',
		color:'#3d3d3f',
		hover: true
	});
	
	Cufon.set('fontFamily', 'Avenir LT 55 Roman');
	Cufon.replace('.aaavenir', {
		fontStyle: 'Avenir LT 55 Roman',
	
		hover: true
	});
	Cufon.set('fontFamily', 'Myriad Pro');
	Cufon.replace('.mp', {
		fontStyle: 'Myriad Pro',
		fontSize:'11px',
		hover: true
	});
	
	Cufon.set('fontFamily', 'Times New Roman');
	Cufon.replace('.tnr', {
		fontStyle: 'Times New Roman',
		fontSize:'12px',
		color:'#37373d',
		hover: true
	});
	
	
	
	$("#mainnav li").hover(function(){

		$(this).find("div").show();
	},function(){
	
		$(this).find("div").hide();
	});
	
	d = new Date();
	today_year = d.getFullYear();
	toyear=today_year-2000;
	today_month = d.getMonth()+1;
	if (today_month<10) {
		today_month = '0'+today_month;
	}
	today_day = d.getDate();
	if (today_day<10) {
		today_day = '0'+today_day;
	}
	today = today_month+'/'+today_day+'/'+toyear;
	t = d.getTime();
	d = new Date(t+1000*3600*24);
	tomorrow_year = d.getFullYear();
	tomyear=tomorrow_year-2000;
	tomorrow_month = d.getMonth()+1;
	if (tomorrow_month<10) {
		tomorrow_month = '0'+tomorrow_month;
	}
	tomorrow_day = d.getDate();
	if (tomorrow_day<10) {
		tomorrow_day = '0'+tomorrow_day;
	}
	tomorrow = tomorrow_month+'/'+tomorrow_day+'/'+tomyear;	
	$("#check-in-date").datepicker({
	    closeText: 'Close',
	    dateFormat: 'mm/dd/y',
	    defaultDate: 0,
	    minDate: '+0',
	    maxDate: '+1Y',
	    showAnim: 'slideDown',
	    showButtonPanel: true,
	    onSelect: function(date,thisPicker){
			date = $(this).datepicker("getDate");
			date.setDate(date.getDate()+1);
			$("#check-out-date").datepicker("setDate",date).datepicker("option", "minDate", date);
	    }
	}).val(today);
	
	$("#check-out-date").datepicker({
	    closeText: 'Close',
	    dateFormat: 'mm/dd/y',
	    defaultDate: '+1',
	    minDate: '+1',
	    maxDate: '+1Y',
	    showAnim: 'slideDown',
	    showButtonPanel: true
	}).val(tomorrow);
	
	$("#people").spicyselect();
	$("#type").spicyselect();
	
	$("#email").click(function(){
		$(this).val('');
		
	});
	$("#rm").click(function(){
		$("#hide_content").removeClass("hide");
		$(this).removeClass("readMore").addClass("hide");
		$("#rl").removeClass("hide").addClass("readLess");
	});
	$("#rl").click(function(){
		$("#hide_content").addClass("hide");
		$(this).removeClass("readLess").addClass("hide");
		$("#rm").removeClass("hide").addClass("readMore");
	});
	
	pcount = parseInt($('#bar a').size());


	$('div.rb').jcarousel({
		scroll: 1,
		animation: 400,
		auto: promos_timeout,

		wrap: "circular",
		initCallback: function(e,s) {

		},		
		itemLoadCallback: function(e){
			running = e.first%pcount - 1;
			$('#bar a').removeClass('current').eq(running).addClass('current');
			href1 = $('div.rb a').eq(running).attr('href');
			om = $('div.rb a').eq(running).attr('name');
			var tttmp = $('div.rb a').eq(running).attr('target');
			if(tttmp =="_blank"){
				$('#bara').unbind('click').attr('href', href1).attr('name',om).attr('target','_blank').bind('click', function(){
					window.open(href1);
					return false;
				});
			}else{
				$('#bara').unbind('click').attr('href', href1).attr('name',om).bind('click', function(){
					window.location.href=href1;
					return false;
				});
				
			}

		}
	});


	$('#bar a').click(function(e){
		jcar = $('div.rb').data('jcarousel');
		jcar.stopAuto();
		
		this_idx = parseInt($(this).attr('idx'));
		jcar.scroll(this_idx+1);
		jcar.first = this_idx+1;
		jcar.last = this_idx+1;


		
		$('#bar a').removeClass('current').eq(this_idx).addClass('current');


		href = $('div.rb a').eq(this_idx).attr('href');
		var ttmp = $('div.rb a').eq(this_idx).attr('target');

		if(ttmp=="_blank"){
			$('#bara').unbind('click').attr('href', href).attr('target','_blank').bind('click', function(){
				window.open(href);
				return false;
			});
		}else{
			$('#bara').unbind('click').attr('href', href).bind('click', function(){
			window.location.href=href;
			return false;
		});
		
		}

		
		



		
		jcar.startAuto();


		
		return false;   
	});
	
	
	$("#2").mouseover(function(){
	
		this_obj = $(this);
		this_obj.find("ul").show();
		this_obj.addClass("arrow");

	}).mouseout(function(){
		this_obj = $(this);
		this_obj.find("ul").hide();
		this_obj.removeClass("arrow");
	});
	
	$("#people").click(function(){
		$('#type_mask ol').hide();
	});
	
	if ($.browser.msie && $.browser.version==7) {
		$('#type').removeClass('dropList').addClass('dropListt');
		$('#type_mask').removeClass('dropList').addClass('dropListt');
	}
	
	$("#mainnav li:first-child").addClass('none_border');
	
	$(".bottomList span:last-child").css({'display':'none'});
	
	
	$.ajax({
		type: "get",
		url: "/yahoo.php?act=getwether",
		dataType: "html",
		data: "",
		success:function(msg){
		
		
			$("#ucufon").html(msg);
			
	      
			Cufon.replace('#ucufon', { fontFamily: 'Avenir LT 55 Roman' });

		}
	
	}); 

	Cufon.replace('#kucufon', { fontFamily: 'Avenir LT 55 Roman' });

	
	$('#esub').click(function(){
		$('form[name="NDMxMjU1MjU6LTE"]').trigger('submit');
		return false;
	});
	
	
	$(".gallery_imgs a[rel^='prettyPhoto']").prettyPhoto({
		animation_speed:'normal', 
		theme:'facebook', 
		slideshow:6000, 
		autoplay_slideshow: true,
		callback: function(){
		}
	});
	
	$('#site_logo').wrap('<a href="/"></a>');
	
	$('#arrival_date,#event_date_start,#event_date_end,#proposal,#event_date').datepicker({
	    closeText: 'Close',
	    dateFormat: 'mm/dd/yy',
	    defaultDate: 0,
	    minDate: '+0',
	    maxDate: '+5Y',
	    showAnim: 'slideDown',
	    showButtonPanel: true		
	});
	
	$('#arrival_date_a,#event_date_start_a,#event_date_end_a,#proposal_a,#event_date_a').click(function(){
		_key_ = $(this).attr('id');
		$('#'+_key_.replace('_a', '')).trigger('focus');
		return false;
	});
	
	
	$('#contactus_submit,#meeting_submit,#wedding_submit').click(function(){
		_key_ = $(this).attr('id');
		$('#'+_key_.replace('_submit', '')).trigger('submit');		
		return false;
	});
	
	$('#contactus_reset, #meeting_reset,#wedding_reset').click(function(){
		_key_ = $(this).attr('id');
		$('#'+_key_.replace('_reset', '')).trigger('reset');	
		return false;
	});
	
	$('#contactus_country_select').change(function(){
		val = '';
		$(this).find('option').each(function(){
			if ($(this).attr('selected')) {
				val = $(this).text();
			}
		});
		if (val!='') {
			$('#contactus_country').val(val);
		}
	});

	$("a[href$='.pdf']").attr("target","_blank");
	
	$('#left_check_availability').click(function(){
		$('form[name="omni_reservation_form"]').trigger('submit');
	});
	
	$("#mainnav li a.expand").parent().unbind('mouseenter').unbind('mouseleave');
	$("#mainnav li a.expand").next().show();
	
	$('#contactus_submit,#contactus_reset,#wedding_submit,#wedding_reset').mouseover(function(){
		$(this).prev().attr('src', assets+'images/subtn_off.png');
	}).mouseout(function(){
		$(this).prev().attr('src', assets+'images/subtn_on.png');
	});
	
	
	/* 
	$(".contactBox p").css({"*margin-top":"-4px"});
	Cufon.set('fontFamily', 'Times New Roman').replace($(".contactBox p"), {
			fontStyle: 'Times New Roman',
			fontSize:'12px',
			color:'#37373d',
			hover: true

		});	
		 */
		
});
