var urlPath = 'http://www.wrwater.com/';
var imagesUrl = urlPath +'images/';
var siteUrl = urlPath +'site/';
var siteImagesUrl = siteUrl +'images/';
var siteFlashUrl = siteUrl +'flash/';
var siteCssUrl = siteUrl +'css/';



function $() {var a = new Array(); for (var i = 0; i < arguments.length; i++) {var b = arguments[i]; if (typeof b == 'string') b = document.getElementById(b); if (arguments.length == 1) return b; a.push(b);} return a;}


var vcf = {
	init : function(a, b) {
		this.form = a;
		this.fields = b;
	},

	check : function() {
		if ($(this.form)) {
			this.verify = true;

			for (i in this.fields) {
				if (!$(this.fields[i].e)) continue;
				var a = $(this.fields[i].e);
				
				if (this.fields[i].t == 'text') {
					this.txt(a, this.fields[i].m);
				} else if (this.fields[i].t == 'email') {
					this.email(a, this.fields[i].m);
				} else if (this.fields[i].t == 'select') {
					this.sel(a, this.fields[i].m);
				}
				
				if (!this.verify) return false;
			}

			return (this.verify);
		} else {
			return true;
		}
	},

	email: function(a, b) {
		var c = (a) ? a.value : false;
		var d = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
		if (!a || c == "" || !c.match(d)) return this.msg(a, b);
		return true;
	},
	sel: function(a, b) {
		var c = (a) ? a.options[a.selectedIndex].value : false;
		if (!a || c == "" || c == -1 || c == "na") return this.msg(a, b);
		return true;
	},
	txt: function(a, b) {
		if (!a || a.value == "" || a.value == -1 || a.value == "na") return this.msg(a, b);
		return true;
	},
	msg: function (a, b) {
		alert (b);
		if (a) a.focus();
		this.verify = false;
	}
};


/* Browser Detection */
var browser = {
	events: function() {
	},
	compliance : function() {
		// Style Compliance Overrides
		if (browser.browser == 'Explorer') document.write('<link rel="stylesheet" href="'+ siteCssUrl +'screen_ie'+ ((browser.version >= 7) ? 7 : 6) +'.css" media="all">\n');
	},
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version";
		this.os = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if ((dataString && dataString.indexOf(data[i].subString) != -1) || dataProp) return data[i].identity;
		}
		return false;
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{string: navigator.userAgent, subString: "OmniWeb", versionSearch: "OmniWeb/", identity: "OmniWeb"},
		{string: navigator.vendor, subString: "Apple", identity: "Safari"},
		{prop: window.opera, identity: "Opera"},
		{string: navigator.vendor, subString: "iCab", identity: "iCab"},
		{string: navigator.vendor, subString: "KDE", identity: "Konqueror"},
		{string: navigator.userAgent, subString: "Firefox", identity: "Firefox"},
		{string: navigator.vendor, subString: "Camino", identity: "Camino"},
		// for newer Netscapes (6+)
		{string: navigator.userAgent, subString: "Netscape", identity: "Netscape"},
		{string: navigator.userAgent, subString: "MSIE", identity: "Explorer", versionSearch: "MSIE"},
		{string: navigator.userAgent, subString: "Gecko", identity: "Mozilla", versionSearch: "rv"},
		// for older Netscapes (4-)
		{string: navigator.userAgent, subString: "Mozilla", identity: "Netscape", versionSearch: "Mozilla"}
	],
	dataOS : [
		{string: navigator.platform, subString: "Win", identity: "Windows"},
		{string: navigator.platform, subString: "Mac", identity: "Mac"},
		{string: navigator.platform, subString: "Linux",identity: "Linux"}
	]

};

/* Run object checks */
browser.init();
browser.events();




