

function convertToFarenheit()
{
   var C = ValueGet('txtcelsius');
   var F = (C * 1.8) + 32;
   ValueSet('txtfarenheit', F);
}

function coolStart(frm)
{
    var boolValid = true;
    var strField = "";
    var charpos = 0;

    /* roomlength */
    strField = ValueGet("txtroomlength");
    if (boolValid == true && strField.length == 0 )
    {
        boolValid = false;
        alert("You must provide the length of the room");
        Select("txtroomlength");
    }
    charpos = strField.search("[^0-9]"); 
    if (boolValid == true && strField.length > 0 && charpos >= 0)
    {
        boolValid = false;
        alert("You must provide a valid length of the room");
        Select("txtroomlength");
    }
    
    /* roomwidth */
    strField = ValueGet("txtroomwidth");
    if (boolValid == true && strField.length == 0 )
    {
        boolValid = false;
        alert("You must provide the width of the room");
        Select("txtroomwidth");
    }
    charpos = strField.search("[^0-9]"); 
    if (boolValid == true && strField.length > 0 && charpos >= 0)
    {
        boolValid = false;
        alert("You must provide a valid width of the room");
        Select("txtroomwidth");
    }
    
    /* roomheight */
    strField = ValueGet("txtroomheight");
    if (boolValid == true && strField.length == 0 )
    {
        boolValid = false;
        alert("You must provide the height of the room");
        Select("txtroomheight");
    }
    charpos = strField.search("[^0-9]"); 
    if (boolValid == true && strField.length > 0 && charpos >= 0)
    {
        boolValid = false;
        alert("You must provide a valid height of the room");
        Select("txtroomheight");
    }
    
    /* people */
    strField = ValueGet("txtpeople");
    if (boolValid == true && strField.length == 0 )
    {
        boolValid = false;
        alert("You must provide the number of people in the room");
        Select("txtpeople");
    }
    charpos = strField.search("[^0-9]"); 
    if (boolValid == true && strField.length > 0 && charpos >= 0)
    {
        boolValid = false;
        alert("You must provide a valid number for the amount of people in the room");
        Select("txtpeople");
    }
    
    /* electricalappliances */
    strField = ValueGet("txtelectricalappliances");
    if (boolValid == true && strField.length == 0 )
    {
        boolValid = false;
        alert("You must provide the number of electrical appliances in the room");
        Select("txtelectricalappliances");
    }
    charpos = strField.search("[^0-9]"); 
    if (boolValid == true && strField.length > 0 && charpos >= 0)
    {
        boolValid = false;
        alert("You must provide a valid number for the amount of electrical appliances in the room");
        Select("txtelectricalappliances");
    }
    
    
    if (boolValid == true)
    {
        frm.submit();
    }
}

function warmStart(frm)
{
    var boolValid = true;
    var strField = "";
    var charpos = 0;
    
    /* roomlength */
    strField = ValueGet("txtroomlength");
    if (boolValid == true && strField.length == 0 )
    {
        boolValid = false;
        alert("You must provide the length of the room");
        Select("txtroomlength");
    }
    charpos = strField.search("[^0-9]"); 
    if (boolValid == true && strField.length > 0 && charpos >= 0)
    {
        boolValid = false;
        alert("You must provide a valid length of the room");
        Select("txtroomlength");
    }
    
    
    /* roomwidth */
    strField = ValueGet("txtroomwidth");
    if (boolValid == true && strField.length == 0 )
    {
        boolValid = false;
        alert("You must provide the width of the room");
        Select("txtroomwidth");
    }
    charpos = strField.search("[^0-9]"); 
    if (boolValid == true && strField.length > 0 && charpos >= 0)
    {
        boolValid = false;
        alert("You must provide a valid width of the room");
        Select("txtroomwidth");
    }
    
    
    /* roomheight */
    strField = ValueGet("txtroomheight");
    if (boolValid == true && strField.length == 0 )
    {
        boolValid = false;
        alert("You must provide the height of the room");
        Select("txtroomheight");
    }
    charpos = strField.search("[^0-9]"); 
    if (boolValid == true && strField.length > 0 && charpos >= 0)
    {
        boolValid = false;
        alert("You must provide a valid height of the room");
        Select("txtroomheight");
    }
    
    
    /* internaltemp */
    strField = ValueGet("txtinternaltemp");
    if (boolValid == true && strField.length == 0 )
    {
        boolValid = false;
        alert("You must provide the internal target temperature");
        Select("txtinternaltemp");
    }
    charpos = strField.search("[^0-9]"); 
    if (boolValid == true && strField.length > 0 && charpos >= 0)
    {
        boolValid = false;
        alert("You must provide a valid number for the internal target temperature");
        Select("txtinternaltemp");
    }
    
    
    /* lowesttemp */
    strField = ValueGet("txtlowesttemp");
    if (boolValid == true && strField.length == 0 )
    {
        boolValid = false;
        alert("You must provide the lowest external temperature");
        Select("txtlowesttemp");
    }
    charpos = strField.search("[^0-9]"); 
    if (boolValid == true && strField.length > 0 && charpos >= 0)
    {
        boolValid = false;
        alert("You must provide a valid number for the lowest external temperature");
        Select("txtinternaltemp");
    }
    
    
    if (boolValid == true)
    {
        frm.submit();
    }
}

