function TtW_EnableProduct(){
   var elProductBasic = document.getElementsByName( "Product-basic" ).item(0);
   var elMoveExtra = document.getElementsByName( "Extras-move" ).item(0);
   var elProductCustom = document.getElementsByName( "Product-custom-template" ).item(0);
   var elFullBrand = document.getElementsByName( "Full-branding" ).item(0);

   if( !elProductBasic.checked ) elProductBasic.checked = true;
   if( elProductCustom.checked ) elMoveExtra.checked = true;
   if( elFullBrand.checked ){
      elMoveExtra.checked = true;
      elProductCustom.checked = true;
      TtW_ShowDiscount( true );
   }else TtW_ShowDiscount( false );
}

function TtW_EnableHosting( strType ){
   var elHostingFree = document.getElementsByName( "Hosting-free" ).item(0);
   var elHostingCartika = document.getElementsByName( "Hosting-cartika" ).item(0);
   var elInstallWP = document.getElementsByName( "Install-WP" ).item(0);

   elHostingFree.checked = false;
   elHostingCartika.checked = false;
   elInstallWP.checked = false;

   if( "free" == strType ) elHostingFree.checked = true;
   if( "cartika" == strType ) elHostingCartika.checked = true;
   if( "install" == strType ) elInstallWP.checked = true;
}

function TtW_ShowDiscount( bShow ){
   document.getElementById( "divDiscount" ).style.display = (bShow) ? "block" : "none";
}

function TtW_CountPrice(){
   var elProductBasic = document.getElementsByName( "Product-basic" ).item(0);
   var elMoveExtra = document.getElementsByName( "Extras-move" ).item(0);
   var elProductCustom = document.getElementsByName( "Product-custom-template" ).item(0);
   var elFullBrand = document.getElementsByName( "Full-branding" ).item(0);
   var elHostingCartika = document.getElementsByName( "Hosting-cartika" ).item(0);
   var elInstallWP = document.getElementsByName( "Install-WP" ).item(0);

   var iPrice = 0;
   if( elProductBasic.checked ) iPrice += Number( elProductBasic.value );
   if( elMoveExtra.checked ) iPrice += Number( elMoveExtra.value );
   if( elProductCustom.checked ) iPrice += Number( elProductCustom.value );
   if( elFullBrand.checked ) iPrice += Number( elFullBrand.value );
   if( elInstallWP.checked ) iPrice += Number( elInstallWP.value );

   if( elFullBrand.checked && elMoveExtra.checked ) iPrice = 1000;

   var strPrice = String( iPrice );

   var elSpanHide = document.getElementById( "spanPrice" );
   if( elSpanHide.innerText ) elSpanHide.innerText = strPrice;
   else elSpanHide.innerHTML = strPrice;

   document.getElementById( "hidPrice" ).value = String( iPrice );
}

function TtW_Run(){
   TtW_EnableProduct();
   TtW_CountPrice();
}

function TtW_HostRun( strName ){
   TtW_EnableHosting( strName );
   TtW_CountPrice();
}