var requestcount;

function swapimg(galleryID, newimg){
	if (gallerycontainer = document.getElementById(galleryID)){
		gallerycontainer.style.backgroundImage = 'url(\''+newimg+'\')';
	}
	
}
function setactivemenu(mID){
	if (menu = document.getElementById('menu'+mID)){
		menu.style.color = '#C6FC6C';
		menu.style.fontWeight = 'bold';
	}
}

function getmoreinfo(itemID){
	
	kill();
	
	var theaction	= 'moreinfo';
	var theurl 		= 'ajax.php?action='+theaction+'&ID='+itemID+'&sid='+Math.random();
	var thevars 	= '';
	var thediv 		= '';
	var theajaxdescription = '';
	xmlreqGET(theurl, theaction, thediv, thevars, theajaxdescription);
		
}
function getelements(name) {

	// all elementen ophalen
	var elem = document.getElementsByTagName('span');
	var arr = new Array();
	// loopen door elementen
	for(i = 0, iarr = 0; i < elem.length; i++){
		// checken of name overeen komt, zo wel, toevoegen aan array
		att = elem[i].getAttribute('name');
		if(att == name){
			arr[iarr] = elem[i];
			iarr++;
		}
	}
	return arr;
}
function showmoreinfos(){
	
	var theelements = getelements('moreinfo');
	for (var i = 0; i < theelements.length; i++){
		
		if (theelements[i]){
			theelements[i].style.display = 'block';
		}
		
	}
	
}

function kill(){
	
	if (document.getElementById('windowcontainer')){
		document.getElementById('windowcontainer').parentNode.removeChild(document.getElementById('windowcontainer'));
	}
	
}

function postform(){
	
	var theaction	= 'postform';
	var theurl 		= 'ajax.php?action='+theaction+'&sid='+Math.random();
	var thevars 	= '';
	var thediv 		= '';
	var theajaxdescription = '';
	
	var naam = encodeURIComponent(document.getElementById('naam').value);
	var telefoon = encodeURIComponent(document.getElementById('telefoon').value);
	var email = encodeURIComponent(document.getElementById('email').value);
	var productnaam = encodeURIComponent(document.getElementById('productnaam').value);
	var opmerking = encodeURIComponent(document.getElementById('opmerking').value);
	
	if (naam == '' || telefoon == '' || email == '' || opmerking == '' || productnaam == ''){
		alert('Alle velden moeten ingevuld worden!');
		return false;
	}
	
	var data = '&naam='+naam+'&telefoon='+telefoon+'&email='+email+'&productnaam='+productnaam+'&opmerking='+opmerking;
	xmlreqPOST(theurl, data, theaction, thediv, thevars, theajaxdescription);
		
}


// browsercheck
function Browser(){
	var ua, s, i;
	this.isIE    = false;
	this.isNS    = false;
	this.version = null;
	ua = navigator.userAgent;
	
	s = "MSIE";
	if ((i = ua.indexOf(s)) >= 0){
		this.isIE = true;
		this.version = parseFloat(ua.substr(i + s.length));
		return;
	}
	
	s = "Netscape6/";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		this.version = parseFloat(ua.substr(i + s.length));
		return;
	}
	
	s = "Gecko";
	if ((i = ua.indexOf(s)) >= 0) {
		this.isNS = true;
		this.version = 6.1;
		return;
	}
}

var browser = new Browser();
