function calc (cWeight) {
 //calculate Calories Burnt

var time_unit=document.CalorieCalculator.cboDuration.options[document.CalorieCalculator.cboDuration.selectedIndex].value/60;

extypeselected=document.CalorieCalculator.extype.selectedIndex;
switch (extypeselected) {

case 1:
if ( cWeight >0 && cWeight < 100)
 {
    bcalories=((cWeight*160)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=100 && cWeight < 150)
 {
    bcalories=((cWeight*160)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=150 && cWeight < 200)
 {
    bcalories=((cWeight*240)/150)*time_unit;
    return bcalories;
}
else 
 {
    bcalories=((cWeight*312)/200)*time_unit;
    return bcalories;
 }


case 2:
if ( cWeight >0 && cWeight < 100)
 {
    bcalories=((cWeight*160)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=100 && cWeight < 150)
 {
    bcalories=((cWeight*270)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=150 && cWeight < 200)
 {
    bcalories=((cWeight*410)/150)*time_unit;
    return bcalories;
}
else 
 {
    bcalories=((cWeight*534)/200)*time_unit;
    return bcalories;
 }


case 3:
if ( cWeight >0 && cWeight < 100)
 {
    bcalories=((cWeight*610)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=100 && cWeight < 150)
 {
    bcalories=((cWeight*610)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=150 && cWeight < 200)
 {
    bcalories=((cWeight*920)/150)*time_unit;
    return bcalories;
}
else 
 {
    bcalories=((cWeight*1230)/200)*time_unit;
    return bcalories;
 }


case 4:
if ( cWeight >0 && cWeight < 100)
 {
    bcalories=((cWeight*500)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=100 && cWeight < 150)
 {
    bcalories=((cWeight*500)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=150 && cWeight < 200)
 {
    bcalories=((cWeight*750)/150)*time_unit;
    return bcalories;
}
else 
 {
    bcalories=((cWeight*1000)/200)*time_unit;
    return bcalories;
 }


case 5:
if ( cWeight >0 && cWeight < 100)
 {
    bcalories=((cWeight*440)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=100 && cWeight < 150)
 {
    bcalories=((cWeight*440)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=150 && cWeight < 200)
 {
    bcalories=((cWeight*660)/150)*time_unit;
    return bcalories;
}
else 
 {
    bcalories=((cWeight*962)/200)*time_unit;
    return bcalories;
 }


case 6:
if ( cWeight >0 && cWeight < 100)
 {
    bcalories=((cWeight*850)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=100 && cWeight < 150)
 {
    bcalories=((cWeight*850)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=150 && cWeight < 200)
 {
    bcalories=((cWeight*1280)/150)*time_unit;
    return bcalories;
}
else 
 {
    bcalories=((cWeight*1664)/200)*time_unit;
    return bcalories;
 }


case 7:
if ( cWeight >0 && cWeight < 100)
 {
    bcalories=((cWeight*185)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=100 && cWeight < 150)
 {
    bcalories=((cWeight*185)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=150 && cWeight < 200)
 {
    bcalories=((cWeight*275)/150)*time_unit;
    return bcalories;
}
else 
 {
    bcalories=((cWeight*358)/200)*time_unit;
    return bcalories;
 }


case 8:
if ( cWeight >0 && cWeight < 100)
 {
    bcalories=((cWeight*325)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=100 && cWeight < 150)
 {
    bcalories=((cWeight*325)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=150 && cWeight < 200)
 {
    bcalories=((cWeight*500)/150)*time_unit;
    return bcalories;
}
else 
 {
    bcalories=((cWeight*650)/200)*time_unit;
    return bcalories;
 }


case 9:
if ( cWeight >0 && cWeight < 100)
 {
    bcalories=((cWeight*265)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=100 && cWeight < 150)
 {
    bcalories=((cWeight*265)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=150 && cWeight < 200)
 {
    bcalories=((cWeight*400)/150)*time_unit;
    return bcalories;
}
else 
 {
    bcalories=((cWeight*535)/200)*time_unit;
    return bcalories;
 }


case 10:
if ( cWeight >0 && cWeight < 100)
 {
    bcalories=((cWeight*160)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=100 && cWeight < 150)
 {
    bcalories=((cWeight*160)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=150 && cWeight < 200)
 {
    bcalories=((cWeight*240)/150)*time_unit;
    return bcalories;
}
else 
 {
    bcalories=((cWeight*312)/200)*time_unit;
    return bcalories;
 }

case 11:
if ( cWeight >0 && cWeight < 100)
 {
    bcalories=((cWeight*210)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=100 && cWeight < 150)
 {
    bcalories=((cWeight*210)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=150 && cWeight < 200)
 {
    bcalories=((cWeight*320)/150)*time_unit;
    return bcalories;
}
else 
 {
    bcalories=((cWeight*416)/200)*time_unit;
    return bcalories;
 }

case 12:
if ( cWeight >0 && cWeight < 100)
 {
    bcalories=((cWeight*295)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=100 && cWeight < 150)
 {
    bcalories=((cWeight*295)/100)*time_unit;
    return bcalories;
}
else if ( cWeight >=150 && cWeight < 200)
 {
    bcalories=((cWeight*440)/150)*time_unit;
    return bcalories;
}
else 
 {
    bcalories=((cWeight*572)/200)*time_unit;
    return bcalories;
 }

}
}



function Reset()
{

document.CalorieCalculator.cWeight.value="";
document.CalorieCalculator.extype.selectedIndex=0;
document.CalorieCalculator.cboDuration.selectedIndex=0;
document.CalorieCalculator.bCalories.value="";
}


function process(callerObj) {

if (!gIsNumber(callerObj.form.cWeight.value,1)) { 
   alert("Geçerli bir ağırlık değeri giriniz");
   callerObj.form.cWeight.focus();
   callerObj.form.cWeight.select();
   return false;
}

if (callerObj.form.extype.selectedIndex < 1)
{
   alert("Bir egzersiz türü seçmelisiniz");
   callerObj.form.extype.focus();
   return false;
}

if (document.CalorieCalculator.cboDuration.selectedIndex < 1)
{
   alert("Bir süre seçmelisiniz ");
   callerObj.form.cboDuration.focus();
   return false;
}
 var CWeight=callerObj.form.cWeight.value; 
     result=calc(CWeight);

document.CalorieCalculator.bCalories.value=roundToPennies(result);

}
function roundToPennies(n)
{
   pennies = n * 100 * 2.2;
   pennies = Math.round(pennies);
   strp = "" + pennies;
   len = strp.length;
   return strp.substring(0,len-2) + "." + strp.substring(len-2,len);
}

