//Ajax reageersysteem
$(function() {
$(".ajaxsubmit").click(function()
{
var naam = $("#naam").val();
var email = $("#email").val();
var bericht = $("#bericht").val();
var nieuwsid = $("#nieuwsid").val();
var dataString = {
'naam': naam,
'email': email,
'bericht': bericht,
'nieuwsid': nieuwsid
}

if(naam=='' || bericht=='')
{
$("#reactieformulier").hide();

$("div#succes").hide();
$("div#succes").fadeIn(600).html('<p style="color:#CC0000;">Je hebt niet alle gegevens ingevuld. Klik hier om het nogmaals te proberen.</p>');

$("div#succes").click(function(){$("div#succes").hide();$("#reactieformulier").fadeIn('slow');});

setTimeout(function(){$("div#succes").hide();$("#reactieformulier").fadeIn('slow');}, 2000);

}
else
{
$("#loader").show();
$("div#loader").fadeIn(400).html('<img src="/images/ajax-loading.gif" />Reactie toevoegen...');
$.ajax({
type: "POST",
url: "/modules/nieuws/reactietoevoegen.php",
data: dataString,
cache: false,
success: function(html){

$("#noggeenreacties").hide();
$("div#reacties").append(html);
$("div#reacties div#nieuwereactie:last").fadeIn(600);
$("#reactieformulier").fadeOut(800);

$("div#succes").hide();
$("#succes").append(html);
$("div#succes").fadeIn(600).html('Je reactie is toegevoegd.');
var huidigeaantal = parseInt($('#aantalreacties').html());
$("#aantalreacties").html(huidigeaantal+1);
}
});
}return false;
}); });

$(document).ready(function() {

	//Select all anchor tag with rel set to tooltip
	$('a[rel=tooltip]').mouseover(function(e) {
		
		//Grab the title attribute's value and assign it to a variable
		var tip = $(this).attr('title');	
		
		//Remove the title attribute's to avoid the native tooltip from the browser
		$(this).attr('title','');
		
		//Append the tooltip template and its value
		$(this).append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');		
				
		//Show the tooltip with faceIn effect
		$('#tooltip').fadeIn('500');
		$('#tooltip').fadeTo('10',0.9);
		
	}).mousemove(function(e) {
	
		//Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
		$('#tooltip').css('top', e.pageY + 10 );
		$('#tooltip').css('left', e.pageX + 20 );
		
	}).mouseout(function() {
	
		//Put back the title attribute's value
		$(this).attr('title',$('.tipBody').html());
	
		//Remove the appended tooltip template
		$(this).children('div#tooltip').remove();
		
	});

});



//checkcall
function checkAll(){
	for (var i=0;i<document.forms[0].elements.length;i++)
	{
		var e=document.forms[0].elements[i];
		if ((e.naam != 'allbox') && (e.type=='checkbox'))
		{
			e.checked=document.forms[0].allbox.checked;
		}
	}
}

//showhide
function ShowHide(id)
{
	if(document.getElementById(id).style.display == 'block')
	{
		document.getElementById(id).style.display = 'none';	
	}
	else
	{	
		document.getElementById(id).style.display = 'block';	
	}
}


//Colorbox
$(document).ready(function(){
    //Examples of how to assign the ColorBox event to elements
    $("a[rel='example1']").colorbox();
    $("a[rel='example2']").colorbox({transition:"fade"});
    $("a[rel='fotobox']").colorbox({transition:"none", width:"70%", height:"70%"});
    $("a[rel='example4']").colorbox({slideshow:true});
    $(".example5").colorbox();
    $(".example6").colorbox({iframe:true, innerWidth:425, innerHeight:344});
    $(".paginabox").colorbox({width:"90%", height:"90%", iframe:true,
							onOpen:function() { $("html").css("overflow", "hidden"); },
							onClosed:function() { $("html").css("overflow", "auto"); }
							 });
    $(".paginaboxrefresh").colorbox({
                             width:"85%", height:"85%", iframe:true, 
							 onOpen:function(){$('body').css({overflow:'hidden'})},
                             onClosed:function(){ location.reload(true); $('body').css({overflow:'auto'})}
                             });
    
    $(".example8").colorbox({width:"50%", inline:true, href:"#inline_example1"});
    $(".example9").colorbox({
        onOpen:function(){ alert('onOpen: colorbox is about to open'); },
        onLoad:function(){ alert('onLoad: colorbox has started to load the targeted content'); },
        onComplete:function(){ alert('onComplete: colorbox has displayed the loaded content'); },
        onCleanup:function(){ alert('onCleanup: colorbox has begun the close process'); },
        onClosed:function(){ alert('onClosed: colorbox has completely closed'); }
    });
    
    //Example of preserving a JavaScript event for inline calls.
    $("#click").click(function(){ 
        $('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
        return false;
    });
});

function addSmilie(code)
{
document.reageren.bericht.value+=code;
document.reageren.bericht.focus();
}

