	// Functions for tip menu
	function tip(){
		zoekwoord = document.getElementById('q').value;
		if(zoekwoord.length > 2){
			document.getElementById("tip").innerHTML = "<img src='/opmaak/ajax-loader-grijs.gif' />";
			document.getElementById('tip_all').style.display = "block";
			getTimestamp(zoekwoord);
		}else{
			document.getElementById('tip_all').style.display = "none";
		}

	}
	function fill(zoekwoord){
		document.getElementById('q').value = zoekwoord;
		document.getElementById('tip_all').style.display = "none";
		document.getElementById('q').focus();
		document.getElementById('sform').submit();
	}
	
	var xmlhttp = null;
    
    if(window.XMLHttpRequest){
        xmlhttp = new XMLHttpRequest();
    }else{
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(e){
            window.alert("Uw browser ondersteunt het XMLHttpRequest object niet!");
        }
    }
    
    function getTimestamp(zoekwoord){
		id_tserver = zoekwoord;
        xmlhttp.open("GET", "/inc/zoek_tip.php?q=" + id_tserver + "&rand=" + Math.random(), true);
        xmlhttp.onreadystatechange = showTimestamp;
        xmlhttp.send('');
    }
    function showTimestamp(){
        if(xmlhttp.readyState == 4){
         	document.getElementById("tip").innerHTML = xmlhttp.responseText;
         	sel_tab = 0;
        }
    }
    var keycode;
	document.onkeydown = checkKeycode;
	function checkKeycode(e) {
		
		if(window.event){
			keycode = window.event.keyCode;
		}else if(e){
			keycode = e.which;
		} 
		
		if(keycode == '40'){
			tabbdown();
		}else if(keycode == '38'){
			tabbup();
		}else if(keycode == '13'){
		 	if(sel_tab > 0){
		 	 	if(document.getElementById('val_'+sel_tab)){
		 	 	 	check = false;
					fill(document.getElementById('val_'+sel_tab).value);
				}
			}
		}
	}
	
	var sel_tab = 0;
	var color_link_bg 	= 'transparent';
	var color_link 		= '#3C3C3C';
	var color_hover_bg	= '#3C3C3C';
	var color_hover		= 'black';
	
	function tabbdown(){
	 	// oude tab standaard kleur geven
	 	document.getElementById('tab_'+sel_tab).style.backgroundColor=color_link_bg;
	 	document.getElementById('tab_'+sel_tab).style.color=color_link;
	 	
	 	// nieuwe tab selecteren
		sel_tab = sel_tab + 1;
		
		// nieuwe tab inkleuren
		if(document.getElementById('tab_'+sel_tab)){
			document.getElementById('tab_'+sel_tab).style.backgroundColor=color_hover_bg;
			document.getElementById('tab_'+sel_tab).style.color=color_hover;
		}else{
			sel_tab = sel_tab - 1;
			document.getElementById('tab_'+sel_tab).style.backgroundColor=color_hover_bg;
			document.getElementById('tab_'+sel_tab).style.color=color_hover;
		}
		
	}
	function tabbup(){
		document.getElementById('tab_'+sel_tab).style.backgroundColor=color_link_bg;
		document.getElementById('tab_'+sel_tab).style.color=color_link;
		if(sel_tab > 1){
			sel_tab = sel_tab - 1;
		}
		document.getElementById('tab_'+sel_tab).style.backgroundColor=color_hover_bg;
		document.getElementById('tab_'+sel_tab).style.color=color_hover;
	}
	function check(){
		if(document.getElementById('tip').style.display == 'none'){
			return true;
		}else{
			return false;
		}
	}
	// End functions for tip menu

