<!-- 
function cart(id){
    this.id=id;
    this.products=new Array();
    this.items=new Array();
    this.sort=function(){
        a=this.products;
        for (var i=0;i<a.length;i++){ 
            for (var j=i+1;j<a.length;j++){ 
                if(parseInt(a[i].id)>parseInt(a[j].id)){
                    var temp=a[i];
                    a[i]=a[j];
                    a[j]=temp;
                }
            }
            if(a[i].qty>0)a[i].textBox.value=a[i].qty;
        }
        var t=document.getElementById('showOrder');
	    if(t==null)return;
	    var rows=t.getElementsByTagName("tr");
	    if(rows==null)return;
	    var endRow=1;
	    while(!rows[endRow].id){
	        t.deleteRow(endRow)
	    }
        for (var i=0;i<a.length;i++){
            if(a[i].rowNum>0){
                var row = t.insertRow(endRow);
	            var col = row.insertCell(0);
                col.appendChild(document.createTextNode(a[i].qty));
	            col = row.insertCell(1);
	            col.appendChild(document.createTextNode(a[i].shortName));
	            col = row.insertCell(2);
	            col.className="money";
	            //alert(a[i].cost);
	            col.appendChild(document.createTextNode(formatNumber(a[i].qty*a[i].cost)));
                a[i].rowNum=endRow;
                endRow+=1;
            }
        }
        if(endRow==1){ // no items currently in cart
            this.empty=true;
            this.displayNone=true;
        }else{
            this.empty=false;
            this.displayNone=false;
        }
    }
}
function product(id,pName,shName,ctrl,row,cost){
    this.id=id;
    this.qty=0;
    this.cost=cost;
    this.pName=pName;
    this.shortName=shName;
    this.totalQty=0;
    this.rowNum=row;
    this.textBox=ctrl;
	this.textBox.onkeyup=addQty;
	this.textBox.calc=addQty;
	this.textBox.n=this;
}
function addQty(obj){
    itemPrice=this.n.cost;
    var q=(this.value>"")?this.value:0;
	numRegExp=/^[0-9]\d*$/;
	if(numRegExp.test(q)){	// is number
        var t=document.getElementById('showOrder');
	    if(t==null)return;
	    if(q>0){ 
            this.n.totalQty=parseInt(q);
            this.n.qty=parseInt(q);
            if(this.n.totalQty>0){ //add or edit row
                //alert(this.n.rowNum);
	                var rows=t.getElementsByTagName("tr");
	                if(rows==null)return;
                    if(this.n.rowNum>0){ //row exists,edit qty,price
	                    var cells=rows[this.n.rowNum].getElementsByTagName("td");
	                    if(cells==null)return;
	                    cells[0].replaceChild(document.createTextNode(this.n.totalQty), cells[0].firstChild);
	                    cells[2].replaceChild(document.createTextNode(formatNumber(this.n.totalQty*itemPrice)), cells[2].firstChild);
                    }else{ //add new row
                        if(newCart.displayNone){
                            t.deleteRow(1);
                            newCart.displayNone=false;
                            for (var i=0;i<newCart.products.length;i++){
                                if(newCart.products[i].rowNum>0){
                                    newCart.products[i].rowNum-=1;
                                }
                            }
                        }
                        var newRowPos=1;
                        var pos=0;
                        for (var i=0;i<newCart.products.length;i++){
                            if(newCart.products[i].shortName==this.n.shortName){//alert(i+":"+newCart.products[i].shortName+" Break");
                                pos=i+1;
                                break;
                            }else{
                                if(newCart.products[i].rowNum>0){
                                    newRowPos=newCart.products[i].rowNum+1;
                                }
                                
                            }
                        }
                        for (var i=pos;i<newCart.products.length;i++){//alert("i:"+i);
                            if(newCart.products[i].rowNum>0){
                                newCart.products[i].rowNum++;
                            }
                        }
                        this.n.rowNum=newRowPos;
	                    var row = t.insertRow(newRowPos);
	                    var col = row.insertCell(0);
                        col.appendChild(document.createTextNode(this.n.totalQty));
	                    col = row.insertCell(1);
	                    col.appendChild(document.createTextNode(this.n.shortName));
	                    col = row.insertCell(2);
	                    col.className="money";
	                    col.appendChild(document.createTextNode(formatNumber(this.n.totalQty*itemPrice)));
                    }
                calculateTotal(t);
            }
        }else{ //invalid entry. Set textbox to blank remove row if it exists
            proccessZero(this,this.n);
        }    
    }else{
        proccessZero(this,this.n);
    }
}
function proccessZero(txtBox,product){
    product.qty=0;
    var t=document.getElementById('showOrder');
    txtBox.value="";
    if(product.rowNum>0){ // row exists
        /* uncomment if mini cart items should not be overwritten ... don't forget to uncomment the closing bracket
        if(product.qty>0){ // has qty in cart edit row
            var rows=t.getElementsByTagName("tr");
	        var cells=rows[product.rowNum].getElementsByTagName("td");
	        if(cells==null)return;
	        cells[0].replaceChild(document.createTextNode(product.qty), cells[0].firstChild);
	        cells[2].replaceChild(document.createTextNode(formatNumber(product.qty*itemPrice)), cells[2].firstChild);        
        }else{ // no qty in cart. delete row
        */
            var rowNum=product.rowNum;
            t.deleteRow(rowNum);
            product.rowNum=0;
            for (var i=0;i<newCart.products.length;i++){
	            if(newCart.products[i].rowNum>rowNum){
	                newCart.products[i].rowNum--;
	            }
	        }            
            if(!hasItems()){
                if(!newCart.displayNone){
                    toggleDisplay(t,"on");
                }
            }
        //}
    }else{ //row does not exist
        if(product.qty>0){ // has qty in cart 
            alert("must add row");
        }
    }
    calculateTotal(t);
}
function hasItems(){
    for (var i=0;i<newCart.products.length;i++){
        var hasItems=false;
        if(newCart.products[i].rowNum>0){
            return true;
        }
    }            
    return false;
}
function toggleDisplay(t,mode){
    newCart.displayNone=true;
    var row = t.insertRow(1);
    var col = row.insertCell(0);
    col.appendChild(document.createTextNode(""));
    col = row.insertCell(1);
    col.className="discount";
    col.appendChild(document.createTextNode("No Items Ordered"));
    col = row.insertCell(2);
    col.appendChild(document.createTextNode(""));
}
function calculateTotal(t){//alert("calculate total:" + newCart.products);
    var total=0;
    for (var i=0;i<newCart.products.length;i++){//alert("i:"+i);
        if(newCart.products[i].qty>0){
            total+=newCart.products[i].qty*newCart.products[i].cost;
            //alert(total);
        }
    }
    var qty=0;
    var rows=t.getElementsByTagName("tr");
	for (var i=1;i<rows.length-3;i++){//alert(i+":"+rows[i].id);
	    if(rows[i].id=='noItemsRow'){
	        qty=0;
	        break;
	    }
	    if(!rows[i].id){
	        var cells=rows[i].getElementsByTagName("td");
	        qty+=parseInt(cells[0].firstChild.nodeValue);
	    }
	}
	var cells=rows[rows.length-3].getElementsByTagName("td");
    cells[2].replaceChild(document.createTextNode(formatNumber(total)), cells[2].firstChild);   
	cells=rows[rows.length-2].getElementsByTagName("td");
	var d=discount(qty);
	cells[1].replaceChild(document.createTextNode(d*100+"% Discount"), cells[1].firstChild);   
    cells[2].replaceChild(document.createTextNode(formatNumber(d*(total))), cells[2].firstChild);   
	cells=rows[rows.length-1].getElementsByTagName("td");
    cells[2].replaceChild(document.createTextNode(formatNumber((total)-(d*(total)))), cells[2].firstChild);

    //cells[1].replaceChild(document.createTextNode(discount(total)*100+"% Discount"), cells[1].firstChild);   
    //cells[2].replaceChild(document.createTextNode(formatNumber(discount(total)*(total))), cells[2].firstChild);   
	//cells=rows[rows.length-1].getElementsByTagName("td");
    //cells[2].replaceChild(document.createTextNode(formatNumber((total)-(discount(total)*(total)))), cells[2].firstChild);
    //var c=document.getElementById('orderInfo');
    //if(c){
        //alert(c.style.backgroundColor);
        //c.style.backgroundColor="blue";
        //var t=setTimeout("c.style.backgroundColor='#c03'",1000);
     //changeBG(1);
     //var t=setTimeout("changeBG(2)",100);
     //var t=setTimeout("changeBG(0)",200);
     //var t=setTimeout("changeBG(2)",300);
     //var t=setTimeout("changeBG(1)",400);
     //var t=setTimeout("changeBG(0)",500);
    //}
}
function changeBG(n){//alert("in");
    var c=document.getElementById('orderInfo');
    if(c){
        //alert(c.style.backgroundColor);
        if(n==0){
            c.style.backgroundColor="#c03";
        }
        if(n==1){
            c.style.backgroundColor="blue";
        }
        if(n==2){
            c.style.backgroundColor="yellow";
        }
    }
}
function formatNumber(num,cur) {
	var c=(cur)?cur:'';
	num=Math.abs(Math.round(num * Math.pow(10,2)));
	if(num>0){
	    var y = (''+num).split('');
	    y.splice(y.length - 2, 0, '.');
	    return c+y.join('');
	}return c+"0";
}


function compute(id,desc,qty){
	var t=document.getElementById('showOrder');
	numRegExp=/^[1-9]\d*$/;
	if(!numRegExp.test(qty)){	
		var rows=t.getElementsByTagName("tr");
		for (var i=0;i<rows.length;i++){
			if(rows[i].id==id){
				t.deleteRow(i);
			}
		}
		return 0;
	}
	return parseInt(qty);
}
function total(x){
	var x=document.getElementsByTagName('input');
	var total=0;
	numRegExp=/^[1-9]\d*$/;
	for (var i=0;i<x.length;i++){
		if(x[i].className=="jInput"){
			if(numRegExp.test(x[i].value)){	
				total+=parseFloat(x[i].value);
			}
		}
	}
	//alert("total: "+newCart);
	return total*itemPrice;
}
if(!document.getElementById)document.getElementById=function(){return null;}
-->