// Copper Development Assocation, Inc. copper.org javascript file


// global variables for top navigation 'active' highlight for path
	var currentassetid = '',  currenttopnassetid = '',  currentassetidul = '',  currenttopnassetidul = '',  parentassetid = '',  parenttopnassetid = '',  parentassetidul = '',  parenttopnassetidul ='',  grandparentassetid = '',  grandparenttopnassetid = '',  grandparentassetidul = '', grandparenttopnassetidul = '', greatgrandparentassetid = '', greatgrandparenttopnassetid = '', greatgrandparentassetidul = '', greatgrandparenttopnassetidul = '', greatgreatgrandparentassetid = '', greatgreatgrandparenttopnassetid = '', greatgreatgrandparentassetidul = '', greatgreatgrandparenttopnassetidul = '';

	document.observe('dom:loaded', newFunction=function(){
		if(currenttopnassetid != ''){
			var currenttopnliarray = $A($$('li.'+currenttopnassetid+''));
			currenttopnliarray.each(function(ctopnli){
				Element.addClassName(ctopnli,'active');
			});
		}
		if(parenttopnassetid != ''){
			var parenttopnliarray = $A($$('li.'+parenttopnassetid+''));
			parenttopnliarray.each(function(ptopnli){
				Element.addClassName(ptopnli,'active');
			});
		}
		if(grandparenttopnassetid != ''){
			var grandparenttopnliarray = $A($$('li.'+grandparenttopnassetid+''));
			grandparenttopnliarray.each(function(gptopnli){
				Element.addClassName(gptopnli,'active');
			});
		}
		if(greatgrandparenttopnassetid != ''){
			var greatgrandparenttopnliarray = $A($$('li.'+greatgrandparenttopnassetid+''));
			greatgrandparenttopnliarray.each(function(ggptopnli){
				Element.addClassName(ggptopnli,'active');
			});
		}
		if(greatgreatgrandparenttopnassetid != ''){
			var greatgreatgrandparenttopnliarray = $A($$('li.'+greatgreatgrandparenttopnassetid+''));
			greatgreatgrandparenttopnliarray.each(function(ggptopnli){
				Element.addClassName(ggptopnli,'active');
			});
		}
	});

	//document.observe('dom:loaded', newFunction=function(){
	Event.observe(window, 'load', function() {
		checkFontCookie();
	});

// add a url to Favorites
var urlAddress; 
var pageName;


function addToFavorites(urlAddress,pageName) { 
if (window.external)
 { window.external.AddFavorite(urlAddress,pageName) } 
else { alert("Sorry! Your browser doesn't support this function."); } 
} 

// create a popup
function openPopUp(theURL,winName,widthn,heightn) { 
  var features = "'toolbar=no,locaton=no,scrollbars=yes,resizable=yes,width=" + widthn + ",height=" + heightn + "'";
  window.open(theURL,winName,features);
}

// legacy check form
function checkform(theForm){
	if (legalEmail(theForm.EMAIL.value) && !isNull(theForm.FULLNAME.value)){
		return true;
	} else {
		x = [];
		y = [];
		
		if (isNull(theForm.FULLNAME.value))
			x = 'Name field is required.';
		if (!legalEmail(theForm.EMAIL.value))
			y = 'Email address is not valid.';
		alert(x + '\n' + y);	
		return false;
	}
}

function isNull(val){
	if (val == null || val.length < 1 || val == '')
		return true;

	if (val.length > 1)
	{
		return isStringEmpty(val);
	}
	else
		return false;
}

function isStringEmpty(val){
	empty = true;
	for (i = 0; i < val.length; i++){
		if (val.charAt(i) != ' ')
		{
			empty = false;
			break;
		}	
	}
	return empty;
}

function legalEmail(val){
    var checkspace=new Boolean();
    var checkat=new Boolean();
    var checkdot=new Boolean();
    var i=0;
    var countAtsign = 0;
    
    for (i = 0; i < val.length; i++){  
	switch(val.charAt(i)){
		  case ' ': checkspace = true;continue;
		  case '@': checkat = true;countAtsign++;continue;
		  case '.': checkdot = true;continue;
	   }
    }

	
    if(checkspace == false && checkat == true && checkdot == true && countAtsign == 1){
	   checkspace=new Boolean();
	   checkat=new Boolean();
	   checkdot=new Boolean();
    }else{
	   checkspace=new Boolean();
	   checkat=new Boolean();
	   checkdot=new Boolean();		
       return false;
    }
    return true;
}


// begin cookie functions


