$(document).ready(function(){
    $('.box').parent().attr('id', function (arr) {
		var setBoxID = 'box-id' + arr;
		return setBoxID;
	})
	
	$('.box div, ul.actions').hide();
	
	$('.short_info,.box').each(function() {
    	var getId = $(this).parent().attr('id');
    	//$('#'+getId+' .box div').fadeIn(1);
    	var getImage = $('.short_info img').parent().attr('id'); 
    	$('.short_info img').each(function(){
	    	imgWidth = $(this).width();
			imgHeight = $(this).height();
			imgWidthNew = '85';
			imgRatio = imgWidth / imgWidthNew;
			//alert(imgWidth +' ' + imgHeight +' ' +imgRatio);
			imgHeightNew = imgHeight / imgRatio;
			$(this).animate({
				width	: imgWidthNew + 'px',
				height	: imgHeightNew + 'px'
			},1);
		});	
	});
	
	$('a.read_more,a.read_less').click(function(){ 
		showMore(this);
	});
});

function showMore(getTheClick){
	var getClass = $(getTheClick).attr('class');
	var getId = $(getTheClick).parent().parent().attr('id');
	//alert(getId);
	
	if(getClass == 'read_more'){
		$('#'+getId+' .box p:first').slideUp(300)
		$('#'+getId+' .box div, #'+getId+' ul.actions').slideDown(300);
		var getClassNew = getClass.replace('_more','_less');  
        $('#'+getId+' a.'+getClass).each(function() {
        	//alert('#'+getId+' '+getTheClick);
        	$(this).text('Weniger Informationen');
        	$(this).removeClass();
        	$(this).addClass(getClassNew);
        });
        $('#'+getId+' .short_info img').each(function(){
			$(this).animate({
				width	: imgWidth + 'px',
				height	: imgHeight + 'px'
			},300);
		});	
	} else if(getClass == 'read_less') {
		$('#'+getId+' .box p:first').slideDown(300);
		$('#'+getId+' .box div, #'+getId+' ul.actions').slideUp(300);	
		var getClassNew = getClass.replace('_less','_more');
        $('#'+getId+' a.'+getClass).each(function() {
        	//alert('#'+getId+' '+getTheClick);
        	$(this).text('mehr...');
        	$(this).removeClass();
        	$(this).addClass(getClassNew);
        });
        $('#'+getId+' .short_info img').each(function(){
			$(this).animate({
				width	: imgWidthNew + 'px',
				height	: imgHeightNew + 'px'
			},300);
		});	

	}
}	
