jQuery(document).ready(function() {
    

    jQuery(".request-form-iframe").fancybox({
        'width'             : 600,
        'height'            : 650,
        'autoScale'         : false,
        'transitionIn'      : 'none',
        'transitionOut'     : 'none',
        'type'              : 'iframe'
    });

	var is_ipad = navigator.userAgent.match(/iPad/i);
	if(is_ipad != null)
	{
		jQuery('body').css('background-position','left top');
		jQuery('body.home').css('background-position','10px center !important');
		jQuery('body.main').css('background-position','center center');
		jQuery('body.history, body.menus').css('background-position','10px center !important');
		jQuery('body.washington-dc-location, body.washington-dc-sidecar').css('background-position','-320px center !important');
		jQuery('body.las-vegas-reservations, body.las-vegas-sidecar-reservations, body.las-vegas-sidecar-gallery').css('background-position','-180px center !important');
	}
	
	jQuery('body.main').css('background','#000000 url(images/bg/' + jQuery.random(5) + '.jpg) no-repeat center center');
	
	jQuery('body.menus').css('background','#000000 url(images/bg_menus/' + jQuery.random(21) + '.jpg) no-repeat center center');
	
	jQuery('body.home, body.community, body.news_twitter').css('background','#000000 url(images/bg_home/' + jQuery.random(8) + '.jpg) no-repeat center center');
	
	jQuery('body.history').css('background','#000000 url(images/bg_history/' + jQuery.random(4) + '.jpg) no-repeat center center');
	
	jQuery('body.private_affairs').css('background','#000000 url(images/bg_private_affairs/' + jQuery.random(4) + '.jpg) no-repeat center center');
	
	jQuery('body.sidecar_menus').css('background','#000000 url(images/bg_menus/sidecar/' + jQuery.random(2) + '.jpg) no-repeat center center');
	
	jQuery('body.55-street-location').css('background','#000000 url(images/bg_locations/location_55th/' + jQuery.random(5) + '.jpg) no-repeat center center');
	jQuery('body.55-street-information').css('background','#000000 url(images/bg_locations/location_55th/' + jQuery.random(5) + '.jpg) no-repeat center center');
	jQuery('body.55-street-reservations').css('background','#000000 url(images/bg_locations/location_55th/' + jQuery.random(5) + '.jpg) no-repeat center center');
	jQuery('body.55-street-gallery').css('background','#000000 url(images/bg_locations/location_55th/' + jQuery.random(5) + '.jpg) no-repeat center center');
	jQuery('body.55-street-private-dining').css('background','#000000 url(images/bg_locations/location_55th/' + jQuery.random(5) + '.jpg) no-repeat center center');
	jQuery('body.55-street-hours').css('background','#000000 url(images/bg_locations/location_55th/' + jQuery.random(5) + '.jpg) no-repeat center center');
	
	
	jQuery('body.lincoln-square-location').css('background','#000000 url(images/bg_locations/location_lincoln/' + jQuery.random(12) + '.jpg) no-repeat center center');
	jQuery('body.lincoln-square-information').css('background','#000000 url(images/bg_locations/location_lincoln/' + jQuery.random(12) + '.jpg) no-repeat center center');
	jQuery('body.lincoln-square-reservations').css('background','#000000 url(images/bg_locations/location_lincoln/' + jQuery.random(12) + '.jpg) no-repeat center center');
	jQuery('body.lincoln-square-gallery').css('background','#000000 url(images/bg_locations/location_lincoln/' + jQuery.random(12) + '.jpg) no-repeat center center');
	jQuery('body.lincoln-square-private-dining').css('background','#000000 url(images/bg_locations/location_lincoln/' + jQuery.random(12) + '.jpg) no-repeat center center');
	jQuery('body.lincoln-square-hours').css('background','#000000 url(images/bg_locations/location_lincoln/' + jQuery.random(12) + '.jpg) no-repeat center center');
	
	jQuery('body.hudson-location').css('background','#000000 url(images/bg_locations/location_hudson/' + jQuery.random(15) + '.jpg) no-repeat center center');
	jQuery('body.hudson-information').css('background','#000000 url(images/bg_locations/location_hudson/' + jQuery.random(15) + '.jpg) no-repeat center center');
	jQuery('body.hudson-reservations').css('background','#000000 url(images/bg_locations/location_hudson/' + jQuery.random(15) + '.jpg) no-repeat center center');
	jQuery('body.hudson-gallery').css('background','#000000 url(images/bg_locations/location_hudson/' + jQuery.random(15) + '.jpg) no-repeat center center');
	jQuery('body.hudson-private-dining').css('background','#000000 url(images/bg_locations/location_hudson/' + jQuery.random(15) + '.jpg) no-repeat center center');
	jQuery('body.hudson-hours').css('background','#000000 url(images/bg_locations/location_hudson/' + jQuery.random(15) + '.jpg) no-repeat center center');
	
	jQuery('body.washington-dc-location').css('background','#000000 url(images/bg_locations/location_dc/' + jQuery.random(13) + '.jpg) no-repeat center center');
	jQuery('body.washington-dc-information').css('background','#000000 url(images/bg_locations/location_dc/' + jQuery.random(13) + '.jpg) no-repeat center center');
	jQuery('body.washington-dc-reservations').css('background','#000000 url(images/bg_locations/location_dc/' + jQuery.random(13) + '.jpg) no-repeat center center');
	jQuery('body.washington-dc-gallery').css('background','#000000 url(images/bg_locations/location_dc/' + jQuery.random(13) + '.jpg) no-repeat center center');
	jQuery('body.washington-dc-private-dining').css('background','#000000 url(images/bg_locations/location_dc/' + jQuery.random(13) + '.jpg) no-repeat center center');
	jQuery('body.washington-dc-hours').css('background','#000000 url(images/bg_locations/location_dc/' + jQuery.random(13) + '.jpg) no-repeat center center');
	
	jQuery('body.las-vegas-location').css('background','#000000 url(images/bg_locations/location_las_vegas/' + jQuery.random(14) + '.jpg) no-repeat center center');
	jQuery('body.las-vegas-information').css('background','#000000 url(images/bg_locations/location_las_vegas/' + jQuery.random(14) + '.jpg) no-repeat center center');
	jQuery('body.las-vegas-reservations').css('background','#000000 url(images/bg_locations/location_las_vegas/' + jQuery.random(14) + '.jpg) no-repeat center center');
	jQuery('body.las-vegas-gallery').css('background','#000000 url(images/bg_locations/location_las_vegas/' + jQuery.random(14) + '.jpg) no-repeat center center');
	jQuery('body.las-vegas-private-dining').css('background','#000000 url(images/bg_locations/location_las_vegas/' + jQuery.random(14) + '.jpg) no-repeat center center');
	jQuery('body.las-vegas-hours').css('background','#000000 url(images/bg_locations/location_las_vegas/' + jQuery.random(14) + '.jpg) no-repeat center center');
	
	jQuery('body.new-york-sidecar').css('background','#000000 url(images/bg_locations/location_sidecar_ny/' + jQuery.random(5) + '.jpg) no-repeat center center');
	jQuery('body.new-york-sidecar-information').css('background','#000000 url(images/bg_locations/location_sidecar_ny/' + jQuery.random(5) + '.jpg) no-repeat center center');
	jQuery('body.new-york-sidecar-reservations').css('background','#000000 url(images/bg_locations/location_sidecar_ny/' + jQuery.random(5) + '.jpg) no-repeat center center');
	jQuery('body.new-york-sidecar-gallery').css('background','#000000 url(images/bg_locations/location_sidecar_ny/' + jQuery.random(5) + '.jpg) no-repeat center center');
	jQuery('body.new-york-sidecar-private-dining').css('background','#000000 url(images/bg_locations/location_sidecar_ny/' + jQuery.random(5) + '.jpg) no-repeat center center');
	jQuery('body.new-york-sidecar-hours').css('background','#000000 url(images/bg_locations/location_sidecar_ny/' + jQuery.random(5) + '.jpg) no-repeat center center');
	
	jQuery('body.washington-dc-sidecar').css('background','#000000 url(images/bg_locations/location_sidecar_dc/' + jQuery.random(6) + '.jpg) no-repeat center center');
	jQuery('body.washington-dc-sidecar-information').css('background','#000000 url(images/bg_locations/location_sidecar_dc/' + jQuery.random(6) + '.jpg) no-repeat center center');
	jQuery('body.washington-dc-sidecar-reservations').css('background','#000000 url(images/bg_locations/location_sidecar_dc/' + jQuery.random(6) + '.jpg) no-repeat center center');
	jQuery('body.washington-dc-sidecar-gallery').css('background','#000000 url(images/bg_locations/location_sidecar_dc/' + jQuery.random(6) + '.jpg) no-repeat center center');
	jQuery('body.washington-dc-sidecar-private-dining').css('background','#000000 url(images/bg_locations/location_sidecar_dc/' + jQuery.random(6) + '.jpg) no-repeat center center');
	jQuery('body.washington-dc-sidecar-hours').css('background','#000000 url(images/bg_locations/location_sidecar_dc/' + jQuery.random(6) + '.jpg) no-repeat center center');
	
	jQuery('body.las-vegas-sidecar').css('background','#000000 url(images/bg_locations/location_sidecar_lv/' + jQuery.random(5) + '.jpg) no-repeat center center');
	jQuery('body.las-vegas-sidecar-information').css('background','#000000 url(images/bg_locations/location_sidecar_lv/' + jQuery.random(5) + '.jpg) no-repeat center center');
	jQuery('body.las-vegas-sidecar-reservations').css('background','#000000 url(images/bg_locations/location_sidecar_lv/' + jQuery.random(5) + '.jpg) no-repeat center center');
	jQuery('body.las-vegas-sidecar-gallery').css('background','#000000 url(images/bg_locations/location_sidecar_lv/' + jQuery.random(5) + '.jpg) no-repeat center center');
	jQuery('body.las-vegas-sidecar-private-dining').css('background','#000000 url(images/bg_locations/location_sidecar_lv/' + jQuery.random(5) + '.jpg) no-repeat center center');
	jQuery('body.las-vegas-sidecar-hours').css('background','#000000 url(images/bg_locations/location_sidecar_lv/' + jQuery.random(5) + '.jpg) no-repeat center center');
	
	jQuery('body.sidecar').css('background','#000000 url(images/bg_locations/location_sidecar_ny/0.jpg) no-repeat center center');
	
	jQuery('body.new-york-sidecar').css('background','#000000 url(images/bg_locations/location_sidecar_ny/' + jQuery.random(5) + '.jpg) no-repeat center center');
	
	jQuery('.places > ul > li > a:not(:has(>img))').hover( function() {
		jQuery(this).prev().children('img').css('margin-top', '-102px');
	}, function() {
		jQuery(this).prev().children('img').css('margin-top', '0');
	});
	
	jQuery('.triple_links > li > a:not(:has(>img))').hover( function() {
		jQuery(this).prev().children('img').css('margin-top', '-105px');
	}, function() {
		jQuery(this).prev().children('img').css('margin-top', '0');
	});
	
	jQuery('.location_box').click( function(e) {
		e.stopImmediatePropagation();
		jQuery(this).children('.location_sub').show();
		jQuery('#gallery').css('position','static');
		jQuery('#gallery').css('z-index','0');
	});
	
	jQuery('.location_box_sub').click( function(e) {
		e.stopImmediatePropagation();
		jQuery('#gallery').css('position','static');
		jQuery('#gallery').css('z-index','0');
	});
	
	jQuery('body').click( function() {
		jQuery('.location_sub').hide();
		jQuery('#gallery').css('position','relative');
		jQuery('#gallery').css('z-index','101');
	});
    
    jQuery('.menu_type li:first-child, .menu_type li:nth-child(3), .menu_type li:nth-child(5)').addClass('margin-right-40');
	
	/*if(jQuery('ul').is('.menu_type')){
	jQuery('.menu_type a').fancybox(
		{						
			"imageScale" : false, // ��������� �������� true - �������(�����������) �������������� �� ������� ����, ��� false - ���� ������������ �� ������� ��������. �� ��������� - TRUE
			"zoomOpacity" : false,	// ��������� ������������ �������� �� ����� �������� (�� ��������� false)
			"zoomSpeedIn" : 1000,	// �������� �������� � �� ��� ���������� ���� (�� ��������� 0)
			"zoomSpeedOut" : 1000,	// �������� �������� � �� ��� ���������� ���� (�� ��������� 0)
			"zoomSpeedChange" : 1000, // �������� �������� � �� ��� ����� ���� (�� ��������� 0)
			"overlayShow" : true, // ���� true �������� �������� ��� ����������� �����. (�� ��������� true). ���� �������� � jquery.fancybox.css - div#fancy_overlay 
			"overlayOpacity" : 0.8,	 // ������������ ��������� 	(0.3 �� ���������)	
			"hideOnContentClick": false,
			"centerOnScroll": false
		});
	}*/
	
	jQuery('.menu ul > li > ul').css('left', function() {
		var leftCoord = jQuery(this).parent().css('padding-left');
		return leftCoord;
	});
	
	jQuery('.menu > ul > li:last').addClass('last');
	
	jQuery('.menu > ul > li:last > ul').css('right', function() {
		jQuery(this).css('left', 'auto');
		var rightCoord = jQuery(this).parent().css('padding-right');
		return rightCoord;
	});
	
	if (jQuery.browser.msie && jQuery.browser.version == 6) {
		jQuery('.menu > ul > li').hover( function() {
			jQuery(this).children('ul').show();
		}, function() {
			jQuery(this).children('ul').hide();
		});
	}
	
	theRotator();
	
	jQuery('.twitter_content ul li:odd').addClass('bg');
	
});

