var images = [];
var totimages = 0;
var processed_images = 0;
var lh = 0;

$(document).ready(function()
{	
	$('#naviHolder ul li ul').each(function(){
		$(this).hide();
	});
	// menu
	$('#naviHolder ul li').each(function(){
		$(this).hover(function(){
			
			$(this).css('background-color','#a4cacf').find('ul').show();
			
		},function(){
			
			$(this).css('background-color','').find('ul').hide();
		});
	});

	$('#logo_holder').cycle();
	var $slides = $('#logo_holder .slide');
	totimages = $slides.length;
	
	$slides.each(function(ix){
		var $img = $(this).find('img');
		
		var ih = $img.height();
		var id = 'img_'+ix;
		
		$img.attr('id',id);
		
		$("<img/>").attr("id",id).attr("src", $img.attr("src")).load(function() {
			images.push({'id':id,'w':this.width,'h':this.height});
			processed_images++;
    	});

	});
	check_images();
	
});

function check_images(){
	if(processed_images != totimages){
		setTimeout('check_images()',100);
	}else{
		v_align_images();
	}
}

function v_align_images(){
	lh = $('#logo_holder').height();
	for(var i in images){
		var $img = $('#'+images[i].id);
		var pad = Math.round((lh - images[i].h) / 2) 
		$img.parent().css({'padding':pad+'px 0 0 0'});
	}
}


