// js/general.js
// Copyright (c) 2000-2006 SpuyMore Web/Applications
//
// General client-side utilities, event handlers and form handling routines
// Preferably loaded in a first script tag on a page

/*** OBJECT SELECTION ***/

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}


/*** DHTML MENU'S ***/

var dmTimeOut='';
var oActiveMenu='';

function dOpen(menuId) { // (c)SpuyMore v1.0
  oActiveMenu=menuId;
  if((obj=MM_findObj(menuId).style).visibility!='visible')obj.visibility='visible';
  dCloseNow();
}

function dClose() { // (c)SpuyMore v1.0
  dmTimeOut=setTimeout('dCloseNow()',300);
}

function dCloseNow() { // (c)SpuyMore v1.0
  clearTimeout(dmTimeOut);
  var i=0;
  while(o=MM_findObj(m="sm_hmenu"+i)){ // close horizontal menu's, if not active
    if(oActiveMenu!=m)o.style.visibility='hidden';
    i++;
  };
  oActiveMenu='';
}

/* Scrolling photo's */

var iScrolled = 0;

function scrollImg() {
  if(document.getElementById('scrollingImg')) {
    iScrolled--;
    document.getElementById('scrollingImg').style.left=iScrolled + "px";
    if(iScrolled<=-677) iScrolled=0;
    if(oActiveMenu=='') setTimeout('scrollImg()',40);
  }else{
    setTimeout('scrollImg()',50);
  }
}