function getRefToDiv(divID,oDoc) {
  if( document.getElementById ) {
    return document.getElementById(divID); }
  if( document.all ) {
    return document.all[divID]; }
  if( !oDoc ) { oDoc = document; }
  if( document.layers ) {
    if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
      //repeatedly run through all child layers
      for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
        //on success, return that layer, else return nothing
        y = getRefToDiv(divID,oDoc.layers[x].document); }
    return y; } }
  return false;
}
function showDiv(divID) {
  //get a reference as above ...
  myReference = getRefToDiv(divID);
  if( !myReference ) {
    window.alert('Nothing works in this browser');
    return; //don't go any further
  }
  //now we have a reference to it
  if( myReference.style ) {
    //DOM & proprietary DOM
    myReference.style.visibility = 'visible';
  } else {
    //layers syntax
    myReference.visibility = 'show';
  }
}

function changeDisplay(elementId, selected, compare, price) {
  var theElement;
  if( document.getElementById ) {
    //DOM
    theElement = document.getElementById( elementId );
  } else if( document.all ) {
    //Proprietary DOM
    theElement = document.all[ elementId ];
  }
  if( !theElement ) {
    /* The page has not loaded, or the browser claims to
    support document.getElementById or document.all but
    cannot actually use either */
    return;
  }
  //Reference the style ...
  if( theElement.style ) { theElement = theElement.style; }
  if( typeof( theElement.display ) == 'undefined' ) {
    //The browser does not allow us to change the display style
    //Alert something sensible (not what I have here ...)
    window.alert( 'Your browser does not support this' );
    return;
  }
  //Change the display style
  var DisplayChoice = 'none';
  if((theElement.display == 'none') && (selected.value == compare))
  { 
	DisplayChoice = 'block';
	var x;
	x = price.split(",");
	var i;
	i = x.length - 1;
	setTotal('lblTotal',x[i],0);	
  } 
  else
  {
		var x;
		x = price.split(",");
		setTotal('lblTotal',x[selected.selectedIndex],0);		
  } 
  theElement.display = DisplayChoice;
}
function chkInput(value,price,multipleOf,addTo)
{				
	if ((value % multipleOf) != 0)
	{ 
		alert("Please enter a multiple of " + multipleOf + "."); 
	}
	else if (value == 0)
	{
		alert("Please enter a multiple of " + multipleOf + "."); 
	}
	else
	{
		var total;					
		total = (eval(value/multipleOf) * eval(price));
		setTotal('lblTotal',addTo, total);
	}				
}
function setTotal(elementId, price, addlCost)
{
	var theElement;
	if( document.getElementById ) {
		//DOM
		theElement = document.getElementById( elementId );
	} else if( document.all ) {
		//Proprietary DOM
		theElement = document.all[ elementId ];
	}
	if( !theElement ) {
		/* The page has not loaded, or the browser claims to
		support document.getElementById or document.all but
		cannot actually use either */
		return;
	}
	theElement.innerHTML = '$' + formatAsMoney((eval(price) + eval(addlCost)));	
	document.getElementById('inTotal').value = formatAsMoney((eval(price) + eval(addlCost)));
}
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);
}