function getCookie(c_name){
	if(document.cookie.length > 0){ 
		c_start=document.cookie.indexOf(c_name + "=");
		if(c_start!=-1){ 
			c_start=c_start + c_name.length+1 
			c_end=document.cookie.indexOf(";",c_start)
			if (c_end==-1) c_end=document.cookie.length
			return unescape(document.cookie.substring(c_start,c_end))
		} 
	}
	return "default";
}

function setCookie(c_name,value,expiredays){
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+expiredays)
	document.cookie=c_name+'=' + escape(value)+((expiredays==null) ? '' : '; expires='+exdate.toGMTString()) + '; path=/'
}

function checkFontCookie(){
	fontsize=getCookie('CUFontsize');
	if(fontsize!=null && fontsize!=""){
		if(fontsize=='small'){	
			Element.setStyle('bodycontent', {fontSize:'80%'} );
			return false;
		}
		if(fontsize=='large'){
			Element.setStyle('bodycontent', {fontSize:'140%'} );
			return false;			
		}
		if(fontsize=='default'){
			Element.setStyle('bodycontent', {fontSize:'100%'} );
			return false;			
		}
	}
	else{
		Element.setStyle('bodycontent', {fontSize:'100%'} );
		return false;
  	}
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


// end cookie functions


// begin font-size admustment

function fontsizeadjustment(){
	
		if(getCookie('CUFontsize')=='small'){
			document.write('<a href="#" onclick="$(\'bodycontent\').setStyle({fontSize:\'80%\'})\x3B $(\'smallfontsignifier\').writeAttribute(\'class\',\'active\').show()\x3B $(\'defaultfontsignifier\').writeAttribute(\'class\',\'\').show()\x3B $(\'largefontsignifier\').writeAttribute(\'class\',\'\').show()\x3B setCookie(\'CUFontsize\',\'small\',7)\x3B return false\x3B " title="Small font size" id="smallfontsignifier" class="active">A</a>');
			document.write('<a href="#" onclick="$(\'bodycontent\').setStyle({fontSize:\'100%\'})\x3B $(\'defaultfontsignifier\').writeAttribute(\'class\',\'active\').show()\x3B $(\'smallfontsignifier\').writeAttribute(\'class\',\'\').show()\x3B $(\'largefontsignifier\').writeAttribute(\'class\',\'\').show()\x3B setCookie(\'CUFontsize\',\'default\',7)\x3B return false\x3B " title="Medium font size" id="defaultfontsignifier">A</a>');
			document.write('<a href="#" onclick="$(\'bodycontent\').setStyle({fontSize:\'140%\'})\x3B $(\'largefontsignifier\').writeAttribute(\'class\',\'active\').show()\x3B $(\'defaultfontsignifier\').writeAttribute(\'class\',\'\').show()\x3B $(\'smallfontsignifier\').writeAttribute(\'class\',\'\').show()\x3B setCookie(\'CUFontsize\',\'large\',7)\x3B return false\x3B " title="Large font size" id="largefontsignifier">A</a>');
		}
		else if(getCookie('CUFontsize')=='default'){
			document.write('<a href="#" onclick="$(\'bodycontent\').setStyle({fontSize:\'80%\'})\x3B $(\'smallfontsignifier\').writeAttribute(\'class\',\'active\').show()\x3B $(\'defaultfontsignifier\').writeAttribute(\'class\',\'\').show()\x3B $(\'largefontsignifier\').writeAttribute(\'class\',\'\').show()\x3B setCookie(\'CUFontsize\',\'small\',7)\x3B return false\x3B " title="Small font size" id="smallfontsignifier">A</a>');
			document.write('<a href="#" onclick="$(\'bodycontent\').setStyle({fontSize:\'100%\'})\x3B $(\'defaultfontsignifier\').writeAttribute(\'class\',\'active\').show()\x3B $(\'smallfontsignifier\').writeAttribute(\'class\',\'\').show()\x3B $(\'largefontsignifier\').writeAttribute(\'class\',\'\').show()\x3B setCookie(\'CUFontsize\',\'default\',7)\x3B return false\x3B " title="Medium font size" id="defaultfontsignifier" class="active">A</a>');
			document.write('<a href="#" onclick="$(\'bodycontent\').setStyle({fontSize:\'140%\'})\x3B $(\'largefontsignifier\').writeAttribute(\'class\',\'active\').show()\x3B $(\'defaultfontsignifier\').writeAttribute(\'class\',\'\').show()\x3B $(\'smallfontsignifier\').writeAttribute(\'class\',\'\').show()\x3B setCookie(\'CUFontsize\',\'large\',7)\x3B return false\x3B " title="Large font size" id="largefontsignifier">A</a>');
		}
		else if(getCookie('CUFontsize')=='large'){
			document.write('<a href="#" onclick="$(\'bodycontent\').setStyle({fontSize:\'80%\'})\x3B $(\'smallfontsignifier\').writeAttribute(\'class\',\'active\').show()\x3B $(\'defaultfontsignifier\').writeAttribute(\'class\',\'\').show()\x3B $(\'largefontsignifier\').writeAttribute(\'class\',\'\').show()\x3B setCookie(\'CUFontsize\',\'small\',7)\x3B return false\x3B " title="Small font size" id="smallfontsignifier">A</a>');
			document.write('<a href="#" onclick="$(\'bodycontent\').setStyle({fontSize:\'100%\'})\x3B $(\'defaultfontsignifier\').writeAttribute(\'class\',\'active\').show()\x3B $(\'smallfontsignifier\').writeAttribute(\'class\',\'\').show()\x3B $(\'largefontsignifier\').writeAttribute(\'class\',\'\').show()\x3B setCookie(\'CUFontsize\',\'default\',7)\x3B return false\x3B " title="Medium font size" id="defaultfontsignifier">A</a>');
			document.write('<a href="#" onclick="$(\'bodycontent\').setStyle({fontSize:\'140%\'})\x3B $(\'largefontsignifier\').writeAttribute(\'class\',\'active\').show()\x3B $(\'defaultfontsignifier\').writeAttribute(\'class\',\'\').show()\x3B $(\'smallfontsignifier\').writeAttribute(\'class\',\'\').show()\x3B setCookie(\'CUFontsize\',\'large\',7)\x3B return false\x3B " title="Large font size" id="largefontsignifier" class="active">A</a>');
		}
		else{
			document.write('<a href="#" onclick="$(\'bodycontent\').setStyle({fontSize:\'80%\'})\x3B $(\'smallfontsignifier\').writeAttribute(\'class\',\'active\').show()\x3B $(\'defaultfontsignifier\').writeAttribute(\'class\',\'\').show()\x3B $(\'largefontsignifier\').writeAttribute(\'class\',\'\').show()\x3B setCookie(\'CUFontsize\',\'small\',7)\x3B return false\x3B " title="Small font size" id="smallfontsignifier">A</a>');
			document.write('<a href="#" onclick="$(\'bodycontent\').setStyle({fontSize:\'100%\'})\x3B $(\'defaultfontsignifier\').writeAttribute(\'class\',\'active\').show()\x3B $(\'smallfontsignifier\').writeAttribute(\'class\',\'\').show()\x3B $(\'largefontsignifier\').writeAttribute(\'class\',\'\').show()\x3B setCookie(\'CUFontsize\',\'default\',7)\x3B return false\x3B " title="Medium font size" id="defaultfontsignifier" class="active">A</a>');
			document.write('<a href="#" onclick="$(\'bodycontent\').setStyle({fontSize:\'140%\'})\x3B $(\'largefontsignifier\').writeAttribute(\'class\',\'active\').show()\x3B $(\'defaultfontsignifier\').writeAttribute(\'class\',\'\').show()\x3B $(\'smallfontsignifier\').writeAttribute(\'class\',\'\').show()\x3B setCookie(\'CUFontsize\',\'large\',7)\x3B return false\x3B " title="Large font size" id="largefontsignifier">A</a>');
		}
}

//


// added ability to add numerous onload functions via the addLoadEvent() method
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}




