window.addEvent('domready', function() {	
	new VenueListSlideGroup("VenueListSlideGroup");
});		//END: Window.AddEvent

var VenueListSlideGroup = new Class({
	options: {
	},

	//Create class instance
	//container = the first argument in "new VenueListSlideGroup" call in "window.addEvent("domready"..."
	initialize: function(container, options) {
		this.setOptions(options);
		this.container = $(container);
		var cookieName = "";
		var cValue = "";
		
		var curView = location.search;
		cookieName = "prevVenueListView";
		if(typeof document.cookie != 'undefined'){
			cValue = (cValue=document.cookie.match(new RegExp("(^|;|\\s)"+cookieName+'=([^;]+);?'))) ? cValue[2] : "";
			if(curView != cValue){
				//Save current URL param
				document.cookie = cookieName+"="+curView;
				//And, reset all of the slider cookies
				cookieName = "VenueListMapSlide";
				document.cookie = cookieName+"="+0; 	//Set "hide" status in a cookie
				cookieName = "VenueListSlide";
				document.cookie = cookieName+"="+0; 	//Set "hide" status in a cookie
				cookieName = "VenueSearchSlide";
				document.cookie = cookieName+"="+0; 	//Set "hide" status in a cookie
			}
		}
		
		//********************************************************************************
		//ListMap Info
/*		var ListMapVertSlide = new Fx.Slide('VenueListMapInfo', 
			{
		    mode: 'vertical',
		    //Due to inheritance, all the [Fx][] options are available.
		    duration: 'long',
		    transition: Fx.Transitions.Bounce.easeOut		
		    }
		);
*/		
		ListMapVertSlide = new Fx.Morph($('VenueListMapInfo'), {duration: 800, transition: Fx.Transitions.Bounce.easeInOut});

		var ListMapSlideStatus = 1;	//1 means it's visible, which it is on load, until it gets hidden (below)

		//Check if a cookie has been set with slide status
		cookieName = "SlideListMap";
		if(typeof document.cookie != 'undefined'){
			cValue = (cValue=document.cookie.match(new RegExp("(^|;|\\s)"+cookieName+'=([^;]+);?'))) ? cValue[2] : "";
			ListMapSlideStatus = cValue;
			
			if(ListMapSlideStatus != ""){
				if(ListMapSlideStatus == 1){	//Slide was visible before page was exited?
					ListMapSlideStatus = 0;		//Trick the "onComplete" function into setting slide status
					ListMapVertSlide.start({	//Make it visible again
					    'margin-top':[0],
					    'opacity': [1]
					});
				}
				else{								//Slide was hidden before page was exited?
					ListMapSlideStatus = 1;			//Trick the "onComplete" function into clearing slide status
					ListMapVertSlide.start({		//Hide it again
					    'margin-top':[-480],
					    'opacity': [0]
					});
				}
			}
			else{	//First time through, so hide it
				ListMapSlideStatus = 1;	//1 means it's visible, which it is on load, until it gets hidden (below)
				ListMapVertSlide.start({		//Hide it again
				    'margin-top':[-480],
				    'opacity': [0]
				});
			}
		}

		$('VenueListMapView').addEvent('click', function(e){
			e.stop();
			cookieName = "SlideListMap";
			if(ListMapSlideStatus == 0){
				ListMapVertSlide.start({	//Make it visible again
				    'margin-top':[0],
				    'opacity': [1]
				});

				document.cookie = cookieName+"="+1; 	//Flag status in a cookie

/*				(function(){	//Delay
					if($('location_map_canvas'))	//Content in the container, i.e. photos to display?
						$('location_map_canvas').setStyle('display', 'block');					
				}).delay(600, this);																	
*/			}				
			else{
				ListMapVertSlide.start({		//Hide it again
				    'margin-top':[-480],
				    'opacity': [0]
				});
				document.cookie = cookieName+"="+0; 	//Flag status in a cookie
			}				
		});

		
		$('VenueListMapView').addEvent('mouseleave', function(e){
			e.stop();
			$('VenueListMapView').setStyle('color', '#444444');
		});

		$('VenueListMapView').addEvent('mouseenter', function(e){
			e.stop();
			$('VenueListMapView').setStyle('color', 'black');
		});

		// When Vertical Slide ends its transition, we check for its status
		// note that complete will not affect 'hide' and 'show' methods
		ListMapVertSlide.addEvent('complete', function() {
			if(ListMapSlideStatus == 0)
				ListMapSlideStatus = 1;
			else
				ListMapSlideStatus = 0;
		});

		
		//********************************************************************************
		//Venue List Info
		var VenueListVertSlide = new Fx.Slide('VenueListInfo', 
			{
		    mode: 'vertical',
		    //Due to inheritance, all the [Fx][] options are available.
		    duration: 500,	//'long',
		    transition: Fx.Transitions.Bounce.easeOut		
		    }
		);
		
		var VenueListSlideStatus = 1;	//1 means it's visible, which it is on load, until it gets hidden (below)

		//Check if a cookie has been set with slide status
		cookieName = "VenueListSlide";
		if(typeof document.cookie != 'undefined'){
			cValue = (cValue=document.cookie.match(new RegExp("(^|;|\\s)"+cookieName+'=([^;]+);?'))) ? cValue[2] : "";
			VenueListSlideStatus = cValue;
			
			if(VenueListSlideStatus != ""){
				if(VenueListSlideStatus == 1){			//Slide was visible before page was exited?
					VenueListSlideStatus = 0;			//Trick the "onComplete" function into setting slide status
					VenueListVertSlide.slideIn();	//Make it visible again
				}
				else{								//Slide was hidden before page was exited?
					VenueListSlideStatus = 1;			//Trick the "onComplete" function into clearing slide status
					VenueListVertSlide.slideOut();	//Hide it again
				}
			}
			else{	//First time through, so hide it
				VenueListSlideStatus = 1;	//1 means it's visible, which it is on load, until it gets hidden (below)
				VenueListVertSlide.slideOut();
			}
		}
		
		$('VenueListView').addEvent('click', function(e){
			e.stop();
			cookieName = "VenueListSlide";
			if(VenueListSlideStatus == 0){
				VenueListVertSlide.slideIn();
				document.cookie = cookieName+"="+1; 	//Flag status in a cookie
			}				
			else{
				VenueListVertSlide.slideOut();
				document.cookie = cookieName+"="+0; 	//Flag status in a cookie
			}				
		});

		$('VenueListView').addEvent('mouseleave', function(e){
			e.stop();
			$('VenueListView').setStyle('color', '#444444');
		});

		$('VenueListView').addEvent('mouseenter', function(e){
			e.stop();
			$('VenueListView').setStyle('color', 'black');
		});

		// When Vertical Slide ends its transition, we check for its status
		// note that complete will not affect 'hide' and 'show' methods
		VenueListVertSlide.addEvent('complete', function() {
			if(VenueListSlideStatus == 0)
				VenueListSlideStatus = 1;
			else
				VenueListSlideStatus = 0;
		});


		//********************************************************************************
		//Venue Search Info
/*		var VenueSearchVertSlide = new Fx.Slide('VenueSearchInfo', 
			{
		    mode: 'vertical',
		    //Due to inheritance, all the [Fx][] options are available.
		    duration: 500,	//'long',
		    transition: Fx.Transitions.Bounce.easeOut		
		    }
		);
		
		var VenueSearchSlideStatus = 1;	//1 means it's visible, which it is on load, until it gets hidden (below)

		//Check if a cookie has been set with slide status
		cookieName = "VenueSearchSlide";
		if(typeof document.cookie != 'undefined'){
			cValue = (cValue=document.cookie.match(new RegExp("(^|;|\\s)"+cookieName+'=([^;]+);?'))) ? cValue[2] : "";
			VenueSearchSlideStatus = cValue;
			
			if(VenueSearchSlideStatus != ""){
				if(VenueSearchSlideStatus == 1){			//Slide was visible before page was exited?
					VenueSearchSlideStatus = 0;			//Trick the "onComplete" function into setting slide status
					VenueSearchVertSlide.slideIn();	//Make it visible again
				}
				else{								//Slide was hidden before page was exited?
					VenueSearchSlideStatus = 1;			//Trick the "onComplete" function into clearing slide status
					VenueSearchVertSlide.slideOut();	//Hide it again
				}
			}
			else{	//First time through, so hide it
				VenueSearchSlideStatus = 1;	//1 means it's visible, which it is on load, until it gets hidden (below)
				VenueSearchVertSlide.slideOut();
			}
		}
		
		$('VenueSearchView').addEvent('click', function(e){
			e.stop();
			cookieName = "VenueSearchSlide";
			if(VenueSearchSlideStatus == 0){
				VenueSearchVertSlide.slideIn();
				document.cookie = cookieName+"="+1; 	//Flag status in a cookie
			}				
			else{
				VenueSearchVertSlide.slideOut();
				document.cookie = cookieName+"="+0; 	//Flag status in a cookie
			}				
		});

		$('VenueSearchView').addEvent('mouseleave', function(e){
			e.stop();
			$('VenueSearchView').setStyle('color', '#444444');
		});

		$('VenueSearchView').addEvent('mouseenter', function(e){
			e.stop();
			$('VenueSearchView').setStyle('color', 'black');
		});

		// When Vertical Slide ends its transition, we check for its status
		// note that complete will not affect 'hide' and 'show' methods
		VenueSearchVertSlide.addEvent('complete', function() {
			if(VenueSearchSlideStatus == 0)
				VenueSearchSlideStatus = 1;
			else
				VenueSearchSlideStatus = 0;
		});
END comment out search stuff */		
	}	//END: initialize
});

VenueListSlideGroup.implement(new Events); // Implements addEvent(type, fn), fireEvent(type, [args], delay) and removeEvent(type, fn)
VenueListSlideGroup.implement(new Options);// Implements setOptions(defaults, options)

