YAHOO.util.Dom.getElementsByExternal = function(root) {
	var method = function(el) { 
		if (el.href.indexOf(location.hostname) > -1 || el.href.indexOf(':') == -1) {
			return false;
		}
		return true;
	};
	return this.getElementsBy(method, 'a', root);
};
YAHOO.util.Dom.getElementsByInternal = function(root) {
	var method = function(el) { 
		if (el.href.indexOf(location.hostname) > -1 || el.href.indexOf(':') == -1) {
			return true;
		}
		return false;
	};
	return this.getElementsBy(method, 'a', root);
};
YAHOO.util.Dom.getElementsByAttribute = function(atr, val, tag, root) {
	var method = function(el) { 
		var re = new RegExp('(?:^|\\s+)' + val + '(?:\\s+|$)');
		if ( el.getAttribute(atr) && re.test(el.getAttribute(atr)) ) {
			return true;
		}
		return false;
	};
	return this.getElementsBy(method, tag, root);
};
	
YAHOO.widget.Effect = function(el) {
	this.objEl = YAHOO.util.Dom.get(el);
	this.height = parseInt(YAHOO.util.Dom.getStyle(this.objEl,'height'));
	this.width = parseInt(YAHOO.util.Dom.getStyle(this.objEl,'width'));
};
YAHOO.widget.Effect.prototype.BlindUp = function(iTimer,hide) {
	var $D = YAHOO.util.Dom;
	var timer = iTimer || 1;
	this.objEl.style.overflow = 'hidden';
	var blind = new YAHOO.util.Anim(this.objEl, { height: { to:0} }, timer, YAHOO.util.Easing.easeOut);
	var that = this;
	if ( hide ) {
		blind.onComplete.subscribe(
			function() {
				$D.addClass(hide,'hide');
			}
		);
	}
	blind.animate();
};

