// JavaScript Document
window.addEvent('domready', function() {
//alert('test');
var currentDept = '';
	$$('.expander').addEvent('click',function(e){
		e.stop();
		var target = $(e.target);
		var container = target.getParent('.expandable-container');
	
		container.getElements('.expandable').each(function(expandable){
			var myFx = new Fx.Slide(expandable);
			myFx.toggle();
		});
		/*
		if (target.title == 'Click to show Collection Description')
			target.title = "Click to hide description";
		else
			target.title = "Click to show Collection Description";
		*/
		if (target.innerHTML == 'View Description')
			target.innerHTML = "Close Description";
		else
			target.innerHTML = "View Description";
	});

	$$('.expandable').each(function(expandable){
		if (expandable.style.display == 'none')
			expandable.style.display='';									
		var fx = new Fx.Slide(expandable);
		fx.hide();
		expandable.toggleClass('hidden');
	});

//alert('test2');

	$$('.dept').addEvent('click',function(e){
		e.stop();
		var target = $(e.target);
		var selDept = "."+target.id;
		//alert(selDept);
		//alert('blah');
		//$$('.finearts').style.backgroundColor="blue";
		if (currentDept != ''){
			$$(currentDept+'LUNA').each(function(department){
				department.style.backgroundColor="#fff";
			});
		}
		$$(selDept+'LUNA').each(function(department){
			department.style.backgroundColor="#b7d8fb";
		});

		if (currentDept != ''){
			$$(currentDept+'Weblink').each(function(department){
				department.style.backgroundColor="#fff";
			});
		}
		$$(selDept+'Weblink').each(function(department){
			department.style.backgroundColor="#b7d8fb";
		});

		var allDepts = new Array();
		allDepts[0] = '.all';
		allDepts[1] = '.fashion';
		allDepts[2] = '.mpt';
		allDepts[3] = '.photography';

		var i;
		for(i=0; i<= 3; i++){
			//alert('selDept='+selDept);
			//alert('check='+allDepts[i]);
			if (selDept != allDepts[i]){
				$$(allDepts[i]).each(function(dept){
					if(!dept.hasClass(target.id)){
						//dept.style.display="none";
						dept.style.backgroundColor="#ffffff";
						//alert('hide '+dept.id);
					}
				});
			}
			else{
				$$(allDepts[i]).each(function(dept){
					//alert(mpt.id);
					//dept.style.display="";
					dept.style.backgroundColor="#b7d8fb";
					//alert('show '+dept.id);
				});
			}
		}
		
		/*
		if (selDept != '.mpt'){
			$$('.mpt').each(function(mpt){
				mpt.style.display="none";
			});
		}
		else{
			$$('.mpt').each(function(mpt){
				//alert(mpt.id);
				mpt.style.display="";
			});
		}
		*/
		currentDept=selDept;
	});

	var imgList1=['url(/images/digimageStatue.jpg)','url(/images/digimageSketch.jpg)','url(/images/digimagePhoto.jpg)','url(/images/digimageFashion.jpg)'];
	var creditList1=['Rodin, Auguste. &quot;The Thinker.&quot; c. 1880.','Picasso, Pablo. &quot;T&ecirc;te de femme (Head of a woman), from La suite des saltimbanques (The acrobats set).&quot; 1905.', 'Felice  Nicholas. &quot;Minneapolis Bus.&quot; 1974.','Unknown American designer. &quot;The Souper Dress.&quot; ca. 1966.'];
	var imgCount1 = 4;
	
	var i = 0;
//alert('test3');
	var slideShowFunc = function(){
		//alert(this.imgList[1]);
		//alert(this.imgCount);
		//alert(this.counter);
		//this.counter++;
		var effect = new Fx.Morph(this.element,{duration: 'long', transition: Fx.Transitions.Sine.easeOut});
		
		if (this.counter < (this.imgCount - 1)){
			effect.start({'opacity':[0,1],
						  'background-image':[this.imgList[this.counter+1]]
						 });
			$('imgCredit').innerHTML = creditList1[this.counter+1]
		}
		else{
			effect.start({'opacity':[0,1],
						  'background-image':[this.imgList[0]]
						 });
			$('imgCredit').innerHTML = creditList1[0];

		}
		
		this.counter++;
		if (this.counter > (this.imgCount-1))this.counter=0;
		//alert('2'+this.counter);
	};
	
	var showSlideShow1 = { element: 'testImg',
						   infoDiv: 'imgCredit',
						   imgList : imgList1,
						   imgCount : imgCount1,
						   counter: i};
	
	slideShowFunc.periodical(7000,showSlideShow1);

	//alert('test');
});
