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

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

	//Create class instance
	//container = the first argument in "new ArtistListSlideGroup" call in "window.addEvent("domready"..."
	initialize: function(container, options) {
		this.setOptions(options);
		this.container = $(container);
		var cookieName = "";
		var cValue = "";
		
		var curView = location.search;
		cookieName = "prevArtistListView";
		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 = "ArtistListMapSlide";
				document.cookie = cookieName+"="+0; 	//Set "hide" status in a cookie
				cookieName = "ArtistListSlide";
				document.cookie = cookieName+"="+0; 	//Set "hide" status in a cookie
				cookieName = "ArtistSearchSlide";
				document.cookie = cookieName+"="+0; 	//Set "hide" status in a cookie
			}
		}
		
		//********************************************************************************
		//ListMap Info
/*		var ListMapVertSlide = new Fx.Slide('ArtistListMapInfo', 
			{
		    mode: 'vertical',
		    //Due to inheritance, all the [Fx][] options are available.
		    duration: 'long',
		    transition: Fx.Transitions.Bounce.easeOut		
		    }
		);
*/		
		ListMapVertSlide = new Fx.Morph($('ArtistListMapInfo'), {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;
			
//			alert(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]
					});
//					$('ArtistListMapInfo').setStyle('display', 'none')
				}
			}
			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({
				    'margin-top':[-480],
				    'opacity': [0]
				});
			}
		}

		$('ArtistListMapView').addEvent('click', function(e){
			e.stop();
			cookieName = "SlideListMap";
			if(ListMapSlideStatus == 0){	//Make it visible
				ListMapVertSlide.start({
				    '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{	//Hide it
				ListMapVertSlide.start({
				    'margin-top':[-480],
				    'opacity': [0]
				});
				
				document.cookie = cookieName+"="+0; 	//Flag status in a cookie
			}				
		});

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

		$('ArtistListMapView').addEvent('mouseenter', function(e){
			e.stop();
			$('ArtistListMapView').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;
//				$('ArtistListMapInfo').setStyle('display', 'block')
			}
			else{
				ListMapSlideStatus = 0;
			}
		});

		
		//********************************************************************************
		//Artist List Info
		var ArtistListVertSlide = new Fx.Slide('ArtistListInfo', 
			{
		    mode: 'vertical',
		    //Due to inheritance, all the [Fx][] options are available.
		    duration: 500,	//'long',
		    transition: Fx.Transitions.Bounce.easeOut		
		    }
		);
		
		var ArtistListSlideStatus = 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 = "ArtistListSlide";
		if(typeof document.cookie != 'undefined'){
			cValue = (cValue=document.cookie.match(new RegExp("(^|;|\\s)"+cookieName+'=([^;]+);?'))) ? cValue[2] : "";
			ArtistListSlideStatus = cValue;
			
			if(ArtistListSlideStatus != ""){
				if(ArtistListSlideStatus == 1){			//Slide was visible before page was exited?
					ArtistListSlideStatus = 0;			//Trick the "onComplete" function into setting slide status
					ArtistListVertSlide.slideIn();	//Make it visible again
				}
				else{								//Slide was hidden before page was exited?
					ArtistListSlideStatus = 1;			//Trick the "onComplete" function into clearing slide status
					ArtistListVertSlide.slideOut();	//Hide it again
				}
			}
			else{	//First time through, so hide it
				ArtistListSlideStatus = 1;	//1 means it's visible, which it is on load, until it gets hidden (below)
				ArtistListVertSlide.slideOut();
			}
		}
		
		$('ArtistListView').addEvent('click', function(e){
			e.stop();
			cookieName = "ArtistListSlide";
			if(ArtistListSlideStatus == 0){
				ArtistListVertSlide.slideIn();
				document.cookie = cookieName+"="+1; 	//Flag status in a cookie
			}				
			else{
				ArtistListVertSlide.slideOut();
				document.cookie = cookieName+"="+0; 	//Flag status in a cookie
			}				
		});

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

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

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


		//********************************************************************************
		//Artist Search Info
/*		var ArtistSearchVertSlide = new Fx.Slide('ArtistSearchInfo', 
			{
		    mode: 'vertical',
		    //Due to inheritance, all the [Fx][] options are available.
		    duration: 500,	//'long',
		    transition: Fx.Transitions.Bounce.easeOut		
		    }
		);
		
		var ArtistSearchSlideStatus = 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 = "ArtistSearchSlide";
		if(typeof document.cookie != 'undefined'){
			cValue = (cValue=document.cookie.match(new RegExp("(^|;|\\s)"+cookieName+'=([^;]+);?'))) ? cValue[2] : "";
			ArtistSearchSlideStatus = cValue;
			
			if(ArtistSearchSlideStatus != ""){
				if(ArtistSearchSlideStatus == 1){			//Slide was visible before page was exited?
					ArtistSearchSlideStatus = 0;			//Trick the "onComplete" function into setting slide status
					ArtistSearchVertSlide.slideIn();	//Make it visible again
				}
				else{								//Slide was hidden before page was exited?
					ArtistSearchSlideStatus = 1;			//Trick the "onComplete" function into clearing slide status
					ArtistSearchVertSlide.slideOut();	//Hide it again
				}
			}
			else{	//First time through, so hide it
				ArtistSearchSlideStatus = 1;	//1 means it's visible, which it is on load, until it gets hidden (below)
				ArtistSearchVertSlide.slideOut();
			}
		}
		
		$('ArtistSearchView').addEvent('click', function(e){
			e.stop();
			cookieName = "ArtistSearchSlide";
			if(ArtistSearchSlideStatus == 0){
				ArtistSearchVertSlide.slideIn();
				document.cookie = cookieName+"="+1; 	//Flag status in a cookie
			}				
			else{
				ArtistSearchVertSlide.slideOut();
				document.cookie = cookieName+"="+0; 	//Flag status in a cookie
			}				
		});

		$('ArtistSearchView').addEvent('mouseleave', function(e){
			e.stop();
			$('ArtistSearchView').setStyle('color', 's');
		});

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

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

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