function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

bShop = {
	curShopRow: 0,
	abba: null,


	productDetails: function(sCat, prodID) {
		new Ajax.Updater("productDetails",'productDetailsFetcher.php', {
			method: 'post',
			parameters: {cat: sCat, id: prodID},
			onComplete: this.showProductDetails
		});
	},
	
	showProductDetails: function() {
		if(browser.isIE) {
			$("productDetails").show();
		} else {
			new Effect.Appear("productDetails", { duration: 0.3});
		}
	},

	backToShoppin: function() {
		if(browser.isIE) {
			$("productDetails").hide();
		} else {
			new Effect.DropOut("productDetails");
		}
	},
	
	addToCart: function() {
		$("daShopForm").submit();
	},
	
	checkQuantity: function(e) {
		if(isNaN(e.value) || parseInt(e.value) <= 0) {
			e.value = 1;
			alert("Quantity must be a number greater than zero");
		}
	},

	scrollUp: function() {
		if (this.a != null || this.curShopRow == 0) {
			return;
		}

		slidey = $("shopSlider");

		this.a = new Accelimation(slidey.style, "top", (parseInt(slidey.style.top) + 230), 600, .8, "px");
		this.a.onend = this.onSlideGoodsEnd;
		this.a.onframe = this.slideTheGoods;
		this.a.start();

		this.curShopRow--;
//		if(this.curShopRow > 0) {
//			slidey.style.top = (parseInt(slidey.style.top) + 190) + "px";
//			this.curShopRow--;
//		}
	},

	scrollDown: function(iLimit) {
		if (this.a != null || this.curShopRow == iLimit) {
			return;
		}

		slidey = $("shopSlider");

		this.a = new Accelimation(slidey.style, "top", (parseInt(slidey.style.top) - 230), 600, .8, "px");
		this.a.onend = this.onSlideGoodsEnd;
		this.a.onframe = this.slideTheGoods;
		this.a.start();
		
		this.curShopRow++;
		
	},
	
	onSlideGoodsEnd: function() {
		bShop.a.stop();
		bShop.a = null;
	},
	
	slideTheGoods: function(x) {
		$("shopSlider").style.top = x + "px";	
	}

}
