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 cufon_remove( selector ) {
	$( selector ).each( function(){
		var g = '';
		$( this ).find( 'cufon cufontext' ).each( function(){
			g = g + $( this ).html();
		} );
		g = $.trim( g );
		if( g != '' ){
			$( this ).html( g );
		}
	} );
	return true;
}

function screenHeight(){
	return $.browser.opera? window.innerHeight : $(window).height();
}

function resizeCultureColumns(){
	var item_height = 200;
	var item_margin = 30;
	var column_width = 409; //width+margin+padding, 39 - margin
	var columns_height = screenHeight()-120-parseInt( $('#maincontent').css('top') ) - 105;
	var n_row = parseInt( $('#culture_content_columns').attr('class').split('_')[1] );
	var min_h = n_row * item_height + ( n_row - 1 ) * item_margin;
	var max_h = ( n_row + 1 ) * item_height + n_row * item_margin;

	if( $( '#culture_content_columns' ).height() != columns_height ){
		cufon_remove('#culture_content_columns h1');
		cufon_remove('#culture_content_columns h2');
		cufon_remove('#culture_content_columns h3');
		cufon_remove('div.urban-staff-item div.credo-quote div.quote p');
		//change items position when needed only
		if( ( columns_height < min_h ) || ( columns_height > max_h ) ) {
			var items = $( '#culture_content_columns div.culture_column_item' );
			var n_items = $( items ).length;
			n_row = Math.floor( ( columns_height + item_margin ) / ( item_height + item_margin ) );
			if ( n_row == 0 ) n_row = 1;
			var n_col = Math.ceil( n_items / n_row );
			$( '#culture_content_columns' ).empty();
			$( '#culture_content_columns' ).css({ 'width' : n_col*column_width-39 + 'px' });
			var curr_item = 0;
			for( i = 1; i <= n_col; i++ ){
				$( '#culture_content_columns' ).append( '<div class="culture_column"></div>' );
				var last_column = $( '#culture_content_columns div.culture_column:last' );
				for( j = 1; j <= n_row; j++ ){
					var curr_item_obj = $( items )[curr_item];
					$( last_column ).append( '<div class="culture_column_item">' + $( curr_item_obj ).html() + '</div>' );
					curr_item++;
					if( curr_item == n_items ) {
						break;
					}
				}
			}
			$( '#culture_content_columns div.culture_column:last' ).css({'margin-right':0});
			$( '#culture_content_columns' ).append( '<div class="clear"></div>' ).attr('class', 'row_' + n_row );
			Cufon.replace('#culture_content_columns h1, #culture_content_columns h2, #culture_content_columns h3, div.urban-staff-item div.credo-quote div.quote p',{fontFamily:'DaxlineLF-Light'});
		}
		$( '#culture_content_columns' ).css( { 'height' : columns_height +'px' } );
		min_h = n_row * item_height + ( n_row - 1 ) * item_margin;
		$( '#culture_content_columns div.culture_column' ).css( { 'height' : min_h +'px' } );
		//update scrollbar size
		var pane_api = $('#culture_content').data('jsp');
		pane_api.reinitialise();
		if( $('#culture_content').width() < $( '#culture_content_columns' ).width() ){
			$( '#culture_drag_info' ).show();
		} else {
			$( '#culture_drag_info' ).hide();
		}
	}
}

