var urlPath = 'http://www.b2ideas.com/';

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;}




// 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', 'lb', 'lb');
	},

	// 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 = imagesUrl + 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 (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 = 10+o[1];
				a.py2 = a.childNodes[0].offsetHeight+o[1]-10;
				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.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', urlPath + 'images/mark1.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 = urlPath + 'images/mark2.gif';
					}
					$('jaxbox').style.top = y +'px';
					$('jaxbox').style.left = this.px-Math.round($('jaxbox').offsetWidth/2) +'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.childNodes[0]) ? e.childNodes[0].offsetLeft+((x) ? e.childNodes[0].offsetWidth : 0) : e.offsetLeft-((x) ? e.offsetWidth : 0)); offsetY = ((e.childNodes[0]) ? e.childNodes[0].offsetTop+((y) ? e.childNodes[0].offsetHeight : 0) : 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.locate('class', 'lb', 'lb');}
window.onresize = attrEffLb;

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);
}
