// Script to expand the estate post-text
$(document).ready(function(){
 $('.readMore').show();	
 var rowsshown = 11;
 var rowheight = 1.2; // line height in 'em'
 var ht = (rowsshown * rowheight) - .5; // subtracting the .5 prevents the top of the next line from showing
 $('div.info')
  .css({'overflow':'hidden','line-height' : rowheight + 'em','height': ht + 'em' })
  $('.readMore').click(function(){
   if ( $('div.info').css('height') == 'auto') {
    $('div.info').css('height', ht + 'em');
   } else {
	$('.readMore').hide();	
    $('div.info').css('height','auto');
   }
  });
})



// Script to expand the A-Z navigation
function hideall (){
	$('.hideable, .hidden').css('display', 'none');
	$('.AlphaButton').removeClass('AlphaButtonActive');
}

function show(letter){
	hideall();
	$('#top-'+letter).css('display', 'block');
	$('#'+letter).css('display', 'block');
	$('#more-'+letter).addClass('AlphaButtonActive');
	$('#moreTop-'+letter).addClass('AlphaButtonActive');
}

$(document).ready(function(){
	hideall();
	
	//toggle moreText box in resultList
	$('.detailsToggleBtn').click(function(){
		//search element with class .hideable from current element
		moreText = $(this).parent().parent().parent().children().filter('.hideable');
		//remember element is hidden
		isHidden = moreText.is(':hidden');
		hideall();
		//toggles moreText depending on isHidden
		isHidden 
			? moreText.show()
			: moreText.hide();
		return false;
	});
})

$(document).ready(function(){
	//show more-link only if the text is more than 490 characters
	
	if($('.first p').length != 0){
		if($('.first p').html().length > 490){
			$('.first p').parent().parent().find('.moreLink').show();
		}
	}
	if($('.second p').length != 0){
		if($('.second p').html().length > 490){
			$('.second p').parent().parent().find('.moreLink').show();
		}
	}
	if($('.third p').length != 0){
		if($('.third p').html().length > 490){
			$('.third p').parent().parent().find('.moreLink').show();
		}
	}
	//show only the object-tab ontent
	$('.tab_content:lt(3)').hide();
	var rowsshownSeo = 7;
	var rowheightSeo = 1.3; // line height in 'em'
	var ht = (rowsshownSeo * rowheightSeo) - .5; // subtracting the .5 prevents the top of the next line from showing
	//hide overflow text
	$('.objectPostText').css({'overflow':'hidden','line-height' : rowheightSeo + 'em','height': ht + 'em' });

	//show and hide text
	$('.arrow').click(function(){
		post = $(this).parent().parent().children();	  
	   	if ( post.filter(':first').css('height') == 'auto') {
	   		post.filter(':last').css({'margin-top':'10px'})
			post.filter(':last').children().filter(':first').html('mehr');
			post.filter(':first').css('height', ht + 'em');
		} else {
			post.filter(':last').css({'margin-top':'0px'})
			post.filter(':last').children().filter(':first').html('weniger');	
			post.filter(':first').css('height','auto');
	   }
	});
	
	//show and hide tab content
	$('.tabNavi a').click(function(){
		liTab = $(this).parent().filter('li');
		if(!liTab.hasClass('active')){
			$('.tab_content').hide();
			liTab.parent().find('li.active').removeClass('active');
			liTab.addClass('active');
			$(liTab.children('a').attr('name')).show().siblings('.tab_content').hide();
			return false;
		}		
	});
});