//prodImg, prodID, prodExtID, prodName, prodPub, prodAuth, prodCat, prodPrice, prodDesc
function showDetail(prodImg, prodMp3, prodID, extID, prodPrice, prodDesc) {

	var e = document.getElementById("detailArea_"+prodID);
	if(e.style.display == 'none'){
	e.style.display = '';

		showObj = document.getElementById(prodID).innerHTML;
		showObj = showObj.toLowerCase();
		prodName = showObj.substring(0, showObj.indexOf("</a>"));
		prodName = prodName.substring(prodName.lastIndexOf("\">")+2);
		prodPub = showObj.substring(showObj.lastIndexOf(" | ")+3, showObj.indexOf("<!--pub-->"));
		if (showObj.indexOf("<!--pub-->") < 0) prodPub ="";
		prodAut = showObj.substring(showObj.indexOf("<b>by</b>")+9, showObj.indexOf("<!--auth-->"));
		if (showObj.indexOf("<!--auth-->") < 0) prodAut = "";
		prodCat = showObj.substring(showObj.indexOf(">(")+2, showObj.indexOf(")</b>"));
		prodDesc = prodDesc;
		
		document.getElementById("detailArea_"+prodID).style.display = "block";
		
		//detailHTML = "<br><hr class='description'>";
		detailHTML = "<br><table id='sound_description"+prodID+"' class=\"prodDetailTable\">\n";
		//detailHTML += "	<tr>\n";
		
		//product Name
		//detailHTML += "		<td class=\"detailTabTitle\" colspan=\"2\" align=\"center\"><h2>"+prodName+"</h2></td>\n";
		//detailHTML += "		<td width=\"25\"><a href=\"javascript:closeDetail('"+prodID+"');\"><img class=\"exiter\" src=\"images/close.gif\"/></a></td>\n";
		//detailHTML += "	</tr>\n";
		/*detailHTML += "	<tr>\n		<td width=\"30px\">";
		
		//product image
		if (prodImg != "") {
			detailHTML += "<a href=\"" + prodImg + "\" target=\"_blank\"><img class=\"dispImg\" src=\"" + prodImg + "\" width=\"250\"/></a>";
		}
	
		if (prodMp3 != "") {
			detailHTML += "<a class=\"sound\" href=\"" + prodMp3 + "\">Download Audio</a><br/>";
			detailHTML += "<embed class=\"audio\" src=\"" + prodMp3 + "\" autostart=\"true\" hidden=\"false\" />";
		}
	
		//product inforamtions(ID, Publisher, Type, Price)
		detailHTML += "</td>\n";
		detailHTML += "		<td width=\"225\"><div class=\"detail_span\">\n";
		detailHTML += "		<h3>ID: </h3>" + prodID + "<br/>\n";
		if (extID != "") {
		detailHTML += "		<h3>SID: </h3>" + extID + "<br/>\n"; }
		if (prodAut != "") {
		detailHTML += "		<h3>Author: </h3>" + prodAut + "<br/>\n"; }
		if (prodPub != "") {
		detailHTML += "		<h3>Publisher: </h3>" + prodPub + "<br/>\n"; }
		if (prodCat != "") {
		detailHTML += "		<h3>Type: </h3>" + prodCat + "<br/>\n"; }
		detailHTML += "		<h3>Retail: </h3>" + prodPrice + "<br/>\n";
		detailHTML += "		</div><br>";
		*/	
		//product sample sound clips
		if (prodMp3 != "") {
			detailHTML += "<br><div class=\"sound\">";
			while( prodMp3 != "" ){
				//track number
				detailHTML += prodMp3.substring(0,prodMp3.indexOf("|")) + ". ";
				prodMp3 = prodMp3.substring(prodMp3.indexOf("|")+1);
				//track name
				detailHTML += prodMp3.substring(0,prodMp3.indexOf("|")) + " - ";
				prodMp3 = prodMp3.substring(prodMp3.indexOf("|")+1);
				//track file link
				detailHTML += "<a class='sound' href=\"" + prodMp3.substring(0,prodMp3.indexOf("|")) + "\" target=\"_blank\">Listen</a><br/>";
				prodMp3 = prodMp3.substring(prodMp3.indexOf("|")+1);
			}//end while
			detailHTML += "</div><br>";
		}//end if
	
		/*detailHTML += "</td>\n";
		detailHTML += "		<td>&nbsp;</td>\n";
		detailHTML += "	</tr>\n";
		
		//product description*/
		if (prodDesc != "") {
		//detailHTML += "<tr><td colspan=\"2\"><div class=\"detail_span_des\">";
		//detailHTML += "		<br/><h3>Description: </h3><br><i class=\"description\">" + prodDesc + "</i>\n"; 
		detailHTML += "<tr><td>"+prodDesc+"</td></tr>";
		//detailHTML += "		<td>&nbsp;</td>\n";
		//detailHTML += "</div></td></tr>";
		}
	
		detailHTML += "</table><br><br>\n";
		
		document.getElementById("detailArea_"+prodID).innerHTML = detailHTML;
		
	}
	else{
		e.style.display = 'none';
	}
	
}//end function

function closeDetail(prodID) {
	document.getElementById("detailArea_"+prodID).style.display = "none";
}

function tester(abc, def) {
	alert(abc);
	alert(def);
}


//show/hide quantity input area (for Create New Cart)
function show_hide2(id){

  var e = document.getElementById(id);
  if(e.style.display == 'none'){
	e.style.display = '';
	//set the text focus
	document.getElementById('cart_name').focus();
  }
  else{
	e.style.display = 'none';
  }

}//end function


//show/hide quantity input area
function show_hide(id){

  var e = document.getElementById(id);
  if(e.style.display == 'none'){
	e.style.display = '';
	//set the text focus
	document.getElementById(id+"_text").focus();
  }
  else{
	e.style.display = 'none';
  }

}//end function



//output html for edit quantity in shopping cart
function edit(id, pID, quantity){

  var eDiv = document.getElementById(id);
  
  html_string = "<form action=\"cart.php\">";
  html_string += "<input type=\"hidden\" name=\"action\" value=\"update\">"; 
  html_string += "<input type=\"hidden\" name=\"p\" value='" + pID + "'>";
  html_string += "<input id='"+id+"_text' type='text' style='width: 3em' name='q' value='" + quantity + "' maxlength='8'>";                 
  html_string += "<input class='btn' type='submit' value='Update'>";
  html_string += "</form>";

  eDiv.innerHTML = html_string;

  //highlight quantity
  document.getElementById(id+"_text").select();

}//end edit()



//to confirm b4 delete the cart
function confirm_delete(cart_id, cart_name){

  var str = cart_name.replace("(#double_quote#)","\"")
  var answer = confirm("Are sure you want to delete the order \""+str+"\"?")
  if (answer){
    window.location="manage_carts.php?action=delete_cart&c_id="+cart_id+"";
  }

}//end confirm_delete()