jQuery(document).ready(function()
{
	// Relocates Elements Exposed
	$jq(window).resize(function(){ RelocateExposed(); });
	
	// For The Images Slide Show
	$jq('#imagesSlideShow').cycle({ fx:'fade', random:1 });
	
	// Add Bookmarks Vars
	a2a_linkname="Seat For Two";
	a2a_linkurl="http://www.seatfortwo.com";
	
	// Change CSS positioned element
	RelocateExposed();
	
	// Detach Elements Exposed
	$jq('#frontPageSignIn').detach().appendTo('body');
	$jq('#flashTab').detach().appendTo('body');
	$jq('#slideTab1').detach().appendTo('body');
	$jq('#slideTab2').detach().appendTo('body');
	$jq('#slideTab3').detach().appendTo('body');
	
	// Attach The Expose Behavior To Elements
	var ExposeFlashTab = $jq('#flashTab').expose({ 
		color:'#CCC', api:true, lazy:true, zIndex:15,
		onLoad:function(){
			$jq('#flashTab').animate({'width':'725px'},300,
				function(){
					$jq('#flashTabCtn').css('overflow','visible');
				}).addClass('open');
			$jq('#flashTabBtn').animate({'left':'725px'},300);
		},
		onBeforeClose:function(){
			$jq('#flashTabCtn').css('overflow','hidden');
			$jq('#flashTab').animate({'width':'0'},300).removeClass('open');
			$jq('#flashTabBtn').animate({'left':'0'},300);
		}
	});
	
	var ExposeLogin = $jq('#frontPageSignIn').expose({ 
		maskId:'expMask', api:true, lazy:true, 
		onBeforeLoad:function(){
			$jq('#getIn').fadeIn('slow');
		},
		onLoad:function(){
			$jq("#username").focus();
		},
		onClose:function(){
			$jq('#getIn').fadeOut('slow');
		} 
	});
		
	// Expose Show/Hide Elements Handlers
	$jq('#flashTabBtn').click( function(){
		if($jq('#flashTab').hasClass('open'))
			ExposeFlashTab.close(); 
		else 
			ExposeFlashTab.load(); 
	});

	$jq('#MenuBtn1').click(function(){
		MLeft = ( $jq('#elementsWrapper').offset().left + $jq('#elementsWrapper').width() ) - 497;
		
		$jq('#slideTab1').css( {'width':'497px','margin-left':MLeft} );
		$jq('#slideTabBtn1').css('display','block');
		$jq('#slideTabContent1').animate( {'right':'0'}, 300 );
	});
	$jq('#MenuBtn2').click(function(){
		MLeft = ( $jq('#elementsWrapper').offset().left + $jq('#elementsWrapper').width() ) - 497;
		
		$jq('#slideTab2').css( {'width':'497px','margin-left':MLeft} );
		$jq('#slideTabBtn2').css('display','block');
		$jq('#slideTabContent2').animate( {'right':'0'}, 300 );
	});
	$jq('#MenuBtn3').click(function(){
		MLeft = ( $jq('#elementsWrapper').offset().left + $jq('#elementsWrapper').width() ) - 527;
		
		$jq('#slideTab3').css( {'width':'527px','margin-left':MLeft} );
		$jq('#slideTabBtn3').css('display','block');
		$jq('#slideTabContent3').animate( {'right':'0'}, 300 );
	});
	
	$jq('#slideTabBtn1').click(function(){
		MLeft = $jq('#elementsWrapper').offset().left + $jq('#elementsWrapper').width();
		
		$jq('#slideTabContent1').animate( {'right':'-470px'}, 300, function(){
			$jq('#slideTab1').css( {'width':'0px','margin-left':MLeft} );
			$jq('#slideTabBtn1').css('display','none');
			$jq('#forgotMsg').css('display','none');
		});
	});
	$jq('#slideTabBtn2').click(function(){
		MLeft = $jq('#elementsWrapper').offset().left + $jq('#elementsWrapper').width();
		
		$jq('#slideTabContent2').animate( {'right':'-470px'}, 300, function(){
			$jq('#slideTab2').css( {'width':'0px','margin-left':MLeft} );
			$jq('#slideTabBtn2').css('display','none');
		});
	});
	$jq('#slideTabBtn3').click(function(){
		MLeft = $jq('#elementsWrapper').offset().left + $jq('#elementsWrapper').width();
		
		$jq('#slideTabContent3').animate( {'right':'-500px'}, 300, function(){
			$jq('#slideTab3').css( {'width':'0px','margin-left':MLeft} );
			$jq('#slideTabBtn3').css('display','none');
		});
	});
	
	// Exposing The Form On Focus Or Click Inputs
	$jq('#username,#password').bind('click focus', function(){
		ExposeLogin.load();
	});

	// Change Elements Exposed Position
	function RelocateExposed(){
		ReferencePointR = parseInt( $jq('#elementsWrapper').offset().left );
		ReferencePointL = ReferencePointR + $jq('#elementsWrapper').width();

		$jq('#frontPageSignIn').css('left',590+ReferencePointR);
		$jq('#flashTab').css('left',ReferencePointR);
		$jq('#slideTab1').css('margin-left',ReferencePointL);
		$jq('#slideTab2').css('margin-left',ReferencePointL);
		$jq('#slideTab3').css('margin-left',ReferencePointL);
	};
	
	// At Hit Enter...
	$jq('#username,#password').keypress(function(key){
		if(key.keyCode == 13){
			xajax_TryToLogin( xajax.getFormValues('signIn') );
			return false;
		}
	});
	
	// Xajax Forget
	$jq('#forgetMeLabel,.forgetMeCheckbox').click(function(){
		xajax_DeleteUserData();
		$jq('#username').val('');
		$jq('#password').val('');
		$jq('#getIn').fadeOut('slow');
		$jq('#forgetMeLabel').unbind();
		$jq('.forgetMeCheckbox').unbind();
	});
	
	// Xajax Try To Sign In
	$jq('#getIn').click(function(){
		xajax_TryToLogin( xajax.getFormValues('signIn') );
	});

	// For The Images Red/Grays Effects In The Tabs Menu
	$jq('#MenuBtn1').mouseover(function(){ $jq('#frontpageMenu').css('background-position','-31px 0'); });
	$jq('#MenuBtn2').mouseover(function(){ $jq('#frontpageMenu').css('background-position','0 0'    ); });
	$jq('#MenuBtn3').mouseover(function(){ $jq('#frontpageMenu').css('background-position','-62px 0'); });
		
	$jq('#MenuBtn1,#MenuBtn2,#MenuBtn3').mouseout(function(){
		$jq('#frontpageMenu').css('background-position','-93px 0');
	});
	
	$jq('#flash_require').jqm({overlay:80, modal:true, trigger:false});		
	
	$jq('#ifrClose,#afrClose').click(function(){
		$jq('#flash_require').jqmHide();
	})

	// returns a JavaScript object
	var playerVersion = swfobject.getFlashPlayerVersion(); 
	if ( playerVersion.major < 8 ) 
		setTimeout("flash_require()", 6000);
});

function flash_require(){
  $jq('#flash_require').jqmShow();
}