YAHOO.widget.Effect.prototype.CartDelete = function(iTimer) {
	var $D = YAHOO.util.Dom;
	var timer = iTimer || 1;
	if (!this.objEl) return;
	this.objEl.style.overflow = 'hidden';

	var blind = new YAHOO.util.Anim(this.objEl, { height: { to:0 }, opacity: { to:0, from:1 } }, timer, YAHOO.util.Easing.easeOut);
	var that = this;
	blind.onComplete.subscribe(
		function() {
			that.objEl.style.display = 'none';
			that.objEl.parentNode.removeChild(that.objEl);
			YAHOO.nubedo.reorderCart();
		}
	);
	blind.animate();
};
YAHOO.widget.Effect.prototype.BlindDown = function(iTimer,onComplete) {
	var $D = YAHOO.util.Dom;
	var timer = iTimer || 1;
	this.objEl.style.visibility = 'hidden';
	this.objEl.style.overflow = 'hidden';
	display = $D.setStyle(this.objEl,'display','block');
	this.objEl.style.height = '';
	var height = parseInt(YAHOO.util.Dom.getStyle(this.objEl,'height'));
	if (!height) var height = this.objEl.offsetHeight;
	if (!height) var height = 400;
	this.objEl.style.height = '0';
	this.objEl.style.visibility = 'visible';
	this.objEl.style.display = '';
	var blind = new YAHOO.util.Anim(this.objEl, { height: { to:height, from:0} }, timer, YAHOO.util.Easing.easeOut);
	var that = this;
	blind.onComplete.subscribe(
		function() {
			if (onComplete) {
				onComplete();
			}
			that.objEl.style.height = '';
			that.objEl.style.visibility = 'visible';
			that.objEl.style.overflow = '';
		}
	);
	blind.animate();
};
YAHOO.widget.Effect.prototype.BlindDownPartial = function(iTimer,endHeight,onComplete) {
	var timer = iTimer || 1;
	var startHeight = parseInt(YAHOO.util.Dom.getStyle(this.objEl,'height'));
	if (!startHeight) var startHeight = this.objEl.offsetHeight;
	var endHeight = startHeight + endHeight;
	this.objEl.style.visibility = 'visible';
	this.objEl.style.display = '';
	var blind = new YAHOO.util.Anim(this.objEl, { height: { to:endHeight, from:startHeight} }, timer, YAHOO.util.Easing.easeOut);
	var that = this;
	blind.onComplete.subscribe(
		function() {
			if (onComplete) {
				onComplete();
			}
			that.height = '';
		}
	);
	blind.animate();
};
YAHOO.widget.Effect.prototype.FadeBlindDown = function(iTimer,onComplete) {
	var timer = iTimer || 1;
	YAHOO.util.Dom.setStyle(this.objEl,'opacity',0);
	this.objEl.style.visibility = 'hidden';
	this.objEl.style.overflow = 'hidden';
	this.objEl.style.height = '';
	var height = parseInt(YAHOO.util.Dom.getStyle(this.objEl,'height'));
	if (!height) var height = this.objEl.offsetHeight;
	if (!height) var height = 120;
	this.objEl.style.height = '0';
	this.objEl.style.visibility = 'visible';
	this.objEl.style.display = '';
	var blind = new YAHOO.util.Anim(this.objEl, { height: { to:height, from:0}, opacity: { to: 1 } }, timer, YAHOO.util.Easing.easeOut);
	if ( onComplete ) {
		blind.onComplete.subscribe(onComplete);
	}
	blind.animate();
};
YAHOO.widget.Effect.prototype.FadeIn = function(iTimer,fadeTo,onComplete) {
	var timer = iTimer || 1;
	var timer = fadeTo || 1;
	YAHOO.util.Dom.setStyle(this.objEl,'opacity',0);
	this.objEl.style.display = '';
	var blind = new YAHOO.util.Anim(this.objEl, { opacity: { to: fadeTo } }, timer, YAHOO.util.Easing.easeOut);
	if ( onComplete ) {
		blind.onComplete.subscribe(onComplete);
	}
	blind.animate();
};
YAHOO.widget.Effect.prototype.FadeOut = function(iTimer,fadeTo,onComplete) {
	var timer = iTimer || 1;
	var timer = fadeTo || 1;
//	YAHOO.util.Dom.setStyle(this.objEl,'opacity',1);
	this.objEl.style.display = '';
	var blind = new YAHOO.util.Anim(this.objEl, { opacity: { to: fadeTo } }, timer, YAHOO.util.Easing.easeOut);
	var that = this;
	blind.onComplete.subscribe(
		function() {
			YAHOO.util.Dom.setStyle(that.objEl,'display','none');
			YAHOO.util.Dom.setStyle(that.objEl,'opacity',1);
		}
	);
	blind.animate();
};
YAHOO.widget.Effect.prototype.yoyo = function(iTimer,show,hide,onComplete) {
	var $D = YAHOO.util.Dom;
	this.objEl.style.overflow = 'hidden';
	var height = parseInt(YAHOO.util.Dom.getStyle(this.objEl,'height'));
	if (!height) var height = this.objEl.offsetHeight;
	var timer = iTimer || 1;
	var yoyo = new YAHOO.util.Anim(this.objEl, { height: { to:0} }, timer, YAHOO.util.Easing.easeOut);
	var that = this;
	yoyo.onComplete.subscribe(
		function() {
		
			$D.addClass(hide,'hide');
			$D.removeClass(show,'hide');
		
			that.objEl.style.visibility = 'hidden';
			that.objEl.style.overflow = 'hidden';
			that.objEl.style.height = '';
			var height = parseInt(YAHOO.util.Dom.getStyle(that.objEl,'height'));
			if (!height) var height = that.objEl.offsetHeight;
			that.objEl.style.height = '0';
			that.objEl.style.visibility = 'visible';
			var blind = new YAHOO.util.Anim(that.objEl, { height: { to:height, from:0} }, timer, YAHOO.util.Easing.easeIn);
			if ( onComplete ) {
				blind.onComplete.subscribe(onComplete);
			}
			blind.animate();
		}
	);
	yoyo.animate();
};