// Attribute Selector Effects
// ------------------------------------------------------------------
// Developed by Greg Leuch, Virticle Corp (2007 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 = {
	start : function () {
		// Use: this.set(-attr-, -effect-, -func-, [-opt-...]);
		this.locate('class', 'over', 'imgover');
		this.resize();
	},

	resize : function() {
		this.locate('class', 'lb', 'lb');
		//this.locate('class', 'clearance', 'clearance', true); // Force clear (ok if double clears)
		//this.cleared++;
	},

	// Columns need clearence due to use of absolute positioning for menus (prevents irregular shifting of cols on large content)
	clearance : function(a, b, c, d, e) {
		if (a && e && e != null) {
			if (d && a.cleared >= this.cleared) return; // Prevent double clearance on new load
			this.locate('class', 'clearance', 'clearance', false, false, a, true); // Children must clear before parent.
			var g = new RegExp('([\\S\\s]*)('+ b +' c:)([\\S]*)([\\S\\s]*)');
			var h = e.replace(g, '$3');
			var m = 0;
			if (h && h > 0) m = parseInt(h);
			var k = a.childNodes;
			for (i=0; i<k.length; i++) {
				if (k[i].offsetHeight == null) continue;
				// offsetHeight includes padding, so we deduct padding since we are adding it to the element's height
				var y = k[i].offsetHeight - parseInt(getStyle(k[i], 'padding-top')) - parseInt(getStyle(k[i], 'padding-bottom'));
				if (y > m) m = y;
			}
			for (i=0; i<k.length; i++) if (k[i].offsetHeight != null) k[i].style.height = m +'px';
			a.style.height = m +'px';
			a.cleared = this.cleared;
		}
	},
	cleared : 0,

	// Image Rollover Effects
	imgover : function (a, b, c, d, e) {
		if (a && e && e != null) {
			var g = new RegExp('([\\S\\s]*)('+ b +' s:)([\\S]*)([\\S\\s]*)');
			var h = e.replace(g, '$3');
			if (e != h && h != '') {
				var f = h.split(':');
				var i = new RegExp('((\.png)$)$');
				var j = ((browser) ? (i.test(f[0]) && (browser.browser == 'Explorer' && browser.version < 7)) : false);
				if (j) 	var k = new RegExp('(^|[\\S\\s]*)(src=\')([\\S]*)(\')([\\S\\s]*|$)');
				a = ((f[1] == 'p') ? a.parentNode : a);
				a.h = ((j) ? ((f[1] == 'c') ? a.childNodes[0].style.filter.replace(k, '$3') : a.style.filter.replace(k, '$3')) : ((f[1] == 'c') ? a.childNodes[0].src : a.src));
				if (!a.h || a.h == '') return;
				a.j = siteImagesUrl + f[0];
				a.k = new Image();
				a.k.l = ((f[1] == 'c') ? eval(a.childNodes[0]) : eval(a));
				a.k.n = j;
				a.k.onload = function() {((this.m) ? ((this.n) ? (this.l.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=\'crop\', src=\''+ this.src +'\'') : (this.l.src = this.src)) : ''); this.m = false; return true;};
				a.onmouseover = function() {this.k.m = true; this.k.src = this.j;};
				a.onmouseout = function() {this.k.m = true; this.k.src = this.h;};
				a.k.m = false;
				a.k.src = a.j;
			}
		}
	},


	lb : function(a, b, c, d, e) {
		//if (browser.browser == 'Explorer' && browser.version < 7) return;
		if (a && e && e != null) {
			var g = new RegExp('([\\S\\s]*)('+ b +' s:)([\\S]*)([\\S\\s]*)');
			var h = e.replace(g, '$3');
			if (e != h && h != '') {
				var f = h.split(':');
				var o = this.getOffset(a, true, true);
				a.s = ((f[0] == 'href') ? a.href : (urlPath + f[0]));
				a.px = Math.round(a.childNodes[0].offsetWidth/2)+o[0]-50;
				a.py = 13+o[1];
				a.py2 = a.childNodes[0].offsetHeight+o[1]-13;
				a.t = a.childNodes[0].title;
				a.childNodes[0].title = '';
				a.onclick = function() {return false;}
				a.k = new Image(); a.k.src = a.s; //cache
				a.onmouseover = function() {
					var a = document.createElement('div');
					a.setAttribute('id', 'jaxbox');
					$('main').appendChild(a);
					$('jaxbox').className = 'imgbox';

					var b = document.createElement('div');
					b.setAttribute('class', 'surround');
					b.className = 'surround';
					var c = document.createElement('div');
					c.setAttribute('class', 'photo');
					c.setAttribute('id', 'imgboxphoto');
					c.className = 'photo';
					var ci = document.createElement('img');
					ci.setAttribute('src', this.s);
					c.appendChild(ci);
					if (this.t != '') {
						var cp = document.createElement('p');
						cp.innerHTML = this.t;
						c.appendChild(cp);
					}
					var d = document.createElement('img');
					d.setAttribute('src', siteImagesUrl + 'lb_mark_down.gif');
					d.setAttribute('class', 'mark');
					d.className = 'mark';
					d.setAttribute('id', 'imgbox_mark');
					b.appendChild(c);
					b.appendChild(d);
					$('jaxbox').appendChild(b);

					if (this.t != '') cp.style.width = ci.offsetWidth +'px';
					$('imgbox_mark').style.left = Math.round($('jaxbox').offsetWidth/2)+60 +'px';
					var y = this.py - $('jaxbox').offsetHeight;
					/*
					if (y-window.scrollY < 0) {
						y = this.py2;
						$('jaxbox').className = 'imgbox2';
						$('imgbox_mark').src = siteImagesUrl + 'lb_mark_up.gif';
					}
					*/
					var x = this.px-Math.round($('jaxbox').offsetWidth/2);
					$('jaxbox').style.top = y +'px';
					$('jaxbox').style.left = ((x > 0) ? x : 0) +'px';
					$('jaxbox').style.visibility = 'visible';
					$('jaxbox').onmouseover = function() {attributeEffects.lbover = true;};
					$('jaxbox').a = this;
					$('jaxbox').onmouseout = function(e) {if (m_event(e, this)) attributeEffects.lb_remove();};
				};
				a.onmouseout = function(e) {if (m_event(e, $('jaxbox'))) attributeEffects.lb_remove();};
			}
		}		
	},
	lb_remove : function() {$('main').removeChild($('jaxbox'));},

	replacePNG: function(a, b, c, d, e) {
		a.style.width = a.offsetWidth +'"px';
		a.style.height = a.offsetHeight +'px';
		a.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale src=\''+ a.src +'\')';
		a.src = imagesUrl +'spacer.gif';
	},


	// Additional required functions
	doFind : function (a, b, c, d) {if (!a || a == '') return false; var e = (a.all) ? a.all : a.getElementsByTagName('*'); var f = []; var g = ((typeof c != 'undefined') ? new RegExp(((d) ? c : '(^|\\s)'+ c +'(\\s|$)')) : null); for (var i=0; i<e.length; i++) {if (e[i] == null) continue; var h = this.objGetAttr(e[i], b); if (h && h != '' && ((!c || c == '') || (g && g.test(h)))) f.push(e[i]);} return f;},

	objGetAttr : function(a, b) {if (typeof a != 'object') return false; return (b == 'class') ? a.className : (b == 'href') ? a.href : (b == 'src') ? a.src : (b == 'value') ? a.value : a.getAttribute(b);},

	locate : function (a, b, c, d, e, f) {	var z = this.doFind($((f && f != '') ? f : 'main'), a, b, e); if (z.length > 0) for (var i in z) if (typeof z[i] == 'object') eval('this.'+c+'(z[i], b, a, d, this.objGetAttr(z[i], a));');},

	getOffset : function(e, x, y) {x = (x !== true); y = (y !== true); offsetX = e.offsetLeft-((x) ? e.offsetWidth : 0); offsetY = e.offsetTop-((y) ? e.offsetHeight : 0); var p = e.offsetParent; r=0; while (p) {r++; offsetX += p.offsetLeft; offsetY += p.offsetTop; p = p.offsetParent;} return Array(offsetX, offsetY);}};

function attrEffLb() {	attributeEffects.resize();}
window.onresize = attrEffLb;

function getStyle(a, b) {return ((a.currentStyle) ? a.currentStyle[b] : ((window.getComputedStyle) ? document.defaultView.getComputedStyle(a,null).getPropertyValue(b) : false));}

function m_event(e, f) {
	if (!e) var e = window.event;
	if (e.type != 'mouseout' && e.type != 'mouseover') return false;
	var c = ((e.relatedTarget) ? e.relatedTarget : ((e.type == 'mouseout') ? e.toElement : e.fromElement));
	while (c && c != f) c = c.parentNode;
	return (c != f);
}