// begin IE 5.5 and IE6 support for transparent 24-bit PNG files
var supersleight	= function() {
	
	var root = false;
	var root = false;
	var applyPositioning = true;
	
	// Path to a transparent GIF image
	var shim			= '/scripts/x.gif';
	
	// RegExp to match above GIF image name
	var shim_pattern	= /x\.gif$/i;
	
	
	
	var fnLoadPngs = function() { 
		if (root) {
			root = $(root);
			if (root2){
				root2=$(root2);
			}else{
				root2 = root;
			}
		}else{
			root = document;
		}
		for (var i = root.all.length - 1, obj = null; (obj = root.all[i]); i--) {
			// background pngs
			if (obj.currentStyle.backgroundImage.match(/\.png/i) !== null) {
				bg_fnFixPng(obj);
			}
			// image elements
			if (obj.tagName=='IMG' && obj.src.match(/\.png$/i) !== null){
				el_fnFixPng(obj);
			}
			// apply position to 'active' elements
			if (applyPositioning && (obj.tagName=='A' || obj.tagName=='INPUT') && obj.style.position === ''){
				obj.style.position = 'relative';
			}
		}
			for (var k = root2.all.length - 1, obj = null; (obj = root2.all[k]); k--) {
			// background pngs
			if (obj.currentStyle.backgroundImage.match(/\.png/i) !== null) {
				bg_fnFixPng(obj);
			}
			// image elements
			if (obj.tagName=='IMG' && obj.src.match(/\.png$/i) !== null){
				el_fnFixPng(obj);
			}
			// apply position to 'active' elements
			if (applyPositioning && (obj.tagName=='A' || obj.tagName=='INPUT') && obj.style.position === ''){
				obj.style.position = 'relative';
			}
		}
	};

	var bg_fnFixPng = function(obj) {
		var mode = 'scale';
		var bg	= obj.currentStyle.backgroundImage;
		var src = bg.substring(5,bg.length-2);
		if (obj.currentStyle.backgroundRepeat == 'no-repeat') {
			mode = 'crop';
		}
		obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + mode + "')";
		obj.style.backgroundImage = 'url('+shim+')';
	};

	var el_fnFixPng = function(img) {
		var src = img.src;
		img.style.width = img.width + "px";
		img.style.height = img.height + "px";
		img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')";
		img.src = shim;
	};
	
	var addLoadEvent = function(func) {
		var oldonload = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			window.onload = function() {
				if (oldonload) {
					oldonload();
				}
				func();
			};
		}
	};
	
	return {
		init: function() { 
			addLoadEvent(fnLoadPngs);
		},
		
		limitTo: function(el,el2) {
			root = el;
			root2 = el2;
		},
		
		run: function() {
			fnLoadPngs();
		}
	};
}();

