// JavaScript Document

 function timestamper(){d = new Date(); return d.getTime();}
 
 
function initshopoptions(pid){
	$('#prod-options').load('/dsdcms/shopoptionsA.php?pid='+pid);
}

function initshopoptionsB(){
	var e = document.getElementById("optionA");
	var aid = e.options[e.selectedIndex].value;
	$('#prod-optionsB').load('/dsdcms/shopoptionsB.php?aid='+aid, function() {
											aprice = document.getElementById("aprice").value;
											pprice = document.getElementById("pprice").value;
											if (aprice != 0 && aprice != ''){
												document.getElementById("displayprice").innerHTML = aprice;
											}else{
												document.getElementById("displayprice").innerHTML = pprice;
											}
											
											
																		   });	
	
}

function selectoptionB(){
	var f = document.getElementById("optionB");
	var bid = f.options[f.selectedIndex].value;
		$.ajax({
 type: "GET",
 data: ({
bid: bid}),
  url: '/dsdcms/getbprice.php?ts='+timestamper(),
  success: function(data) {
	  
	  
	  if (data != '0'){
		  document.getElementById("displayprice").innerHTML = data;
	  }else{
		 
		 									aprice = document.getElementById("aprice").value;
											pprice = document.getElementById("pprice").value;
											if (aprice != 0 && aprice != ''){
												document.getElementById("displayprice").innerHTML = aprice;
											}else{
												document.getElementById("displayprice").innerHTML = pprice;
											}
		  
	  }
  }
});
	
}

function submitaddtocart(){
	if ($("#addtocart").valid()){
		$("#addtocart").submit();
	}
}












// Remove item from cart
function remove_line(line_num){
	document.getElementById(line_num).value = "0";
	$('#update').submit();	
}
