$(document).ready(function(){
	$(".QuickTrip").bind("mouseenter",function(){
		/*if ( TripFlyout.CloseTimeout ){
			clearTimeout ( Flyout.CloseTimeout ) ;
			TripFlyout.CloseTimeout = false ;
		}*/
	}).bind("mouseleave",function(eventObject){
		if ( $(this).context.parentNode.id != "QuickTrip" ) {
			clearInterval ( TripFlyout.WatchDog ) ;
			TripFlyout.WatchDog = 0 ;
			TripFlyout.AnimationSteps = 5 ;
			TripFlyout.TripFlyoutCount = 50 ;
			if ( TripFlyout.AnimationWatchDog == 0 ) {
				TripFlyout.AnimationWatchDog = setInterval('TripFlyout.Animate()', 50);
			}
			eventObject.stopPropagation();
		} 
	});
});
  
var TripFlyout = new Object ( );
	TripFlyout = {
	TripFlyoutCount : 50,
	WatchDog : 0,
	AnimationWatchDog : 0,
	AnimationSteps : 5,
	Obj : null,
	TripFlyout : function ( ) {
	},
	DoFlyout : function ( doflyout ) {
		this.Obj	= document.getElementById ( 'QuickTrip' ) ;
		if ( this.Obj ) {
			if ( doflyout ) {
				this.Obj.style.display = "block" ;
				this.Obj.style.zIndex = "1000" ;
				//if ( this.WatchDog == 0 ) {
					//this.TripFlyoutCount = 50 ;
					//this.WatchDog = setInterval('TripFlyout.Timeout()', 50);
				//}else{
				//	alert ( "WatchDog not 0" ) ;
				//}
			} else {
				this.Obj.style.display = "" ;
				this.Obj.style.zIndex = "-1" ;
			}
		} else {
			//alert ( "TripFlyout does not exist" ) ;
		}
	},

	Timeout : function  ( ){
		this.TripFlyoutCount -- ;
		if ( this.TripFlyoutCount <= 0 ){
			clearInterval ( this.WatchDog ) ;
			this.WatchDog = 0 ;
			this.AnimationSteps = 5 ;
			if ( this.AnimationWatchDog == 0 ) {
				this.AnimationWatchDog = setInterval('TripFlyout.Animate()', 50);
			} else {
				this.Obj.style.display = "" ;
			}
		}
	},

	Animate : function  ( ) {
		this.AnimationSteps -- ;
		if ( this.AnimationSteps <= 0 ) {
			clearInterval ( this.AnimationWatchDog ) ;
			this.AnimationWatchDog = 0 ;
			this.Obj.style.display = "" ;
			this.Obj.style.zIndex = "-1" ;
			this.Obj.style.opacity =  1 ;
			this.Obj.style.mozOpacity = 1 ;
		} else {
			this.Obj.style.opacity = this.AnimationSteps / 5 ;
			this.Obj.style.mozOpacity = this.AnimationSteps / 5 ;
		}
	},

	Reset : function ( ) {
		this.TripFlyoutCount = 50 ;
	}
	};

var Scroller = {
	obj:null,
	WatchDog:0,
	ScrollSpeed:1,
	ScrollMax:16,
	ScrollUp:function ScrollUp( ) {
		Scroller.obj = document.getElementById ( 'QuickTripContent' ) ;
		if ( Scroller.obj && Scroller.WatchDog == 0 ) {
			Scroller.WatchDog = setInterval ( "Scroller.DoScroll(1)",50) ;
		}
	},
	ScrollDown:function ( ) {
		Scroller.obj = document.getElementById ( 'QuickTripContent' ) ;
		if ( Scroller.obj && Scroller.WatchDog == 0 ) {
			Scroller.WatchDog = setInterval ( "Scroller.DoScroll(-1)",50) ;
		}
	},
	KillScroll:function ( ) {
		if ( Scroller.WatchDog ) {
			clearInterval ( Scroller.WatchDog ) ;
			Scroller.WatchDog = 0 ;
			Scroller.ScrollSpeed = 1 ;
			Scroller.obj = null ;
		}
	},
	DoScroll:function ( direction ){
		if ( !Scroller.obj ) {
			clearInterval ( Scroller.WatchDog ) ;
			Scroller.WatchDog = 0 ;
			Scroller.obj = null ;
			Scroller.ScrollSpeed = 1 ;
			//alert ( "Obj is null" ) ;
		}
		if ( direction > 0 ) {
			amount = + Scroller.ScrollSpeed ;
		}else if ( direction < 0 ) {
			amount = - Scroller.ScrollSpeed ;
		}
		if ( Scroller.ScrollSpeed < Scroller.ScrollMax ) {
			Scroller.ScrollSpeed = Scroller.ScrollSpeed * 2 ;
		} else {
			Scroller.ScrollSpeed = Scroller.ScrollMax ;
		}
		var maxtop = Scroller.obj.scrollHeight ;
		var top = Scroller.obj.scrollTop ;
		if ( top == '' ) {
			top = 0 ;
		}
		top += amount ;
		if ( ( parseInt ( top ) + parseInt ( Scroller.obj.clientHeight ) ) >= maxtop ) {
			Scroller.obj.scrollTop = maxtop - Scroller.obj.clientHeight ;
			clearInterval ( Scroller.WatchDog ) ;
			Scroller.WatchDog = 0 ;
			Scroller.obj = null ;
			Scroller.ScrollSpeed = 1 ;
		} else if ( parseInt ( top ) < 0 ) {
			Scroller.obj.scrollTop = 0;
			clearInterval ( Scroller.WatchDog ) ;
			Scroller.WatchDog = 0 ;
			Scroller.obj = null ;
			Scroller.ScrollSpeed = 1 ;
		}else{
			Scroller.obj.scrollTop = top ;
		}
	}	
}