/*
	Standards Compliant Popup Script
	Author : Kevin Cannon
	http://www.multiblah.com
	Last Edited: 12.12.2004
	Version 1.0
	
	Searches through a document for links with the class popup.
	When clicked, this link will open in a popup window.
	This means you don't have to add javascript to your code, 
	and means the links continue to work, for search engines, 
	and browsers without javascript
	
*/

function toggleEWShow(rID)
{
   document.getElementById("ew-" + rID).style.display = "block";
   document.getElementById("ew-img-" + rID).innerHTML = "<a title='Show less Details' href='javascript: toggleEWShow2(" + rID + ");'><img src='images/ew-contract.jpg' /></a>";
}

function toggleEWShow2(rID)
{
   document.getElementById("ew-" + rID).style.display = "none";
   document.getElementById("ew-img-" + rID).innerHTML = "<a title='Show less Details' href='javascript: toggleEWShow(" + rID + ");'><img src='images/ew-expand.jpg' /></a>";   
}

function initPopups() {

	if (!document.getElementById) return
	
	var aLinks = document.getElementsByTagName('a');

	for (var i = 0; i < aLinks.length; i++) {		
		if (aLinks[i].className.indexOf('popup') >= 0 || aLinks[i].className.indexOf('external') >= 0) {
			
			if (aLinks[i].className.indexOf('popup') >= 0) {
				aLinks[i].onclick = function() {
					var url = this.href;
					openPopup(url,1);
					return false;
					}
				}
			else {
				aLinks[i].onclick = function() {
					var url = this.href;
					openPopup(url,0);
					return false;
					}
				}	
		}
	}
}

// popupWindow function
// This is where you set your specific height & width etc... for your popups.
function openPopup(url,popType) {
	if (popType==1)
		window.open(url, 'popupwindow', 'width=500,height=500,scrollbars,resizable'); 
	else
		window.open(url);
	return false;
}


// Piggy-back function onto onLoad event ............................................
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

addLoadEvent(initPopups);

var lastBox = false;
var lastBtn = false;

//MoreInfo box functions
function showMoreInfoBox(box,btn) {
	//hide any open more info box
	if (lastBox && lastBox.id != box) {
		lastBox.className = "moreInfoBox";
		lastBox = false;
	}
	
	//toggle any open more info button
	if ( (lastBtn && btn) && (lastBtn.id != btn.id) ) {
			lastBtn.innerHTML = "show more info";
			lastBtn.className= "showMoreInfoBtn";
	}
	
	
	var target = document.getElementById(box);
	
	if (target.className ==  "moreInfoBox")	{
		target.className = "showMoreInfoBox";

		if (btn) {
			btn.innerHTML = "c l o s e";
			btn.className= "hideMoreInfoBtn";
		}
		lastBox = target;
		lastBtn = btn;
	}
	else {
		target.className = "moreInfoBox";
		if (btn) {
			btn.innerHTML = "show more info";
			btn.className= "showMoreInfoBtn";
		}
	}
	return false;
}

function windowWidth() {
  var myWidth = 0
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}