// limit to part of the page ... pass an ID to limitTo:
// supersleight.limitTo('header');

// supersleight.init();
// end IE 5.5 and IE6 support for transparent 24-bit PNG files


// begin adjust the width of imagecaptioncontainers if they exist
Event.observe(window, 'load', function() { 
	if($$('.imagecaptioncontainer')){
		var f = $$('div#primarycontent .imagecaptioncontainer');
		var s = [];
		var newSize=0;
		for(var i=0; i<f.size(); i++){
			// if multiple images, add to array
			s[0] = $(f[i]).down('img');
			if($(f[i]).down('img', 1)){
				s[1]=$(f[i]).down('img', 1);
			}
			if($(f[i]).down('img', 2)){
				s[2]=$(f[i]).down('img', 2);
			}
			
			s.each(function(j){
				var w = j.getWidth();
				newSize = parseInt(w);
				j.up('div').setStyle({width: newSize + 'px'});
			});
		}
	}

	if($$('.multiple')){ // for those imagecaptioncontainers with child <div/> tags
		var m = $$('.multiple');
		m.each(function(smx){
			var mNewSize=0;
			if($(smx).descendants('div')){
				var sm = smx.descendants('div');
				sm.each(function(sw){
					if($(sw).down()){
						var sx=$(sw).down();
						sx.up('div').setStyle({width:sx.getWidth() + 'px'});
						mNewSize =+ parseInt(mNewSize)+parseInt(sx.getWidth()) + parseInt(4);
					}
				});
			}
			$(smx).down('div.clear').setStyle({width:mNewSize + 'px'});
			if($(smx).down('p')){
				$(smx).down('p').setStyle({width:mNewSize + 'px'});
			}
			mNewSize=mNewSize+parseInt(10);
			$(smx).setStyle({width: mNewSize + 'px'});
			
		});
	}
	
	if($$('.initialimagecaption')){
		var d = $$('div#primarycontent .initialimagecaption');
		var c = [];
		var bnewSize='';
		for(var i=0; i<d.size(); i++){
			c = $(d[i]).down('img').getWidth();
			bnewSize = c + 'px';
			$(d[i]).setStyle({width: bnewSize});
		}	
	}

	if($$('.imagecaptioncontaineralternate')){
		var h = $$('div#primarycontent .imagecaptioncontaineralternate');
		var k = [];
		var cnewSize='';
		for(var i=0; i<h.size(); i++){
			k = $(h[i]).down('img').getWidth();
			cnewSize = k + 'px';
			$(h[i]).setStyle({width: cnewSize});
		}

	}
	
	var borders = $A($$('.primarytierborder'));
	borders.each(function(enumli){
		var parentw = enumli.up().getWidth();
		var parentwn = parseInt(parentw)-3;
		enumli.setStyle({'width':parentwn+'px'});
	});
	
});

