// site-wide javascript files go here

function MM_reloadPage(init) {//reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
//MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
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 && d.getElementById) x=d.getElementById(n); return x;
}

function showHideDivs() { //v6.0
var i,p,v,obj,args=showHideDivs.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
obj.display=v; }
}

// this function is needed to work around 
// a bug in IE related to element attributes
function hasClass(obj) {
   var result = false;
   if (obj.getAttributeNode("class") != null) {
       result = obj.getAttributeNode("class").value;
   }
   return result;
}   

function table_stripe(id) {

    // the flag we'll use to keep track of 
    // whether the current row is odd or even
    var even = false;
  
    // if arguments are provided to specify the colours
    // of the even & odd rows, then use the them;
    // otherwise use the following defaults:
    var evenColor = arguments[1] ? arguments[1] : "#DBE0DB";
    var oddColor = arguments[2] ? arguments[2] : "#CFCFCF";
  
    // obtain a reference to the desired table
    // if no such table exists, abort
    var table = document.getElementById(id);
    if (! table) { return; }
    
    // by definition, tables can have more than one tbody
    // element, so we'll have to get the list of child
    // &lt;tbody&gt;s 
    var tbodies = table.getElementsByTagName("tbody");

    // and iterate through them...
    for (var h = 0; h < tbodies.length; h++) {
    
     // find all the &lt;tr&gt; elements... 
      var trs = tbodies[h].getElementsByTagName("tr");
      
      // ... and iterate through them
      for (var i = 0; i < trs.length; i++) {

        // avoid rows that have a class attribute
        // or backgroundColor style
        if (! hasClass(trs[i]) &&
            ! trs[i].style.backgroundColor) {
 		  
          // get all the cells in this row...
          var tds = trs[i].getElementsByTagName("td");
        
          // and iterate through them...
          for (var j = 0; j < tds.length; j++) {
        
            var mytd = tds[j];

            // avoid cells that have a class attribute
            // or backgroundColor style
            if (! hasClass(mytd) &&
                ! mytd.style.backgroundColor) {
        
              mytd.style.backgroundColor =
                even ? evenColor : oddColor;
            
            }
          }
        }
        // flip from odd to even, or vice-versa
        even =  ! even;
      }
    }
  }
  
  // determines the maximum height of every div of a specified CSS class 
  // (e.g., used in directory rows)
  function matchheight(div_class) {
	var max = 0;
	var divs = document.getElementsByTagName("div");
	var class_divs = []
	for (var i = 0; i < divs.length; i++) {
		if (divs[i].className == div_class) {
			d = divs[i];
			class_divs[class_divs.length] = d
			var divheight = 0
			if (d.offsetHeight) {
				div_height = d.offsetHeight;
			} else if (d.style.pixelHeight) {
				div_height = d.style.pixelHeight
			}
			max = Math.max(max, div_height)
		}
	}
	
	for(var i = 0; i<class_divs.length; i++) {
		class_divs[i].style.height=max+"px"
	}
	//return max
  }
  
  // set the height of every element of a specified CSS class 
  // to the specified value
  function setheight(div_class, height) {
	var divs = document.getElementsByTagName("div");
	for (var i = 0; i < divs.length; i++) {
		if (divs[i].className == div_class) {
			divs[i].style.height = height;
		}
	}
  }

  // determines the maximum height of every div of a specified CSS class 
  // (e.g., used in directory rows)
  function matchwidth(div_class) {
	var max = 0;
	var divs = document.getElementsByTagName("div");
	var class_divs = []
	for (var i = 0; i < divs.length; i++) {
		if (divs[i].className == div_class) {
			d = divs[i];
			class_divs[class_divs.length] = d
			var div_width = 0
			if (d.offsetHeight) {
				div_width = d.offsetWidth;
			} else if (d.style.pixelHeight) {
				div_width = d.style.pixelWidth
			}
			max = Math.max(max, div_width)
		}
	}
	
	for(var i = 0; i<class_divs.length; i++) {
		class_divs[i].style.width=max + "px"
	}
	//return max
  }
  
  // set the height of every element of a specified CSS class 
  // to the specified value
  function setwidth(div_class, width) {
	var divs = document.getElementsByTagName("div");
	for (var i = 0; i < divs.length; i++) {
		if (divs[i].className == div_class) {
			divs[i].style.width = width;
		}
	}
  }
  
  function angelLogin() {
	document.angelLoginForm.submit();
  }

