if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
	var ieversion=new Number(RegExp.$1); // capture x.x portion and store as a number
	if (ieversion<8) {
		alert("U heeft een verouderde browser. U wordt doorverwezen.");
		window.location="http://www.talence.nl/oude-browser.html";
	}
}

/* Rollover klanten logo
	$(document).ready(function(){
		$("ul.thumb li").hover(function() {
			$(this).css({'z-index' : '10', 'cursor' :  'normal'});
			$(this).find('img').addClass("hover").stop()
				.animate({
					marginTop: '0px', 
					marginLeft: '0px', 
					width: '150px', 
					height: '100px',
				}, 200);
			
			} , function() {
			$(this).css({'z-index' : '10', 'cursor' :  'normal'});
			$(this).find('img').removeClass("hover").stop()
				.animate({
					marginTop: '0', 
					marginLeft: '0',
					top: '0', 
					left: '0', 
					width: '150px', 
					height: '100px', 
				}, 400);
		});
	 
	});
*/

/* rollover header social media */

jQuery(
	function()
	{
		// set up rollover
		$("img.rollover").hover(
			function()
			{
				this.src = this.src.replace(".png","_hover.png");
			},
			function()
			{
				this.src = this.src.replace("_hover.png",".png");
			}
		);
	}
)


/* AJAX auto form aanvullen */
function createRequestObject() {
	var req;
	if(window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		alert('Helaas geen goede browser');
	}
	return req;
}

var http = createRequestObject(); 

/*
======================================================
=================== AJAX loader ======================
======= Copyright februari 2011 - N. Peters ==========
======================================================
*/

function ajax_loading(div, html, tijd, duur, fade_duur) {
	document.getElementById(div).style.display	= 'block';
	if(tijd == 0 || duur == 0) {
		document.getElementById(div).innerHTML	= html;
	} else {
		document.getElementById(div).innerHTML	= html;
		huidige_tijd	= new Date().getTime();
		verschil		= huidige_tijd - tijd;
		if(duur == 0) {
			// ajax loading melding laten staan
		} else if(verschil >= duur) {
			clear_ajax_loading(div);
		} else {
			setTimeout(function(){clear_ajax_loading(div, fade_duur)},(duur-verschil));
		}
	}
}

function clear_ajax_loading(div, fade_duur) {
	if(fade_duur == 0) {
		document.getElementById(div).style.display = 'none';
	} else {
		interval_id	= setInterval(function(){fade_ajax_loading_div(div)},100);
	}
}

function fade_ajax_loading_div(div) {
	if(document.getElementById(div).style.opacity > 0.11) {
		doorzichtig	= document.getElementById(div).style.opacity-0.1;
		document.getElementById(div).style.opacity	= doorzichtig;
		document.getElementById(div).style.filter	= "alpha(opacity=" + (doorzichtig*100) + ")";
	} else {
		document.getElementById(div).style.display = 'none';
		clearInterval(interval_id);
	}
}

/*
======================================================
=================== Contactform ======================
======================================================
*/

function contact_veld(veld, waarde, actie) {
	if(actie == 0) {
		if(veld.value == waarde) {
			veld.value = '';
		}
	} else {
		if(veld.value == '') {
			veld.value = waarde;
		}
	}
}

function verzend_bericht() {
	var url		= "/includes/contactformulier.php";
	var params = "naam=" + document.getElementById('naam').value + "&emailadres=" + document.getElementById('emailadres').value + "&telefoonnummer=" + document.getElementById('telefoonnummer').value + "&bericht=" + document.getElementById('bericht').value;
	
	start_tijd	= new Date().getTime();
	ajax_loading('contactformulier', 'Uw bericht wordt verzonden..', 0, 0, 0);
	
	http.open("POST", url, true);
	//Send the proper header information along with the request
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	
	http.onreadystatechange = function () {
		if(http.readyState == 4 && http.status == 200) {
			if(http.responseText) {
				ajax_loading('contactformulier', http.responseText, start_tijd, 0, 0);
			} else {
				ajax_loading('contactformulier', 'Er is een fout opgetreden..', start_tijd, 2000, 0);
			}
		} else if(http.readyState == 4) {
			ajax_loading('contactformulier', 'Er is een fout opgetreden..', start_tijd, 2000, 0);
		}
	}
	http.send(params);
}