jQuery(window).load(function() {
	
	// if (jQuery('.containers').height() < jQuery(window).height()) {
	// 		var padTop = Math.floor((jQuery(window).height() - jQuery('.container').height())/2);
	// 		jQuery('.containers').css('padding-top', padTop)
	// 	}
	
	//jQuery('.container').css('height',jQuery(window).height() +'px');
	
	//--------------------------------------------------
	//Altered by Alex 08/04/2011
	//Get the width of the window in the resized state
	var win_width = jQuery(this).width();
	
	//If the width is less than 965 lets run this code.
	//I determined that this is the window size at which the content starts shifting
	if(win_width < 965)
	{
		
		//Get the new width for the site content margin 
		//This is roughly the ratio of the container divided by the static margin width defined in the css
		var new_main_page_width = win_width/3.05;
		var new_inner_page_width = win_width/3.05;
		jQuery('.container .site').css('margin-left', new_inner_page_width +'px');
		jQuery('.container.mainpage .site').css('margin-left', new_main_page_width +'px');
	}
	
	//If the width is greater than or equal to 965 let's set the static 
	//margin width back to it's original values.
	if(win_width >= 965)
	{
		jQuery('.container .site').css('margin-left', '330px');
		jQuery('.container.mainpage .site').css('margin-left', '330px');
	}
	//--------------------------------------------------
	
});

