// ---------------------------------------------------- var url = "http://www.DetectoScale.com"; var title = "www.DetectoScale.com"; // ---------------------------------------------------- function makeLink() { if(document.all) window.external.AddFavorite(url,title) } // ---------------------------------------------------- function MM_displayStatusMsg(msgStr) { //v1.0 status=msgStr; document.MM_returnValue = true; } // ---------------------------------------------------- function calculate_bmi_feet_pounds(lbs, ins) { h2 = ins * ins; bmi = lbs/h2 * 703 f_bmi = Math.floor(bmi); diff = bmi - f_bmi; diff = diff * 10; diff = Math.round(diff); if (diff == 10) { f_bmi += 1; diff = 0; } bmi = f_bmi + "." + diff; return bmi; } function compute_bmi() { var f = window.document.frmCalculateBMIfeetpounds; var fi = parseInt(f.htf.options[f.htf.selectedIndex].value * 12); var ii = parseInt(f.hti.options[f.hti.selectedIndex].value); var i = fi + ii; w = f.wt.value; if (chkw(w)) {f.bmi.value = calculate_bmi_feet_pounds(w, i);} else { alert("Please select your height in feet and enter your weight in pounds"); } } function chkw(w) { if (isNaN(parseInt(w))){ return false; } else if (w < 0){ return false; } else{ return true; } } // ---------------------------------------------------- function cknull(src) { if (!src) { alert("Please enter your height in centimeters and your weight in kilograms"); return false; } return true; } function calcbmi(ht, wt) { return (wt/(Math.pow(ht, 2))); } function converttometers(ht) { return (ht/100); } function compute_bmi_metric() { var ht; var wt; var b; if (!(cknull(document.frmCalculateBMImetric.height.value))) return false; else ht=(converttometers(document.frmCalculateBMImetric.height.value)); if (!(cknull(document.frmCalculateBMImetric.weight.value))) return false; else wt=(document.frmCalculateBMImetric.weight.value); b=calcbmi(ht, wt); //if (b<19) // document.frmCalculateBMImetric.txtresult.value = "A BMI value of less than 18 may be unhealthy. You may want to visit your doctor. A BMI of 18-19 is optimal."; //if ((b>18.9) && (b < 22)) // document.frmCalculateBMImetric.txtresult.value = "A BMI value of 19-21 is optimal. Congratulations!"; //if ((b > 21.9)&&(b<23)) // document.frmCalculateBMImetric.txtresult.value = "A BMI value of 21-23 is better than average. Good work! "; //if ((b >22.9) && (b<26)) // document.frmCalculateBMImetric.txtresult.value = "A BMI value of 23-26 is average, but you may want to begin a healthful diet and exercise program to bring your BMI down to the more healthful 19-23 range."; //if (b > 25.9) // document.frmCalculateBMImetric.txtresult.value = "A BMI value over 26 may be unhealthy. See your physician, then start a healthy diet and exercise program to reduce your BMI to the more healthful 18-22 range."; b=Math.round(b); document.frmCalculateBMImetric.txtbmi.value = parseInt(b); return true; } // ---------------------------------------------------- function NurNumerisch(objInputTextfield) { //Inhalt des übergenenen Textfeldes einlesen var txtInputTextfieldContent = objInputTextfield.value; var txtInputTextfieldContent=txtInputTextfieldContent.replace(/\,/gi,"."); //Ersetzen var txtInputTextfieldContent=txtInputTextfieldContent.replace(/[^0-9\,\.\-]/gi,""); //Ersetzen objInputTextfield.value = txtInputTextfieldContent; //Ausgeben } // ---------------------------------------------------- function HttpInTextboxVorhanden(objInputTextfield) { //Überprüft, ob in der Textbox "objInputTextfield" entweder http:// oder https:// oder ftp:// steht //Falls ja, gibt die function "true" zurück if(objInputTextfield.value.indexOf ("http://") > -1 || objInputTextfield.value.indexOf ("https://") > -1 || objInputTextfield.value.indexOf ("ftp://") > -1) { return true; } } // ---------------------------------------------------- function DatumDropdownListenBefuellen(objJahresListe,objMonatsListe,objTagesListe,objZusammenGesetztesDatum) { ZeitpunktA = new Date(objJahresListe.options[objJahresListe.selectedIndex].text, objMonatsListe.options[objMonatsListe.selectedIndex].value,1); ZeitDifferenz = ZeitpunktA - 86400000; ZeitpunktB = new Date(ZeitDifferenz); var MaximaleTageDiesesMonats = ZeitpunktB.getDate(); for (var n = 0; n < objTagesListe.length; n++) { objTagesListe.options[0] = null; } for (var n = 0; n < MaximaleTageDiesesMonats; n++) { objTagesListe.options[n] = new Option(n+1); } DatumDropdownListenKombinieren(objJahresListe,objMonatsListe,objTagesListe,objZusammenGesetztesDatum); } // ---------------------------------------------------- function DatumDropdownListenKombinieren(objJahresListe,objMonatsListe,objTagesListe,objZusammenGesetztesDatum) { strJahr = objJahresListe.options[objJahresListe.selectedIndex].text strMonat = objMonatsListe.options[objMonatsListe.selectedIndex].value strTag = objTagesListe.options[objTagesListe.selectedIndex].text if(strTag<10){strTag = "0"+strTag} //> if(strMonat<10){strMonat = "0"+strMonat} //> strKombiniertesDatum = strJahr+"-"+strMonat+"-"+strTag+" 00:00:00"; objZusammenGesetztesDatum.value = strKombiniertesDatum; } // ---------------------------------------------------- function PopupWindow(strPopupURL,intPopupPosX,intPopupPosY,intPopupWidth,intPopupHeight) { if(intPopupPosX == -1 || intPopupPosY == -1) {//Falls X oder Y Position -1 ist, dann soll das Popup in der Bildschirmmitte platziert werden intScreenWidthInPixel = screen.width; intScreenHeightInPixel = screen.height; intPopupPosX = (intScreenWidthInPixel/2) - (intPopupWidth/2); intPopupPosY = (intScreenHeightInPixel/2) - (intPopupHeight/2); } window.open(strPopupURL,'PopupWindow','scrollbars=yes,resizable=yes,width=' + intPopupWidth + ',height=' + intPopupHeight + ',screenX=' + intPopupPosX + ',screenY=' + intPopupPosY + ',left=' + intPopupPosX + ',top=' + intPopupPosY); } // ---------------------------------------------------- function CloseThisWindow() { window.close(); } // ---------------------------------------------------- function urlencode(strInput) { strInput = strInput.replace(/[ ]/g,"+"); return escape(strInput); } // ---------------------------------------------------- function runden(wert,stellen) { addstr=Math.pow(10,stellen).toString().substring(1); wert=Math.round(wert*Math.pow(10,stellen))/Math.pow(10,stellen); if(wert.toString().indexOf(".")==-1) { wert=wert+"."+addstr; } else { //'if(wert.toString().substring(wert.toString().indexOf(".")+1).length wert=wert.toString()+addstr.substr(0,(addstr.length-wert.toString().substring(wert.toString().indexOf(".")+1).length)); } return wert } // ---------------------------------------------------- function DrueckeEnterZumNaechsten(e, objFeldFuerFocusSetzen) {//Wenn Der User auf Enter drückt, dann soll der Focus zum angegebenen Objekt springen if(e.keyCode==13) {//User hat Enter gedrückt objFeldFuerFocusSetzen.focus(); } } // ---------------------------------------------------- function mySqlDateTime(datDatum) {//Wandelt JavaScript Datum in mySQLDatum um: "2003-11-29 20:37:49" strMySqlDate = NullVorFallsNoetig(datDatum.getYear())+"-"+NullVorFallsNoetig(datDatum.getMonth()+1)+"-"+NullVorFallsNoetig(datDatum.getDate()); strMySqlTime = NullVorFallsNoetig(datDatum.getHours())+"-"+NullVorFallsNoetig(datDatum.getMinutes()+1)+"-"+NullVorFallsNoetig(datDatum.getSeconds()); strMySqlDateTime = strMySqlDate+" "+strMySqlTime; return strMySqlDateTime; } // ---------------------------------------------------- function NullVorFallsNoetig(intZahl) {//Stellt eine 0 vor eine andere Zahl, falls diese unter 10 ist: 4 -> 04 if(intZahl < 10) { strZahl="0"+intZahl; } else { strZahl=intZahl; } return strZahl; } // ---------------------------------------------------- function IstHttpInUrl(objTextfeld) {// Warnung ausgeben, falls http:// vergessen wurde var strZuPruefendeURL = objTextfeld.value; if(strZuPruefendeURL.indexOf("http://") == -1 && strZuPruefendeURL.indexOf("https://") == -1 && strZuPruefendeURL != "") { alert("WARNUNG: Alle eingegebenen URL müssen mit http:// oder https:// beginnen!\nBitte korrigieren Sie die gerade gemachte Eingabe falls es eine URL war."); } }