/*
    Written by Jonathan Snook, http://www.snook.ca/jonathan
    Add-ons by Robert Nyman, http://www.robertnyman.com
*/

function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && document.all)? document.all : 
    oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}

/*
    opens link or image in pop up window
*/
function popUp(objLink, w, h) {
	day = new Date();
    windowid = day.getTime();
	window.open(objLink.href, windowid, "width="+w+",height="+h+",scrollbars=yes,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=no");
}

/*
    sends page to printer
*/
function printit(){
	if (window.print) {
		window.print();
	}
	else {
		alert('Please use the print feature of your browser.');
	}
} 

/*
	hides and shows the case study baloon graphic
*/
function showHideBallon(theLink)
{

	var arrImages = theLink.childNodes;
	
	var intLength;
	
	// find the case balloon
	intLength = arrImages.length;
	
	for (i=0; i<intLength;i++){ 
		if(arrImages[i].className == "caseballoon")
		{
			arrImages[i].className = "caseballoonshow";
		}
		else if(arrImages[i].className == "caseballoonshow")
		{
			arrImages[i].className = "caseballoon";
		}
	}
}


/*
	Swaps out details of other project thumbnails and shows popups
*/
function openProj(theImage, imgHeight, imgWidth) {
	var imgWindowHeight;
	var imgWindowWidth;
	day = new Date();
    windowid = day.getTime();
	
	if (document.getElementById && !document.all) 
	{
		imgWindowHeight = imgHeight;
		imgWindowWidth = imgWidth;
	}
	else if (document.getElementById) 
	{
		// for internet explorer
		imgWindowHeight = (+imgHeight) + 4;
		imgWindowWidth = (+imgWidth) + 19;
	}
	else
	{
		imgWindowHeight = imgHeight;
		imgWindowWidth = imgWidth;
	}
	window.open('/results/showcase.aspx?image=' + theImage + '&width=' + imgWidth + '&height=' + imgHeight, windowid, 'width=' + imgWindowWidth + ',height=' + imgWindowHeight + ',resizable,scrollbars=yes');
}

var state = 'none';

function swapProj(layer_ref) {

varSection = document.getElementById('opdetails');
varDivs = varSection.getElementsByTagName('div');

for (var i = 0; i < varDivs.length; i++) {
   varDivs[i].style.display = 'none';
}

if (state == 'block') {
state = 'none';
}
else {
state = 'block';
}

if (document.all) { //IS IE 4 or 5 (or 6 beta)
var divStyle = eval( "document.all." + layer_ref + ".style.display");
  if (divStyle == 'none') {
      state = 'block';
   }
   else if (divStyle == '') {
      state = 'block';
   }
   else {
      state = 'none';
   }
eval( "document.all." + layer_ref + ".style.display = state");
}
if (document.layers) { //IS NETSCAPE 4 or below
document.layers[layer_ref].display = state;

}
if (document.getElementById &&!document.all) {
hza = document.getElementById(layer_ref);
var divStyle = hza.style.display;
   if (divStyle == 'none') {
      state = 'block';
   }
   else if (divStyle == '') {
      state = 'block';
   }
   else {
      state = 'none';
   }
hza.style.display = state;
}
}