if (document.getElementsByTagName && document.getElementsByClassName  ) {
	// Create a link to the Javascript-only stylesheet

	var $link_element1 = document.createElement('link');
	$link_element1.setAttribute("rel","stylesheet");
	$link_element1.setAttribute("href","css/javascript_only.css");
	$link_element1.setAttribute("media","screen");
	

	// Append this stylesheet link to the document
	var $head_element = document.getElementsByTagName('head')[0];
	$head_element.appendChild($link_element1);
}


function init(){

	/*
	 * Not ALL pages have the search widget - check by looking for an instance of the id searchType
	 */
	if ($('searchType')) {
	
		/*
		 * Hide the advanced link when the home page loads
		 */
		$('searchAdvanced').hide();
		
		var searchOptions = $$('#searchInner form ul li a')
		searchOptions.each(function(link){
			link.onclick = function(){
				searchOptions.each(function(l){
					l.removeClassName('active') // close all 
				})
				
				this.addClassName('active')
				
				
				var mySearchRel = link.getAttribute('rel');
				
				
				if ($('searchType')) {
					var searchType = $('searchType');
					searchType.setAttribute('value', link.getAttribute('rel'))
				}
				
				if ($('searchAdvanced')) {
				
					var searchAdvanced = $('searchAdvanced');
					
					if (mySearchRel == 'website') {
						searchAdvanced.hide();
					}
					
					if (mySearchRel == 'news') {
						searchAdvanced.setAttribute('href', '/news-and-events/news/');
						searchAdvanced.show();
					}
					
					if (mySearchRel == 'resources') {
						searchAdvanced.setAttribute('href', '/resources-and-networks/resources-library/');
						searchAdvanced.show();
					}
					
				}
				
			}
			
			
			
			
		})
		
	}
	
	
	if ($('print') ){
		var print=$('print');
		print.onclick=function(){
		window.print();
		}
	}
	if ($('printPage') ){
		var printPage=$('printPage');
		printPage.onclick=function(){
		window.print();
		}
	}	

	var c = readCookie("style");	

	
	
	if ($('small') ){
		var small=$('small');
		small.onclick=function(){
			setActiveStyleSheet('small text'); 
			removeActiveSize();
			small.addClassName('active');return false;
		}
		if (c=='small text') small.addClassName('active')
	}
	if ($('medium') ){
		var medium=$('medium');
		medium.onclick=function(){
			setActiveStyleSheet('medium text'); 
			removeActiveSize();
			medium.addClassName('active');return false;
		}
		if (c=='medium text') medium.addClassName('active')

	}
	if ($('large') ){
		var large=$('large');
		large.onclick=function(l){
			setActiveStyleSheet('large text'); 
			removeActiveSize();
			large.addClassName('active');return false;
			
		}
			if (c=='large text') large.addClassName('active')
	}
	function removeActiveSize(){
		$$('#textSize a').each(function(textSizeLink){
			textSizeLink.removeClassName('active')
		})
	}
	

	

	
}



Event.observe(window, 'load', init, false);
// addEvent(window,'load',init)