jQuery(window).resize(function() {

	// if (jQuery('.containers').height() < jQuery(window).height()) {
	// 		var padTop = Math.floor((jQuery(window).height() - jQuery('.container').height())/2);
	// 		jQuery('.containers').css('padding-top', padTop);
	// 	}
	
	
	
	jQuery('#gallery').css('position','relative');
	jQuery('#gallery').css('z-index','101');
	
	//--------------------------------------------------
	//Altered by Alex 08/04/2011
	//Get the width of the window in the resized state
	var win_width = jQuery(this).width();

	//If the width is less than 965 lets run this code.
	//I determined that this is the window size at which the content starts shifting
	if(win_width < 965)
	{
		//Get the new width for the site content margin 
		//This is roughly the ratio of the container divided by the static margin width defined in the css
		var new_main_page_width = win_width/3.05;
		var new_inner_page_width = win_width/3.05;
		jQuery('.container .site').css('margin-left', new_inner_page_width +'px');
		jQuery('.container.mainpage .site').css('margin-left', new_main_page_width +'px');
	}
	
	//If the width is greater than or equal to 965 let's set the static 
	//margin width back to it's original values.
	if(win_width >= 965)
	{
		jQuery('.container .site').css('margin-left', '330px');
		jQuery('.container.mainpage .site').css('margin-left', '330px');
	}
	//--------------------------------------------------
	
});


jQuery.extend({
	random: function(X) {
		var current_number = Math.floor(X * (Math.random() % 1));
	    return current_number;
	},
	randomBetween: function(MinV, MaxV) {
		var current_number_3 = MinV + jQuery.random(MaxV - MinV + 1);
	  	return current_number_3;
	}
});
