google.load("prototype", "1.6.0.3");

function resetFields(form) {
    for (var i = form.elements.length - 1; i >= 0; i--) {
        var element = form.elements[i];
        if (element.type == "submit") continue;
        if (!element.defaultValue) continue;
        element.onfocus = function() {
            if (this.value == this.defaultValue) this.value = "";
        }
        element.onblur = function() {
            if (this.value == "") this.value = this.defaultValue;
        }
    };
};

function prepareForms() {
    for (var i = document.forms.length - 1; i >= 0; i--) {
        resetFields(document.forms[i]);
    };
}

function selectImage(images, width, height, alt, path) {
    var max = images.length;
    var num = Math.floor((Math.random() * max));
    document.writeln(path);
    document.writeln("<img src='" + path + "' alt='" + alt + "' name='rotating photo' width='" + width + "' height='" + height + "' />");
}

startList = function() {
    //alert('function called');
    if (document.all && document.getElementById) {
        //alert('if statement called');
        var topnav = document.getElementById("topnavul");

        for (i = 0; i < topnav.childNodes.length; i++) {
            node = topnav.childNodes[i];
            if (node.nodeName == "LI") {
                node.onmouseover = function() {
                    this.className += " over";
                }
                node.onmouseout = function() {
                    this.className = this.className.replace(" over", "");
                }
            }
        }
    }
}

// Drop Downify Function
// This function takes the string of an ID of a UL and adds
// a mouseover event to add the "over" 
function dropDownify(str) {
	if(Prototype.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) == 6) {
		var list = $(str);
		if (list) {
			list.select('li').each(function(item) {
				item.setAttribute('onmouseover', function() {
					item.addClassName('over');
				});
				item.setAttribute('onmouseout', function() {
					item.removeClassName('over');
				});
			});
		}
	}
}

// search box clearing
function searchBox(boxid) {
	// if(!boxid) { boxid = 'site-search-query'; }
	if ( $(boxid)) {
		searchbox_value = $(boxid).value
		$('site-search-query').observe('focus', function(event) {
			if(escape(this.value)==escape(searchbox_value)) {
				this.value='';
			}
		}).observe('blur', function(event) {
			if(this.value=='') {
				this.value=searchbox_value;
			}
		});
	}
}

function dave() {
    alert('stilldavid');
}

