/** Fn move_box sets position of the div element relative to the calling link */
function move_box (an, box, offsetleft, offsettop) {
  var cleft = offsetleft;
  var ctop = offsettop;
  var obj = an;
  while (obj.offsetParent) {
    cleft += obj.offsetLeft;
    ctop += obj.offsetTop;
    obj = obj.offsetParent;
  }
  box.style.left = cleft + 'px';
// replace 0 with an integer to offset the vertical position 
  ctop += an.offsetHeight + 0;
  if (document.body.currentStyle &&
    document.body.currentStyle['marginTop']) {
    ctop += parseInt(
      document.body.currentStyle['marginTop']);
  }
  box.style.top = ctop + 'px';
}

/** Scripts for creating popup iframes on page by mousing over anchor links
 * <a href="file_to_display_in_box" onMouseOver="return show_hide_box(this,'div_element_id',304,346,'2px solid orange','no',-145,-5)" onMouseOut="hide('div_element_id')">click here</a>
<div id="div_element_id" style="display:none;" onMouseOver="show('div_element_id')" onMouseOut="hide('div_element_id')"></div>*/
function show_hide_box (an, div_id, width, height, borderStyle, scroll, shiftleft, shifttop) {
var href = an.href;
var boxdiv = document.getElementById(div_id);
var scr = scroll;
// if boxdiv (var representing div element) exists, display it; for browsers that conform to W3C DOM
  if (boxdiv != null)
  {
    if (boxdiv.style.display=='none') 
	{
	// if the iframe sub-element does not exist yet, create it
	var iframe_exists = document.getElementById(div_id + '_i');
	if (iframe_exists == null)
		{
		// create iframe sub-element within the existing div element
		var contents = document.createElement('iframe');
		contents.setAttribute('id', div_id + '_i');
		contents.scrolling = scr;
		contents.frameBorder = '0';
		contents.style.width = width + 'px';
		contents.style.height = height + 'px';
		contents.src = href;
		boxdiv.appendChild(contents);
		document.body.appendChild(boxdiv);
		}
	// set the div element parameters
	boxdiv.style.position = 'absolute';
	boxdiv.style.width = width + 'px';
	boxdiv.style.height = height + 'px';
	boxdiv.style.border = borderStyle;
	boxdiv.style.backgroundColor = '#fff';
	// position div element and display
	move_box(an, boxdiv, shiftleft, shifttop);
	boxdiv.style.display='block';
    }
	else
	{
	boxdiv.style.display='none';
    }
    return false;
  }
  return false;
}

function getStyleObject(objectId) {
 // cross-browser function to get an object's style object given its id
 if(document.getElementById && document.getElementById(objectId)) {
   // W3C DOM
   return document.getElementById(objectId).style;
 } else if (document.all && document.all(objectId)) {
   // MSIE 4 DOM
   return document.all(objectId).style;
 } else if (document.layers && document.layers[objectId]) {
   // NN 4 DOM.. note: this won't find nested layers
   return document.layers[objectId];
 } else {
   return false;
 }
}

function changeObjectDisplay(objectId, newDisplay) {
// get a reference to the cross-browser style object and make sure the object exists
var styleObject = getStyleObject(objectId);
if(styleObject) {
  styleObject.display = newDisplay;
  return true;
} else {
  // we couldn't find the object, so we can't change its visibility
  return false;
	}
}

function hide(elemId) {
changeObjectDisplay(elemId, 'none');
}
function show(elemId){
changeObjectDisplay(elemId, '');
}

/** eg, <a href="#" onclick="toggleObjectDisplay('iwb_dest_checklist'); return false;" title="View and select individual properties to search">On or Off</a> */
function toggleObjectDisplay(objectId) {
  // get a reference to the cross-browser style object and make sure the object exists
 var styleObject = getStyleObject(objectId);
 if(styleObject) 
 {
   if(styleObject.display=='none') 
	 {
  styleObject.display = '';
  return true;
 }
else
 {
  styleObject.display = 'none';
  return true;
 }
 } else {
   // we couldn't find the object, so we can't change its visibility
   return false;
 }
}

/** eg, <a href="#" onclick="toggleObjectDisplay('iwb_dest_checklist'); toggleImage(this,'toggle_hide_properties_link.gif','toggle_show_properties_link.gif'); return false;" title="View and select individual properties to search">On or Off</a> */
function toggleImage(src_element, imgSrc1, imgSrc2) {
  // get a reference to the image source object and make sure it exists
image = src_element.getElementsByTagName('img')[0];
 if(image) 
 {
 	image.src = image.src.match(imgSrc1) ? imgSrc2 : imgSrc1;
	return true;
 } else {
   // we couldn't find the image, so we can't change its source
   return false;
 }
}

// a href="JavaScript:openWindow('height=475,width=700,menubar=1,resizable=yes,scrollbars=yes,location=no','url','windowname')"
function openWindowWithSpecs(url,windowname,specs)
{window.open(url, windowname, specs)}