// JavaScript Document

var photogallery = {
	images: function(){
		new Asset.image('/images/ratingIcons/1.gif');
		new Asset.image('/images/ratingIcons/2.gif');
		new Asset.image('/images/ratingIcons/3.gif');
		new Asset.image('/images/ratingIcons/4.gif');
		new Asset.image('/images/ratingIcons/5.gif');
		new Asset.image('/images/ratingIcons/1grey.gif');
		new Asset.image('/images/ratingIcons/2grey.gif');
		new Asset.image('/images/ratingIcons/3grey.gif');
		new Asset.image('/images/ratingIcons/4grey.gif');
		new Asset.image('/images/ratingIcons/5grey.gif');
	}, //end images
	
	start: function(){
		photogallery.rating();
	}, //end start
	
	rating: function(){
		//action to highlight ratings less than the moused over one and dim the ratings greater than
		$$('.rating a').each(function(a){	
			a.addEvent('mouseenter', function(){
				aTitle = a.title;
				a.getParent().getChildren().each(function(el){
					if (el.title<=aTitle)
						el.getFirst().src = '/images/ratingIcons/'+el.title+'.gif';
					else
						el.getFirst().src = '/images/ratingIcons/'+el.title+'grey.gif';
				});
			});
		}); //end each
		
		//action to return all images to normal
		$$('.rating').each(function(el){	
			el.addEvent('mouseleave', function(){
				el.getChildren().each(function(a){
					a.getFirst().src = '/images/ratingIcons/'+a.getFirst().title+'.gif';
				});
			});
		}); //end each	
	} //end rating
	
}; //end photogallery

window.addEvent('domready', photogallery.start);
window.addEvent('load', photogallery.start);