var doform = false; 


// clear text in the search box.
function clear_people_search()
{
    if (document.getElementById('p-q').value == 'search')
    {
        document.getElementById('p-q').value = '';
    }
}

// clear text in the search box.
function clear_search()
{
    if (document.getElementById('f-q').value == 'search')
    {
        document.getElementById('f-q').value = '';
    }
}

function init() {
       // quit if this function has already been called
       if (arguments.callee.done) return;

       // flag this function so we don't do the same thing twice
       arguments.callee.done = true;

       init_page();
   };

   /* for Mozilla */
   if (document.addEventListener) {
       document.addEventListener("DOMContentLoaded", init, null);
   }

// for Internet Explorer (using conditional comments)
/*@cc_on @*/
/*@if (@_win32)
document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
var script = document.getElementById("__ie_onload");
script.onreadystatechange = function() {
    if (this.readyState == "complete") {
        init(); // call the onload handler
    }
};
/*@end @*/


   /* for other browsers */
   window.onload = init;
   
function init_page()
{ 
	init_rollovers();
	init_backbutton();
}



function init_backbutton()
{
    //if we don't support getElementById then exit
	if (!document.getElementById || !document.getElementById('backbutton')) return;
	
	var spanback = document.getElementById('backbutton');
	spanback.innerHTML = '<a href="#" onclick="history.back(); return false;">Back button</a>';
}

/** note this puts roll over on image, not href **/
function init_rollovers()
{
    //if we don't support getElementById then exit
	if (!document.getElementById) return
	
	//yes it even does preload
	var aPreLoad = new Array();
	var aImages  = new Array();
	var sTempSrc;

    //nb if you want all images on page  you do this instead (i only wanted nav)
    var aImages = document.getElementsByTagName("img");


    //loop over images
	for (var i = 0; i < aImages.length; i++)
	{	
	    //we use class name to find image	
		if (aImages[i].className.match('img-o'))
		{
		    //grab src
			var src = aImages[i].getAttribute('src');

			//grab extension (neato works for gif and jpg nd png if you so feel)
			var ftype = src.substring(src.lastIndexOf('.'), src.length);

			//create a new attribute for rollover (for fyi = '-over')
			var hsrc = src.replace(ftype, '-h'+ftype);
			aImages[i].setAttribute('hsrc', hsrc);

			//PRELOAD !!
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;

			//on mouseover grab hsrc
			aImages[i].onmouseover = function()
			{
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	

			//on mouse out strip out "on"
			aImages[i].onmouseout = function()
			{
			    //alert(sTempSrc);
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('-h'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
	
    var aImages = document.getElementsByTagName("input");


    //loop over images
	for (var i = 0; i < aImages.length; i++)
	{	
	    //we use class name to find image	
		if (aImages[i].className.match('img-o'))
		{
		    //grab src
			var src = aImages[i].getAttribute('src');

			//grab extension (neato works for gif and jpg nd png if you so feel)
			var ftype = src.substring(src.lastIndexOf('.'), src.length);

			//create a new attribute for rollover (for fyi = '-over')
			var hsrc = src.replace(ftype, '-h'+ftype);
			aImages[i].setAttribute('hsrc', hsrc);

			//PRELOAD !!
			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;

			//on mouseover grab hsrc
			aImages[i].onmouseover = function()
			{
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	

			//on mouse out strip out "on"
			aImages[i].onmouseout = function()
			{
			    //alert(sTempSrc);
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('-h'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}	
}