// Contains standard JavaScript functions used by the website

// Adds an event handler to the onload event of the window object
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

function imgzoom(imgurl, width, height, comment){
	theImg=document.getElementById("imglarge");
	theImg.setAttribute("src", imgurl);
	theImg.setAttribute("width", width);
	theImg.setAttribute("height", height);
	
    theComment=document.getElementById("imgcomment");
    if( theComment == null )
	 	{ theComment=document.getElementById("imgcommenthidden"); 
		
	} else {
	
		if( comment != "" ) {
		    theComment.setAttribute("id", "imgcomment");
		    theComment.childNodes[0].nodeValue = comment;
		} else {
		    theComment.setAttribute("id", "imgcommenthidden");
		}

	}
	
	
}

// SHOW AND HIDE LAYERS

function toggleLayer(whichLayer)
{
    if (document.getElementById)
    {
        // this is the way the standards work
        var style2 = document.getElementById(whichLayer).style;
        style2.display = style2.display? "":"block";
    }
    else if (document.all)
    {
        var style2 = document.all[whichLayer].style;
        style2.display = style2.display? "":"block";
    }
    else if (document.layers)
    {
        // this is the way nn4 works
        var style2 = document.layers[whichLayer].style;
        style2.display = style2.display? "":"block";
    }
    if( whichLayer == "contactusthankyou" ) style2.display = "none";
}
if (whichLayer == "newsletter-popup-thankyou") {
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    var pageTracker = _gat._getTracker("UA-899811-1");
    pageTracker._setCampNameKey('contact forms');
    pageTracker._setCampMediumKey('newsletter form');
    pageTracker._setCampSourceKey('<?php $url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'];echo $url; ?>');
    pageTracker._setCampNOKey('ga_nooverride');
    //add campaign details  
    pageTracker._initData();
    pageTracker._trackPageview();
}

