
/* ------------------------------------------------------- */
/* ON LOAD ON LOAD ON LOAD ON LOAD ON LOAD ON LOAD ON LOAD */
/* ------------------------------------------------------- */

Shadowbox.init();

$(document).ready(function(){
		
	// SUBMENU
	var users = ["RdSportsupport", "SSVRotterdam", "m_vanberkel", "GwendaTromp", "sanne_scholten", "MarkLensselink", "DanielKlijn", "GJLammens", "MeinouSteemers"];
	var query = "#srs OR #huisstijl " + 'from:'+users.join(' OR from:');
	
	$("#tweet").tweet({
		count: 2,
		query: query,
		loading_text: "searching twitter..."
	}).bind("empty", function() { 
		$(this).append("No matching tweets found");
	});

	$("#twitter").tweet({
		count: 8,
		query: query,
		loading_text: "searching twitter..."
	}).bind("empty", function() { 
		$(this).append("No matching tweets found");
	});
	
	$('#formulier').validate();
	
	$('#frmSearch').validate({
		errorLabelContainer: $('#search .error')
	});
	errorContainer = $('#nieuwsbrief .error')[0] ?  $('#nieuwsbrief .error') :  $('#nieuwsbrief_2 .error');
	
	$('#frmNieuwsbrief').validate({
		errorLabelContainer: errorContainer
	});
	$('#sliderNieuwsbrief').easySlider();
	
	$('#sliderNieuwsbrief_2').easySlider({
		prevId:'vorigeNieuws',
		nextId:'volgendeNieuws',
		nextText: '',
		prevText: ''	
	});
	
	$(".uitgelichtSlider").easySlider({
		prevId: 'vorigeUitgelicht',
		nextId: 'volgendeUitgelicht',
		nextText: '',
		prevText: '',
		autoHeight: false
	});
	
	$('#tblNieuwsbrief').hide();
});

function showOptions() {
	$('#tblNieuwsbrief').show();
}

function clearText(frm) {
	frm.value = '';
}

function toggle(id)
{
	if (document.all)
	{
		if(document.all[id].style.display == 'none')
		{
			document.all[id].style.display = '';
		} 
		else 
		{
			document.all[id].style.display = 'none';
		}
		
		return false;
	} 
	else if (document.getElementById)
	{
		if(document.getElementById(id).style.display == 'none') 
		{
			document.getElementById(id).style.display = 'block';
		} 
		else 
		{
			document.getElementById(id).style.display = 'none';
		}
	
		return false;
	}
}

function toggle_close(id)
{
	if (document.all)
	{
		if(document.all[id].style.display == 'none')
		{
			document.all[id].style.display = 'none';
		} 
		else 
		{
			document.all[id].style.display = 'none';
		}
	
		return false;
	} 
	else if (document.getElementById)
	{
		if(document.getElementById(id).style.display == 'none') 
		{
			document.getElementById(id).style.display = 'none';
		} 
		else 
		{
			document.getElementById(id).style.display = 'none';
		}
		
		return false;
	}
}

function scCheck(value, id) {
	inputSelect = id.replace("ronde1", "ronde2");
	
	//console.log(value);
	
	if(value == "1" || value == "2") {
		document.getElementById(inputSelect).options[0].selected = true;
		document.getElementById(inputSelect).disabled = true;
		alert('U heeft gekozen voor een sessie die twee rondes duurt. Dit betekent dat u geen gebruik kunt maken van een nieuwe sessie in de tweede ronde.');
	} else {
		document.getElementById(inputSelect).disabled = false;
	}
}

function slideShow() {
	//Set the opacity of all images to 0
	$('#gallery div.slide').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#gallery div:first').css({opacity: 1.0});
	
	//Set the caption background to semi-transparent
	/*$('#gallery .caption').css({opacity: 0.7});*/

	//Resize the width of the caption according to the image width
	$('#gallery .caption').css({width: $('#gallery div').find('img').css('width')});
	
	//Get the caption of the first image from REL attribute and display it
	$('#gallery .content').html($('#gallery div:first').find('p').html());
	//.animate({opacity: 0.7}, 400);
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('gallery()',6000);
}

function gallery() {
	//if no IMGs have the show class, grab the first image
	var current = ($('#gallery div.show')?  $('#gallery div.show') : $('#gallery div:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery div:first') :current.next()) : $('#gallery div:first'));	
	
	//Get next image caption
	var caption = next.find('p').html();	
	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	//Set the opacity to 0 and height to 1px
	//$('#gallery .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });	
	$('#gallery .caption').animate({height: '1px'}, { queue:true, duration:300 });	
	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	//$('#gallery .caption').animate({opacity: 0.7},100 ).animate({height: '60px'},500 );
	$('#gallery .caption').animate({height: '60px'},500 );
	
	//Display the content
	$('#gallery .content').html(caption);
}

function MM_validateForm_NL() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm_NL.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' moet een e-mailadres bevatten.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' moet een nummer bevatten.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' moet een nummer bevatten tussen '+min+' en '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is verplicht.\n'; }
  } if (errors) alert('U bent iets vergeten:\n'+errors);
  document.MM_returnValue = (errors == '');
}
