var urlPath = "http://auburnattorney.com/";


// Attribute Selector Effects
// ------------------------------------------------------------------
// Developed by Greg Leuch, Virticle Corp (2006 January 02)
// (C) 2007 Virticle Corp <www.virticle.com> -- All Rights Reserved.
// DO NOT USE WITHOUT PERMISSION - FAILURE TO USE WIHTOUT PERMISSION
// WILL RESULT IN LEGAL AND CIVIL ACTIONS.
// ------------------------------------------------------------------
// Works in Gecko 1+ (Firefox/Mozilla/NS7+), Opera 7+, and IE7+.
// CSS use by using "class" attribute is tricky in earlier browsers.
//
// Searches through attribute values under specified element
// to find rollover instances.
//
// Use: <tag attr="-effect- src:-imgsrc-">
// Recommended: Use "class" attribute for XHTML Compliance and CSS
// styling options.
//
// Can be used with multiple attribute values.
// Ex. class="classname -effect-- src:-imgsrc-"
// (To ensure compatibility with all browsers supporting JavaScript,
// place required classname first, then rollover "classes")
//
// Can also be located for styling via CSS2 selectors
// Use: <style>*[attr~="-effect-"] {-code-}</style>
// ------------------------------------------------------------------
//

var attributeEffects = {
	init: function () {
		// Use: this.set(-attr-, -effect-, -func-, [-opt-...]);
		this.set("class", "hoverover", this.imgover, "this");
	}, 
	set: function (a, b, c, d, e) {
		var z = this.doFind(getElement(((e && e != "") ? e : "main")), a, b);
		if (z.length > 0) for (var i in z) c(z[i], b, a, d, objGetAttr(z[i], a));
	},

	// Image Rollover Effects
	imgover: function(a, b, c, d, e) {
		if (a && e != null) {
			var g = new RegExp("([\\S\\s]*)("+ b +" src:)([\\S]*)([\\S\\s]*)");
			var h = e.replace(g, "$3");
			if (e != h && h != "") {
				a.h = ((d == "parent") ? a.childNodes[0].src : a.src);
				a.j = h;
				a.k = new Image();
				a.k.l = a;
				a.k.onload = ((d == "parent") ? function() {this.l.childNodes[0].src = this.src; return false;} : function() {this.l.src = this.src; return false;});
				a.onmouseover = function() {this.k.src = urlPath+"site/images/" + this.j;};
				a.onmouseout = function() {this.k.src = this.h;};
			}
		}
	},

	// Additional required functions
	doFind: function (a, b, c) {
		var e = (a.all)? a.all : a.getElementsByTagName("*");
		var f = [];
		var g = (typeof c != "undefined") ? new RegExp("(^|\\s)" + c +".*(\\s|$)") : null;
		for(var i=0; i<e.length; i++){
			if (e[i] == null) {alert(e[i]); continue;}
			var h = objGetAttr(e[i], b);
			if (h && h != "" && ((!c || c == "") || (g && g.test(h)))) f.push(e[i]);
		}
		return f;
	}
};
function loadEffects() {
	// Called because addEvent does not understand class prototype functions
	attributeEffects.init();
}

/* DOM Functions */

Object.prototype.getAttr = function(a) {return objGetAttr(this, a);}
function objGetAttr(a, b) {
	if (typeof a != "object") return null;
	return (b == "class") ? a.className : (b == "href") ? a.href : (b == "src") ? a.src : (b == "value") ? a.value : a.getAttribute(b);
}


function getElement(a) {
	return ((document.getElementById) ? document.getElementById(a) : eval("document.all."+a));
}

function checkform (form) {
	if (!checkvalue(form.Name, 'Please enter your name.')) return false;
	if (!checkemailaddress(form.vCONTROL_from, 'Please enter an email address in the correct format (name@domain.com).')) return false;
	if (!checkvalue(form.Question, 'Please enter a question or comment.')) return false;
	return true;
}

function checkvalue(formfield, message) {
	if (formfield.value == "" || formfield.value == "Your Name") {
		alert (message);
		formfield.focus();
		return false;
	}
	return true;
}

function getselected(formfield) {
	return formfield.options[formfield.selectedIndex].value;
}

function checkemailaddress(formfield, message) {
	var str = formfield.value;
	var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	if (str == "") {
		alert(message);
		formfield.focus();
		return false;
	} else if (!str.match(re)) {
		alert(message);
		formfield.focus();
		return false;
	} else {
		return true;
	}
}

/* queryBox User Effects */
var queryBox = {
	boxFocus : function(a) {
		if (this.bBox[a]) {
			this.bBox[a].className = this.bBoxClassFocus[a];
			if (this.bBox[a].value == this.bBoxDefault[a]) this.bBox[a].value = "";
		}
	},
	boxBlur : function(a) {
		if (this.bBox[a]) {
			if (this.bBox[a].value == "" || this.bBox[a].value == this.bBoxDefault[a]) {
				this.bBox[a].className = this.bBoxClassBlur[a];
				this.bBox[a].value = this.bBoxDefault[a];
			} else {
				// null
			}
		}
	},
	boxSet : function(a, b, c, d) {
		this.bBox[a] = getElement(a);
		if (this.bBox[a]) {
			this.bBox[a].n = a;
			this.bBoxDefault[a] = ((b != "") ? b : "");	
			this.bBoxClassFocus[a] = ((c && c != "") ? c : "txtFocus");	
			this.bBoxClassBlur[a] = ((d && d != "") ? d : "txtBlur");
			this.bBox[a].onfocus = function() {queryBox.boxFocus(this.n);};
			this.bBox[a].onblur = function() {queryBox.boxBlur(this.n);};
			this.bBox[a].className = this.bBoxClassBlur[a];
			this.bBox[a].value = this.bBoxDefault[a];
		}
	},

	boxInit : function() {
		this.bBox = new Array();
		this.bBoxDefault = new Array();
		this.bBoxClassFocus = new Array();
		this.bBoxClassBlur = new Array();
	}
};

function getFind(a, b, c, d, e){
	if (!e || e == "") e = false;
    var f = ((b == "*" && a.all) ? a.all : a.getElementsByTagName(b));
    var r = new Array();
    var q = ((typeof d != "undefined") ? new RegExp("(^|\\s)" + d + ((e) ? ".*" : "") + "(\\s|$)") : null);
    for (var i=0; i<f.length; i++){
        var p = objGetAttr(f[i], c);
        if (p && p != "" && ((!d || d == "") || (q && q.test(p)))) {
			r.push(f[i]);
        }
    }
    return r;
}

function removeElement(e) {
	var em = getElement(e)
	if (em) em.parentNode.removeChild(em);
	else e.parentNode.removeChild(e);
}

function addEvent(elm, evType, fn, useCapture) {
	if (evType == "DOM") {
		return new domFunction(fn, useCapture);
	} else 	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	} else if (elm.attachEvent) {
		return elm.attachEvent("on"+evType, fn)
	}
	return false;
} 

function domFunction(f, a) {
	var n = 0;
	var t = setInterval(function() {
		var c = true;
		n++;
		if (typeof document.getElementsByTagName != 'undefined' && (document.getElementsByTagName('body')[0] != null || document.body != null)) {
			c = false;
			if (typeof a == 'object') {
				for (var i in a) {
					if ((a[i] == 'id' && document.getElementById(i) == null) || (a[i] == 'tag' && document.getElementsByTagName(i).length < 1)) {c = true; break;}
				}
			}
			if(!c) { f(); clearInterval(t); }
		}
		if(n >= 60) clearInterval(t);
	}, 250);
}


addEvent(window, "DOM", loadEffects);