<?php

include $site_root . 'includes/functions.php';
ini_set('session.use_trans_sid', false);
ini_set('display_errors', false);
session_start();

//new i18n:
 $UA_LANG = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
 $LANGUAGES = array("en", "de", "fr", "es", "it"); // available languages

//did the user set a language? which?
if(isset($HTTP_GET_VARS['lang']) && in_array($HTTP_GET_VARS['lang'], $LANGUAGES))
{
    $lang = $HTTP_GET_VARS['lang'];
    // add URL suffix for lang
    $sfx['lang'] = $lang;
}// else, what language is preferred by the user agent?
elseif( in_array(substr($UA_LANG, 0, 2), $LANGUAGES))
{
    $lang = substr($UA_LANG, 0, 2);
}// else default
else    $lang = "en";

// some strings needed for i18n, english defaults loaded first
include($site_root.$lang_path."includes/localized-en.inc");
include($site_root.$lang_path."includes/localized-$lang.inc");

// add URL suffix for CSS
if( isset($HTTP_GET_VARS['css']) )
{
 $sfx['css'] = $HTTP_GET_VARS['css'];
}

// merge suffix
if(isset($sfx))
while (list ($key, $val) = each ($sfx))
{
 if(! isset($suffix_set)) $suffix  = "?";
 else                     $suffix .= "&amp;";
 $suffix_set = 1;        //normal link suffix

 if(! isset($lang_suffix_set)) $lang_suffix  = "?";
 else                          $lang_suffix .= "&amp;";
 $lang_suffix_set =1;

 $suffix      .= "$key=$val";
if($key != 'lang')
 $lang_suffix .= "$key=$val";    // language selection link suffix
}
if(! isset($lang_suffix)) $lang_suffix  = "?";
if(isset($lang_suffix) && $lang_suffix != "?") $lang_suffix .= "&amp;"; //needed for language selection links
$lang_suffix .= "lang=";


// disable/enable CSS per page
// set what the default style is for the page
$cssDefault = 'css/base.css';
$cssEmpty   = 'css/none.css';

$_SESSION['css'] = $cssDefault;

if (isset($_REQUEST['css'])) {
    $_SESSION['css'] = $_REQUEST['css'];
}


// set this last...to account for if you are in another folder
$myCSS = $site_root . $_SESSION['css'];
  
// site name shit
if ( isset( $_SERVER['HTTP_HOST'] ) && $_SERVER['HTTP_HOST'] !== "" ) {
     $sitename = preg_replace('/^www\.(.*)/', "\\1", $_SERVER['HTTP_HOST']);
} else
     $sitename = 'inkscape.org';

if ( $sitename == 'localhost' ||
     $sitename == '127.0.0.1' ||
     $sitename == '192.168.0.100' ||
     $sitename == 'inkscape.localhost')
{   
    $is_test_site = true;
}
else
{   
    $is_test_site = false;
}

$class = str_replace(array(".php","/"),array("",""),$_SERVER['PHP_SELF']);
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $lang; ?>" lang="<?php echo $lang; ?>">
<head>
    <title>INKSCAPE . Desenhe Livremente</title>
    <meta name="description" content="<?php echo $local_descript; ?>" />
    <meta name="keywords" xml:lang="<?php echo $lang; ?>" content="<?php echo $local_keywords; ?>" />

    <meta name="robots" content="index, follow" />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <!-- the xml header (1st line) is not sufficent (ignored?) -->

    <link rel="stylesheet" type="text/css" href="<?php echo $myCSS; ?>"/>

    <link rel="alternate" type="application/rss+xml" title="inkscape news" href="/inkscape.rss" />

    <link rel="icon" href="<?php echo $site_root; ?>favicon.ico" type="image/ico" /> 
    <link rel="SHORTCUT ICON" href="<?php echo $site_root; ?>favicon.ico" />


    <script language="JavaScript" type="text/javascript">
    <!--

    function openBrWindow(theURL,winName,features) {
        window.open(theURL,winName,features);
    }
    
    window.onload = function() 
    {
        if (navigator.platform.indexOf("Win32") != -1) {
            document.getElementById("downloadnowlink").href =
                "http://prdownloads.sourceforge.net/inkscape/Inkscape-0.43-2.win32.exe?download";
        }else if (navigator.userAgent.indexOf("Mac OS X") != -1) {
            document.getElementById("downloadnowlink").href =
                "http://prdownloads.sourceforge.net/inkscape/Inkscape-0.43-4.dmg?download";
        }
    } 

    // -->
    </script>
        
</head>

<body class="<?php echo $class; ?>">

    <!-- This allows users with non-CSS browsers a quick way to get to the page content -->
        <a id="skipnav" href="#content"><?php echo $local_skip2cn; ?></a>
        
        <div id="wrapper">
        <div class="top">
        
        <h1 id="header"><a href="<?php echo $site_root ?>index.php<?php echo $lang_suffix ?>">Inkscape</a></h1>
        
        <div class="topRight">
            <img src="images/draw-freely.png" class="drawfreely" alt="draw freely" width="62" height="13" />
 <!-- SiteSearch Google -->
            <form method="get" action="http://www.google.com/search" class="search">
            <input type="hidden" name="domains" value="http://www.inkscape.org" />
            <input type="hidden" name="sitesearch" value="http://www.inkscape.org" />
            <input type="text" name="q" size="19" maxlength="255" value="" class="searchbox" />
            <input type="image" class="searchboxsubmit" src="<?php echo $site_root; ?>images/search-button.png" name="btnG" value="<?php echo $local_SiteSearch ?>"/>
            </form>
            <!-- SiteSearch Google -->
        </div>
            </div>

            <?php include $site_root.$lang_path."includes/navigation.php"; ?>

            <a name="content"></a>
        <div class="downloadnow">
            <span><?php echo $local_LatestStable ?>: 0.43</span>
            <a id="downloadnowlink" href="<?php echo $site_root; ?>download.php<?php echo $suffix; ?>"><img src="<?php echo $site_root; ?>images/header-download.png" width="25" height="30" alt=" " /><img src="<?php echo $site_root; ?>images/header-download-link.png" width="105" height="30" alt="Download now!" /></a>
        </div>

                <div class="headerImage">
                    <img src="<?php echo $site_root; ?>images/header-image.png" width="540" height="120" />
                </div>
                
                <div class="rule">&nbsp;</div>
                
            <div class="content">
