var totalCartPrice;

function addAll(div){
	getElementsByClass(document,'addToTotal','*');
}

function getElementsByClass(node,searchClass,tag) {
	totalCartPrice = 0.00;
	var classElements = new Array();
	var els = node.getElementsByTagName(tag); // use "*" for all elements
	var pattern = new RegExp('\\b'+searchClass+'\\b');
	for (var i = 0; i < els.length; i++){
		if(pattern.test(els[i].className)){
			classElements[classElements.length] = els[i];
			name = els[i].id;
			productid = name.split("_");
			productid = productid[1];
			
			price = document.getElementById('Price_'+productid).value*document.getElementById('Quantity_'+productid).value,2;
			totalCartPrice = totalCartPrice + price;
		}
	}
	document.getElementById('totalCartPrice').innerHTML = format(totalCartPrice,2);
}

function format(expr,decplaces)
{
	var str=""+Math.round(eval(expr)*Math.pow(10,decplaces));
	while(str.length<=decplaces)
	{
		str="0"+str;
	}
	var decpoint=str.length-decplaces;
	return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
}

function copy_properties(){
	url=window.location.href.split("#");
	if(url[1]){
		urlhash=url[1].split("&");
		newurl=url[0];
		for(i=0;i<urlhash.length;i++){
			urlhash[i]=urlhash[i].split("=");
			if(!urlhash[i][1]){ urlhash[i][1]=""; }
			if(url[0].indexOf("?")){
				newurl+="&";
			}
			else {
				newurl+="?";
			}
			newurl+=urlhash[i][0]+"="+urlhash[i][1];
		}
		if(url[0]!==newurl){
			window.location=newurl;
		}
	}
}