YAHOO.nubedo = function() {
	var $D = YAHOO.util.Dom;
	var $E = YAHOO.util.Event;
	var $M = YAHOO.util.Motion;
	var $A = YAHOO.util.Anim;
	var $ = $D.get;
	var timeoutID;
	var updateTimeoutID;
	var viewer;
	var focused = false;
	var btnadd;
	var btnTimeoutID;

	return {
		init : function() {
			
			var functions = $D.getElementsByClassName('functions');
			var fc = $('functionsContent');
			var fcC = fc.getElementsByTagName("INPUT");
			var btn = ['functionsCart','functionsAccount','functionsLogout','functionsSearch'];
			var closeB = $D.getElementsByClassName('btn_close','div',fc);
			$E.on([btn,closeB],'click',this.minicart);
			
			$E.on(fc,'mouseover',this.cancel);
			$E.on(fc,'mouseout',this.timeout);
			$E.on(fcC,'focus',this.setFocused);
			$E.on(fcC,'blur',this.unsetFocused);
			fc.style.display = 'none';		
			
			var updateCartQty = $D.getElementsByClassName('updateQty');
			var updateGiftWrap = $D.getElementsByClassName('updateGiftWrap');
			$E.on(updateCartQty,'keydown',this.updateTimeout); 
			$E.on(updateGiftWrap,'click',this.updateTimeout); 
			// make sure the minicart is always correct
			$E.onAvailable('miniCart-body',this.refreshCart);
			
			if ($('numCharCount')) {
				$E.on($('note'),'keydown',this.countChars);
				$E.on($('note'),'blur',this.countCharsFinal);
				$E.on($('note'),'keyup',this.countCharsFinal);
			}
			ship = $('swapShipping');
			if(ship) {
				$E.on(ship,'change',this.swapShipping);
			}
			
		},
		swapShipping : function(e) {
			$sS = $('swapShipping');
			$ship = $('cartShipping');
			$total = $('cartTotal');
			
			$price = $sS.value.substr($sS.value.lastIndexOf('|')+1);
			$price = $price.replace('/[$,]/ig','');
			
			postBody = 'service='+$sS.value.substr(0,$sS.value.lastIndexOf('|'));
			postBody = postBody+'&price='+$sS.value.substr($sS.value.lastIndexOf('|')+1);
			var callback = {
				success: function(o) {
					if ($price == 0) {
						$ship.innerHTML = 'FREE';
					}else{
						$ship.innerHTML = '$'+$price;
					}
					$total.innerHTML = '$'+o.responseText;
					
				},
				failure: function(o) { },
				timeout: 5000
			}
			
			var transaction = YAHOO.util.Connect.asyncRequest('POST',$path+'checkout/shipping',callback,postBody);
		},
		initContent : function() {	
						
			var updateCart = $D.getElementsByClassName('updatecart');
			$E.on(updateCart,'submit',this.modifyCart); 
			
			var checkOut = $D.getElementsByClassName('btn_checkout');
			$E.on(checkOut,'click',this.modifyCart); 	
			
			var addCart = $D.getElementsByClassName('addcart');
			$E.on(addCart,'submit',this.addcart);
			
			var imageS = $D.getElementsByClassName('enlargeImage');
			$E.on(imageS,'click',this.enlargeImage);
			
			
			var notifications = $D.getElementsByClassName('notify');
			$E.on(notifications,'click',this.notify);
			
			if ($('btn_update')) $('btn_update').style.display = 'none';
			
		},
		countChars : function (e) {
			len = $('note').value.length;
			if (len > 149) {
				$E.stopEvent(e);
				$('note').value = $('note').value.substr(0,150);
				len = $('note').value.length;
				$('numCharCount').innerHTML = len;
			}else{
				$('numCharCount').innerHTML = len;
			}
		},
		countCharsFinal : function (e) {
			len = $('note').value.length;
			if (len > 149) {
				$E.stopEvent(e);
				$('note').value = $('note').value.substr(0,150);
				len = $('note').value.length;
				$('numCharCount').innerHTML = len;
			}else{
				$('numCharCount').innerHTML = len;
			}
		},
		tellFriend : function (e) {
			$E.stopEvent(e);
			obj = $('friendForm');
			post = ''
			
			elements = obj.elements;
			for(i=0;i<elements.length;i++) {
				post += '&'+elements[i].name+'='+elements[i].value;
			}
			var callback = {
				success: function(o) {
					viewer.innerHTML = o.responseText;
					$E.on($('closeviewer'),"click",YAHOO.nubedo.killNotify);
					if ($('tf_continue')) $E.on($('tf_continue'),"click",YAHOO.nubedo.killNotify);
					if ($('friend')) {
						$E.on($('friendForm'),'submit',YAHOO.nubedo.tellFriend);
					}
					
				},
				failure: function(o) {  },
				timeout: 5000
			}
			var transaction = YAHOO.util.Connect.asyncRequest('POST',$path+'tellafriend/pagesInline',callback,post);
		},
		clearSearch : function () {
			sq = $('searchQuery');
				if ($D.hasClass(sq,'init')) {
				$D.removeClass(sq,'init');
				sq.value = '';
			}
		},
		checkSearch : function () {
			sq = $('searchQuery');
			if (sq.value == '') {
				$D.addClass(sq,'init');
				sq.value = 'search for keyword or item #';				
			}
		},
		refreshUpdate : function() {		
			var updateCartQty = $D.getElementsByClassName('updateQty');
			var updateGiftWrap = $D.getElementsByClassName('updateGiftWrap');
			YAHOO.util.Event.purgeElement(updateCartQty, false, "keydown"); 
			YAHOO.util.Event.purgeElement(updateGiftWrap, false, "click"); 
			$E.on(updateCartQty,'keydown',this.updateTimeout);
			$E.on(updateGiftWrap,'click',this.updateTimeout);
		},
		enlargeImage : function(e,obj) {
			$E.stopEvent(e);
			node = this;
			loading = document.createElement("div");
			loading.id = "loading";
			document.body.appendChild(loading);
			
			var callback = {
				start: function(o) {
				},
				success: function(o) {
					img = YAHOO.lang.JSON.parse(o.responseText);
					
					parent = node.parentNode;
					if ($('imgViewer')) {
						parent = $('imgViewer').parentNode;
						parent.removeChild($('imgViewer'));
					}
					if ($('loading')) {
						d = $('loading').parentNode;
						d.removeChild($('loading'));
					}
					
					var image = document.createElement("img");
					var av = new YAHOO.widget.Effect(image);
					image.id = 'imgViewer';
					
					$D.setStyle(image,'position','absolute');
					$D.setXY(image,[-5000,-5000]);
					$D.setStyle(image,'visibility','hidden');
					$D.setStyle(image,'z-index','9999');
					
					image.src = node.href;
					document.body.appendChild(image);
					
					pX = $D.getX(parent) + (parent.offsetWidth/2);
					pY = $D.getY(parent) + (parent.offsetHeight/2);
					
					imgX = pX-(img.width/2);
					imgY = pY-(img.height/2);
					
					imgR = imgX+img.width;
					imgB = imgY+img.height;
					
					scTop = $D.getDocumentScrollTop();
					scBottom = scTop + $D.getViewportHeight();
					
					scLeft = $D.getDocumentScrollLeft();
					scRight = scLeft + $D.getViewportWidth();
								
					imgX = (imgX<scLeft) ? scLeft+10 : imgX;
					imgY = (imgY<scTop) ? scTop+10 : imgY;			
					imgX = (imgR>scRight) ? scRight-10-img.width : imgX;
					imgY = (imgB>scBottom) ? scBottom-10-img.height : imgY;
					
					imgX = (imgX<10) ? 10 : imgX;
					imgY = (imgY<10) ? 10 : imgY;
								
					$D.setXY(image,[imgX,imgY]);
					$D.setStyle(image,'visibility','visible');
					
					av.FadeIn(0.75,1);
					$E.on(image,"click",YAHOO.nubedo.killScreen);
					
				},
				failure: function(o) {  },
				timeout: 5000
			}
			
			var transaction = YAHOO.util.Connect.asyncRequest('GET',$path+'image.php?image='+this.href,callback);
			
		},
		killScreen : function(e) {
			$E.stopEvent(e);
			if ($('imgViewer')) {
				parent = $('imgViewer').parentNode;
				parent.removeChild($('imgViewer'));
			}
			if ($('viewer')) {
				parent = $('viewer').parentNode;
				parent.removeChild($('viewer'));
			}
			if ($('screen')) {
				parent = $('screen').parentNode;
				parent.removeChild($('screen'));
			}
		},
		quickCartNotify : function (e,type,id) {
		
			viewer = document.createElement("div");
			var av = new YAHOO.widget.Effect(viewer);
			viewer.className = 'quickNotify';
			viewer.id = 'notification';
			$E.on(viewer,"click",YAHOO.nubedo.killNotify);
			$D.setStyle(viewer,'opacity',0);
			document.body.appendChild(viewer);
			
			var loading = document.createElement("div");
			loading.className = 'loading';
			loading.id = 'loading';
			document.body.appendChild(loading);
			
			var callback = {
				success: function(o) {
					viewer.innerHTML = o.responseText;
					av.FadeIn(0.35,0.85, function() { document.body.removeChild($('loading')); });
					window.setTimeout(function() {
						
						av.FadeOut(0.35,0,function () { document.body.removeChild(viewer);  });
						
					},2500);
					
				},
				failure: function(o) {  },
				timeout: 5000
			}
			
			var transaction = YAHOO.util.Connect.asyncRequest('GET',$path+'cartInline.php?type='+type+'&notify='+id,callback);
			
		},
		refreshCart : function() {
			mcb = $('miniCart-body').innerHTML;
				var callback = {
					success: function(o) {
						mcb = o.responseText },
					failure: function(o) {  },
					timeout: 5000
				};
				var transaction = YAHOO.util.Connect.asyncRequest('POST',$path+'cartInline.php?minicart=true&ajax=true',callback);
			
		},
		setFocused : function(e) {
			focused = true;	
		},
		unsetFocused : function(e) {
			focused = false;	
			YAHOO.nubedo.timeout();
		},
		timeout : function() {
			if (focused == true) return;
			if(typeof timeoutID != "number") {
				timeoutID = window.setTimeout(function() {
					af = $D.getElementsByClassName('activeFunction');
					te = new YAHOO.widget.Effect($('functionsContent'));
					te.BlindUp(0.5);
					$D.removeClass($('functionsContent'),'under');
					$D.removeClass(af,'activeFunction');
				},5000);
			}
		},
		updateTimeout : function(e) {
			that = this;
			YAHOO.nubedo.cancelUpdate();
			if(typeof updateTimeoutID != "number") {
				updateTimeoutID = window.setTimeout(function() {
					that.blur();
					YAHOO.nubedo.modifyCart(e,that);
				},2500);
			}
		},
		cancelUpdate: function() {
			if(typeof updateTimeoutID == "number") {
				window.clearTimeout(updateTimeoutID);
				updateTimeoutID=null;
			}
		},
		cancel: function() {
			if(typeof timeoutID == "number") {
				window.clearTimeout(timeoutID);
				timeoutID=null;
			}
		},
		minicart : function(e) {
			YAHOO.nubedo.cancel();
			var $CT = $D.getElementsByClassName('miniFunction');
			var $C = $('functionsContent');
			var a = new YAHOO.widget.Effect($C);
			var $aF = $D.getElementsByClassName('activeFunction');
			if($D.hasClass(this,'btn_close')) {
				show = this.parentNode;
			}else{
				show = String(this.id+'Content');
			}
			
			if ( $(show) ) {
			
				if ( !$D.hasClass($C,'under')) {
				
					$D.addClass($CT,'hide');
					$D.removeClass($(show),'hide');
					$D.addClass($C,'under');
					
					$D.addClass(this.childNodes[0],'activeFunction');
					
					a.BlindDown(0.5);
				}else{
					if ($D.hasClass(show,'hide')) {
						$D.removeClass($aF,'activeFunction');
						a.yoyo(0.5,$(show),$CT);
						$D.addClass(this.childNodes[0],'activeFunction');
					}else{
						a.BlindUp(0.5,$CT);
						$D.removeClass($C,'under');
						$D.removeClass(this.childNodes[0],'activeFunction');
					}
				}
				$E.stopEvent(e);
			}
		},
		showcart : function(e,newHeight) {
			YAHOO.nubedo.cancel();
			var $CT = $D.getElementsByClassName('miniFunction');
			var $CA = $('functionsCartContent');
			var $C = $('functionsContent');
			var a = new YAHOO.widget.Effect($C);
			$E.stopEvent(e);
			
			if ( !$D.hasClass($C,'under') ) {
				
				$D.addClass($CT,'hide');
				$D.removeClass($CA,'hide');
				$D.addClass($C,'under');
				
				a.BlindDown(0.5);
			
			}else{
				if ( $D.hasClass($CA,'hide') ) {
					a.yoyo(0.5,$CA,$C.getElementsByTagName("DIV"));
				}else{
					a.BlindDownPartial(0.5,newHeight);	
				}
			
			}
			YAHOO.nubedo.timeout();
		},
		modifyCart : function (e,obj) {
			var afterComplete = false;
			if (!obj) var obj = this;
			if (obj.tagName == 'FORM') {
				$E.stopEvent(e);
				theForm = obj;
			}else{
				forms = document.getElementsByTagName("FORM");
				for (i=0;i<forms.length;i++) {
					if ($D.isAncestor(forms[i],obj)) {
						theForm = forms[i];	
					}
				}
			}
			if ($D.hasClass(obj,'btn_checkout')) {
				$E.stopEvent(e);
				afterComplete = true;
				theForm = obj.parentNode.parentNode;
			}
			YAHOO.nubedo.cancel();
			YAHOO.nubedo.cancelUpdate();
			YAHOO.util.Connect.setForm(theForm);
			var callback = {
				success: function (o) {
					if (afterComplete == true) {
						window.location = $path+'checkout/step1';
						return;
					}
					YAHOO.nubedo.updateCart(o);
				},
				failure: function (o) {  },
				timeout: 5000
			}
			var connection = YAHOO.util.Connect.asyncRequest('POST',$path+'cartInline.php?bender=true&update=true&ajax=true',callback);
			
		},
		notifyStock : function (e) {
			$E.stopEvent(e)
			qty = this.href.substr(this.href.lastIndexOf('/')+1,this.href.length-this.href.lastIndexOf('/')+1);
			tgz = this.href.substr(0,this.href.lastIndexOf('/'));
			id = tgz.substr(tgz.lastIndexOf('/')+1,tgz.length-tgz.lastIndexOf('/')+1);
			post = 'qty['+id+']='+qty;
			YAHOO.nubedo.cancel();
			YAHOO.nubedo.cancelUpdate();
			var connection = YAHOO.util.Connect.asyncRequest('GET',$path+'notify/'+id+'/'+qty);
			YAHOO.nubedo.killError(e);
			
		},
		directModifyCart : function (e) {
			$E.stopEvent(e)
			qty = this.href.substr(this.href.lastIndexOf('/')+1,this.href.length-this.href.lastIndexOf('/')+1);
			tgz = this.href.substr(0,this.href.lastIndexOf('/'));
			id = tgz.substr(tgz.lastIndexOf('/')+1,tgz.length-tgz.lastIndexOf('/')+1);
			post = 'qty['+id+']='+qty;		
			YAHOO.nubedo.cancel();
			YAHOO.nubedo.cancelUpdate();			
			var callback = {
				success: function (o) { YAHOO.nubedo.updateCart(o); },
				failure: function (o) {  },
				timeout: 5000
			}
			var connection = YAHOO.util.Connect.asyncRequest('POST',$path+'cartInline.php?bender=true&update=true&ajax=true',callback,post);
			YAHOO.nubedo.killError(e);
		},
		addcart : function(e) {
			YAHOO.nubedo.cancel();
			var postBody = 'bender=youbetcha&ajax=true';
			var $CA = $('functionsCartContent');
			var form = this.elements;
			$E.stopEvent(e);
			var addcarts = $D.getElementsByClassName('btn_addcart','input',this);
			btnadd = addcarts[0];
			
			for (i=0;i<form.length;i++) {
				if (form[i].className != 'addcart') {
					if ((form[i].className != 'addGiftWrap') || (form[i].checked == true))
					postBody =	postBody+'&'+form[i].name+'='+form[i].value;
				}
			}
			
			if ( postBody.length > 0 ) {
				var callback = {
					success: function(o) { YAHOO.nubedo.updateCart(o); },
					failure: function(o) { },
					timeout: 5000
				};
				var transaction = YAHOO.util.Connect.asyncRequest('POST',$path+'cartInline.php',callback,postBody);
			}
		},
		reorderCart : function() {
			var $mc = $('miniCart-body');
			var $fc = $('fullCart-body');
			var rows = $mc.getElementsByTagName("TR");
			x=1;
			for(i=0;i<rows.length;i++) {
				if (rows[i].style.display != 'none') {
					$D.removeClass(rows[i],'even');
					$D.removeClass(rows[i],'odd');
					if (x  %2 == 0) { $D.addClass(rows[i],'even'); }else{ $D.addClass(rows[i], 'odd'); }
					if (!$D.hasClass(rows[i],'nogiftwrap'))
					x++;
				}
			}
			if ($fc) {
				var full = $fc.getElementsByTagName("TR");
				x=1;
				for(i=0;i<full.length;i++) {
					if (full[i].style.display != 'none') {
						if (x  %2 == 0) { full[i].className = 'even'; }else{ full[i].className = 'odd'; }
						x++;
					}
				}
			}
			
		},
		killError : function (e) {
			$E.stopEvent(e);
			document.body.removeChild($('screen'));
			document.body.removeChild($('mc-error'));
		},
		cartError : function (errorMsg) {		
			
			var scr = document.createElement("div");
			var a = new YAHOO.widget.Effect(scr);
			scr.className = 'screen';
			scr.id = 'screen';
			$D.setStyle(scr,'opacity',0);
			document.body.appendChild(scr);
			a.FadeIn(0.75,0.35);
			$E.on(scr,"click",YAHOO.nubedo.killError);
			
			error = document.createElement("div");
			var av = new YAHOO.widget.Effect(error);
			error.className = 'error';
			error.id = 'mc-error';
			error.innerHTML = errorMsg;
			$D.setStyle(error,'opacity',0);
			av.FadeIn(0.25,1);
			document.body.appendChild(error);
			ids = [ 'continue-shopping', 'closeviewer', 'close'];
			$E.on(ids,"click",YAHOO.nubedo.killError);
			
			// check for options
			var addFull = $('addFull');
			if (addFull) {
				$E.on(addFull,"click",YAHOO.nubedo.directModifyCart);
			}
		},
		updateCart : function(o,type) {
			YAHOO.nubedo.cancel();
			var newHeight = 0;
			var coll ='';
			var $mc = $('miniCart-body');
			var $fc = $('fullCart-body');
			var $fcc = $('functionsCartContent');
			var $mcc = $('miniCart');
			var $X = o.responseXML.getElementsByTagName('cart').item(0);
			var cartTotal = $X.getAttribute('total');
			var $ADD = $X.getElementsByTagName('additions');
			var $MOD = $X.getElementsByTagName('modify');
			var $DEL = $X.getElementsByTagName('removals');
			var $ERR = $X.getElementsByTagName('error');
			notified = false;
			
			if ($ERR.length > 0) {
				notified = true;
				var str = '';
				for(i=0;i<$ERR.length;i++) {
					str = str+"\n"+$ERR.item(i).childNodes[0].nodeValue;	
				}
				YAHOO.nubedo.cartError(str);
			}
			
			// process additions
			if ($ADD.length > 0) {
				add = $ADD.item(0).getElementsByTagName('item');	
				if (add) {
					for(i=0;i<add.length;i++) {						
						empty = $('miniCartEmpty');
						if (empty) {
							$mc.deleteRow(0);
						}
						
						id = add.item(i).getAttribute('id');
						qty = add.item(i).getAttribute('qty');
						price = add.item(i).getAttribute('price');
						subtotal = add.item(i).getAttribute('subtotal');
						plink = add.item(i).getAttribute('link');
						title = add.item(i).childNodes[0].nodeValue;
						index = new Number(add.item(i).getAttribute('index'));
						giftwrap = add.item(i).getAttribute('giftwrapprice') ? add.item(i).getAttribute('giftwrapprice') : false;
						giftwrapA = add.item(i).getAttribute('giftwrap') ? add.item(i).getAttribute('giftwrap') : false;
						giftwrapA = giftwrapA ? ' checked="checked"' : '';
						
						
						row = $mc.insertRow(index);
						if (index  %2 == 0) { rowClass = 'even'; }else{ rowClass = 'odd' }
						$D.addClass(row,rowClass);
						
						row.id = 'miniCart_'+id;
						$D.setStyle('miniCart_'+id,'opacity',0);
						
						row2 = false;
						if (giftwrap) {
							ni = index+1;
							row2 = $mc.insertRow(ni);
							$D.addClass(row,'nogiftwrap');
							$D.addClass(row2,'giftwrap');
							$D.addClass(row2,rowClass);
							row2.id = 'miniCart-gc_'+id;
							
							giftWrapC = row2.insertCell(-1);
							giftWrapC.colSpan = 3;
							giftWrapC.className = 'giftwrap';
							giftWrapC.id = row.id+'-giftwrap';
							giftWrapC.innerHTML = '<label for="giftwrap'+id+'" class="giftwrap"><input value="1" class="updateGiftWrap" type="checkbox" name="giftwrap['+id+']" id="giftwrap'+id+'"'+giftwrapA+'>Gift wrap for ';
							giftWrapC.innerHTML += giftwrap > 0 ? '$'+parseFloat(giftwrap).toFixed(2) : 'FREE';
							giftWrapC.innerHTML += '</label>';
						}
						
						titleC = row.insertCell(-1);
						titleC.id = row.id+'-title';
						titleC.innerHTML = '<h4><a href="'+plink+'">'+title+'</a></h4>';
						
						priceC = row.insertCell(-1);
						priceC.id = row.id+'-price';
						priceC.className = 'price';
						priceC.innerHTML = '$'+parseFloat(price).toFixed(2);
						
						qtyC = row.insertCell(-1);
						qtyC.id = row.id+'-qty';
						qtyC.className = 'qty';
						qtyC.innerHTML = '<input autocomplete="off" class="updateQty" size="3" name="qty['+id+']" value="'+qty+'" type="text">';
						
						subtotalC = row.insertCell(-1);
						subtotalC.id = row.id+'-subtotal';
						subtotalC.className = 'subtotal';
						subtotalC.innerHTML = '$'+parseFloat(subtotal).toFixed(2);
						if (giftwrap) { subtotalC.rowSpan = 2; }
						
						newHeight = parseInt(newHeight) + parseInt(row.offsetHeight);
						
						rowA = new YAHOO.widget.Effect(row);
						rowA.FadeIn(0.5,1);
						if (row2) {
							rowB = new YAHOO.widget.Effect(row2);
							rowB.FadeIn(0.5,1);
						}

					}
						
					if (notified != true) {
						YAHOO.nubedo.quickCartNotify(o,'add', id);
						notified = true;
					}
				}
			}
			
			// process removals
			if ($MOD.length > 0) {
			//	alert ('mod');
				mod = $MOD.item(0).getElementsByTagName('item');	
				if (mod) {
					for(i=0;i<mod.length;i++) {
						id = mod.item(i).getAttribute('id');
						qty = mod.item(i).getAttribute('qty');
						price = mod.item(i).getAttribute('price');
						subtotal = mod.item(i).getAttribute('subtotal');
				//		img = mod.item(i).getAttribute('img');
						title = mod.item(i).childNodes[0].nodeValue;
						index = mod.item(i).getAttribute('index');
						
						$('miniCart_'+id+'-title').getElementsByTagName("A").item(0).innerHTML = title;
						$('miniCart_'+id+'-qty').getElementsByTagName("INPUT").item(0).value = qty;
						$('miniCart_'+id+'-subtotal').innerHTML = '$'+parseFloat(subtotal).toFixed(2);
						$('miniCart_'+id+'-price').innerHTML = '$'+parseFloat(price).toFixed(2);
						if ($fc) {
							$('fullCart_'+id+'-title').getElementsByTagName("A").item(0).innerHTML = title;
							$('fullCart_'+id+'-qty').getElementsByTagName("INPUT").item(0).value = qty;
							$('fullCart_'+id+'-subtotal').innerHTML = '$'+parseFloat(subtotal).toFixed(2);
							$('fullCart_'+id+'-price').innerHTML = '$'+parseFloat(price).toFixed(2);							
						}
					}
					if (notified != true) {
					  YAHOO.nubedo.quickCartNotify(o,'update', 'false');
						notified = true;
					}
				}
			}
			
			// process removals
			if ($DEL.length > 0) {
				rem = $DEL.item(0).getElementsByTagName('item');
				if (rem) {
					for(i=0;i<rem.length;i++) {
						id = rem.item(i).getAttribute('id');
						index = rem.item(i).getAttribute('index');
						row = $('miniCart_'+id);
						row2 = $('miniCart-gc_'+id);
						var a2 = new YAHOO.widget.Effect(row2);
						a2.CartDelete(0.5);
						var a = new YAHOO.widget.Effect(row);
						a.CartDelete(0.5);
						
						if ($fc) {
							rowFull = $('fullCart_'+id);
							var aN = new YAHOO.widget.Effect(rowFull);
							aN.CartDelete(0.5);
						}
					}
					if (notified != true) {
					  YAHOO.nubedo.quickCartNotify(o,'remove', id);
						notified = true;
					}
				}
			}
			
			// update the total
			$('miniCart-total').innerHTML = '$'+parseFloat(cartTotal).toFixed(2);
			if ($fc) {
				$('fullCart-total').innerHTML = '$'+parseFloat(cartTotal).toFixed(2);
			}
			YAHOO.nubedo.reorderCart();
			YAHOO.nubedo.refreshUpdate();
			if (!$fc) {
				YAHOO.nubedo.showcart(o,newHeight);
			}
			
		}
	};
}();

YAHOO.util.Event.onAvailable('functionsContent', YAHOO.nubedo.init, YAHOO.nubedo, true);
YAHOO.util.Event.onAvailable('footer', YAHOO.nubedo.initContent, YAHOO.nubedo, true);