/* Spotlight anim */
var fxBulletsq1;
var fxBullets = [];
var numEl  = 2;
var curEl  = 1;
var nextEl = 2;

function spotlightAnim() {

	/*
	$('#spotlightsContainer').innerfade({ 
		speed: 1500,
		timeout: 5000,
		type: 'sequence'
	}); 
	*/
	
	
	numEl = $('#spotlightsContainer').children('.spotlight-blok').length;

	if (numEl > 1)
		setTimeout(function() { startAnim(numEl, curEl); }, 5000);
	
}


function startAnim(elLength, curEl) {
	/* Determine next fade Element num */
	nextEl = curEl + 1;
	if (nextEl > elLength)
		nextEl = 1;

	/* Perform the animation */
	$('#spotlight-blok-'+curEl).fadeOut(1000);
	$('#spotlight-bullet-'+curEl).animate({backgroundColor: 'rgb(12,216,255)'},1000);
	$('#spotlight-blok-'+nextEl).fadeIn(2000);
	$('#spotlight-bullet-'+nextEl).animate({backgroundColor: 'rgb(255,255,255)'},2000);

	setTimeout(function() { startAnim(elLength, nextEl); }, 7000);
}

/* Show popup */
function showPopup(strTitle, strStamString, strSoortText) {
	$('#popupTitle').html(strTitle);
	$('#popupInnerContent').html("Informatie wordt opgehaald, een moment geduld a.u.b.");
	$('#popup').fadeIn('fast');
	
	$.post("/includes/AJAX/request-handler.asp", {
		strActie: 'get-popup-content',
		strStamgegeven: strStamString,
		strSoortText: strSoortText
	}, function(response){
		$('#popupInnerContent').html(response);
	});

	return false;
}


/* Show small popup */
function showSmallPopup(strTitle, strStamString, strSoortText) {
	$('#smallpopupTitle').html(strTitle);
	$('#smallpopupInnerContent').html("Informatie wordt opgehaald, een moment geduld a.u.b.");
	$('#smallpopup').fadeIn('fast');
	
	$.post("/includes/AJAX/request-handler.asp", {
		strActie: 'get-popup-content',
		strStamgegeven: strStamString,
		strSoortText: strSoortText
	}, function(response){
		$('#smallpopupInnerContent').html(response);
	});

	return false;
}

/* Suckerfish menu hover */
sfHover = function() {
	if(document.getElementById("TopNavMenu")) {
		var sfEls = document.getElementById("TopNavMenu").getElementsByTagName("LI");

		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}
if (window.attachEvent) { window.attachEvent("onload", sfHover); }


/* Controleren op valide postcode invoer */
function checkInput(elem, strFocus) {
	var strInput = elem.value.replace(' ','');
	if (isNaN(strInput))
		strInput = '';

	elem.value = strInput;

	if (strFocus != '') {
		$('#'+strFocus).focus();
	}
}
	
/********************** Tonen van reclameblokken **********************/

function submitPollForm(strVraag1, strVraag2) {
	if ($('#lngAntwoordID').val() == '') {
		alert('Selecteer een optie voor de vraag "'+strVraag1+'".');
		return false
	} 
	
	else if ($('#lngAntwoord2ID').val() == '') {
		alert('Selecteer een optie voor de vraag "'+strVraag2+'".');
		return false
	} 
	
	else {
	
		var lngID 			= $('input[name=lngPollID]').val();
		var lngOptieID 	= $('#lngAntwoordID').val();
		var lngOptie2ID = $('#lngAntwoord2ID').val();
				
		jQuery.post(
			'/includes/AJAX/request-handler.asp',
			{
				strActie		:	'poll_submit',
				lngID				:	lngID,
				lngOptieID	:	lngOptieID, 
				lngOptie2ID	:	lngOptie2ID
			},
			function(response){
				//doe niets met de response
			}
		);

		//$('#poll-popup').fadeOut('fast');
		
		jQuery.post(
			'/includes/AJAX/request-handler.asp',
			{
				strActie:'poll-toon-resultaten',
				lngID:lngID
			},
			function(response) {
				$('#poll-popup #popupInnerContent').html(response);
			}
		);
		
	}
	return false;
}
/********************** //Tonen van reclameblokken **********************/


function showToelichtingBetaalmethodetoeslag(strBetaalmethode){
	
	var strTekst = $('span#strBetaalmethodeToelichtingTekst_' + strBetaalmethode).html();
	$.cursorMessage(strTekst, {hideTimeout:2500});
}




/* functie om elementen uit een array te verwijderen, aangezien deze niet in javascript bestaat */
Array.prototype.remove = function(from, to) {
	var rest = this.slice((to || from) + 1 || this.length);
	this.length = from < 0 ? this.length + from : from;
	return this.push.apply(this, rest);
};

/* Functie om positie in Array te bepalen, IE7 heeft deze functie nog niet */
if (!Array.indexOf) {
	Array.prototype.indexOf = function (obj, start) {
		for (var i = (start || 0); i < this.length; i++) {
			if (this[i] == obj) {
				return i;
			}
		}
		return -1;
	}
}

$(document).ready(function(){
	if( navigator.userAgent.indexOf ("MSIE") !=-1 && $('#extLink').length > 0){
		var iframeHideTimeout;
		$('#TopNavMenu').bgiframe();

		$('#TopNavMenu *')
		.mouseover( function(){
			clearTimeout( iframeHideTimeout );
			iframeHideTimeout = setTimeout( "$('#extLink').hide()", 200 );
		})
		.mouseout( function(){
			clearTimeout( iframeHideTimeout );
			iframeHideTimeout = setTimeout( "$('#extLink').slideDown(250)", 200 );
		});
	}
});