function resizeBillboard( cycle ){
	$('#billboard-items').cycle('pause');
	$('#billboard-items').width( $('#billboard').width() );
	$('#billboard-items .item').width( $('#billboard-items').width() );
	$('#billboard-items .item .image img').width( $('#billboard-items').width() );
	var imgheight = screenHeight()-40;//+'px';

	$('#billboard-items .item').css({'height':imgheight+'px'});
	$('#billboard').css({'height':imgheight+'px'});

if( !$('.large-image').length ){ //tmp
	var img = $('#billboard-items .active .image img')[0];
	var picheight = $(img).height();//+'px';
	if(picheight=='0'){
		var imgs = $('#billboard-items .item .image img');
		for(i=0;i<=$(imgs).length;i++ ){
			var img = $(imgs)[i];
			if( $(img).height() > 0 ){
				picheight = $(img).height();
				break;
			}
		}
	}
        /**
         * @VD: If top is negative, image will not be shown correctly,
         * Tmp solution
         */

	var imgtop = 0;//Math.round( ( imgheight - picheight)/2 )+'px';
	$('#billboard-items .item').css({'top':imgtop});

}//tmp

	var windowheight = screenHeight()+'px';
	$('#allcontent').css({'height':windowheight});
	var mainheight = screenHeight()-120-parseInt( $('#maincontent').css('top') );
	if( mainheight < 250 ){
		mainheight = 250;
	}
	var culture_height = mainheight - 105 + 'px';
	if( $('#allcontent').hasClass('urban_culture') && ( $('#maincontent .mc').height() != mainheight ) ){
		mainheight = mainheight -55 +'px';
		$('#maincontent .mc').css({'height':mainheight});
		//$('#culture_content_columns div.culture_column').css({'height':culture_height});
		//$('#culture_content_columns').css({'height':culture_height});
		resizeCultureColumns();
		$('#culture_content').css({'max-height':mainheight, 'height':mainheight});
		var cult_con = $('#culture_content').data('jsp');
		cult_con.reinitialise();
	}

	$('#billboard-items').cycle('resume');
}
$(window).load( function(){

	if( $( '#culture_content_columns' ).length ){
		var column_width = 409; //width+margin+padding, 39 - margin
		$( '#culture_content_columns' ).css({ 'width' : $('div.culture_column').length*column_width-39 + 'px' });
		$( '#culture_content_columns div.culture_column:last' ).css({'margin-right':0});
	}
	//scrollers
	if( $('#culture_content').length ){
		$('#culture_content').jScrollPane(
			{
				horizontalDragMinWidth: 20,
				horizontalDragMaxWidth: 120
			}
		);
		if( $('#culture_content').width() < $( '#culture_content_columns' ).width() ){
			$( '#culture_drag_info' ).show();
		} else {
			$( '#culture_drag_info' ).hide();
		}
	}

	resizeBillboard();
	//remove black scroller in FF/Webkit
	if( $( '#billboard-items' ).width() != $( '#billboard' ).width() ){
		resizeBillboard();
	}

	//billboard rotation
	$('#billboard-items').cycle({
		//fx: 'scrollLeft',
		fx: 'fade',
		//startingSlide: index,
		before: function( currSlideElement, nextSlideElement, options, forwardFlag ){
					$(currSlideElement).addClass('active');
				},
		after: function( currSlideElement, nextSlideElement, options, forwardFlag ){
					$('#billboard-items .item').removeClass('active');
					$(currSlideElement).addClass('active');
					//window.location.hash = options.currSlide + 1;
				},
		cleartypeNoBg: true,
		pager:	'#billboard-thumbnails',
		//speed: 600,
		speed: 1000,
		timeout: 10000,
		pagerAnchorBuilder: pagerFactory
	});

	$('#billboard-items .item').css({'visibility':'visible'});

	function pagerFactory(idx, slide) {
		return '#billboard-thumbnails div.item:eq('+idx+') a';
	};

		var container = $('div.sliderGallery');
		var ul = $('ul', container);

		//var itemsWidth = ul.innerWidth() - container.outerWidth();
		var itemsWidth = ul.innerWidth() - ul.parent().outerWidth();

		$('.slider', container).slider({
			min: 0,
			max: itemsWidth,
			stop: function (event, ui) {
				ul.animate({'left' : ui.value * -1}, 500);
			},
			slide: function (event, ui) {
				ul.css('left', ui.value * -1);
			}
		});

	//vertical align for partners
	if( $( 'div.urban-partner' ).length ){
		var item_height = $( $( 'div.urban-partner div.attr-image' )[0] ).height();
		$( 'div.urban-partner img' ).each( function(){
			var mtop = Math.round( ( item_height - $(this).height() ) / 2 );
			if( mtop < 0 ){
				mtop = 0;
			}
			$(this).css({'margin-top': mtop + 'px'});
		} );
	}

} );