// for pages that link to an ID or anchor - the page may jump after initialimagecaptioncontainer size adjustment - need to recorrect
Event.observe(window, 'load', function() {
	if($$('.imagecaptioncontaineralternate') || $$('.initialimagecaption') || $$('.imagecaptioncontainer')){			
			if (window.location.hash.length > 0){
				var match = window.location.href.match(/^[^#]+#([^?]*)\??(.*)/);
				var movePoint = match[1];
				Effect.ScrollTo(movePoint);
			}
	}
});

// end adjust size of imagecaptioncontainers if they exist


// next 2 functions remove ul tags on the top- and left-hand navigation if there are no child li nodes (CMS component limitations)
function destroyEmptyTopUls(){
	//if($$('#primarytiernav li ul.secondarytiernav li ul:empty').length > 0){
		if($$('#primarytiernav li ul.secondarytiernav li ul').length > 0){
		/**var ule = $$('#primarytiernav li ul.secondarytiernav li ul:empty');
		ule.each(function(topul){
			//console.log(topul.identify());
			topul.remove();
		});
		*/
		//$$('#primarytiernav li ul.secondarytiernav li ul:empty').each(function(topul){
		$$('#primarytiernav li ul.secondarytiernav li ul').each(function(topul){
			//console.log(topul.identify());
			if(topul.empty()){
				topul.remove();
			}
		});
		
		
	}
}

function destroyEmptyUls(){
	if($$('#tertiarytiercontainer ul:empty')){
		var ull = $$('#tertiarytiercontainer ul:empty');
		ull.each(function(leftul){
			leftul.remove();
		});
	}
}


// convert links to active class
function activate(aelement,parentelement){
	var anchorelement = aelement;
	var pelement = parentelement;
	//$(anchorelement).observe('click',function(event){
		elementslia = $(pelement).descendants();	
		elementslia.each(function(linknode){
			$(linknode).removeClassName('active');
		});
		$(anchorelement).addClassName('active');
	//});	
}


// destroy all empty UL tags created from CMS from Navbar component limitation
document.observe('dom:loaded', newFunction=function(){
	destroyEmptyTopUls();
	destroyEmptyUls();
});


// $cmasset
var styleSheetURL = '/css/copper_org.css';
// $/cmasset

// print the LightBox JS window
function printLightBox(){
	var newlbwin = window.open('','printwin','left=100,top=100,scrollbars=yes,width=600,height=600');
	newlbwin.document.open();
	newlbwin.document.write('<html><head>');
	newlbwin.document.write('<title>Print Page</title>\n');
	newlbwin.document.write('<link rel="stylesheet" type="text/css" href="' + styleSheetURL + '" />');
	newlbwin.document.write('</head>\n');
	//newlbwin.document.write('<body onload="window.print();window.close();">\n');
    newlbwin.document.write('<body onload="window.close();">');
    newlbwin.document.write('<img src="' + $('lightboxImage').readAttribute('src') + '" /><br/>\n');
	newlbwin.document.write($('imageDetails').innerHTML);
	newlbwin.document.write('</body>\n');
	newlbwin.document.write('</html>');
	newlbwin.print();
    newlbwin.document.close();
}


// print the LightWindow JS window
function printLightWindow(){
	var newlwwin = window.open('','printlwin','left=100,top=100,scrollbars=yes,width=600,height=600');
	newlwwin.document.open();
	newlwwin.document.write('<html><head>');
	newlwwin.document.write('<title>Print Page</title>\n');
	newlwwin.document.write('<link rel="stylesheet" type="text/css" href="' + styleSheetURL + '" />');
	newlwwin.document.write('</head>\n');
    newlwwin.document.write('<body onload="window.close();">');
	newlwwin.document.write($('primarycontent').innerHTML);
	newlwwin.document.write('</body>\n');
	newlwwin.document.write('</html>');
	newlwwin.print();
    newlwwin.document.close();
}

// print an element's contents in pop-up print window
function printElementWindow(DOMElement){
	var elem = DOMElement;
	var newEwin = window.open('','printlwin','left=100,top=100,scrollbars=yes,width=600,height=600');
	newEwin.document.open();
	newEwin.document.write('<html><head>');
	newEwin.document.write('<title>Print Page</title>\n');
	newEwin.document.write('<link rel="stylesheet" type="text/css" href="' + styleSheetURL + '" />');
	newEwin.document.write('</head>\n');
    newEwin.document.write('<body onload="window.close();">');
	newEwin.document.write('<div id="print-container">');
	newEwin.document.write($(elem).innerHTML);
	newEwin.document.write('</div>');
	newEwin.document.write('</body>\n');
	newEwin.document.write('</html>');
	newEwin.print();
    newEwin.document.close();
}


// reusable function to play CDA YouTube videos in a modal lightbox
// usage example:  <a href="javascript:youTubePlayer('http://www.youtube.com/v=fie8ef9f3i3');">Video A</a>
function youTubePlayer(url){
	var url = url;
	var embedcode = embedcode;
	var windown= 'YouTube'
	var win = new Window(windown,{className: "dialog", title: "CDA Video Player", 
	width:430,
	height:350,
	minimizable:false,
	maximizable:false,
	resizable:false,
	destroyOnClose:true,
	overlayShowEffectOptions: {duration:0.5}
	})
	win.setHTMLContent('<object height="344" width="425"><param name="movie" value="' + url + '"/><param name="allowFullScreen" value="true"/><param name="allowscriptaccess" value="always"/><embed allowfullscreen="true" allowscriptaccess="always" height="344" src="' + url + '" type="application/x-shockwave-flash" width="425"/></object>');
	win.showCenter(true);
	win.toFront();
}


// function to parse out specific URL parameters
function getPar(name){
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp( regexS );
	var tmpURL = window.location.href;
	var results = regex.exec( tmpURL );
	if( results == null )
		return "";
	else
		return results[1];
} // end getPar(name)

// prototypical date function that will be used in the following date parsing functions (like the 'new' badge)
Date.prototype.addMonths = function(n)
{
this.setMonth(this.getMonth()+n);
return this;
}


// function that scans a page and adds a 'new' badge when class:  'new' is applied to an object.  automatic, not reusable.
// use MM-dd-yyyy format.  like 03-15-2010
document.observe('dom:loaded', newFunction=function(){
	if($$('.new')){ // for those imagecaptioncontainers with child <div/> tags
		var n = $$('.new');
		n.each(function(newd){
			var d = $w(newd.className);
			d.each(function(dd){
				if(dd != 'new'){
					var dde = dd.substring(dd.length - 10);
      	              	dde = dde.replace(new RegExp('-','g'),'/');
					var newDate = new Date(dde);
					newDate = newDate.addMonths(4);
					var today = new Date();
					if(newDate > today){
						newd.insert({top:'<span class="new-badge">new</span>'});
					}
				}
			
			});
		});
	}
});


// function that updates the parent from an iFrame (for chrome compatibility) - necessary for use with lightwindow.js (which uses iFrames)
function updateParentURL(url){
	if(url){
		document.location=url;
	}
}


// function to open a hidden container
document.observe('dom:loaded', function(){
	$$('a.reveal-more').each(function(element){
    		element.observe('click', function(event){
      		var target = element.readAttribute('href');
			$(target).show();
			//Event.stop(event);
			event.preventDefault();
          });
	});

	$$('a.close-container').each(function(element){
    		element.observe('click', function(event){
			var target = element.up('div');
			$(target).hide();
			event.preventDefault();
          });
	});


});
// end opening hidden containers



// adds WebTrends tracking to the Sharethis social media buttons
// function to open a hidden container
Event.observe(window, 'load', function() {

	$$('li.st_twitter_large').invoke('observe','click', function(){
		dcsMultiTrack('DCS.dcssip','www.sharethis.com','DCS.dcsuri','/twitter','WT.ti','ShareThis Twitter share button','DCS.dcsqry','');
	});
	
	$$('.st_facebook_large').invoke('observe','click', function(event){
		dcsMultiTrack('DCS.dcssip','www.sharethis.com','DCS.dcsuri','/facebook','WT.ti','ShareThis Facebook share button','DCS.dcsqry','');
	});
	$$('.st_sharethis_large').invoke('observe','click', function(event){
		dcsMultiTrack('DCS.dcssip','www.sharethis.com','DCS.dcsuri','/sharethis','WT.ti','ShareThis share button','DCS.dcsqry','');
	});

	$$('li.st_email_large').invoke('observe','click',function(){
		dcsMultiTrack('DCS.dcssip','www.sharethis.com','DCS.dcsuri','/email','WT.ti','ShareThis Email share button','DCS.dcsqry','');	
	});
	
});
// ends adding WebTrends tracking to ShareThis social media buttons
