$(function(){
    $('a.print').click(function(){
        window.print();
    });
    
    $(".iframe").colorbox({width:"660px", height:"90%", iframe:true});
    
    $(".show_visie").colorbox({width:"60%", height:"50%", inline:true, href:"#inline_visie"});
    $(".show_views").colorbox({width:"60%", height:"50%", inline:true, href:"#inline_views"});
    $(".show_books").colorbox({width:"60%", height:"50%", inline:true, href:"#inline_books"});
    
    $("#example_1").monthpicker({
	elements: [
		{tpl:"month"},
		{tpl:"year",opt:{

			range: "-0~1"
		}}

	],
	onChanged: callback
    });
    
    function callback(data,$e){
	var str = "";

	for(key in data) {
		str += " " + key + ": " + data[key]+ "; ";

	}
        $('.newslist').hide();
        $('#not_found').show();
        $('.'+data['month']+data['year']).each(function() {
            $(this).fadeIn();
            $('#not_found').hide();
        });
    }

    $('#vakgebied').change(function(){
 
        if ($(this).val() != 'All'){
                $('.publication_item.book').hide();
                $('.publication_item.book').filter('#'+$(this).val()).fadeIn();
        }else{
            $('.publication_item.book').show();
        }
            
    });

    $('.show').click(function(){
        $('#vakgebied').val($(this).attr("id"));
        $('#expertise').val('All');
        $('.publications_overview').hide();
        $('.publication_item').hide();
        $('.publication_item').filter('.'+$(this).attr("id")).show();
        $('.publications_overview').filter('.'+$(this).attr("id")).show();
    });
    $('a.mail.dutch').click(function(){
	
	var currentUrl = location.href;
	
	var email = "";
	var subject = "Ik attendeer je graag op deze webpagina : " + currentUrl;
	var body_message = "Beste,%0D%0D Graag wil ik je attenderen op de volgende website : "+currentUrl+" %0D%0D Met vriendelijke groet,%0D%0D  ";
	
	var mailto_link = 'mailto:'+email+'?subject='+subject+'&body='+body_message;
	
	win = window.open(mailto_link,'emailWindow');
	if (win && win.open &&!win.closed) win.close();

	
    });
    $('a.mail.english').click(function(){
	
	var currentUrl = location.href;
	
	var email = "";
	var subject = "I would like to draw your attention to this webpage : " + currentUrl;
	var body_message = "Dear ....,%0D%0D I would like to draw your attention to this website : "+currentUrl+" %0D%0D Kind regards,%0D%0D  ";
	
	var mailto_link = 'mailto:'+email+'?subject='+subject+'&body='+body_message;
	
	win = window.open(mailto_link,'emailWindow');
	if (win && win.open &&!win.closed) win.close();

	
    });
    
    $('.ncr,.nck,.igrac,.elgip').mouseover(function(){
        
        $(this).attr('src','/TXP/deltares-internet/images/'+$(this).attr('class')+'_over.png');
    });

    $('.ncr,.nck,.igrac,.elgip').mouseout(function(){
        
        $(this).attr('src','/TXP/deltares-internet/images/'+$(this).attr('class')+'.png');
    });
    
    $("#unit option[value='']").attr('selected','selected');
    
    $("#discipline option[value='']").attr('selected','selected');

    $("#aanmelden").click(function() {
            $("#p_type").attr('value','aanmelden');
            $("#abonneren").submit();
    });

    $("#afmelden").click(function() {
            $("#p_type").attr('value','afmelden');
            $("#abonneren").submit();
    });

    $("#abonneren").submit(function() {
            var onderwerp = '';
            $("input:checked").each(function(){
                    if ($(this).val() == "Informatie over workshops en symposia") {
                                      $(this).val("workshopsensymposia");
                                      $(this).attr("name","workshopsensymposia");  
                    }
               onderwerp = onderwerp + $(this).val() + ',';
            });
            $("#p_onderwerp").attr('value',onderwerp);
    });
    
    
    
});

function showInstructor(id){
  $('.instructor_list > ul > li').removeClass("active");
  $('.instructor').hide();
  $('#'+id).show();
  $('#'+id+'m').addClass("active");
}

function searchResultsHightlight(text)
{
    $("div.summary > p").highlight(text);
}
function pageHighlight(text)
{
    $("div.center_content > p").highlight(text);
}