/*****************************************************************************************
window functions
*****************************************************************************************/
function PopUp(xPopUpUrl, Args, aWidth, aHeight)
{
  window.showModalDialog(xPopUpUrl,Args,"dialogHeight: " + aHeight + "px; dialogWidth: " + aWidth + "px; edge: Raised; center: Yes; resizable: No;  status: No;");
}




/*****************************************************************************************
string functions
*****************************************************************************************/

function Trim(TRIM_VALUE){
if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} //End Function

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function


/*****************************************************************************************
image functions
*****************************************************************************************/

function swapImage(iID, sNewImage, sPath) {
	document.getElementById(iID).src = sPath + sNewImage;
}

function preloadImage(sPath) {
	var oImg = new Image();
	oImg.src = sPath;
}

var SlideShowSpeed=4000
var CrossFadeDuration=2
var SlideShowTimer
var pCounter = 0
var SlideIndex = 0
var preLoadSlides


function initSlideShow(SlidePics, ASlideShowSpeed, ACrossFadeDuration)
{
  pCounter = SlidePics.length

  preLoadSlides = new Array()
  for (i = 0; i < pCounter; i++)
  {
    preLoadSlides[i] = new Image()
    preLoadSlides[i].src = SlidePics[i]
  }
  SlideShowSpeed=ASlideShowSpeed
  CrossFadeDuration=ACrossFadeDuration
  runSlideShow()
}


function runSlideShow(){
   if (document.all){
      document.images.SlideShow.style.filter="blendTrans(duration=CrossFadeDuration)"
      document.images.SlideShow.filters.blendTrans.Apply()      
   }
   document.images.SlideShow.src = preLoadSlides[SlideIndex].src
   if (document.all){
      document.images.SlideShow.filters.blendTrans.Play()
   }
   SlideIndex  = SlideIndex  + 1
   if (SlideIndex  > (pCounter-1)) SlideIndex =0
   SlideShowTimer = setTimeout('runSlideShow()', SlideShowSpeed)
}

/*****************************************************************************************
other
*****************************************************************************************/

function getCookie(ADocument, NameOfCookie){
    if (ADocument.cookie.length > 0) {              
    begin = ADocument.cookie.indexOf(NameOfCookie+"=");       
    if (begin != -1) {           
      begin += NameOfCookie.length+1;       
      end = ADocument.cookie.indexOf(";", begin);
      if (end == -1) end = ADocument.cookie.length;
        return unescape(ADocument.cookie.substring(begin, end));
    } 
  }
  return null;
}

function setCookie(ADocument,NameOfCookie, value, expiredays) {
var ExpireDate = new Date ();
ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));

  ADocument.cookie = NameOfCookie + "=" + escape(value) + 
  ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function delCookie (ADocument,NameOfCookie) {
  if (getCookie(ADocument,NameOfCookie)) {
    ADocument.cookie = NameOfCookie + "=" +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

function fullScreen()
{
  top.window.moveTo(0,0);
  if (document.all) 
  { 
    top.window.resizeTo(screen.availWidth,screen.availHeight); 
  } 
  else
  if (document.layers || document.getElementById) 
  { 
    if (top.window.outerHeight < screen.availHeight || top.window.outerWidth < screen.availWidth) 
    { 
      top.window.outerHeight = top.screen.availHeight; top.window.outerWidth = top.screen.availWidth; 
    } 
  }
}


function showCopyright(e) 
{
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    if (event.button == 2 || event.button == 3) 
    {
      var MyNewDate = new Date();
      var message=String.fromCharCode(169) + ' ' + MyNewDate.getYear() + ' Parkheaven\n      Lelystad The Netherlands';
      alert(message);
      return false;
    }
    return true;
  }
  else
  if (document.layers||document.getElementById&&!document.all)
  {
    if (e.which==2||e.which==3)
    {
      var MyNewDate = new Date();
      var message=String.fromCharCode(169) + ' ' + MyNewDate.getYear() + ' Parkheaven\n      Lelystad The Netherlands';
      alert(message);
      return false;
    }
  }
}

//this is for when you need to dynamically change the height off the side menu to make space for content on the right, 
//effectively moving the yellow horizontal bar further down. send height , true to move down or height, false to move back up

function changeMenuHeight(iHeight,bNewOrig)
{
	if(document.getElementById('menuHolder'))
	{
		if(bNewOrig) {
				document.getElementById('fullLeftBar').height = iHeight		
		}
		else {
			document.getElementById('fullLeftBar').height = eval(document.getElementById('fullLeftBar').height-iHeight+1)		
		}
	}
}
//function for showing and hiding elements dynamically
function expandableDiv(lbl, div)
{
if(document.getElementById(lbl).style.display=="none")
{
document.getElementById(lbl).style.display = ""
}
else
 {
  document.getElementById(lbl).style.display = "none"
  }  
  moveFooterDown(div)
}
//function for moving footerdown
function moveFooterDown(div)
{
var divHeightpx = document.getElementById(div).offsetHeight + 50
var divHeightem = divHeightpx/20 * 1.8
document.getElementById('fullLeftBar').style.height = divHeightem + (50/20*1.8) + "em"
}
//function to put focus  on first input element
function inputFocus(oElement)
{	
	if(document.getElementById(oElement))
	{			
	document.getElementById(oElement).focus()
	}
}

//function do Keypress enter
function doEnterPress(e, btn,txtbox) {		
		if (e==13) {	
			if (document.getElementById(btn)) {
				document.getElementById(btn).click();
				waiting(btn,txtbox)
			}			
		}				
	}	
	
//function to prevent futher keypress, till server roundtrip complete by chaing cursor
function waiting(btn,txtbox)
	{
	document.getElementById(btn).style.cursor = "wait"
	document.getElementById(txtbox).style.cursor = "wait"
	}
	
//function to print page
function printPage()
{
	this.print();
	this.marginleft(9);
}	
	