// Common Scripts used throughout the site


// ****** takes focus away from all links when clicked (IE PC only)
function blurAll() { 
 if(document.all) {
   var total = document.links.length;
   for (var n = 0; n < total; n++){
   document.links[n].onfocus=document.links[n].blur;
   }
 }
}

// ****** shows and hides content (DOM only)
  function showElement(elmnt)
  {
		if (document.getElementById(elmnt) && document.getElementById(elmnt).innerHTML != "") {
		document.getElementById(elmnt).style.visibility="visible";
		document.getElementById(elmnt).style.display="";
		}
  }
  function hideElement(elmnt)
  {
    if (document.getElementById(elmnt))
    {
      document.getElementById(elmnt).style.visibility="hidden";
      document.getElementById(elmnt).style.display="none";
    }
  }

  function toggleElement(elmnt)
  {
    var div = document.getElementById(elmnt);
    if (div.style.visibility == 'hidden')
      showElement(elmnt);
    else
      hideElement(elmnt);
  }
  
  
// ****** swaps class
function toggleDisplay(elem, class1, class2) {
  if(!(elem)) return null;
  if (elem.className == class1) {
    elem.className=class2;
  }
  else {
    elem.className=class1;
  }
}

// ****** opens link in popup window
 function openWin(url) { 
    topL=130;
    leftL=40;
    width=540;
    height=410;    
    bar=1;      
    wName='popUp';
    width = (arguments.length>1)?arguments[1]:width; // option to pass in width
    bar = (arguments.length>2)?arguments[2]:bar; // option to turn scrollbar on
    wName = (arguments.length>3)?arguments[3]:wName; // option to pass in window name 
    height = (arguments.length>4)?arguments[4]:height; // option to pass in height       
    
    var str="toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="+ bar +",width="+ width +",height="+ height +",screenX="+ leftL +",screenY="+ topL +",left="+ leftL +",top="+ topL +",resizable=1";
    var Pwin = window.open(url,wName,str,true)
    Pwin.focus();

}

function trim(str) {
	return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

