$(document).ready(function() {
	//openInNewWindow();
	
	if($(".search")){
		// Get the current year
		var currentYear = new Date();
		var year = currentYear.getFullYear();
		// Hide newstitles from past years
		$(".search .meernieuws div h3").not(":contains("+year+")").nextAll("h2").hide();
		// Show newstitles from past years if clicked
		$(".search .meernieuws div h3").click(function(){
			$(this).nextAll("h2").toggle();
			$(".search .meernieuws div h3").not($(this)).nextAll("h2").hide();
		});
	}
	
	if($.browser.msie && ($.browser.version > 7)){
		$('#menu ul li, #menu ul ul li, #menu ul ul ul li').hover(function(){
			$(this).children('ul').css('display','block');
		}, function(){
			$(this).children('ul').css('display','none');
		});		
	}
});

function openInNewWindow() {
	$("a[rel='blank']").each(function() {
		$(this).attr({
			//target: "_blank",
			href: "javascript:window.open('" + $(this).attr("href") + "');void(0);", 
			title: "Link opent in een nieuw venster"
		});
	});
}


var popupel;
var popupwnd;
function OpenImgPopup(el) {
    popupel = el;
    popupwnd = window.open("/manager/modules/imagelibrary/imagepopup.aspx?ftb=" + el.id, 'ImagePopup', 'width=715,height=550,scrollbars=yes');
    popupwnd.focus();
}

function OpenDownloadPopup(el) {
    popupel = el;
    popupwnd = window.open("/manager/modules/downloadlibrary/downloadpopup.aspx?ftb=" + el.id, 'DownloadPopup', 'width=715,height=550,scrollbars=yes');
    popupwnd.focus();
}

function OpenDownloadPopupForDownloads(el) {
    popupel = el;
    popupwnd = window.open("/manager/modules/downloadlibrary/downloadpopup.aspx?ftb=" + el + "downloaditem", 'DownloadPopup', 'width=715,height=550,scrollbars=yes');
    popupwnd.focus();
}

function AddDownload(_filenaam, _linknaam, _elid) {

    var _id = _elid.replace('downloaditem', '');
    var _naam = document.getElementById(_id.replace('hlBestandKiezen', 'txtNaam'));
    var _file = document.getElementById(_id.replace('hlBestandKiezen', 'txtFile'));

    _naam.value = _linknaam;
    _file.value = _filenaam;
    popupwnd.close();
}

function ClosePopup(el, text2Binserted) {
    var textbox = document.getElementById(el);

    textbox.value = text2Binserted
    popupwnd.close();
}