/**
 *
 * Website      :  Businessclub de Betuwe
 * Programmeur  :  Sem Evers
 * Bedrijf      :  Media Solutions
 * Datum        :  14-04-2010
 *
 **/
 
(function($){
	$.fn.extend({
		doWork: function(photos, time){
			this.each(function(){
				if($(this).attr("class") == "head-photo"){
					$(this).attr("class","head-photo head-active");
					$(this).animate({
						height: '+=128px',
						width: '+=183px',
						right: '-=47px',
						top: '-=32px',
						opacity: '1'
					}, 1500, function(){
						$(this).oneTime(time, function(){ $(this).doWork(photos, time) });
					});
					
					$(this).oneTime(3000, function(){
						$(this).animate({
							height: '-=128px',
							width: '-=183px',
							right: '+=47px',
							top: '+=32px',
							opacity: '.6'
						}, 1500, function(){
							$(this).attr("class","head-photo");
						});
					});
				}
			});	
		}			
	});
	
	$(document).ready(function(){
		initOverLabels();
		
		var photos = $('.head-photo').size();
		var time = 3000;
		var sTime = 100;
		
		for(i=1;i<=photos;i++){			
			var cur_right = $('#head-photo_' + i).css('right');
			var right = (parseInt(cur_right) - 2000) + 'px';
			$('#head-photo_' + i).css('height','134px').css('width','191px');
			$('#head-photo_' + i).attr("class","head-photo head-active");
			
			$('#head-photo_' + i).oneTime(sTime, function(){
				
									 $(this).animate({
										height: '-=128px',
										width: '-=183px',
										opacity: '.6'
									 }, 1000, function(){
									 	$(this).css('opacity','.6');
										$(this).attr("class","head-photo");
									 });
			});
			sTime = parseInt(sTime) + 250;
		}
		
		for(i=1;i<=photos;i++){
			$('#head-photo_' + i).oneTime(time, function(){
				$(this).doWork(photos, time);
			});
			time = parseInt(time) + 3000;
		}
	});
})(jQuery);