//
// format date as dd-mmm-yy
// example: 12-Jan-99
//
function date_ddmmmyy(theDate)
{
  var d = theDate.getDate();
  var m = theDate.getMonth() + 1;
  var y = theDate.getYear();

  // handle different year values 
  // returned by IE and NS in 
  // the year 2000.
  if(y >= 2000)
  {
    y -= 2000;
  }
  if(y >= 100)
  {
    y -= 100;
  }

  var mmm = (m<10?"0"+m:m);

  return "" +
    (d<10?"0"+d:d) + "-" +
    mmm + "-" +
    (y<10?"0"+y:y);
}

  // General functions
  function BreakOutOfFrame(){
    // Call this from body onload to make sure this website is not called
	// from another website and put in a small frame  
    if (top.location != location) { top.location.href = document.location.href; }
  }
  
  function Left(str, n){
	if (n <= 0) return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
  }
  
  function Right(str, n){
    if (n <= 0) return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
  }
  
  function MouseOver( objImg ){
    // Hand cursor
	if( objImg ){ if( objImg.style ){ if( objImg.style.cursor ){ objImg.style.cursor="pointer"; } } }
	
	// Hover effect
	SelectImg( objImg.id );
  }
  
  function MouseOut( objImg ){
    // Hand cursor
	if( objImg ){ if( objImg.style ){ if( objImg.style.cursor ){ objImg.style.cursor="default"; } } }
	
	// Deselect
	if( objImg.id != strSelectImg ){
	  DeselectImg( objImg.id );
	}
  } 
  
  function MouseClick( objImg ){
    var strOldImg;
	
	strOldImg = strSelectImg;
    if( strOldImg == objImg.id ){
	  return; // nothing to do
	}
    DeselectImg( strSelectImg ); // deselect previous selected img
	strSelectImg = objImg.id; // change selection
	SelectImg( strSelectImg ); // select new
	
	// Change screen
    	if( strSelectImg == "imgHome" ){
    	  document.location.href = "index.htm";
	}

  	if( strSelectImg == "imgBouwadvies" ){
	  document.location.href = "bouwadvies.htm";
	}

  	if( strSelectImg == "imgContact" ){
          document.location.href = "contact.htm";
	}

	if( strSelectImg == "imgShowroom" ){
	  document.location.href = "showroom.htm"
	}

	if( strSelectImg == "imgLinks" ){
	  document.location.href = "links.htm"
	}
	
	if( strSelectImg == "imgRealisaties" ){
	  document.location.href = "realisaties.php"
	}
  }
  
  function SelectImg( strImg ){
    switch( strImg ){
	  case "imgHome":
	    document.getElementById( strImg ).src = "images/menuknop_home_select.gif";
		break;
	  case "imgBouwadvies":
	    document.getElementById( strImg ).src = "images/menuknop_bouwadvies_select.gif";
	    break;
	  case "imgRealisaties":
	    document.getElementById( strImg ).src = "images/menuknop_realisaties_select.gif";
	    break;
	  case "imgShowroom":
	    document.getElementById( strImg ).src = "images/menuknop_showroom_select.gif";
	    break;
	  case "imgLinks":
	    document.getElementById( strImg ).src = "images/menuknop_links_select.gif";
	    break;
	  case "imgContact":
	    document.getElementById( strImg ).src = "images/menuknop_contact_select.gif";
	    break;
	}
  }
  
  function DeselectImg( strImg ){
    switch( strImg ){
	  case "imgHome":
	    document.getElementById( strImg ).src = "images/menuknop_home.gif";
		break;
	  case "imgBouwadvies":
	    document.getElementById( strImg ).src = "images/menuknop_bouwadvies.gif";
	    break;
	  case "imgRealisaties":
	    document.getElementById( strImg ).src = "images/menuknop_realisaties.gif";
	    break;
	  case "imgShowroom":
	    document.getElementById( strImg ).src = "images/menuknop_showroom.gif";
	    break;
	  case "imgLinks":
	    document.getElementById( strImg ).src = "images/menuknop_links.gif";
	    break;
	  case "imgContact":
	    document.getElementById( strImg ).src = "images/menuknop_contact.gif";
	    break;
	}
  }
  
  function preloadImages() {
    var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; 
	for(i=0; i<a.length; i++)
      if (a[i].indexOf("#")!=0){
	    d.p[j]=new Image; d.p[j++].src=a[i];
	  }
	}
  }