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

$(document).ready(function () {
	$('#DivAlertBoxAchtergrond').css({ backgroundColor: '#000', opacity: '0.6' });
	
	
});

function ToonMelding(Pagina){
	$('#DivAlertBoxAchtergrond').css({ height : $(document).height(), width : $(document).width() });
	$('#DivAlertBoxAchtergrond').fadeIn(200);
	
	var NieuweBreedteDiv = 800;
	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 LaadMeldingInDiv(option) {
	var urls = option;
	$.get(option, function(data){
		document.getElementById('DivAlertBoxContent').innerHTML = data;
		Cufon.replace('h4', { fontFamily: 'HelvetivaLight' });
		$('#DivAlertBoxAchtergrond').fadeIn(200);
		$('#DivAlertBoxContent').fadeIn(300,function(){
		});	
	});
}

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

function FontReplace(){
	Cufon.replace('#OrangeColumn', { fontFamily: 'HelvetivaLight' });
	Cufon.replace('h2', { fontFamily: 'HelvetivaLight' });
	Cufon.replace('h3', { fontFamily: 'HelvetivaLight' });
	Cufon.replace('.broodintro', { fontFamily: 'HelvetivaLight' });
	Cufon.replace('.BroodIntro', { fontFamily: 'HelvetivaLight' });
}

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();
}

/* EIND HOOFDMENU OP HOME */

function LaadAgenda(URL){
	$.post(URL, function(data){
		document.getElementById('AgendaContainer').innerHTML = data;
	});
}

function AgendaOver(URL, ID){
	$.post(URL, function(data){
		//grab all the anchor tag with rel set to shareit
		document.getElementById('shareit-box').innerHTML = data;
			
			//get the height, top and calculate the left value for the sharebox
			var height = $('#'+ID).height();
			var top = ($('#'+ID).offset().top + 15);
			
			//get the left and find the center value
			var left = $('#'+ID).offset().left + ($('#'+ID).width() /2) - ($('#shareit-box').width() / 2);		
			$('#shareit-box').css({'top':top, 'left':left});
			$('#shareit-box').show();
	
		//onmouse out hide the shareit box
		$('#shareit-box').mouseleave(function () {
			$(this).hide();
		});
	});
}

function Toevoegen(ProductID){
	$.post('shop_actions.php', { 'Actie': 'Toevoegen', 'ProductID': ProductID }, function(data){
		window.location.href = data;
	});
}

function WWWijzigAantal(ArtID, Kleur, Aantal, Betalen){
	$.post('shop_actions.php', { 'Actie': 'Wijzigen', 'ArtID': ArtID, 'Kleur': Kleur, 'Aantal': Aantal, 'Betalen': Betalen }, function(data){
		if(data == ''){
			$('#WWRij'+ArtID).slideUp(300);
		} else {
			document.getElementById('WWRij'+ArtID).innerHTML = data;
		}
		WWToonTotalen();
	});
}

function WWToonTotalen(){
	$.post('shop_actions.php', { 'Actie':'showTotalen' }, function(data){
		document.getElementById('WWRijTotaal').innerHTML = data;
	});
}

function WWGegevens(){
	document.getElementById('formGegevens').submit();
}

function BestellingVoltooien(){
	if(document.getElementById('Voorwaarden').checked == true){
		$.post('shop_actions.php', { 'Actie':'Bestellen' }, function(data){
			document.getElementById('divHidden').innerHTML = data;
			document.getElementById('formiDeal').submit();
		});
	} else {
		ToonMelding("alert.php?Kop=Algemene voorwaarden");
	}
}