$(document).ready( function(){

	//clear the focused inputs
	$('input[type="text"]').focus( function(){
		if( $(this).attr('value') == $(this).attr('title') ){
			$(this).attr('value', '');
		};
	} );
	$('input[type="text"]').blur( function(){
		if( $(this).attr('value') == '' && $(this).attr('title') != '' ){
			$(this).attr('value', $(this).attr('title') );
		};
	} );

	//scroll to anchor
	function goTo(where) {
		document.location.replace(where);
		return false;
	}

	//debug
	if( $( '#debug' ).length ){
		$( '#debug' ).click( function( e ){
			e.preventDefault();
			$( this ).toggleClass( 'expanded' );
		} );
	}

	//show|hide thumbnails
	$('#billboard-thumbnails-wrap').mouseover( function(){
		if( $('#billboard-thumbnails-wrap').css('bottom') == '-104px' ){
			$('#billboard-thumbnails-wrap').animate({'bottom': '0'}, 500, function(){
				$('#bt-sticker').hide();
			} );
		}
	} );
	$('#billboard-thumbnails-wrap').mouseleave( function(){
		if( $('#billboard-thumbnails-wrap').css('bottom') == '0px' ){
			$('#billboard-thumbnails-wrap').animate({'bottom': '-104px'}, 500, function(){
				$('#bt-sticker').show();
			} );
		}
	} );

	//var sSel = $('.selectBlock').sSelect();
	$('#select_hotel').sSelect({'direction':'down'});
	$('#number_rooms').sSelect({'direction':'up'});
	$('#number_adults').sSelect({'direction':'up'});

	//show|hide bottom menu
	$('#bottom-menu a').click( function( e ){
		if ( $(this).attr('href') == '#' ){
			e.preventDefault();
			$('bottom-menu').hide();
			$('#bottom-menu-content').animate({'bottom': '0'}, 500 );
			//$('#billboard-items').animate({'top': '-104px'}, 500 );
		}
	} );
	//$('#bottom-menu-content').mouseleave( function(){
	$('#close-bottom-menu').click( function( e ){
		e.preventDefault();
		$('#bottom-menu-content').animate({'bottom': '-288px'}, 500);
		$('#bottom-menu-content').show();
		$('.datepicker').datepicker('hide');
	} );

	$('#topmenu .w_sub').mouseover( function(){
		$('#header').addClass('sub_corner');
	});
	$('#topmenu .w_sub').mouseleave( function(){
		$('#header').removeClass('sub_corner');
	});

	var today = new Date();
	var tomorrow = new Date( today.getFullYear(), today.getMonth(), today.getDate()+1 );
	$('#check_in_date').attr('value', $.datepicker.formatDate( 'yy-mm-dd',today ) );
	$('#check_out_date').attr('value', $.datepicker.formatDate( 'yy-mm-dd',tomorrow ) );

	$('#check_out_date').datepicker({
		'dateFormat': 'yy-mm-dd',
                'flag_calendar':false,
		'minDate': '+1d',
		'maxDate': '+1Y',
		'beforeShow': function(input, inst){
			//inst.dpDiv.css({'marginTop': -input.offsetHeight + 'px', 'marginLeft': input.offsetWidth + 'px'});
			var divHeight = 100;
			inst.dpDiv.css({'marginTop': input.offsetHeight+ divHeight + 'px', 'marginLeft': input.offsetWidth + 'px'}).addClass("small-cal");;
		}
	});

	$('#check_in_date').datepicker({
		'dateFormat': 'yy-mm-dd',
                'flag_calendar':false,
		'minDate': 0,
		'maxDate': '+1Y',
		'beforeShow': function(input, inst){
			//inst.dpDiv.css({'marginTop': -input.offsetHeight + 'px', 'marginLeft': input.offsetWidth + 'px'});
			var divHeight = 100;
			inst.dpDiv.css({'marginTop': input.offsetHeight+ divHeight + 'px', 'marginLeft': input.offsetWidth + 'px'}).addClass("small-cal");
		},
		'onSelect': function( dateText, inst ){
			var tmrw_d = new Date( parseInt(inst.currentYear), parseInt(inst.currentMonth), parseInt(inst.currentDay)+1 );
			var tmrw = $.datepicker.formatDate( inst.settings.dateFormat, tmrw_d );
			$('#check_out_date').datepicker('option', 'minDate', tmrw );
		}
	});

	$('#select_hotel').change( function(){
		var hoteluri = $(this).val();
		$('#book_err_msg').hide();
		if( hoteluri == '0' ){
			hoteluri = '';
			$('#book_err_msg').show();
		}
		$('#booking_form').attr( 'action', hoteluri );
	} );
	$('#booking_form input[type=submit]').click( function( e ){
		e.preventDefault();
		if( $('#select_hotel').val()==0 ){
			$('#book_err_msg').show();
		} else {
			if ( $('#footer_corporate_id').val() == 'Corp. Code' ) {
				$('#footer_corporate_id').val( '' );
			}
			if ( $('#footer_promo_code').val() == 'Promo Code' ) {
				$('#footer_promo_code').val( '' );
			}
			if ( $('#footer_iata_number').val() == 'Group Code' ) {
				$('#footer_iata_number').val( '' );
			}
			$('#booking_form').submit();
		}
	} );

	//open booking form in new window
	/*$('#booking_form').submit( function(){
		var form_url = $(this).attr('action')+'?';
		$(this).find('input').each( function( n, element ){
			if( $(element).attr('type') != 'button' && $(element).attr('type') != 'submit' ){
				form_url = form_url + '&' + $(element).attr('name') + '=' + $(element).val();
			}
		} );
		$(this).find('select').each( function( n, element ){
			if( $(element).attr('name') != 'select_hotel' ){
				form_url = form_url + '&' + $(element).attr('name') + '=' + $(element).val();
			}
		} );
		window.open( form_url );
		return false;
	} );*/


	//signup form
	$('.signup form').attr('target', '_blank');

	//calout

	var callouts = $( 'div#calloutsBlock div.callout' );
	var links = $( 'div#calloutsBlock div.news_switcher a' );
	var countCallouts = callouts.length;
	var currentCallout = 0;
	var allowToRun = true;
	if( countCallouts > 0 ) {
		$( links[ 0 ] ).parent().addClass( 'selected' );
		$( callouts[ 0 ] ).fadeIn( 700 );
		links.each( function(index) {
			$( this ).click( function(event) {
				event.preventDefault();
				if ( index != currentCallout ) {
					showCallout( index );
				}
			} );
		} );
		$( 'div#calloutsBlock' ).mouseenter( function() {
			allowToRun = false;
		} );
		$( 'div#calloutsBlock' ).mouseleave( function() {
			allowToRun = true;
		} );
		var showCallout = function( tabIndex ) {
			$( links[ currentCallout ] ).parent().removeClass( 'selected' );
			$( callouts[ currentCallout ] ).hide();
			$( links[ tabIndex ] ).parent().addClass( 'selected' );
			$( callouts[ tabIndex ] ).fadeIn( 700 );
			currentCallout = tabIndex;
		}
		var periodicCalloutFunction = function() {
			if ( allowToRun ) {
				var tempIndex = currentCallout;
				tempIndex += 1;
				if( tempIndex == countCallouts ) {
					tempIndex = 0;
				}
				showCallout( tempIndex );
			}
		}
		setInterval(periodicCalloutFunction, 5000 );
	}
	//end callout

	//show footer popups
	$('a.pp-link').click( function( e ){
		e.preventDefault();
		$('#maincontent').show();


                if($(this).attr("id") == "lnk-urban-at-glance") {
                    $('#maincontent').addClass("popup-urban-at-glance");
                }

		var popupID = '#pp' + $(this).attr('id').split('lnk')[1];
		$('.pp-content').hide();
		$(popupID).show();
		var mainheight = screenHeight()-120-parseInt( $('#maincontent').css('top') )+'px';
		$('#maincontent').addClass('popup_block');
		$('#maincontent .mc').css({'height': 'auto'});
		//if( $('#maincontent .mc').height() > parseInt( mainheight ) ){
		//	$('#maincontent .mc').css({'height':mainheight});
		//}
		if( $('#maincontent').hasClass('maincontent-visible') ){
			$('#close-btn').show();
		};
		$('#open-btn').hide();
	} );
	$('#close-btn').click( function( e ){
		e.preventDefault();
		if( $('#maincontent').hasClass('popup_block') ){

                
                if( $('#maincontent').hasClass('popup-urban-at-glance')) {
                    $('#maincontent').removeClass("popup-urban-at-glance");
                }
			$('.pp-content').hide();
			$('#maincontent').hide();
			$('#maincontent').removeClass('popup_block');
			if( $('#maincontent').hasClass('maincontent-visible') ){
				$('#maincontent').show();
				$('#pp-main').show();
				var mainheight = screenHeight()-120-parseInt( $('#maincontent').css('top') )+'px';
				$('#maincontent .mc').css({'height': 'auto'});
				if( $('#maincontent .mc').height() > parseInt( mainheight ) ){
					//$('#maincontent .mc').css({'height':mainheight});
				}
				if( $('.small-image').length ){
					$('#close-btn').hide();
				}
				if( $('#maincontent').hasClass('maincontent_collapsed') ){
					$('#open-btn').show();
					$('#close-btn').hide();
				};
			};
		} else {
			$('#pp-main-content').hide();
			$('#close-btn').hide();
			$('#open-btn').show();
			$('#maincontent').addClass('maincontent_collapsed');
		}
	} );
	$('#open-btn').click( function( e ){
		e.preventDefault();
		$('#pp-main-content').show();
		$('#close-btn').show();
		$('#open-btn').hide();
		$('#maincontent').removeClass('maincontent_collapsed');
	} );

	//nav trick, hide empty items
	$('.empty-nav a').click( function( e ){
		e.preventDefault();
	} );
	$('#culture_sidemenu .w_sub').mouseover( function(){
		$( '#culture_sidemenu' ).addClass('w_hover');
	});
	$('#culture_sidemenu .w_sub').mouseleave( function(){
		$( '#culture_sidemenu' ).removeClass('w_hover');
	});

	//open dialogboxes
	if( $('.dialog-popup-button').length ){
		var dialog_blocks  = $('div.dialog-popup');
		var dialog_buttons = $('.dialog-popup-button');
		$(dialog_blocks).each( function( ){
			$(this).dialog( {
				autoOpen: false,
				width: 366,
				modal: false,
				resizable: false,
				dialogClass:"urban-popup"
			} );
		});

		$(dialog_buttons).each( function( key, item ){
			$(item).click( function( e ){
				e.preventDefault();
				$( dialog_blocks[key] ).dialog("open");
			} );
		} );
	}

	//open Term and Services popup
	if( $('#read-terms').length ){
			$('#read-terms').dialog( {
				autoOpen: false,
				width: 600,
				modal: false,
				resizable: false,
				dialogClass:"urban-popup"
			} );
			$('#read-terms-link').click( function( e ){
				e.preventDefault();
				$('#read-terms').dialog("open");
			} );
	}

	/*POPUP*/
        $("#popup-room-policy").dialog({
                        autoOpen: false,
                        width: 366,
                        modal: false,
                        resizable: false,
                        dialogClass:"urban-popup"
        });

        $("#room-policy").click(function(){
            $("#popup-room-policy").dialog("open");
        });

        $("#availability_calendar_popup").dialog({
                autoOpen: false,
                width: 630,
                modal: false,
                resizable: false,
                dialogClass:"urban-popup urban-calendar-popup"
        });

     $("#popup-room-perks").dialog({
                    autoOpen: false,
                    width: 366,
                    modal: false,
                    resizable: false,
                    dialogClass:"urban-popup"
     });

	$("#room-perks").click(function( e ){
		e.preventDefault();
		$("#popup-room-perks").dialog("open");
	});


    $(".popup-rate").dialog({
                    autoOpen: false,
                    width: 437,
                    modal: true,
                    resizable: false,
                    dialogClass:"urban-popup"
     });
    $(".details-rate").click(function(){
        $("#popup-rate").dialog("open");
    });

    $("#login-popup").dialog({
                    autoOpen: false,
                    width: 523,
                    modal: true,
                    resizable: false,
                    dialogClass:"urban-popup login-popup"
     });
    $("#help_popup").dialog({
            autoOpen: false,
            width: 500,
            modal: false,
            resizable: false,
            dialogClass:"urban-popup"
    });
    $("#cancellation_policy_popup").dialog({
            autoOpen: false,
            width: 500,
            modal: false,
            resizable: false,
            dialogClass:"urban-popup"
    });

    $('#help_payment').click(function(){
            $( "#help_popup" ).dialog( "open" );
            return false;
    });

    $('#cancellation_policy').click(function(){
            $( "#cancellation_policy_popup" ).dialog( "open" );
            return false;
    });


	//Urban Culture tab
	if( $( '#urban-stickers' ).length ){
		$( '#urban-stickers' ).css( { 'top' : Math.round( screenHeight()/2 ) + 'px' } );
	}
	if( $('#culture_close').length ){
		var m_width = $( '#maincontent' ).width();
		$( '#urban-culture-sticker' ).click( function( e ){
			e.preventDefault();
			$( '#maincontent' ).removeClass('maincontent-hidden').addClass('maincontent-visible');
			$( '#urban-culture-sticker' ).removeClass('ucst-visible').addClass('ucst-hidden');
			$( '#content' ).css( {'overflow':'hidden'} );
			$( '#maincontent' ).animate( {'padding-left': '-='+ m_width + 'px' }, 'slow', function(){
				$( '#content' ).css( {'overflow':'visible'} );
			} );
		} );
		$('#culture_close a').click( function( e ){
			e.preventDefault();
			$( '#content' ).css( {'overflow':'hidden'} );
			$( '#maincontent' ).animate( {'padding-left': '+='+ m_width + 'px' }, 'slow', function(){
				$( '#content' ).css( {'overflow':'visible'} );
				$( '#maincontent' ).removeClass('maincontent-visible').addClass('maincontent-hidden');
				$( '#urban-culture-sticker' ).removeClass('ucst-hidden').addClass('ucst-visible');
			} );
		} );
	}

        $(".wrap-up").click(function(){
           var link = $(this);
            if ($(this).hasClass("wrap-up-open")){
               $(".wrap-up-open").hide();
               $(".wrap-up-close").show();
            $(this).parent().children(".white-box-wrapper").css("display","none")
             link.parent().children(".conten-close").show();
            }else {
               $(".wrap-up-close").hide();
               $(".wrap-up-open").show()
            $(this).parent().children(".white-box-wrapper").css("display","block")
             link.parent().children(".conten-close").hide();
            }
        } );
        $(".view-details").click(function(){
            $(this).next().slideToggle();

            if ($(this).html()=="view details [+]") {

                $(this).html("hide details [X]")

            } else {

                $(this).html("view details [+]")
            }


        })

	//open T&C popup
	if( $('#t-and-c-popup').length ){
		$('#t-and-c-popup').dialog( {
			autoOpen: false,
			width: 600,
			modal: false,
			resizable: false,
			dialogClass:"urban-popup urban-uc-head",
			title: "Terms and Conditions"
		} );
		$('a.open-t-and-c').click( function( e ){
			e.preventDefault();
			$('#t-and-c-popup').dialog("open");
		} );
	}

	//open Contact-Us popup
	if( $('#contact-us-popup').length ){
		$('#contact-us-popup form').attr('target','_blank');
		$('#contact-us-popup').dialog( {
			autoOpen: false,
			width: 600,
			modal: false,
			resizable: false,
			dialogClass:"urban-popup urban-uc-head",
			title: "Member Service Contact form"
		} );
		$('a.open-contact-us').click( function( e ){
			e.preventDefault();
			$('#contact-us-popup').dialog("open");
		} );
		$('#contact-us-popup form input[type=submit]').click( function( e ){
			//e.preventDefault();
			//$('#contact-us-popup form').submit();
			//reset
			$('#contact-us-popup').dialog("close");
		} );
	}

	//booking form in header
	if( $('#book_now_top_block').length ){
		$('#select_hotel_top').sSelect({'direction':'down'});
		$('#number_rooms_top').sSelect({'direction':'down'});
		$('#number_adults_top').sSelect({'direction':'down'});
		$('#book_now_top').click( function( e ){
			e.preventDefault();
			$('#book_now_top_block').show();
		} );
		$('#book_now_top_close').click( function( e ){
			e.preventDefault();
			$('#book_now_top_block').hide();
		} );

		var today = new Date();
		var tomorrow = new Date( today.getFullYear(), today.getMonth(), today.getDate()+1 );
		$('#check_in_date_top').attr('value', $.datepicker.formatDate( 'yy-mm-dd',today ) );
		$('#check_out_date_top').attr('value', $.datepicker.formatDate( 'yy-mm-dd',tomorrow ) );
	
		$('#check_out_date_top').datepicker({
			'dateFormat': 'yy-mm-dd',
			'flag_calendar':false,
			'minDate': '+1d',
			'maxDate': '+1Y',
			'beforeShow': function(input, inst){
				//inst.dpDiv.css({'marginTop': -input.offsetHeight + 'px', 'marginLeft': input.offsetWidth + 'px'});
				//var divHeight = 100;
				inst.dpDiv.addClass("small-cal");;
			}
		});

		$('#check_in_date_top').datepicker({
			'dateFormat': 'yy-mm-dd',
			'flag_calendar':false,
			'minDate': 0,
			'maxDate': '+1Y',
			'beforeShow': function(input, inst){
				//inst.dpDiv.css({'marginTop': -input.offsetHeight + 'px', 'marginLeft': input.offsetWidth + 'px'});
				//var divHeight = 100;
				inst.dpDiv.addClass("small-cal");
			},
			'onSelect': function( dateText, inst ){
				var tmrw_d = new Date( parseInt(inst.currentYear), parseInt(inst.currentMonth), parseInt(inst.currentDay)+1 );
				var tmrw = $.datepicker.formatDate( inst.settings.dateFormat, tmrw_d );
				$('#check_out_date_top').datepicker('option', 'minDate', tmrw );
			}
		});

		$('#select_hotel_top').change( function(){
			var hoteluri = $(this).val();
			$('#book_err_msg_top').hide();
			if( hoteluri == '0' ){
				hoteluri = '';
				$('#book_err_msg_top').show();
			}
			$('#booking_form_top').attr( 'action', hoteluri );
		} );
		$('#booking_form_top input[type=submit]').click( function( e ){
			e.preventDefault();
			if( $('#select_hotel_top').val()==0 ){
				$('#book_err_msg_top').show();
			} else {
				if ( $('#footer_corporate_id_top').val() == 'Corp. Code' ) {
					$('#footer_corporate_id_top').val( '' );
				}
				if ( $('#footer_promo_code_top').val() == 'Promo Code' ) {
					$('#footer_promo_code_top').val( '' );
				}
				if ( $('#footer_iata_number_top').val() == 'Group Code' ) {
					$('#footer_iata_number_top').val( '' );
				}
				$('#booking_form_top').submit();
			}
		} );

	}//end booking form in header

} );

$(window).bind('resizeEnd', function() {
	//resize billboard and its content
	resizeBillboard( 'cycle' );
});

$(window).resize( function(){
	if(this.resizeTO) clearTimeout(this.resizeTO);
		this.resizeTO = setTimeout(function() {
			$(this).trigger('resizeEnd');
		}, 500);
} );

