function miniCart() {
	this.items = [];
	this.subtotal = 0.00;
	this.curIndex = -1;
	this.timeout = 0;
}

miniCart.prototype.next = function() {
	this.curIndex = ++this.curIndex % this.items.length;
	this.display();
}

miniCart.prototype.previous = function() {
	this.curIndex--;
	if(this.curIndex < 0)
		this.curIndex = this.items.length-1;
	this.display();
}

miniCart.prototype.add = function(newMiniCartItem) {
	this.items[this.items.length] = newMiniCartItem;
	if(this.curIndex == -1)
		this.curIndex = 0;
}

// Display the curIndex in the minicart
miniCart.prototype.display = function() {
	if(this.curIndex == -1) return;
	var p = this.items[this.curIndex];
	$('#mc-pName').text(p.name);
	$('#mc-pStyle').text(p.style);
	$('#mc-pSize').text(p.size);
	$('#mc-pColor').text(p.color);
	$('#mc-pPrice').html(p.amount + "@" + p.price + "&nbsp;&nbsp;<span style='color:red'>" + parseFloat(p.price * p.amount).toFixed(2) + "</span>");
	$('#mc-pImage > img').attr('src', decodeURIComponent(p.thumbnail));
}

function miniCartItem() {
	this.name = "";
	this.style = "";
	this.size = "";
	this.color = "";
	this.amount = 0;
	this.price = 0.00;
	this.thumbnail = "";
}

function blackout() {
	this.b = $('#blackout');
	this.m = $('#bo-messageContainer');
	this.l = $('#bo-loader');
}


blackout.prototype.resize = function() {
	this.b.height($('body').height());
	this.b.width($('body').width());
}

blackout.prototype.center = function(elm) {
	var w = elm.width(),
	    h = elm.height(),
	    sh = 0;

	if (navigator.userAgent.indexOf("MSIE") > -1) {
		sh = document.body.scrollTop;
	}	else {
		sh = window.pageYOffset;
	}

	elm.css({
		'left': (elm.parent().width() - w)/2,
		'top' : sh + $(window).height() / 3 - h/2
	});
}

blackout.prototype.bindScroll = function(elm) {
	var h;

	if(navigator.userAgent.indexOf("MSIE 6") >= 0)
		return;
	
	$(window).bind('scroll', function(event) {
		if (navigator.userAgent.indexOf("Firefox") > -1) {
			h = window.pageYOffset;
		}
		else {
			h = document.body.scrollTop;
		}
		elm.stop(true);
		elm.animate({
			'left': (elm.parent().width() - elm.width())/2,
			'top' : h+$(window).height()/3 - elm.height()/2
		}, 500, 'swing');
	});
}

blackout.prototype.error = function(s) {
	this.resize();
	this.l.hide();

	this.bindScroll(this.m);
	$(this.m).find('blockquote').html(s);
	this.center(this.m);
	this.b.show();
	this.m.show();
}

blackout.prototype.showLoader = function() {
	this.resize();
	this.m.hide();

	this.bindScroll(this.l);
	this.center(this.l);
	this.b.show();
	this.l.show();
}

blackout.prototype.show = function(id) {
	this.resize();
	this.m.hide();
	this.l.hide();
	this.b.show();

	if(id != null) {
		this.bindScroll($(id));
		this.center($(id));
		$(id).show()
	}


}

blackout.prototype.hide = function(id) {
	$(window).unbind('scroll');
	this.b.hide();
	this.l.hide();
	this.m.hide();

	if(id != null)
		$(id).hide()
}

function showDiv(id) {
	var el = document.getElementById(id);
	el.style.display = "";
	agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("msie") != -1) {
		var boxes = document.getElementsByTagName('select');
		for (var i=0; i<boxes.length; i++) {
			boxes[i].style.visibility = "hidden";
		}
	}
}
function hideDiv(id) {
	var el = document.getElementById(id);
	el.style.display = "none";
	agt=navigator.userAgent.toLowerCase();
	if (agt.indexOf("msie") != -1) {
		var boxes = document.getElementsByTagName('select');
		for (var i=0; i<boxes.length; i++) {
			boxes[i].style.visibility = "";
		}
	}
}
function submitForm() {
	document.loginform_logout.submit();
}
// new show function written by Rocco J Carello
// benefit is that the menus are centered below their tabs
function Show2(menu_name, parent_name) {
	var parent = document.getElementById(parent_name);
	var menu = document.getElementById(menu_name);
	menu.style.display = "";
	var location = findPos(parent);
	location[0] -= (menu.offsetWidth - parent.offsetWidth)/2;
	location[1] += 24;
	menu.style.left = location[0] + "px";
	menu.style.top = location[1] + "px";
}
// new hide function written by Rocco J Carello
// only display needs to be adjusted to show and hide things
// redundant javascript is redundant
function Hide2(menu_name) {
	document.getElementById(menu_name).style.display = "none";
}
// find the position of an element called by Show2()
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
}