function formatCurrency(num)
 {
   var customerCurrencySymbol = "$"
   num = num.toString().replace(/\$|\,/g,'');
   
   if(isNaN(num))
     num = "0";
	 sign = (num == (num = Math.abs(num)));

	 num = Math.floor(num*100+0.00000000001);
	 cents = num%100;
	 num = Math.floor(num/100).toString();
	 if(cents<10)
	   cents = "0" + cents;

	   for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	     num = num.substring(0,num.length-(4*i+3))+','+
		 num.substring(num.length-(4*i+3));
		 return (((sign)?'':'-') + customerCurrencySymbol  + num + '.' + cents);
}

function CalcPrice()
{
  var total_price = 0;
  var NumOptions = 0;
    
  var ie4=document.all
  var ns6=document.getElementById&&document.all
  var ns4=document.layers
  var ns7=document.getElementById&&document.all

  if (frmSubmitOrder.chkProduct.length == undefined)
  {
     if (frmSubmitOrder.chkProduct.checked)
	 {
     total_price += parseFloat(frmSubmitOrder.price.value)
	 }
  }else{

     for (i = 0; i < frmSubmitOrder.chkProduct.length; i++)
     {
       if (frmSubmitOrder.chkProduct[i].checked)
	   {
	     total_price += parseFloat(frmSubmitOrder.price[i].value);
	   }
     }
	 
  }
  
  frmSubmitOrder.Total.value = formatCurrency(total_price);  
  frmSubmitOrder.Total2.value = formatCurrency(total_price);    
}

function Color_Click(intIndex, strPath)
{
  document.frmSubmitOrder.selColor.selectedIndex = intIndex-1;
 /* document.frmSubmitOrder.imgColor.src = '/images/autofloormatimages/ultimats/colors/' + document.frmSubmitOrder.selColor.options[document.frmSubmitOrder.selColor.selectedIndex].value + '-' + document.frmSubmitOrder.selColor.options[document.frmSubmitOrder.selColor.selectedIndex].innerHTML + '.jpg';*/
  document.frmSubmitOrder.imgColor.src = strPath + document.frmSubmitOrder.selColor.options[document.frmSubmitOrder.selColor.selectedIndex].innerHTML + '.jpg';
  document.getElementById("ColorDesc").innerHTML = document.frmSubmitOrder.selColor.options[document.frmSubmitOrder.selColor.selectedIndex].innerHTML;
}

function ColorChange(strPath)
{
  document.frmSubmitOrder.imgColor.src = strPath + document.frmSubmitOrder.selColor.options[document.frmSubmitOrder.selColor.selectedIndex].innerHTML + '.jpg';
  document.getElementById("ColorDesc").innerHTML = document.frmSubmitOrder.selColor.options[document.frmSubmitOrder.selColor.selectedIndex].innerHTML;
}

function Binding_Color_Click(intIndex, strPath)
{
  document.frmSubmitOrder.selBindingColor.selectedIndex = intIndex-1;
 /* document.frmSubmitOrder.imgColor.src = '/images/autofloormatimages/ultimats/colors/' + document.frmSubmitOrder.selColor.options[document.frmSubmitOrder.selColor.selectedIndex].value + '-' + document.frmSubmitOrder.selColor.options[document.frmSubmitOrder.selColor.selectedIndex].innerHTML + '.jpg';*/
  document.frmSubmitOrder.imgBindingColor.src = strPath + document.frmSubmitOrder.selBindingColor.options[document.frmSubmitOrder.selBindingColor.selectedIndex].innerHTML + '.jpg';
  document.getElementById("BindingColorDesc").innerHTML = document.frmSubmitOrder.selBindingColor.options[document.frmSubmitOrder.selBindingColor.selectedIndex].innerHTML;
}

function Binding_ColorChange(strPath)
{
  document.frmSubmitOrder.imgBindingColor.src = strPath + document.frmSubmitOrder.selBindingColor.options[document.frmSubmitOrder.selBindingColor.selectedIndex].innerHTML + '.jpg';
  document.getElementById("BindingColorDesc").innerHTML = document.frmSubmitOrder.selBindingColor.options[document.frmSubmitOrder.selBindingColor.selectedIndex].innerHTML;
}
  
function Font_Change(strPath)
{
  if (document.frmSubmitOrder.selFont.options[document.frmSubmitOrder.selFont.selectedIndex].value == '')
  {
     document.frmSubmitOrder.imgFont.style.display = 'none';
  }
  else
  {
     document.frmSubmitOrder.imgFont.style.display = '';
  }
  
  document.frmSubmitOrder.imgFont.src = strPath + document.frmSubmitOrder.selFont.options[document.frmSubmitOrder.selFont.selectedIndex].value + '.jpg';
}

function Logo_Change(strPath)
{
  if (document.frmSubmitOrder.selLogo.options[document.frmSubmitOrder.selLogo.selectedIndex].value == '')
  {
     document.frmSubmitOrder.imgLogo.style.display = 'none';
  }
  else
  {
     document.frmSubmitOrder.imgLogo.style.display = '';
  }
  
  document.frmSubmitOrder.imgLogo.src = strPath + document.frmSubmitOrder.selLogo.options[document.frmSubmitOrder.selLogo.selectedIndex].value + '.jpg';
}

function Prod_Type_Change()
{
  document.frmSubmitOrder.imgColor.src = strPath + document.frmSubmitOrder.selColor.options[document.frmSubmitOrder.selColor.selectedIndex].innerHTML + '.jpg';
  document.getElementById("ColorDesc").innerHTML = document.frmSubmitOrder.selColor.options[document.frmSubmitOrder.selColor.selectedIndex].innerHTML;
}


function Validate_Product_Selection()
{   
     
   if (frmSubmitOrder.chkProduct.length != undefined)
    {
	
      for (i = 0; i < frmSubmitOrder.chkProduct.length; i++)
      {
        if (frmSubmitOrder.chkProduct[i].checked)
	    {
	      return true;
	    }
      }

	}else{
	  if (frmSubmitOrder.chkProduct.checked)
	   {
	     return true;
	   } 
	}
	 
	 alert('You must select a product!');
	 return false;
	 
}  