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

	return {
		init : function() {
			sq = $('searchQuery');
			if (sq) {
				$D.addClass(sq,'init');
				
				sq.value = 'Search';
				$E.on(sq,'focus',this.clearSearch);
			$E.on(sq,'blur',this.checkSearch);
			}
		/*
			var rateProduct = $D.getElementsByClassName('rateProduct');
			if (rateProduct) {
				YAHOO.nubedo.initProductHover(rateProduct);
			//	$E.on(rateProduct,'mouseover',this.rateProductOver);
				$E.on(rateProduct,'mouseout',this.rateProductOut);
			}
			
			if ($('nbp'))
				var tabView = new YAHOO.widget.TabView('nbp');
			*/
		/*	var functions = $D.getElementsByClassName('functions');
			var fc = $('functionsContent');
			var fcC = fc.getElementsByTagName("INPUT");
			var btn = ['functionsCart','functionsAccount','functionsLogout'];
			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);
			}
			*/
			
			var addCart = $D.getElementsByClassName('addcart');
			$E.on(addCart,'submit',this.addcart);
			
			// if it exists, remove catpcha
			if ($('registerUsername2'))
				$('registerUsername2').style.display = 'none';
				
			if ($('reviewForm')) {
				$E.on('reviewForm','submit',this.reviewForm);
			}
			
			var imageS = $D.getElementsByClassName('enlargeImage');
			$E.on(imageS,'click',this.enlargeImage);
			
			
			var notifications = $D.getElementsByClassName('notify');
			$E.on(notifications,'click',this.notify);
			
			
			var notifyText = $D.getElementsByClassName('notifyText');
			$E.on(notifyText,'click',this.notifyText);
									
			/*var updateCart = $D.getElementsByClassName('updatecart');
			$E.on(updateCart,'submit',this.modifyCart); 
			
			var checkOut = $D.getElementsByClassName('btn_checkout');
			$E.on(checkOut,'click',this.modifyCart); */
			
			if ($('swapShipping')) {
				$E.on($('swapShipping'),'change',this.swapShipping)
			}
			
		},
		swapShipping : function(e) {
			$sS = $('swapShipping');
			$ship = $('cartShipping');
			$total = $('cartTotal');
			$tax = $('cartTax');
			
			postBody = 'shippingService='+$sS.value;
			var callback = {
				success: function(o) {
					var resp = YAHOO.lang.JSON.parse(o.responseText);
					if (resp.shipping == 0) {
						$ship.innerHTML = 'FREE';
					}else{
						$ship.innerHTML = '$'+resp.shipping;
					}
					$total.innerHTML = '$'+resp.total;
					$tax.innerHTML = '$'+resp.tax;
				},
				failure: function(o) { },
				timeout: 5000
			}
			
			var transaction = YAHOO.util.Connect.asyncRequest('POST','/checkout/shipping',callback,postBody);
		},
		reviewForm : function (e) {
			$E.stopEvent(e);
			YAHOO.util.Connect.setForm(this);
			
			var loading = document.createElement("div");
			loading.className = 'loading';
			loading.id = 'loading';
			document.body.appendChild(loading);
			
			var callback = {
				success: function(o) {
					document.body.removeChild(loading);
					var resp = YAHOO.lang.JSON.parse(o.responseText);
					if (resp.success) {
						var parent = $('reviewForm').parentNode;
						parent.removeChild($('reviewForm'));
						
						var para = document.createElement("p");
						para.innerHTML = 'Thank you for reviewing this product. Please note that your review may not show up immediately.';
						
						parent.appendChild(para);
					}else{
						if (resp.reviewTitle) {
							var parent = $('reviewTitle').parentNode;
							if (!$D.hasClass(parent,'error')) {
								$D.addClass(parent, 'error');
								parent.innerHTML += '<p class="error">'+resp.reviewTitle+'</p>';
							}else{
								$D.removeClass(parent,'error');
								pError = $D.getElementsByClassName('error','p',parent);
								parent.removeChild(pError);
							}
						}
						if (resp.reviewBody) {
							var parent = $('reviewBody').parentNode;
							if (!$D.hasClass(parent,'error')) {
								$D.addClass(parent, 'error');
								parent.innerHTML += '<p class="error">'+resp.reviewBody+'</p>';
							}else{
								$D.removeClass(parent,'error');
								pError = $D.getElementsByClassName('error','p',parent);
								parent.removeChild(pError);
							}
						}
					}
					
				},
				failure: function(o) {  },
				timeout: 5000
			}
			var post = 'url='+window.location.href;
			var transaction = YAHOO.util.Connect.asyncRequest('POST',this.action+'?output=json', callback, post);
		},
		priceChange : function (e) {
			var theForm = this.form,
				post = '&output=json';
				
			YAHOO.util.Connect.setForm(theForm);
			
			var loading = document.createElement("div");
			loading.className = 'loading';
			loading.id = 'loading';
			document.body.appendChild(loading);
			
			var callback = {
				success: function(o) {
					document.body.removeChild(loading);
					var resp = YAHOO.lang.JSON.parse(o.responseText);
					if (resp.price) {
						$('priceChange').innerHTML = '$'+resp.price
					}
					
				},
				failure: function(o) {  },
				timeout: 5000
			}
			var post = 'url='+window.location.href;
			var transaction = YAHOO.util.Connect.asyncRequest('POST','/cart/getPrice',callback,post);
		},
		initProductHover : function(rpd) {
			for(ii in rpd) {
				var defaultRating = $D.getElementsByClassName('defaultRating','em',rpd[ii]);
				
				if ($D.hasClass(rpd[ii],'disabled'))
					return;
				
				for(i=1;i<6;i++) {
				
					var star = document.createElement("span");
					star.id = 'star'+ii+'_'+i;
					var txt = i>1 ? i+' stars.' : i+' star.';
					
					star.title='Rate this product '+txt;
					
					rpd[ii].appendChild(star);
					
					$E.on(star,'mouseover',YAHOO.nubedo.rateProductHover);
					$E.on(star,'click',YAHOO.nubedo.rateProduct);
				}
			}
		},
		rateProductHover : function (e,obj) {
			if(typeof ratingUpdateID == "number") {
				window.clearTimeout(ratingUpdateID);
				ratingUpdateID=null;
			}
			
			obj = obj || this;
			
			var numStars = obj.id.substr(obj.id.indexOf('_')+1,1);
			var theIDs = obj.id.substr(0,obj.id.indexOf('_')+1);
			
			for(i=1;i<6;i++) {
				var star = theIDs+i
				if (i<=numStars) {
					$D.replaceClass($(star),'starOff','starOn');
				}else{
					$D.replaceClass($(star),'starOn','starOff');
				}
			}
			
		},
		rateProductOut : function (e,obj) {
			
			obj = obj || this;
			var theIDs = obj.id.substr(0,obj.id.indexOf('_')+1);
			
			if(typeof ratingUpdateID != "number") {
				ratingUpdateID = window.setTimeout(function() {			
					for(i=1;i<6;i++) {
						var star = theIDs+i
						$D.removeClass($(star),'starOff');
						$D.removeClass($(star),'starOn');
					}
				},1000);
			}
		},
		rateProduct : function (e, obj) {
			obj = obj || this;
			var parent = obj.parentNode;
			
			var numStars = obj.id.substr(obj.id.indexOf('_')+1,1);
			var theIDs = obj.id.substr(0,obj.id.indexOf('_')+1);
			var postBody = 'score='+numStars;
			
			var loading = document.createElement("div");
			loading.className = 'loading';
			loading.id = 'loading';
			document.body.appendChild(loading);
			
			var callback = {
				success: function(o) {
					for(i=1;i<6;i++) {
						var star = theIDs+i
						$D.removeClass($(star),'starOff');
						$D.removeClass($(star),'starOn');
					}
					var rpd = $D.getElementsByClassName('rateProduct');
					for (i in rpd) {
						if (!$D.hasClass(rpd[i],'rated'))
							$D.addClass(rpd[i],'rated');
						
						if ($D.hasClass(rpd[i],'norating'))
							$D.removeClass(rpd[i],'norating');
						
						var newWidth = numStars*20;
						var defaultRating = $D.getElementsByClassName('defaultRating','em',rpd[i]);
						
						$D.setStyle(defaultRating,'width',newWidth+'px');
					}
					document.body.removeChild(loading);
					if ($D.hasClass(parent,'notifyRating')) {
						YAHOO.nubedo.quickNotify('Thank you for rating. <span class="notice">Please note that your rating will not count towards the public rating unless you write a review.</span>');
						$D.removeClass(parent,'notifyRating');
					}
					
				},
				failure: function(o) {  },
				timeout: 5000
			}
			
			var transaction =
				YAHOO.util.Connect.asyncRequest('POST', window.location+'/rate', callback, postBody);
		
		},
		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;
			}
		},
		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';				
			}
		},
		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);
		},
		notify : function (e,obj) {
			$E.stopEvent(e);
			
			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.25,0.35);
			$E.on(scr,"click",YAHOO.nubedo.killNotify);
			
			viewer = document.createElement("div");
			var av = new YAHOO.widget.Effect(viewer);
			viewer.className = 'notification';
			viewer.id = 'notification';
			$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;
					$E.on($('closeviewer'),"click",YAHOO.nubedo.killNotify);
					av.FadeIn(0.25,1, function() { document.body.removeChild($('loading')); });
					if ($('friend')) {
						$E.on($('friendForm'),'submit',YAHOO.nubedo.tellFriend);
					}
					
				},
				failure: function(o) {  },
				timeout: 5000
			}
			var post = 'url='+window.location.href;
			var transaction = YAHOO.util.Connect.asyncRequest('POST',this.href+'/pagesInline',callback,post);
		},
		notifyText : function (e) {
			$E.stopEvent(e);
			
			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.25,0.35);
			$E.on(scr,"click",YAHOO.nubedo.killNotify);
			
			viewer = document.createElement("div");
			var av = new YAHOO.widget.Effect(viewer);
			viewer.className = 'notification';
			viewer.id = 'notification';
			$D.setStyle(viewer,'opacity',0);
			document.body.appendChild(viewer);
			
			var closeviewer = document.createElement("div");
			closeviewer.id = 'close';
			
			viewer.innerHTML = '<p>'+this.innerHTML+'</p>';
			
			$E.on(closeviewer,"click",YAHOO.nubedo.killNotify);
			
			viewer.appendChild(closeviewer);
			av.FadeIn(0.25,1, function() { document.body.removeChild($('loading')); });
		},
		killNotify : function(e) {
			$E.stopEvent(e);
			if ($('screen')) document.body.removeChild($('screen'));
			document.body.removeChild($('notification'));
		},
		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) {
					document.body.removeChild($('loading'));
					viewer.innerHTML = o.responseText;
					av.FadeIn(0.35,0.85);
					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','/cart/?type='+type+'&notify='+id,callback);
			
		},
		quickNotify : function (msg) {
						
			viewer = document.createElement("div");
			var av = new YAHOO.widget.Effect(viewer);
			viewer.className = 'quickNotify';
			viewer.id = 'notification';
			$E.on(viewer,"click",YAHOO.nubedo.killNotify);
			
			viewer.innerHTML = '<div class="notifyContainer"><p class="notify">'+msg+'</p></div>';
			$D.setStyle(viewer,'opacity',0);
			document.body.appendChild(viewer);
			av.FadeIn(0.35,0.85);
			window.setTimeout(function() {						
				av.FadeOut(0.35,0,function () { document.body.removeChild(viewer);  });
			},5000);
		
		},
		enlargeImage : function(e,obj) {
			$E.stopEvent(e);
			obj = obj || this;
			
			if (!$('loading')) {
				loading = document.createElement("div");
				loading.id = "loading";
				document.body.appendChild(loading);
			}
			
			img = new Image();
			img.src = obj.href;
			
			if (img.complete) {
					
				parent = obj.parentNode;
				if ($('imgViewer')) {
					parent = $('imgViewer').parentNode;
					parent.removeChild($('imgViewer'));
				}
				if ($('loading')) {
					d = $('loading').parentNode;
					d.removeChild($('loading'));
				}
				
				var viewer = document.createElement('div');
				var wrap = document.createElement('div');
				viewer.id = 'imgViewer';
				viewer.appendChild(wrap);
				var close = document.createElement('div');
				close.id = 'close';
				
				var image = document.createElement("img");
				var av = new YAHOO.widget.Effect(viewer);
				
				$D.setStyle(viewer,'position','absolute');
				$D.setStyle(viewer,'z-index','9999');
				
				image.src = obj.href;
				wrap.appendChild(image);
				wrap.appendChild(close);
				document.body.appendChild(viewer);
				
				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(viewer,[imgX,imgY]);
				$D.setStyle(viewer,'visibility','visible');
				
				av.FadeIn(0.75,1);
				$E.on([image,viewer,close],"click",YAHOO.nubedo.killScreen);
				
				return;
			}else{
				imgID = window.setTimeout(function() {
					YAHOO.nubedo.enlargeImage(e,obj);
				},500);
			}
			
		},
		killScreen : function(e) {
			$E.stopEvent(e);
			if ($('imgViewer')) {
				parent = $('imgViewer').parentNode;
				parent.removeChild($('imgViewer'));
			}
		},
		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','/cart/minicart',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 = '/checkout/step1';
						return;
					}
					YAHOO.nubedo.updateCart(o);
				},
				failure: function (o) {  },
				timeout: 5000
			}
			var connection = YAHOO.util.Connect.asyncRequest('POST','/cart/modInline',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','/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','/cart/modInline',callback,post);
			YAHOO.nubedo.killError(e);
		},
		addcart : function(e) {
			$E.stopEvent(e);
		//	YAHOO.nubedo.cancel();
			YAHOO.util.Connect.setForm(this);
			postBody = 'output=json';
			
			var callback = {
				success: function(o,e) {
					YAHOO.nubedo.updateCart(o);
			
					var data = YAHOO.lang.JSON.parse(o.responseText);
					notified = false;
					
					if (!YAHOO.lang.isUndefined(data.error)) {
						notified = true;
						var str = '';
						for(i in data.error) {
							str = str+"\n"+data.error[i];	
						}
						YAHOO.nubedo.cartError(str);
					}else{
					//	window.location = '/cart';
					}
				},
				failure: function(o) { },
				timeout: 5000
			};
			var transaction = YAHOO.util.Connect.asyncRequest('POST',this.action, 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 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);
			viewer.innerHTML = errorMsg;
			av.FadeIn(0.35,0.85);
			window.setTimeout(function() {						
				av.FadeOut(0.35,0,function () { document.body.removeChild(viewer);  });
			},2500);
			
		},
		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 data = YAHOO.lang.JSON.parse(o.responseText);
			notified = false;
			
			if (!YAHOO.lang.isUndefined(data.error)) {
				notified = true;
				var str = '';
				for(i in data.error) {
					str = str+"\n"+data.error[i];	
				}
				YAHOO.nubedo.cartError(str);
			}
			
			if (!YAHOO.lang.isUndefined(data.changes)) {
			// process additions
			if (!YAHOO.lang.isUndefined(data.changes.add)) {
			
				var add = data.changes.add;
				if (add) { 
					for (id in add) {	
					}
					if (notified != true) {
						YAHOO.nubedo.quickCartNotify(o,'add', id);
						notified = true;
					}
				}
			}
			
			// process mod
			if (!YAHOO.lang.isUndefined(data.changes.modify)) {
			
				mod = data.changes.modify;
				if (mod) {
					for (id in mod) {
					}
					if (notified != true) {
					  YAHOO.nubedo.quickCartNotify(o,'update', 'false');
						notified = true;
					}
				}
			}
			
			// process removals
			if (!YAHOO.lang.isUndefined(data.changes.remove)) {
				rem = data.changes.remove;
				if (rem) {
					for (id in rem) {
					}
					if (notified != true) {
					  YAHOO.nubedo.quickCartNotify(o,'remove', id);
						notified = true;
					}
				}
			}
			
			// update the total
			$('miniCart-total').innerHTML = '$'+parseFloat(data.total).toFixed(2);
			if ($fc) {
				$('fullCart-total').innerHTML = '$'+parseFloat(data.total).toFixed(2);
			}
			/*YAHOO.nubedo.reorderCart();
			YAHOO.nubedo.refreshUpdate();
			if (!$fc) {
				YAHOO.nubedo.showcart(o,newHeight);
			} */
			}
			
		}
	};
}();

YAHOO.util.Event.onDOMReady(YAHOO.nubedo.init, YAHOO.nubedo, true);