var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  xmlhttp = new XMLHttpRequest();
}


function validate_login(){
	  
		var nick = document.getElementById('nick');
		var ww = document.getElementById('ww');		
		
		if(nick.value == ''){
		
		  alert("Nickname error");
			
			nick.focus();
	 
	    return false;
		
		}
		if(ww.value == ''){
		
		  if(nick.focus){
			
			  ww.focus();
				
				return false;
			
			}
			
			else{
		
		    alert("Password error");
	 
			  ww.focus();
	 
	      return false;
			
			}
			
		}
		else{
		
		  return true;
		  
		}
	
 
}

function logout(basepath){

  xmlhttp.open("GET",basepath+"functions/verwerk.php?logoff=1",true);//method, target, async (set always true!)
	
	xmlhttp.onreadystatechange=function(){
	
    if (xmlhttp.readyState==4){
  
      if(xmlhttp.responseText != "" && xmlhttp.responseText != " "){
  		 
     		alert("Er is een fout opgetreden bij het uitloggen, \n probeer opnieuw \n"+xmlhttp.responseText);
				
  	  }
			else{
			
			  location = location.href.replace("#","");
				
				location = location.href;
			
			}
  	 
    }		
   
  }
	
	xmlhttp.send(null);
  		 
}


function add_merk(basepath){

  var merk = document.getElementById('add_merk').value;
		
  xmlhttp.open("GET",basepath+"functions/verwerk.php?add_merk="+merk,true);//method, target, async (set always true!)
	
	xmlhttp.onreadystatechange=function(){
	
    if (xmlhttp.readyState==4){
  
      if(xmlhttp.responseText != "" && xmlhttp.responseText != " "){
  		 
     		alert(xmlhttp.responseText);
				
  	  }
			
			else{
			
			  location = location.href+"&merk="+merk;
			
			}
  	 
    }		
   
  }
	
	xmlhttp.send(null);
  	

}


function del_merk(basepath,merk){

  if (confirm("Weet je zeker dat je "+merk+" wilt verwijderen")) {

    xmlhttp.open("GET",basepath+"functions/verwerk.php?del_merk="+merk,true);//method, target, async (set always true!)
  	
  	xmlhttp.onreadystatechange=function(){
  	
      if (xmlhttp.readyState==4){
    
        if(xmlhttp.responseText != "" && xmlhttp.responseText != " "){
    		 
       		alert(xmlhttp.responseText);
  				
    	  }
  			
  			else{
  			
  			  location = basepath+'?p=5';
  			
  			}
    	 
      }		
     
    }
  	
  	xmlhttp.send(null);

  }

}

//variable for new window object.
//Make this accessible to both following procedures, 
//by declaring it global to this page:
  var PhotoFrame 
	
  //-------------------------------------------------------------------------
  //  genHTML(myHTML):
  //  write out a line of html (saves space in following function) 
  //  (note, this doesn't work within HTML-Kit preview, but is fine in a browser)
  //-------------------------------------------------------------------------
  function genHTML(myHTML)
  {
   PhotoFrame.document.writeln(myHTML)
  }
	
  //-------------------------------------------------------------------------
  //  newWindow(caption, treeImage): 
  //  Create a new window and write its html, including the image and caption.
  //-------------------------------------------------------------------------
  function newWindow(titel,verhaaltje,code) 
  {
   PhotoFrame = window.open("",'Klimavision','width=800, height=600, scrollbars=yes, resizable=yes')
			
   genHTML("<html><head><title>Klimavision: Airconditioning installatie en onderhoud</title></head>")
   genHTML("<body>")
   genHTML("<h1>" + titel + "</h1>")
   genHTML(code)
   genHTML("<p>"+verhaaltje+"</p>")
   genHTML("</body></html>")
			
   PhotoFrame.document.close()
   PhotoFrame.focus()
  } 
