codice:
<head>
<script>
function detectLang() {

   var lang = ((document.all) && !(window.opera)) ? window.navigator.systemLanguage : window.navigator.language;
   if (typeof lang == "undefined") lang = "en"; // default

   lang = lang.substr(0,2); // Firefox restituisce "it-IT"
   //alert(lang); 
   document.getElementById('lingua').value = lang;

}
</script>
</head>
<body onload="detectLang()">
<input type="hidden" id="lingua" value="" /> 
</body>

Ciao