function addEvent(obj, evType, fn){ 
	 if (obj.addEventListener){ 
		obj.addEventListener(evType, fn, false); 
		return true; 
	} else if (obj.attachEvent){ 
		var r = obj.attachEvent("on"+evType, fn); 
		return r; 
	} else { 
		return false; 
	} 
}

function ajaxObject(url, callbackFunction) {  
	var that=this;        
	this.updating = false;  
	this.abort = function() {    
		if (that.updating) {      
			that.updating=false;      
			that.AJAX.abort();      
			that.AJAX=null;    
		}  
	}  
	this.update = function(passData,postMethod){     
		if (that.updating) { 
			return false; 
		}    
		that.AJAX = null;                              
		if (window.XMLHttpRequest) {                    
			that.AJAX=new XMLHttpRequest();                  
		} else {                                        
			that.AJAX=new ActiveXObject("Microsoft.XMLHTTP");    
		}                                                 
		if (that.AJAX==null) {                                   
			return false;                                   
		} else {      
			that.AJAX.onreadystatechange = function() {          
				if (that.AJAX.readyState==4) {                       
					that.updating=false;                          
					that.callback(that.AJAX.responseText,that.AJAX.status,that.AJAX.responseXML);                  
					that.AJAX=null;                                                 
				}                                                            
			}                                                              
			that.updating = new Date();                                    
			if (/post/i.test(postMethod)) {        
				var uri=urlCall+'?'+that.updating.getTime();        
				that.AJAX.open("POST", uri, true);        
				that.AJAX.setRequestHeader("Content-type", "application/x-www-form-urlencoded");        
				that.AJAX.send(passData);      
			} else {        
				var uri=urlCall+'?'+passData+'&timestamp='+(that.updating.getTime());         
				that.AJAX.open("GET", uri, true);                                     
				that.AJAX.send(null);                                               
			}                    
			return true;                                                 
		}                                                		
	}  
	var urlCall = url;          
	this.callback = callbackFunction || function () { };
}


function updatewebcart(){
	var webCartRightAjax = new ajaxObject('/includes/webCartRight.php');
	webCartRightAjax .callback = function(responseText, responseStatus, responseXML) {
		document.getElementById("shoppingCart").getElementsByTagName('p')[0].innerHTML = responseText;
    };
	webCartRightAjax.update('','GET');
		
		
		
	
}
/************************************************
Left menu Toggle
*************************************************/

function toggle(e) {
	var menus = e.parentNode.parentNode.getElementsByTagName('ul');
	for (var i=0; i<menus.length; i++) {
		menus[i].style.display = '';
	}
	e.nextSibling.nextSibling.style.display = 'block';
}

addEvent(window, 'load', function(){
	updatewebcart();
	var input = document.getElementById("zoekInput");
	onloadValue = input.value;
	var nlSubmit = document.getElementById("nlSubmit");
	input.blur();
	with ({ "input": input }) {
		//onfocus
		addEvent(input, 'focus', function(){
			if(input.value == onloadValue){
				input.value= '';
				input.style.color = '#000';
			}
		});
		//onblur
		addEvent(input, 'blur', function(){
			if(input.value == ''){
				input.value= onloadValue;
				input.style.color = '#7c7c7c';
				
			}
		});	
		addEvent(input, 'keyup', function(e){
			var evt = e || window.event;
			if(input.value.length >2 || (input.value.length  == 2 && evt.keyCode == 13)){
				var webCartRightAjax = new ajaxObject('/includes/productOverView.php');
				webCartRightAjax .callback = function(responseText, responseStatus, responseXML) {
					document.getElementById("content").innerHTML = responseText;
				};
				webCartRightAjax.update('search='+input.value,'POST');
			}
			
		});
	}

});





