// JavaScript Document
var images = 1;
function showProductImage( id ){
	// hide the others
	for( var i = 1; i <= images; i++ ){
		document.getElementById( "productImage" + i ).style.display = "none";
		document.getElementById( "productImage" + i ).style.visibility = "hidden";
	}
	
	document.getElementById( "productImage" + id ).style.display = "block";
	document.getElementById( "productImage" + id ).style.visibility = "visible";
}

function popImage( img, pid ){
	window.open( "/pop_productImage.php?img=" + img + "&pid=" + pid , "productImage", "toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=300,height=300,left=250,top=50");
	return false;
}

var customOptions = Array();
var basePrice;
function customChange( id, text ){
	// find if there's a price to show
	var begin = text.indexOf( "($" ) + 2;
	var end = text.indexOf( ")" ) - begin;
	if( begin < 2 ){
		var value = 0;
	}else{
		var value = text.substr( begin, end );
	}
	
	customOptions[id] = value;
	
	// update total
	var price = parseFloat( basePrice );
	for( var i in customOptions ){
		price += parseFloat( customOptions[i] );
	}
	
	document.getElementById( "priceDiv" ).innerHTML = "$" + formatAsMoney( price );
}

function formatAsMoney(mnt) {
    mnt -= 0;
    mnt = (Math.round(mnt*100))/100;
    return (mnt == Math.floor(mnt)) ? mnt + '.00' 
              : ( (mnt*10 == Math.floor(mnt*10)) ? 
                       mnt + '0' : mnt);
}