function get_alert() {
	var randomNR = Math.floor(Math.random()*999999999);

	$.getJSON("/wp-content/themes/nlkiest/includes/alert.php?" + randomNR, function(e) {
		if (e.highlight.title) {
			populate_alert(e);
		} else { 
			$("#alert").remove(); 
		}
	});
};

function populate_alert(e) {
	if ( $('#alert').length !== 0 ) { 
		$("#alert").remove(); 
	}

	$("#content").prepend('<div id="alert"><span>Breaking news &raquo;</span><a href="' + e.highlight.url + '">' + e.highlight.title + '</div>');
};

$(document).ready(function() {
	$('.click:has(a)').clickElement();
	$(".news-list").find("li:has(a)").clickElement();
	$('.slider').slider();
	$('.interactive-tabs').interactiveTabs();
	$('.carousel').carousel();
	$('ul.tabs').tabs();
	$('#article .enlarge, .lightbox').lightBox();
	// $('.home #content, .archive #content, .interactive-rows').equalHeights();
	$('.archive #content, .interactive-rows').equalHeights();

	$('.blockquote').each(function() {
		$(this).append('<div class="clear"></div><div class="endquote"></div>');
	});

	/* $('.snippet').each(function() {
		$(this).prepend('<span class="corner tl"></span><span class="corner tr"></span><span class="corner bl"></span><span class="corner br"></span>');
	}); */

	var search_value = $("#header-search #searchform .invoer").attr("value");

	$('#header-search #searchform .invoer').bind("focus", function(e) {
		var init_value = $(this).attr("value");
		if (init_value == search_value) {
			$(this).attr("value",'');
		}
	}).bind("blur", function(e) {
		var init_value = $(this).attr("value");
		if (init_value == '') {
			$(this).attr("value",search_value);
		}
	});

	$('.tooltip').tooltip({
		track: true,
		delay: 0,
		showURL: false,
		showBody: " - ",
		extraClass: "pretty",
		fixPNG: true,
		opacity: 0.95,
		left: -120
	});

	$('.commentlist li').hover(function() {
		$(this).find('.rating').show();
	}).mouseleave(function() {
		$(this).find('.rating').hide();
	});

	get_alert();
	setInterval(get_alert, 60*1000);

	$(document).pngfix();
});
