/***********************************************************************/
/************************************************* javascript core *****/
/***********************************************************************/

// constants
var MACOS_STYLESHEET_REFERENCE  = RESOURCES_PATH + "css/styles-macos.css";
var WEBKIT_STYLESHEET_REFERENCE = RESOURCES_PATH + "css/styles-webkit.css";
var SIFR_PATH                   = RESOURCES_PATH + "sifr/sifr.swf";

// serve special styles for Safari and Mac OS
if (Info.os.isMac)         document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + MACOS_STYLESHEET_REFERENCE + "\" />");
if (Info.browser.isWebkit) document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + WEBKIT_STYLESHEET_REFERENCE + "\" />");

/********************************************************************/
/* START: layout initalisation                                      */

// inits sifr
function initLayout_sifr() {
  if (typeof sIFR != "function") return;

  sIFR.replaceElement(named({
    sSelector:"div.h1 h1",
    sFlashSrc: SIFR_PATH,
    sColor:"#4cb530",
    sWmode:"transparent"
  }));
}

/* END: layout initalisation                                        */
/********************************************************************/
/* START: umrechner                                      */

var start;
function P91Calc(){
  var core;
  switch(start){
    case 0:
      core=document.getElementById('input').value;
      break;
    case 1:
      core=document.getElementById('input2').value*2.54;
      break;
  }
  if(isNaN(core)){
    alert("Bitte eine Zahl eingeben!");
  }else{
    document.getElementById('input').value=runden2(core);
    document.getElementById('input2').value=runden2(core/2.54);
    document.getElementById('zoll').value=runden2(runden2(core*0.665)/2.54);
    document.getElementById('cm').value=runden2(core*0.665);
    document.getElementById('zoll6').value=runden2(runden2(runden2(core*0.665)-4.25)/2.54);
    document.getElementById('cm6').value=runden2(runden2(core*0.665)-4.25);
    document.getElementById('cm2').value=runden2(runden2(core*0.226)*2.54);
    document.getElementById('zoll2').value=runden2(core*0.226);
    document.getElementById('cm3').value=runden2(runden2(core*0.259)*2.54);
    document.getElementById('zoll3').value=runden2(core*0.259);
    document.getElementById('cm4').value=runden2(runden2(core*0.225)*2.54);
    document.getElementById('zoll4').value=runden2(core*0.225);
    document.getElementById('cm5').value=runden2(runden2(core*0.24)*2.54);    
    document.getElementById('zoll5').value=runden2(core*0.24);
  }
}
function switcher(input){
  start=input;
}
function runden2(aaa){
  return Math.round(aaa*100)/100;
}

/* END: umrechner                                      */
/********************************************************************/

