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);
}

RGBG_empty_alt = true;
RGBG_busy = false;				
function imgs(filename)
{
	if(RGBG_busy) return;
	
	RGBG_busy = true;	
	if(RGBG_empty_alt)
	{
		oldc = 'empty_alt';
		newc = 'empty';
		RGBG_empty_alt = false;
	}else{
		
		oldc = 'empty';
		newc = 'empty_alt';
		RGBG_empty_alt = true;		
		
	}
	str = "<img alt=''  src='http://www.hetlamgods.be/images/gal/"+filename+"' />";
	
	
	RGBG_seq = null;
	RGBG_seq = new Parallel();
	
	RGBG_seq.addChild(   new OpacityTween( $(oldc) ,Tween.regularEaseIn, 100, 0, 0.65)   );
	RGBG_seq.addChild(   new OpacityTween( $(newc) ,Tween.regularEaseIn, 0, 100, 0.65)  );
	RGBG_seq.children[0].onMotionFinished = function(){ RGBG_busy = false; };
	$(newc).innerHTML = str;
	
	
	RGBG_seq.start();
	
	$(newc).style.zIndex ="5";
	$(oldc).style.zIndex ="4";
	
	
	
	
	//RGBG_setActive(id);
		
}

var curr = 0;
var page_busy = false;
function page(id)
{
	if(page_busy) return;
	
	page_busy = true;
	
	t1 = new Tween(document.getElementById('thumbholder').style,'top',Tween.regularEaseOut, curr ,-156*(id-1),0.75,'px');
	t1.onMotionFinished = function() { curr= -162*(id-1); page_busy = false; };
	t1.start();
	
}
function accordeon(id, nr)
{
	for(var i = 1; i<=nr; i++)
	{	
		hide("menukaart_"+i);
		$('accor'+i).className = '';
	}
		
	show("menukaart_"+id);
	$('accor'+id).className = 'activemenu';
	
}

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 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"; } } );
