var activemenu = 0;
function popup(url,winName,W,H,X,Y) {
		if(W == undefined) W = 400;	//default width
		if(H == undefined) H = 300; //default height
		if(X == undefined) X = screen.width/2-W/2; //default Xpos (is now centered)
		if(Y == undefined) Y = screen.height/2-H/2; //default Ypos (is now centered)
		X = 10;
		Y = 10;
	
		winprops = 'height='+H+',width='+W+',top='+X+',left='+Y+',scrollbars=yes, resizable=yes';
	
		win = window.open(url, winName, winprops);
		if (parseInt(navigator.appVersion) >= 4) {
			win.window.focus();
		}
	}
	function disclaimer()
	{
	popup(stricturl+"disclaimer.php",'disclaimer',500,600,10,10)
	}
function $(id)
{
	
return document.getElementById(id);
}
function hide(id)
{
$(id).style.display = 'none';
}
function show(id)
{
$(id).style.display = 'block';
}
function isHidden(id)
{
if($(id).style.display == 'none')
return true;
else
return false;
}
function V_switch(id)
{
if(isHidden(id))
show(id);
else
hide(id);
}
												
function processData(responseText, responseStatus)
 { 
	
	//document.getElementById('loadingbar').style.display ='none';
	if (responseStatus==200) // succes
	{
		if(responseText == 'error')
						alert('Error updating data!'+responseText);
		else
		{
			eval(responseText);
			
		}
	 }
	else if(responseStatus == 0)
	{
	
	}
	else 
	{ 
	   alert(responseStatus + ' -- Error Processing Request');
	}
  }
function ajaxObject(url) {
	  var that=this;      
	   this.updating = false;
		  this.abort = function() {
				that.AJAX.onreadystatechange = function () {}
			  that.updating=false;
			  that.AJAX.abort();
			  that.AJAX=null;
			
		  }
	  this.update = function(form,postMethod) { 
		if(that.updating) that.abort();
		 that.AJAX = null;                      
		 var passData = getFormValues(form,"validate");
		 
		 
				
		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=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; charset=UTF-8");
			that.AJAX.setRequestHeader("Content-Length", passData.length);
			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 = processData;
	  }
	  
	 
function getFormValues(fobj,valFunc, url) 

{ 

   var str = ""; 

   var valueArr = null; 

   var val = ""; 

   var cmd = ""; 

   for(var i = 0;i < fobj.elements.length;i++) 

   { 

	   switch(fobj.elements[i].type) 

	   { 
		case "checkbox":
				var myval = fobj.elements[i].checked;
				if(myval) 
					myval = 1;
				else
					myval = 0;								   
			   str += fobj.elements[i].name + 

				"=" + myval + "&"; 

				   break; 
		  case "textarea":
			 str += fobj.elements[i].name + 

					 "=" + escape(fobj.elements[i].value) + "&"; 
					 break; 
	   
			case "password":
				str += fobj.elements[i].name + 

					 "=" + escape(fobj.elements[i].value) + "&"; 

					  break; 
			case "hidden":
				str += fobj.elements[i].name + 

				 "=" + (fobj.elements[i].value) + "&"; 
				  break; 
		   case "text": 

						
				str += fobj.elements[i].name + 

				 "=" + escape(fobj.elements[i].value) + "&"; 

				 break; 

		   case "select-one": 

				str += fobj.elements[i].name + 

				"=" + fobj.elements[i].options[fobj.elements[i].selectedIndex].value + "&"; 

				break; 

	   } 

   } 
						
			
				 
				 
   str = str.substr(0,(str.length - 1)); 

   return str; 

}

function submitReservation()
{
	myRequest.update($('reservatieform'),'POST');	
}

function accordeon(id, nr)
{
	for(var i = 1; i<=nr; i++)
	{	
		hide("menukaart_"+i);
		$('accor'+i).style.fontWeight = 'normal';
	}
		
	show("menukaart_"+id);
	$('accor'+id).style.fontWeight = 'bold';
	
}

function activateMenu(id)
{
	deactivateMenu();
	
	if(id <= 7)
	$('navmenu_'+id).className = 'selected';
	
	
}
function deactivateMenu()
{
	for(var i = 1; i<=7; i++)
	{	
		if(i != activemenu)
		$('navmenu_'+i).className = '';
	}
}
	
	
function submitNewsletter()
{
	myRequest2.update($('index_newsletter_form'),'POST');	 
}

function submitenter_NM(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
	  submitNewsletter();
	   return false;
   }
else
	 return true;
}


function verifycontent(value, bool)
{
	var str = "uw e-mail adres hier";
	if(!bool)
	{
		if(value == str)
		{
			$('nm_email').value = "";	
		}
	}else
	{
		if(value == "")
			$('nm_email').value = str;		
		
	}
	
}



function addListener(element, type, expression)
{
if(window.addEventListener)	
{
 // Standard
 element.addEventListener(type, expression, false);
 return true;
 }
  else if(window.attachEvent)
   { // IE	
	element.attachEvent('on' + type, expression);	
	return true;	
}
 else return false;
}

addListener(document, "keyup", function (e) { if (!e) { e = event; } if (e.keyCode == 27) { document.location.href = "http://www.myrgb.be"; } } );
