// JavaScript Document
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0

  window.open(theURL,winName,features);
}


function StorageDefaultValues(){
			if (document.Storage.CdCount.value == 'Anzahl der CDs') 		document.Storage.CdCount.value 	= '';
			
}

/*Create arrays for each format type having 5 entries for bit rates. Pad using "-- -- --"*/
var Format = new Array("Bitrate","-- -- --","-- -- --", "-- -- --", "-- -- --");
var MP3 = new Array("128","192","224", "320", "-- -- --");
var AAC = new Array("96", "128", "160", "192", "-- -- --");
var WMA = new Array("64", "96", "128", "160", "192");
var FLAC = new Array("<n/a>", "-- -- --", "-- -- --", "-- -- --", "-- -- --");
var WMA_Lossless = new Array("<n/a>", "-- -- --", "-- -- --", "-- -- --", "-- -- --");
var Apple_Lossless = new Array("<n/a>", "-- -- --", "-- -- --", "-- -- --", "-- -- --");
var WAV = new Array("<n/a>", "-- -- --", "-- -- --", "-- -- --", "-- -- --");
var sFormat = "Format", sBitRate = "Bitrate";//Selected format and bitrate

function ChangeFormat(FormatName)//Selected new format from the dropdown list
{
var numbers_select = window.document.Storage.BitRates;
var the_array = eval(FormatName);
sFormat = FormatName
ChangeBitRates(window.document.Storage.BitRates, the_array);
}


function ChangeBitRates(the_select, the_array)//Dynamically change the BitRate dropdown list for the selected format
{
var i=0;
for (;i < the_select.options.length; i++)
{
the_select.options[i].text = the_array[i];
}
sBitRate = the_select.options[0].text
}


function ChangeBitRate(selectedBitRate)//BitRate changed
{
sBitRate = parseInt(selectedBitRate);
}


function MoreCd(){//"+" button pressed, increas CD number
var Count;
var Check;
Check = window.document.Storage.CdCount.value;
if(Check.match(/[^0-9]/)){
    alert ('Ung?ltige Anzahl der CDs');
    return;
    }

Count = parseInt(window.document.Storage.CdCount.value);
    Count = Count + 1;

window.document.Storage.CdCount.value = Count;
return;
}

function LessCd(){//"-" button pressed, decrease the CD number
var Count;
var Check;
Check = window.document.Storage.CdCount.value;
if(Check.match(/[^0-9]/)){
    alert ('Ung?ltige Anzahl der CDs');
    return;
    }

Count = parseInt(window.document.Storage.CdCount.value);
if(Count>1)
    Count = Count - 1;

window.document.Storage.CdCount.value = Count;
return;
}


//Calculate button clicked
function Result(){
var DvdSize, StorageSize, CdCount, DvdCount, iVal, 
      GoldHours, SilverHours, GoldCosts, GoldPlusCosts, Silver25Costs, Silver75Costs;

try{//Get the size of individual DVD
DvdSize = 4;
}
catch (err) {
alert("Ung?ltige DVD Gr??enangabe");
//return;
}
if(!DvdSize){//Validate input
alert("Ung?ltige DVD Gr??enangabe");
return;
}

CdCount = parseInt(window.document.Storage.CdCount.value);//Number opf CDs chosen
if(!CdCount){//Validate
alert("Ung?ltige Anzahl der CDs");
return;
}

//Mp3, AAC, WMA :: LossyFormat :: Storage size & DVD Number calculated using bitrate * duration
if (sFormat == "MP3" || sFormat == "AAC" || sFormat == "WMA")
{
StorageSize = (CdCount * 80 * 60 * sBitRate) / 8 / 1024 / 1024;//GByte
  GoldHours = CdCount * 1.8;
    SilverHours = GoldHours *4 /60;
    OwnHours = CdCount / 4;
    GoldCosts = CdCount * 1.6;
    GoldPlusCosts = CdCount * 1.85;
  }
//WMA Lossless :: StorageSize & Dvd number calculated as 60% of the original audio data
else if(sFormat == "WMA_Lossless")
{
StorageSize = CdCount * 800 * 0.6 / 1024;
  GoldHours = CdCount * 1.2;
    SilverHours = GoldHours *4 /60;
    OwnHours = CdCount / 6;
    GoldCosts = CdCount * 1.6;
    GoldPlusCosts = CdCount * 1.85;
}
//Apple Lossless :: StorageSize & Dvd number calculated as 60% of the original audio data
else if(sFormat == "Apple_Lossless")
{
StorageSize = CdCount * 800 * 0.6 / 1024;
  GoldHours = CdCount * 1.2;
    SilverHours = GoldHours *4 /60;
    OwnHours = CdCount / 6;
    GoldCosts = CdCount * 1.6;
    GoldPlusCosts = CdCount * 1.85;
}
//FLAC :: StorageSize & Dvd number calculated as 58% of the original audio data
else if(sFormat == "FLAC" )
{
StorageSize = CdCount * 800 * 0.58 / 1024;
  GoldHours = CdCount * 1.2;
    SilverHours = GoldHours *4 / 60;
    OwnHours = CdCount / 6;
    GoldCosts = CdCount * 1.6;
    GoldPlusCosts = CdCount * 1.85;
}
else if (sFormat == "WAV" )//Most bulky, 1Min = 10MByte
{
StorageSize = CdCount * 800 / 1024;
  GoldHours = CdCount * 1.2;
    SilverHours = GoldHours *4 / 60;
    OwnHours = CdCount / 6;
    GoldCosts = CdCount * 1.6;
    GoldPlusCosts = CdCount * 1.85;
}
else{
alert("Ung?ltiges Format!");
return;
}

window.document.Storage.NeedSpace.value = ((StorageSize+0.05)*10);
iVal = parseInt(window.document.Storage.NeedSpace.value);
StorageSize = iVal/10;
window.document.Storage.NeedSpace.value = Math.round(StorageSize);

DvdCount= parseInt(StorageSize / DvdSize) + 1;
window.document.Storage.DvdCount.value = DvdCount;

if (SilverHours < 21) 
  {
    Silver25Costs = 60; 
    Silver75Costs = 80;
  }
  else if (SilverHours < 45) 
  {
    Silver25Costs = 132; 
    Silver75Costs = 176;
  }
  else if (SilverHours < 69) 
  {
    Silver25Costs = 204; 
    Silver75Costs = 272;
  }
  else if (SilverHours < 93) 
  {
    Silver25Costs = 276; 
    Silver75Costs = 368;
  }
  else if (SilverHours < 117) 
  {
    Silver25Costs = 348; 
    Silver75Costs = 464;
  }
  else if (SilverHours < 141) 
  {
    Silver25Costs = 420; 
    Silver75Costs = 560;
  }
  else 
  {
    Silver25Costs = "anrufen"; 
    Silver75Costs = "anrufen";
  }
window.document.Storage.GoldRealCosts.value = GoldCosts;
window.document.Storage.GoldPlusCosts.value = GoldPlusCosts;
window.document.Storage.SilverHours.value = Math.round(SilverHours);
window.document.Storage.Silver25Costs.value = Silver25Costs;
window.document.Storage.Silver75Costs.value = Silver75Costs;
window.document.Storage.GoldPlusCosts.value = Math.round(GoldPlusCosts * 10000) / 10000;
window.document.Storage.OwnHours.value = Math.round(OwnHours);
}//Result ends here