/*
======================================================
=================== MENU ======================
======================================================
*/


function menu(pagina) {
	window.location.href='/'+pagina;
}

function lees_meer(over, menu) {
	if(over == 1) {
		document.getElementById(menu + '_lees_meer').setAttribute("class", "lees_meer_border_over");
	} else {
		document.getElementById(menu + '_lees_meer').setAttribute("class", "lees_meer_border");
	}
}

/*
======================================================
=================== OVERIGE ======================
======================================================
*/

function popup_menu(pagina) {
	document.getElementById('popup_content').innerHTML = pagina + '<iframe width="591" height="450" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=nl&amp;geocode=&amp;q=bruningweg+21+arnhem&amp;aq=&amp;sll=37.0625,-95.677068&amp;sspn=48.956293,135.263672&amp;vpsrc=0&amp;ie=UTF8&amp;hq=&amp;hnear=Bruningweg+21,+Industrieterrein,+Arnhem,+Gelderland,+Nederland&amp;t=m&amp;z=14&amp;ll=51.975305,5.942207&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=nl&amp;geocode=&amp;q=bruningweg+21+arnhem&amp;aq=&amp;sll=37.0625,-95.677068&amp;sspn=48.956293,135.263672&amp;vpsrc=0&amp;ie=UTF8&amp;hq=&amp;hnear=Bruningweg+21,+Industrieterrein,+Arnhem,+Gelderland,+Nederland&amp;t=m&amp;z=14&amp;ll=51.975305,5.942207" style="color:#0000FF;text-align:left">Grotere kaart weergeven</a></small>';
}

function fireMyPopup(close_popup, popup_div_naam) {
	if(!popup_div_naam) {
		var popup_div_naam	= 'mypopup';
	}
	
	if(close_popup == 1) {
		document.getElementById(popup_div_naam).style.display	= 'none';
		document.getElementById('fade').style.display			= 'none';
	} else {
		<!-- Due to different browser naming of certain key global variables, we need to do three different tests to determine their values -->
		// Determine how much the visitor had scrolled
		var scrolledX, scrolledY;
		if( self.pageYOffset ) {
			scrolledX = self.pageXOffset;
			scrolledY = self.pageYOffset;
		} else if( document.documentElement && document.documentElement.scrollTop ) {
			scrolledX = document.documentElement.scrollLeft;
			scrolledY = document.documentElement.scrollTop;
		} else if( document.body ) {
			scrolledX = document.body.scrollLeft;
			scrolledY = document.body.scrollTop;
		}
		
		// Determine the coordinates of the center of browser's window
		var centerX, centerY;
		if( self.innerHeight ) {
			centerX = self.innerWidth;
			centerY = self.innerHeight;
		} else if( document.documentElement && document.documentElement.clientHeight ) {
			centerX = document.documentElement.clientWidth;
			centerY = document.documentElement.clientHeight;
		} else if( document.body ) {
			centerX = document.body.clientWidth;
			centerY = document.body.clientHeight;
		}
		
		var leftOffset	= scrolledX + (centerX - 520) / 2;
		var topOffset	= scrolledY + (centerY - 420) / 2;
		
		document.getElementById("fade").style.display			= "block";
		document.getElementById(popup_div_naam).style.top		= topOffset + "px";
		document.getElementById(popup_div_naam).style.left		= leftOffset + "px";
		document.getElementById(popup_div_naam).style.display	= "block";
		//document.getElementById("header").style.display		= "block";
	}
}
