// IE (ie Microsoft) really makes things hard...
//
var sUserAgent = navigator.userAgent.toLowerCase();
var isOp = (sUserAgent.indexOf('opera')!=-1)?true:false;
var isIE = /*@cc_on!@*/false;
var Browser = { // from: http://obvcode.blogspot.com/2007/11/easiest-way-to-check-ie-version-with.html
  // returns 999, or the version of MSIE so a check like:
  // if (Browser.Version() < 7) ( >= 7) works.. 
  Version: function() {
    var version = 999; // we assume a sane browser
    if (isIE) // navigator.appVersion.indexOf("MSIE") != -1)
      // bah, IE again, lets downgrade version number
      version = parseFloat(navigator.appVersion.split("MSIE")[1]);
    return version;
  }
}

var popwindow = null;

if (/msie/i.test (navigator.userAgent)) //only override IE
// Found at: http://www.sixteensmallstones.org/ie-javascript-bugs-overriding-internet-explorers-documentgetelementbyid-to-be-w3c-compliant-exposes-an-additional-bug-in-getattributes
{
 document.nativeGetElementById = document.getElementById;
 document.getElementById = function(id)
  {
   var elem = document.nativeGetElementById(id);
   if(elem) {
     //make sure that it is a valid match on id
     if(elem.attributes['id'].value == id) {
       return elem;
     } else {
       //otherwise find the correct element
       for(var i=1;i<document.all[id].length;i++) {
         if(document.all[id][i].attributes['id'].value == id) {
	   return document.all[id][i];
	 }
       }
     }
   }
   return null;
 };
}


function popup (url, wid, width, hei) {
  var  WinOpts='scrollbars=yes,resizable=yes,status=yes,toolbar=yes,directories=0,copyhistory=0';
  var FullWinOpts=WinOpts + ",width=" + width + ",height=" + hei;

  if (popwindow && popwindow.open && !popwindow.closed) 
    popwindow.close();

  popwindow=window.open(url, wid, FullWinOpts);
  // give it focus
  if (popwindow && !isOp) popwindow.focus();

  return (popwindow)? false : true;
}
// Usage: 
// Styles:  .show { display: block; visibility: visible;}
//          .hide { display: none;  visibility: hidden;}
//<div id="id2" class="show">
//<a href="javascript:toggleVisible('id2')">more...</a>
//</div>
//<div id="id2h" class="hide">
//<a href="javascript:toggleVisible('id2')">Hide..</div>.</a>
//<p>
//This is hidden for a while...
//</div>

function toggleVisible(nameID) {
  var ele1 = document.getElementById(nameID);
  var ele2 = document.getElementById(nameID + 'h');
  var cn;
  cn = "class";
  if (Browser.Version() <= 7 ) {
    cn = "className";
  }
  // if 'show' is within the class name
  if (ele1.getAttribute(cn).indexOf('show') != -1) {
   ele1.setAttribute(cn, "hide");
   ele2.setAttribute(cn, "show");
   ele2.setAttribute("className", "show");
  } else {
   ele2.setAttribute(cn, "hide");
   ele1.setAttribute(cn, "show");
  }
return;
} 

