/**
 * @author Tom
 */

var mWidth = 900;
var mHeight = 450;

 $(document).ready(function(){
 	
	randomize();
	addMouseOver();
	addMouseOut();
	
	$('#prevcat').mouseenter(function(){
		$('#prev').slideDown();
    });
	
	$('#prevcat').mouseleave(function(){
		$('#prev').slideUp();
    });
	
	
 });
 
 function randomize(){
 		
	$("#rand_container img").each(function(){
		
		randX = Math.floor(Math.random()*mWidth);
		randY = Math.floor(Math.random()*mHeight);
				
		$(this).animate({
			left: randX+"px",
			top: randY+"px"
		}, {
			duration: 1000
		});
		
		$(this).draggable({ containment: 'parent' });
		$(this).colorbox({
							href: $(this).attr('id'),
							title: $(this).attr('alt')
						});
		
	});
		
 }
 
 function addMouseOut(){
 	
	$("#rand_container img").each(function(){
		
		$(this).mouseleave(function(){
			$(this).css('filter','alpha(opacity=70)');
			$(this).css('-moz-opacity','0.7');
			$(this).css('-khtml-opacity','0.7');
			$(this).css('opacity','0.7');
		});
		
	});
	
 }
 
 function addMouseOver(){
 	
	$("#rand_container img").each(function(){
		
		$(this).hover(function(){
			$(this).css('filter','alpha(opacity=1)');
			$(this).css('-moz-opacity','1');
			$(this).css('-khtml-opacity','1');
			$(this).css('opacity','1');
 	
			$("#rand_container img").each(function(){
				$(this).css('z-index','1');
			});
			
			$(this).css('z-index','10');
			
		});
		
	});
	
 }

