		function search_focus() {
			var q = document.getElementById('q');
			if ( q.value == 'SEARCH' ) q.value = ''
		}
		function search_blur() {
			var q = document.getElementById('q');
			if ( q.value == '' ) q.value = 'SEARCH'		
		}


function tools(t) {

	var tools_container = document.getElementById('tools');
	var tools_bookmark = document.getElementById('tools_bookmark');
	var tools_facebook = document.getElementById('tools_facebook');
	
	switch( t ) {

		case 'bookmark' :
			tools_container.className = 'tools_bookmark';
			tools_bookmark.src = 'media/images/tools_bookmark_on.png';
			tools_facebook.src = 'media/images/tools_facebook.png';
			break;

		case 'facebook' :
			tools_container.className = 'tools_facebook';
			tools_bookmark.src = 'media/images/tools_bookmark.png';
			tools_facebook.src = 'media/images/tools_facebook_on.png';
			break;
	
	
		default :
			tools_container.className = '';
			tools_bookmark.src = 'media/images/tools_bookmark.png';
			tools_facebook.src = 'media/images/tools_facebook.png';
			break;
	
	}
	
}



/* INSTALLED FUNCTIONS */
function bookmark_page( url, title ) { if (window.sidebar) { window.sidebar.addPanel(title, url, ""); } else if(window.opera && window.print) { var elem = document.createElement('a'); elem.setAttribute('href',url); elem.setAttribute('title',title); elem.setAttribute('rel','sidebar'); elem.click(); } else if(document.all) { window.external.AddFavorite(url, title); } return true; }
function make_web_friendly(str) { str = str.toLowerCase(); str = str.replace(!/^[a-z0-9]/gi, ""); str = str.replace(/  /g, " ").trim(); str = str.substring(0, str.Length <= 45 ? str.Length : 45).trim(); str = str.replace(/ /g, "-"); str = str.replace(/&/g, "and"); return str; }
function trim(str, chars) { return ltrim(rtrim(str, chars), chars); }
function ltrim(str, chars) { chars = chars || "\\s"; return str.replace(new RegExp("^[" + chars + "]+", "g"), ""); }
function rtrim(str, chars) { chars = chars || "\\s"; return str.replace(new RegExp("[" + chars + "]+$", "g"), ""); }

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

	function limit_characters( limit_field_el, limit_count_field_el, limit_num ) {
		var limit_field = document.getElementById(limit_field_el);
		var limit_count_field = document.getElementById(limit_count_field_el);
		if ( limit_field != undefined ) {
			if ( limit_field.value.length > limit_num ) {
				limit_field.value = limit_field.value.substring( 0, limit_num );
			} else {
				limit_count_field.innerHTML	= (limit_num - limit_field.value.length) + ' characters remaining';
			}		
		}	
	}

	function get_url_parameter( name ) {
		name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
		var regexS = "[\\?&]"+name+"=([^&#]*)";
		var regex = new RegExp( regexS );
		var results = regex.exec( window.location.href );
		if( results == null ) {
			return "";
		} else {
			return results[1];
		}
	}
	
		function date_to_unixtime(target_field, month_el, day_el, year_el, hour_el, minute_el) {
		var target = document.getElementById(target_field);
		var year = document.getElementById(year_el).value;
		var month = document.getElementById(month_el).value;
		var day = document.getElementById(day_el).value;
		var hour = document.getElementById(hour_el).value;
		var minute = document.getElementById(minute_el).value;
		var second = '01';
		
		var errors = 0;
		var error_message = 'The following elements appear to be missing or incorrect' + "\n";
		if ( year.length != 4 ) {
			error_message += ' - you must enter a 4 digit year' + "\n";
			errors = 1;
		}
		if ( month > 12 ) {
			error_message += ' - the month must be between 1 and 12' + "\n";
			errors = 1;
		}
		if ( day > 31 ) {
			error_message += ' - the day must be between 1 and 31' + "\n";
			errors = 1;
		}
		if ( hour > 24 ) {
			error_message += ' - the hour must be 24 hour (e.g. 13 = 1pm)' + "\n";
			errors = 1;
		}
		if ( minute > 59 ) {
			error_message += ' - the minutes must be between 0 and 59' + "\n";
			errors = 1;
		}
		if ( errors == 1 ) {
			alert( error_message );
		} else {
			var humDate = new Date(Date.UTC(year, (nozeros(month)-1), nozeros(day), nozeros(hour), nozeros(minute), nozeros(second))); 
			target.value = (humDate.getTime()/1000.0);
		}
	
	}
	
	function get_current_page() {
		var fullpath = location.pathname;
		var patharray = fullpath.split('/');
		var folderposition = patharray.length - 1;
		var filename = patharray[folderposition];
		var filearray = filename.split('.');
		var nav = filearray[0];
		return nav;
	}

	function toggle (el) {
		if ( document.getElementById(el) == undefined ) return false;
		if ( document.getElementById(el).style.display == 'none' ) {
			document.getElementById(el).style.display = '';
		} else {
			document.getElementById(el).style.display = 'none';
		}
		return true;
	}


	function show (el) {
		if ( document.getElementById(el) != undefined ) document.getElementById(el).style.display = '';
	}
	
		function hide (el) {
		if ( document.getElementById(el) != undefined ) document.getElementById(el).style.display = 'none';
	}
	
	function initiate_ajax() {
		var xmlHttp;
		try {

			// Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
		}
		catch (e) {

			// Internet Explorer
			try {
				xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e) {
				try {
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e) {
					alert("Your browser does not support AJAX!");
					return false;
				}
			}
		}
		return xmlHttp;
	}


