/**
 * Calculates the itemCosts in respect to 3 layers of the amount.
 * 
 * @version        11/17/08
 * @author         Tobias Preuss
 * 
 * @param {numItems} numItems can be numCDs or numFreeCDs
 */
function calculateCosts(numItems) {	

	var itemCosts = 0;
	if (numItems>400) {
		itemCosts = itemCosts + 325 + (numItems-400)*0.5;
	} 
	else if (numItems>100 && numItems<401) {
		itemCosts = itemCosts + 100 + (numItems-100)*0.75;
	} 
	else if (numItems>0 && numItems<101) {
		itemCosts = itemCosts + numItems;
	}	
	return Math.round(itemCosts * 100) / 100;
}


/**
 * Calculate preload costs
 * Function is 'called from products_preloadpricing.php' 
 * and 'store_checkout_customer_new_preload_02.php'
 * used in 'products_preload_pricing.php'
 * 
 * @version     12/18/08
 * @author      Tobias Preuss
 * @see			PHP function: 'l_include/util.inc'
 */
function calculatePreloadCosts(){
	
	var cds		= 0;
	var freecds = 0;
	var costs   = 0.00;
	cds     	= document.getElementsByName('numberOfCDs')[0].value;

	// Check if input is a number	
	if (isNaN(cds)) {
	}
	else {
		freecds 	= document.getElementsByName('preloaddevice')[0].value;
		
		// Remove minus
		cds 		= Math.round(Math.abs(cds));
		freecds 	= Math.round(Math.abs(freecds));
	
		// @TODO TP@081117 - Preload charges $40 - should be a value in the db ...
		if(cds>0) 	costs = 40.00;
		if(cds<=freecds) freecds = cds;
		costs += calculateCosts(cds)-calculateCosts(freecds);
	}
	document.getElementById('preloadCost').innerHTML = costs.toFixed(2);
	document.getElementById('freecds').innerHTML = freecds;
}


// -----------------

/**
 * Shows additional text onmouseover on 'customer stories' page
 * 
 * @version		03/06/09
 * @author		Tobias Preuss
 * @param 		{Object} anID
 */
function showUserComment(anID){
	
	if (!(document.getElementById(anID))){
		return;
		}
	
	// show the stuff:
	var username	= document.getElementById(anID + 'name').innerHTML;
	var useralbum	= document.getElementById(anID + 'album').innerHTML;
	var userproduct	= document.getElementById(anID + 'product').innerHTML;
	var usercomment	= document.getElementById(anID + 'quote').innerHTML;
	
	document.getElementById('username').innerHTML		= '<h3 style="margin-top:0;">' + username + '</h3><p>' + userproduct + '</p><p>' + useralbum + '</p>';
	document.getElementById('usercomment').innerHTML	= '<p>' + usercomment + '</p>';
	}

// ----------

function changecolor()
{
    document.getElementById('showinblack06HD').innerHTML = '<img src="http://www.olive.us/p_images//shop/products/O6660-1B.thumb.jpg" alt="Olive O6HD MUSIC SERVER" title="O6HD MUSIC SERVER" />';
}


function changecolorback()
{
    document.getElementById('showinblack06HD').innerHTML = '<img src="http://www.olive.us/p_images//shop/products/O6660-1S.thumb.jpg" alt="Olive O6HD MUSIC SERVER" title="O6HD MUSIC SERVER" />';
}


