
function getElementsByStyleClass(className) 
{
  var all = document.all ? document.all :
    document.getElementsByTagName('*');
  var elements = new Array();
  for (var e = 0; e < all.length; e++)
    if (all[e].className == className)
      elements[elements.length] = all[e];
  return elements;
}


function HideAllNewsItems()
{
	// In case show hide not supported by older browsers only do hide if show is also possible otherwise display all
	if (document.getElementsByTagName)
	{
		var nlinks = getElementsByStyleClass('newsitem');
		var i=0;
			for (i=0; i<nlinks.length; i++)
			{
				nlinks[i].style.display = "none";
			}
	}
}

function ToggleNewsItem(DivId, LinkId)
{
	// if item already displayed then hide and vice versa
	if (document.getElementById(DivId).style.display == "none")
	{
		document.getElementById(DivId).style.display = "inline";
		document.getElementById(LinkId).innerHTML = 'Close Item';
	}
	else
	{
		document.getElementById(DivId).style.display = "none";
		document.getElementById(LinkId).innerHTML = 'more...';
	}
}

function FlipGallery(url)
{
	window.location.href = url;
}

function popupWin(link,attribs) { 
    var popupWin = null; 
    popupWin = window.open(link,'winPopup',attribs);  
}

function popupWindows() { 
    if(!document.getElementsByTagName) { 
         return; 
    } 
    var scrW = screen.availWidth; 
    var scrH = screen.availHeight; 
    var anchors = document.getElementsByTagName("a"); 
    for (var i = 0; i < anchors.length; i++) { 
         var anchor = anchors[i]; 
         var linkDest = anchor.getAttribute("href"); 
         var relIndex = anchor.getAttribute("rel"); 
         var relSplit = relIndex.split("x"); 
         var windowAttributes = ""; 
         if(relSplit[0] == "popup") { 
              if (relSplit[1] > scrW) { 
                 pW = scrW - 10; 
              } 
              else { 
                 pW = relSplit[1]; 
              } 
              if (relSplit[2] > scrH) { 
                 pH = scrH - 40; 
              } 
              else { 
                 pH = relSplit[2]; 
              } 
              scrX = (scrW - pW - 10) * .5; 
              //scrY = (scrH - pH - 30) * .5; 
              scrY = 0;
              var windowAttributes = "width=" + pW + ",height=" + pH + ",left=" + scrX + ",top=" + scrY + ",screenX=" + scrX + ",screenY=" + scrY; 
              windowAttributes += ",location=" + relSplit[4] + ",toolbar=" + relSplit[4] + ",menubar=" + relSplit[4] + ",resizable=" + relSplit[4] + ",scrollbars=" + relSplit[4]; 
              anchor.setAttribute("href", "javascript:popupWin('" + linkDest + "','" + windowAttributes + "')"); 
         } 
    } 
} 

window.onload = popupWindows;