<?php
    //Valores por defecto (igual que 800, la mas comun):
    $table_width = 1000;
    $space_before_languages = 76 * $table_width / 100;
    $logo_extension = ".gif";
    $bg_extension = ".jpg";
    $HTTP_SESSION_VARS["logo"] = "800" . $logo_extension;
    $HTTP_SESSION_VARS["bg"] = "800" . $bg_extension;

    //Si soporta JavaScript:
    if (isset($HTTP_SESSION_VARS["javascript_support"]) && $HTTP_SESSION_VARS["javascript_support"])
    {
        //Si se ha detectado la resolucion:
        if (isset($HTTP_GET_VARS["resolution_detected"]) && is_numeric(trim($HTTP_GET_VARS["resolution_detected"])))
        {
            $HTTP_SESSION_VARS["resolution"] = trim($HTTP_GET_VARS["resolution_detected"]);
            
            //Resolucion de 640:
            if ($HTTP_SESSION_VARS["resolution"] >= 640 && $HTTP_SESSION_VARS["resolution"] < 800)
            {
                $table_width = 600;
                $menu_width = 135;
                $HTTP_SESSION_VARS["logo"] = "640" . $logo_extension;
                $HTTP_SESSION_VARS["bg"] = "640" . $bg_extension;
            }
            //Resolucionde 800:
            else if ($HTTP_SESSION_VARS["resolution"] >= 800 && $HTTP_SESSION_VARS["resolution"] < 1024)
            {
                $table_width = 740;
                $menu_width = 166;
                $HTTP_SESSION_VARS["logo"] = "800" . $logo_extension;
                $HTTP_SESSION_VARS["bg"] = "800" . $bg_extension;
            }
            //Resolucion de 1024:
            else if ($HTTP_SESSION_VARS["resolution"] >= 1024 && $HTTP_SESSION_VARS["resolution"] < 1280)
            {
                $table_width = 920;
                $HTTP_SESSION_VARS["logo"] = "1024" . $logo_extension;
                $HTTP_SESSION_VARS["bg"] = "1024" . $bg_extension;
            }
            //Resolucion de 1280:
            else if ($HTTP_SESSION_VARS["resolution"] >= 1280 && $HTTP_SESSION_VARS["resolution"] < 1600)
            {
                $table_width = 1000;
                $HTTP_SESSION_VARS["logo"] = "1280" . $logo_extension;
                $HTTP_SESSION_VARS["bg"] = "1280" . $bg_extension;
            }
            //Resolucion de 1600:
            else if ($HTTP_SESSION_VARS["resolution"] >= 1600 && $HTTP_SESSION_VARS["resolution"] < 1800)
            {
                $table_width = 1500;
                $HTTP_SESSION_VARS["logo"] = "1600" . $logo_extension;
                $HTTP_SESSION_VARS["bg"] = "1600" . $bg_extension;
            }
            //Resolucion maxima:
            else if ($HTTP_SESSION_VARS["resolution"] >= 1800)
            {
                $table_width = 1700;
                $HTTP_SESSION_VARS["logo"] = "max" . $logo_extension;
                $HTTP_SESSION_VARS["bg"] = "max" . $bg_extension;
            }
            //Resolucion minima:
            else
            {
                $table_width = 400;
                $HTTP_SESSION_VARS["logo"] = "min" . $logo_extension;
                $HTTP_SESSION_VARS["bg"] = "min" . $bg_extension;
            }
        }
    }
    

    //Se calculan los demas valores y se redondea todo:
    $table_width = round($table_width);
    $languages_width = 200;
    $space_before_languages = $table_width - $languages_width;
    if (!isset($menu_width)) { $menu_width = 22.5 * $table_width / 100; }
    $menu_width = floor($menu_width);
    $body_width = $table_width - $menu_width;
    
    echo $body_width + 10;
?>
