// JavaScript Document
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);  
}


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';
		
		theObj = new getObj('caption' + selImg);
		theObj.style.visibility = 'hidden';
		theObj.style.display = 'none';
		selImg++;
		theObj = new getObj('caption' + 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';
		
		theObj = new getObj('caption' + selImg);
		theObj.style.visibility = 'hidden';
		theObj.style.display = 'none';
		selImg--;
		theObj = new getObj('caption' + selImg);
		theObj.style.visibility = 'visible';
		theObj.style.display = 'block';
	}
}





function popupLinks() {
    var fileLink;
    if (document.getElementsByTagName('a')) {
        for (var i = 0; (fileLink = document.getElementsByTagName('a')[i]); i++) {
			if (fileLink.name != "") {
				fileLink.id = fileLink.name;
			}
			if (fileLink.href.indexOf('?page=') != -1) {
				fileLink.onclick = Function("gotoSection('" + fileLink.href.substring(fileLink.href.indexOf('?page=')) + "'); return false;");
				fileLink.href = "#";
			}
        }
    }
}
