var HuidigeFoto = '';
var HuidigeTab = '1';
var Overspringen = '';

$(document).ready(function () {
	$('#DivAlertBoxAchtergrond').css({ backgroundColor: '#000', opacity: '0.85' });
	
	$('#Navbar > li').bind('mouseover', jsddm_open);
  	$('#Navbar > li').bind('mouseout',  jsddm_timer);
  	
});

function ToonMelding(Pagina){
	$('#DivAlertBoxAchtergrond').css({ height : $(document).height(), width : $(document).width() });
	$('#DivAlertBoxAchtergrond').fadeIn(200);
	
	var NieuweBreedteDiv = 600;
	var NieuweHoogteDiv = 200;
	
	var TopPos = ($(window).scrollTop() + 60);
	
	TopPositie = TopPos+'px';
	document.getElementById('DivAlertBoxContent').style.top = TopPositie;
	
	var LinkerPositie = (($(document).width() - NieuweBreedteDiv)/2);
	LinkerPositie = LinkerPositie+'px';
	document.getElementById('DivAlertBoxContent').style.left = LinkerPositie;
	
	LaadMeldingInDiv(Pagina, 'DivAlertBoxContent');
}

function ToonOpening(Pagina){
	$('#DivAlertBoxAchtergrond').css({ height : $(document).height(), width : $(document).width() });
	$('#DivAlertBoxAchtergrond').fadeIn(200);
	
	var NieuweBreedteDiv = 870;
	var NieuweHoogteDiv = 200;
	
	var TopPos = ($(window).scrollTop() + 65);
	
	TopPositie = TopPos+'px';
	document.getElementById('DivAlertBoxContent').style.top = TopPositie;
	
	var LinkerPositie = (($(document).width() - NieuweBreedteDiv)/2);
	LinkerPositie = LinkerPositie+'px';
	document.getElementById('DivAlertBoxContent').style.left = LinkerPositie;
	
	LaadMeldingInDiv(Pagina, 'DivAlertBoxContent');
}

function LaadMeldingInDiv(option) {
	var urls = option;
	$.get(option, function(data){
		document.getElementById('DivAlertBoxContent').innerHTML = data;
		Cufon.replace('.Header', { fontFamily: 'Gotham' });
		Cufon.replace('.HeaderBig', { fontFamily: 'Gotham', textShadow: '#333 1px 1px' });
		Cufon.replace('.BroodEightteen', { fontFamily: 'Gotham', textShadow: '#333 1px 1px' });
		
		$('#DivAlertBoxAchtergrond').fadeIn(150);
		$('#DivAlertBoxContent').fadeIn(200,function(){
		});	
	});
}

function MeldingSluiten(Pagina){
	$('#DivAlertBoxContent').fadeOut(150);
	$('#DivAlertBoxAchtergrond').fadeOut(150);
}

function FontReplace(){
	Cufon.replace('.Header', { fontFamily: 'Gotham' });
}

function formulierVersturen(FormulierID){
	document.getElementById('form'+FormulierID).submit();
}

function BerekenSubMenuHoogte(){
	var Hoogte = $('#SubMenu li.Active').height();
	$('#smbr').css({ 'height':(Hoogte - 2) });
}

/* HOOFDBEELDEN OP HOME */

function StartInterval(){
	Overspringen = setInterval("AutoSpring()", 5000);
}
function StopInterval(){
	clearInterval(Overspringen);
}

function AutoSpring(){
	if(HuidigeTab == '1'){
		var NaarID = '2';
	} else if(HuidigeTab == '2'){
		var NaarID = '3';
	} else if(HuidigeTab == '3'){
		var NaarID = '4';
	} else if(HuidigeTab == '4'){
		var NaarID = '1';
	}
	VerspringTab(NaarID);
}
function VerspringTab(NaarID){
	if(NaarID != HuidigeTab){
		$('#MainImage'+NaarID).fadeIn(250);
		$('#MainImage'+HuidigeTab).fadeOut(250, function(){});
		$('#News'+HuidigeTab).removeClass('Active');
		$('#News'+NaarID).addClass('Active');
		HuidigeTab = NaarID;
	}
}

function TabRollOver(NaarID){
	VerspringTab(NaarID);
	StopInterval();
}

function TabRollOut(){
	StartInterval();
}

function SelectWedstrijden(ID, Team){
	$.post('programma.php', { 'AID': ID, 'Team':Team } , function(data){
		document.getElementById('VervolgBreed').innerHTML = data;
		Cufon.replace('.Header', { fontFamily: 'Gotham' });
	});
}

/* EIND HOOFDMENU OP HOME */

var timeoutjsddm = 500;
var closetimer = 0;
var ddmenuitem = 0;
var HuidigUitklapmenu = '';

function jsddm_open(){  	
	jsddm_canceltimer();
   	if(HuidigUitklapmenu == $(this).attr('id')){
   		ddmenuitem = $(this).find('ul').slideDown(150);
		HuidigUitklapmenu = $(this).attr('id');
   	} else {
   		jsddm_close();
		ddmenuitem = $(this).find('ul').fadeIn(150);
		HuidigUitklapmenu = $(this).attr('id');
	}
}

function jsddm_close(){  
	if(ddmenuitem) ddmenuitem.fadeOut(100);
	if(HuidigUitklapmenu != ''){
	}
	HuidigUitklapmenu = '';
	closetimer = null;
}

function jsddm_timer(){  
	closetimer = setTimeout(jsddm_close, timeoutjsddm);
}

function jsddm_canceltimer(){  
	if(closetimer){  
		clearTimeout(closetimer);
      	closetimer = null;
    }
}
