jQuery(document).ready(function() {
		//Tag Cloud
		if (jQuery('ul.wp-tag-cloud').length > 0) {
			jQuery('ul.wp-tag-cloud').after('<div id="showAllTags" class="clear-both"><a href="#showAllTags">Alle anzeigen</a></div>');
			jQuery("div#showAllTags a").click(function () {
				jQuery('div#showAllTags a').replaceWith('<img src="/blog/wp-content/themes/newsaktuell/images/loading.gif" />');
				jQuery.get('/blog/wp-content/themes/newsaktuell/ajax_get_tags.php', function(data) {
					jQuery('ul.wp-tag-cloud').replaceWith(data);
					jQuery('div#showAllTags').hide();
				});
			});
		}

		jQuery('#s').val('Suchen');

		jQuery('#s').focus(function(e){
			 jQuery('#s').addClass("active");
			 // console.log('<esse');
		});
		jQuery('#s').blur(function(e){
			jQuery('#s').removeClass("active");
		});

		jQuery('#s').focus(function(){
			 if(jQuery(this).attr("value") == 'Suchen')
				 jQuery(this).attr("value", "");
		});


	// make the second column as high as the main content
	var highestCol = Math.max(jQuery('#content').height(),jQuery('.single').height(),jQuery('#sidebar').height());
	if (jQuery('.single').length > 0) {
		jQuery('.col2').height(highestCol+20);
		jQuery('.single').height(highestCol+65);
	} else {
		jQuery('.col2').height(highestCol+20);
		jQuery('#content').height(highestCol);
	}


	// add the individual links
	if (jQuery('#thelinklist').length > 0) {
		var test = jQuery('#thelinklist').html();
		test = trim(test);
		if (test == '')
		{
			jQuery('#replace').parents('div:eq(1)').html('');
			var highestCol = Math.max(jQuery('#wrapperspecial').height(),jQuery('.col1').height());
			jQuery('.col2').height(highestCol-45);
		} else {
			jQuery('#replace').html(test);
		}
	}

});

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

