
/// MAIN FUNCTIONS /// 

function $rgb(id)
{

return document.getElementById(id);
}
function hide(id)
{

$rgb(id).style.display = 'none';
}
function show(id)
{
$rgb(id).style.display = 'block';
}
function isHidden(id)
{
if($rgb(id).style.display == 'none')
return true;
else
return false;
}
function V_switch(id)
{
if(isHidden(id))
show(id);
else
hide(id);
}
function moveto(url)
{
	window.location = url;	
}
function movetoandclearcookie(url)
{
	setCookie("basket", '', 30, '/', '', '');	
	
	window.location = url;	
}

/// MAIN FUNCTIONS ///
/// AJAX  FUNCTIONS ///
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; 

}

/// MYRGB  FUNCTIONS ///
function submitNM()
{
	myRequest.update( $rgb('nmform'), "POST" );	
}
function addListenerx(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;
}

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

var past_date = "";
function submitReservation()
{
	var now = new Date();
	
	var mydate = $rgb('arrivaldate').value;
	var split = mydate.split('-');
	var then = new Date(split[2], split[1]-1, split[0]);

	if( Date.parse(now)-24*3600*1000 > Date.parse(then) ) {
		alert(past_date);
		return;
	}
	
	
	if($rgb('arrivaldate').value != "" &&  $rgb('departuredate').value != "")
		$rgb("booking").submit()	
	else
		alert("Please fill out all the required dates.");
}

/// GALLERY1 FUNCTIONS ///
var filename_array = new Array();
var RGBG_empty_alt = true;
var RGBG_busy = false;
var current_pic = 0;
var timeoutl= 4500;
var timer1 = null;
function imgs()
{
	if(RGBG_busy) { //setTimeout('imgs()', timeoutl); 
	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;		
		
	}
	current_pic++;
	current_pic = current_pic%filename_array.length;
	str = "<img alt=''  src='http://www.parkhotelgent.be/images/header/"+filename_array[current_pic]+"' />";
	
	
	RGBG_seq = null;
	RGBG_seq = new Parallel();
	
	RGBG_seq.addChild(   new OpacityTween( $rgb(oldc) ,Tween.regularEaseIn, 100, 0, 0.75)   );
	RGBG_seq.addChild(   new OpacityTween( $rgb(newc) ,Tween.regularEaseIn, 0, 100, 0.75)  );
	RGBG_seq.children[0].onMotionFinished = function(){ RGBG_busy = false; };
	$rgb(newc).innerHTML = str;
	
	
	RGBG_seq.start();
	
	$rgb(newc).style.zIndex ="5";
	$rgb(oldc).style.zIndex ="4";
	//timer1 = setTimeout('imgs()', timeoutl); 
	
	
		
}

function datePickerClosed(dateField)
{

  var dateObj = getFieldDate(dateField.value);
  dateObj.setTime(dateObj.getTime() + (1 * 24 * 60 * 60 * 1000));
  
 // $rgb('departuredate').value =   getDateString(dateObj);
 }
	  
function updateMyDate(date, id)
{
	//da = date.split("-");
	
	//alert(date+id);
	//$rgb(id).value = (da[0]+1)+"-"+da[1]+"-"+da[2];
}
timer1 = setInterval('imgs()', timeoutl);

/// GALLERY FUNCTIONS ///

/// GALLERY2 FUNCTIONS ///
var filename_array2 = new Array();
var RGBG_empty_alt2 = true;
var RGBG_busy2 = false;
var current_pic2 = 0;
var timeout2= 6000;
var timer2 = null;
function imgs2()
{
	if(RGBG_busy2) { //setTimeout('imgs()', timeout2); 
	return; }
	
	RGBG_busy2 = true;	
	if(RGBG_empty_alt2)
	{
		oldc = 'empty2_alt';
		newc = 'empty2';
		RGBG_empty_alt2 = false;
	}else{
		
		oldc = 'empty2';
		newc = 'empty2_alt';
		RGBG_empty_alt2 = true;		
		
	}
	current_pic2++;
	current_pic2 = current_pic2%filename_array2.length;
	str = "<a href='http://www.parkhotelgent.be/nl/galerij'><img alt=''  src='http://www.parkhotelgent.be/images/kamers/"+filename_array2[current_pic2]+"' /></a>";
	
	
	RGBG_seq = null;
	RGBG_seq = new Parallel();
	
	RGBG_seq.addChild(   new OpacityTween( $rgb(oldc) ,Tween.regularEaseIn, 100, 0, 0.75)   );
	RGBG_seq.addChild(   new OpacityTween( $rgb(newc) ,Tween.regularEaseIn, 0, 100, 0.75)  );
	RGBG_seq.children[0].onMotionFinished = function(){ RGBG_busy2 = false; };
	$rgb(newc).innerHTML = str;
	
	
	RGBG_seq.start();
	
	$rgb(newc).style.zIndex ="5";
	$rgb(oldc).style.zIndex ="4";
	//timer2 =  setTimeout('imgs()', timeout2); 
	
	
		
}
timer2 = setInterval('imgs2()', timeout2);
/// GALLERY FUNCTIONS ///
