// JavaScript Document

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function getObj(objectId)
{
    if(document.getElementById && document.getElementById(objectId)) {
	this.obj = document.getElementById(objectId);
	this.style = document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	this.obj = document.all(objectId);
	this.style = document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	this.obj = document.layers[objectId];
	this.style = document.layers[objectId];
    } else {
	return false;
    }
}

function openGoogleMap(){
	myWindow = window.open('google_map.php','','status=yes,width=800,height=600,scrollbars=1,resizable=1');
	myWindow.focus();
}

function openImage(imageid){
	myWindow = window.open('popup_image.php?id='+imageid,'','status=yes,width=80,height=80,scrollbars=1');
	myWindow.focus();
}

function getRefToDivMod( divID, oDoc ) {
  if( !oDoc ) { oDoc = document; }
  if( document.layers ) {
    if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
      for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
        y = getRefToDivMod(divID,oDoc.layers[x].document); }
      return y; } }
  if( document.getElementById ) { return oDoc.getElementById(divID); }
  if( document.all ) { return oDoc.all[divID]; }
  return document[divID];
}

function resizeWinTo( idOfDiv, extraHt ) {
  var oH = getRefToDivMod( idOfDiv ); if( !oH ) { return false; }
  var oW = oH.clip ? oH.clip.width : oH.offsetWidth;
  var oH = oH.clip ? oH.clip.height : oH.offsetHeight; if( !oH ) { return false; }
  var x = window; x.resizeTo( oW + 50, oH + 50 );
  var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;
  if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }
  else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }
  else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }
  if( window.opera && !document.childNodes ) { myW += 16; }
  finalWidth = oW + ( ( oW + 50 ) - myW )
  finalHeight = oH + ( (oH + 50 ) - myH )
  if (extraHt) {
	  finalHeight = finalHeight + extraHt;
  }
  /*
  if (finalHeight > 590) {
	  var agt=navigator.userAgent;
	  if (!(agt.indexOf("MSIE") > -1)) {
	  	finalWidth = finalWidth + 16
	  }
	  finalHeight = 590
  }
  */
  x.resizeTo(finalWidth, finalHeight); 
  showFirst();
}


function updateWindowSize(wLayer, extraHt){
	resizeWinTo( wLayer, extraHt );
	window.focus();
}

function gotoSection(wSect){
	if (opener) {
		opener.focus();
		opener.document.location.href = "/"+wSect;
		window.self.close();
	} else {
		window.open("/"+wSect);
		window.self.close();
	}
}
	
function nextImage(){
	if (selImg < count) {
		theObj = new getObj('itemImg' + selImg);
		theObj.style.visibility = 'hidden';
		theObj.style.display = 'none';
		selImg++;
		theObj = new getObj('itemImg' + selImg);
		theObj.style.visibility = 'visible';
		theObj.style.display = 'block';
	}
}

function prevImage(){
	if (selImg > 1) {
		theObj = new getObj('itemImg' + selImg);
		theObj.style.visibility = 'hidden';
		theObj.style.display = 'none';
		selImg--;
		theObj = new getObj('itemImg' + selImg);
		theObj.style.visibility = 'visible';
		theObj.style.display = 'block';
	}
}

function setTallest(){
	for (i=1; i<=count; i++) {
		theObj = new getObj('itemImg'+i);
		oH = theObj.obj.clip ? theObj.obj.clip.height : theObj.obj.offsetHeight;
		theMaxHeight = Math.max(theMaxHeight, oH);
	}
	theObj = new getObj('cont');
	if (theObj.obj.clip) {
		theObj.obj.clip.height = theMaxHeight+(bodyPadding*2);
	} else {
		theObj.style.height = (theMaxHeight+(bodyPadding*2))+'px';
	}
	theObj = new getObj('contImgs');
	if (theObj.obj.clip) {
		theObj.obj.clip.height = theMaxHeight;
	} else {
		theObj.style.height = theMaxHeight+'px';
	}
	//alert("theMaxHeight: "+theMaxHeight);
}

function hideImages(){
	for (i=1; i<=count; i++) {
		theObj = new getObj('itemImg'+i);
		oH = theObj.obj.clip ? theObj.obj.clip.height : theObj.obj.offsetHeight;
		if (theObj.obj.clip) {
			theObj.style.posTop = ((theMaxHeight - oH)/2)+bodyPadding;
		} else {
			theObj.style.marginTop = (((theMaxHeight - oH)/2)+bodyPadding)+'px';
		}
		//alert("image"+i+" height: "+oH +  " ___ image"+i+" topPos: "+((theMaxHeight - oH)/2) + " marginTop: " + theObj.style.marginTop);
		if (i > 1) {
			theObj.style.visibility = 'hidden';
			theObj.style.display = 'none';
		}
	}
}

function showFirst(){
	theObj = new getObj('contImgs');
	theObj.style.visibility = 'visible';
}



