// Purpose : Script to test if visitors use an older version than Firefox 1.5 and display an invitation to upgrade. Linux users don't get this alert since it is their distro's job to update their repository 
// needs to be loaded with onload event on body -> modification of includes/model.php
// this script is intimately linked with our Cavendish style, it would have to be adapted if we were to change of layout
// Author : Pascal Chevrel (pascal.chevrel@free.fr)
// Date : 20060204


// convert all characters to lowercase to simplify testing
    var ua=navigator.userAgent.toLowerCase();
    var os=navigator.platform.toLowerCase();
    var is_ff = ua.indexOf('firefox/');
    var ff_ver_full = ua.substring(is_ff+8);
    var ff_ver_short = parseFloat(ff_ver_full);
    var ff_major = parseInt(ff_ver_short);
    var ff_minor = ff_ver_full.substring(3,2); 
 
 if (is_ff != -1 && ff_major == 1 && ff_minor < 5 || is_ff != -1 && ff_major == 0 ){
 // testing if UA is firefox and if its version is below 1.5 
  var navtarget=1;
  }
  else {
  var navtarget=0;
  }
  
  if(os.indexOf("linux") != 0){
 // we exclude linux
  var ostarget=1;
  }
  else {
  var ostarget=0;
  } 
 
 function obsolete_alert(){
  if (ostarget==1 && navtarget==1) {
	// create styled DIV with the alert
  	eDIV = document.createElement("div");
	eDIV.setAttribute("id","obsolete");	
	eDIV.setAttribute("style","margin:0;position:absolute; top:0;width:96%;color:white; background-color:red;height:50px;font-size:14px;font-weight:bold;text-align:center;font-family:Arial, sans-serif;padding:5px 2%;");	

	// this is the text to translate
	eDIV.appendChild(document.createTextNode("Похоже, что вы используете старую версию Firefox. Вам следует установить последнюю версию, обеспечивающую дополнительную безопасность и имеющую новые возможности."));

	cible =document.getElementsByTagName("body")[0];
  	cible.appendChild(eDIV);

	//move the content down to avoid overlap with alert div
	document.getElementById("container-outer").setAttribute("style","margin-top:50px !important;");
	document.getElementById("nav-main").setAttribute("style","margin-top:50px !important;");
	//we move the columns as well and test them because we don't always have them both
	if (document.getElementById("rightCol")){
document.getElementById("rightCol").setAttribute("style","margin-top:50px !important;");}
	if (document.getElementById("leftCol")){
	document.getElementById("leftCol").setAttribute("style","margin-top:50px !important;");}
}
}

