function TagView(){};
TagView.moveUp = function(id,displayCount) {
    id = id.replace(/\$/g,"_");
    var obj = document.getElementById(id);
    var nodeList = obj.getElementsByTagName("LI");
    var count = 0;
	var i = 0;
	while (nodeList[i].style.display=="none")
		i++;

	if (i>0) {
		while (count<displayCount && i>=0) {
			if (nodeList[i].style.display=="none") {
				nodeList[i].style.display="list-item";
				count++;
				if (i + displayCount < nodeList.length) 
					nodeList[i + displayCount].style.display="none";			
			}
			i--;
		}
	} else {
		for (var i = 0, j = nodeList.length; i<j; i++) {
			nodeList[i].style.display="none";
		}
		for (var j = nodeList.length-displayCount, i = nodeList.length; j<i; j++) {
			nodeList[j].style.display="list-item";
		}	
	}
}
TagView.moveDown = function(id,displayCount) {
    id = id.replace(/\$/g,"_");
    var obj = document.getElementById(id);
    var nodeList = obj.getElementsByTagName("LI");
    var count, i;
	count = i = 0;

	while (count<displayCount && (i<(nodeList.length-displayCount))) {
		if (nodeList[i].style.display=="" || nodeList[i].style.display=="list-item") {
            nodeList[i].style.display="none";
            count++;
			if (i + displayCount < nodeList.length) 
				nodeList[i + displayCount].style.display="list-item";			
        }
		i++;
	}
	
	// start from the beginning
	if (count==0) {
		for (var j = nodeList.length-displayCount, i = nodeList.length; j<i; j++) {
			nodeList[j].style.display="none";
		}
		for (i = 0; i<displayCount; i++) {
			nodeList[i].style.display="list-item";
		}
	}
}
function Products(){};
Products.buy = function() {
    var frm = document.forms[0];
    var valid = false;
    var qty = 0;
    
    for (var i=0, j=frm.elements.length; i<j; i++) {
        if (frm.elements[i].name.indexOf("Quantity")>0) {
            qty = parseInt(frm.elements[i].value);
            valid = !isNaN(qty) ? (qty > 0) : false;
            if (valid) break;
        }
    }
    if (!valid) {
        alert("Please select a quantity before putting them in your bag!");
    }
    return valid;
}