﻿function breadcrumbs()
	{
	var x 		= 0;
	var stop 	= 0;
	var output 	= "<a href=\"/\">home</a>  •  ";
	var prefix	= 'you are here >&nbsp;&nbsp;&nbsp;';

	sURL 		= new String;
  	bits 		= new Object;

	sURL 		= location.href;
	sURL 		= sURL.slice(8,sURL.length);
	chunkStart 	= sURL.indexOf("/");
  	sURL 		= sURL.slice(chunkStart+1,sURL.length)

	while(!stop)
		{
    		chunkStart = sURL.indexOf("/");

		if (chunkStart != -1)
			{
     			bits[x] = sURL.slice(0,chunkStart)
      		sURL 	  = sURL.slice(chunkStart+1,sURL.length);
    			}
    		else
    			{
      		stop = 1;
    			}
   		 x++;
  		}

	for(var i in bits)
		{
    		output += "<a href=\"";
    		
    		for(y = 1; y < x-i; y++)
    			{
      		output += "../";
    			}
    		output += bits[i] + "/\">" + bits[i] + "</a>  •  ";
  		}
  	document.write(prefix + output + document.title);
  	}


function switchProductTab(tabNum)
	{
	switch (tabNum)
		{
		case '1': 
			document.getElementById('INFO').style.display 		= 'block';
			document.getElementById('COLORS').style.display 	= 'none';
			document.getElementById('PHOTOS').style.display 	= 'none';
			document.getElementById('VIDEOS').style.display 	= 'none';
			document.getElementById('REVIEWS').style.display 	= 'none';
			document.getElementById('SPECS').style.display 		= 'none';
			break;
		case '2': 
			document.getElementById('INFO').style.display 		= 'none';
			document.getElementById('COLORS').style.display 	= 'block';
			document.getElementById('PHOTOS').style.display 	= 'none';
			document.getElementById('VIDEOS').style.display 	= 'none';
			document.getElementById('REVIEWS').style.display 	= 'none';
			document.getElementById('SPECS').style.display 		= 'none';
			break;
		case '3': 
			document.getElementById('INFO').style.display 		= 'none';
			document.getElementById('COLORS').style.display 	= 'none';
			document.getElementById('PHOTOS').style.display 	= 'block';
			document.getElementById('VIDEOS').style.display 	= 'none';
			document.getElementById('REVIEWS').style.display 	= 'none';
			document.getElementById('SPECS').style.display 		= 'none';
			break;
		case '4': 
			document.getElementById('INFO').style.display 		= 'none';
			document.getElementById('COLORS').style.display 	= 'none';
			document.getElementById('PHOTOS').style.display 	= 'none';
			document.getElementById('VIDEOS').style.display 	= 'block';
			document.getElementById('REVIEWS').style.display 	= 'none';
			document.getElementById('SPECS').style.display 		= 'none';
			break;
		case '5': 
			document.getElementById('INFO').style.display 		= 'none';
			document.getElementById('COLORS').style.display 	= 'none';
			document.getElementById('PHOTOS').style.display 	= 'none';
			document.getElementById('VIDEOS').style.display 	= 'none';
			document.getElementById('REVIEWS').style.display 	= 'block';
			document.getElementById('SPECS').style.display 		= 'none';
			break;
		case '6': 
			document.getElementById('INFO').style.display 		= 'none';
			document.getElementById('COLORS').style.display 	= 'none';
			document.getElementById('PHOTOS').style.display 	= 'none';
			document.getElementById('VIDEOS').style.display 	= 'none';
			document.getElementById('REVIEWS').style.display 	= 'none';
			document.getElementById('SPECS').style.display 		= 'block';
			break;
		}
	}


function totalPkgMSRP()
	{
	var itemPrice		= '';							// Price data from table cell
	var itemPriceFloat 	= 0;							// Floating-point number version of cell data
	var pkgTotal 		= 0;							// Running total of all prices

	var table = document.getElementById("PRICING"); 	// Load the pricing table array
	var cells = table.getElementsByTagName("td");		// Load the cells array from the table

	for (var i = 0; i < cells.length; i++) 				// Loop through all the table cells
		{
	    thisClass = cells[i].className;					// Extract the CSS class name from the current cell

	    if (thisClass == "specs_item_price") 			// If the cell is a price cell
	    	{
	        itemPrice = cells[i].firstChild.data;		// Extract the data from the cell
			itemPrice = itemPrice.replace('$', '');		// Strip off any dollar signs
			itemPrice = itemPrice.replace(',', '');		// Strip off any commas

			itemPriceFloat = parseFloat(itemPrice);		// Convert the data to a floating-point number
			
			if (!isNaN(itemPriceFloat))					// If the conversion was successful (data was numeric)
				{
				pkgTotal += itemPriceFloat;				// Add the new cell's data to the running total
				}
	    	}
		}
	return pkgTotal.toFixed(2);							// return the total with only 2 places after the decimal
	}
	
	
function calcPkgSavings()
	{
	var pkgPrice 		= '';											// Price data from table cell
	var pkgPriceFloat 	= 0;											// Floating-point version of cell data
	var pkgSavings		= 0;											// Calcuated savings

	pkgPrice = document.getElementById('PKG-PRICE').firstChild.data;	// Extract price data from cell
	pkgPrice = pkgPrice.replace('$', '');								// Strip dollar signs from price
	pkgPrice = pkgPrice.replace(',', '');								// Strip commas from price

	pkgPriceFloat = parseFloat(pkgPrice);								// Convert price to floating point number
	
	if (!isNaN(pkgPriceFloat))											// If conversion was successful
		{
		pkgSavings = totalPkgMSRP() - pkgPriceFloat;					// Calculate savings
		}
	else
		{
		pkgSavings = "NaN";												// Notify of unsuccessful conversion
		}

	return pkgSavings.toFixed(2);										// return amount wit only 2 places after the decimal
	}
	
	
function writeAmt(amount)
	{
	var amtString = '';						// Output string
	
	if (amount != "NaN")					// If amount is a number
		{
		amtString = '$' + String(amount);	// Convert number to string, add dollar sign
		}
	else
		{
		amtString = amounts;				// Assign the "NaN" to the output string
		}
		
	document.write(amtString);				// Output the string
	}

