var N=navigator.appName; var V=navigator.appVersion;

var version="?"; var nom=N; var os="?"; var langue="?";
if (N=="Microsoft Internet Explorer") {
	langue=navigator.systemLanguage
	version=V.substring(V.indexOf("MSIE",0)+5,V.indexOf(";",V.indexOf("MSIE",0)));
	if (V.indexOf("Win",0)>0) {

		if ( V.indexOf(";",V.indexOf("Win",0)) > 0 ) {
			os=V.substring(V.indexOf("Win",0),V.indexOf(";",V.indexOf("Win",0)));
		} else {
			os=V.substring(V.indexOf("Win",0),V.indexOf(")",V.indexOf("Win",0)));
		}
	}

}

function SetCookie (name, value)
   {
   var argv = SetCookie.arguments;
   var argc = SetCookie.arguments.length;
   var expires = (argc > 2) ? argv[2] : null;
   var path = (argc > 3) ? argv[3] : null;
   var domain = (argc > 4) ? argv[4] : null;
   var secure = (argc > 5) ? argv[5] : false;
   document.cookie = name + "=" + escape (value) +
        ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
        ((path == null) ? "" : ("; path=" + path)) +
        ((domain == null) ? "" : ("; domain=" + domain)) +
        ((secure == true) ? "; secure" : "");
   }

function SetTheCookie()
   {
      
      var expdate = new Date ();
      expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
      SetCookie('Flash', 'noflash', expdate);
      // alert('Bienvenue dans la version non flash du site du CHU.');
      // document.forms[0].elements[0].value = " ";
      document.location.reload();
      return false;
      
   }
   
function getCookieVal (offset)
   {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
   }

function GetCookie (name)
   {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen)
      {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg)
         return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) break;
      }
   return null;
   }



// Can be used to display name on loading of page.
// Requires onLoad in BODY statement
function DisplayNameOnStartUp(flashvar)
{
   path="http://www.chu-montpellier.fr/fr/";
   
   if(GetCookie('Flash') != null)
      {
	document.write("<table width='634' border='0' cellspacing='0' cellpadding='0'>");
	document.write("<tr><td><img border='0' usemap='#noflash' src='"+path+"images/noflash_menu2.jpg'></td></tr>");
	document.write("<tr><td><img border='0' src='"+path+"images/noflash_menuphoto2.jpg'></td></tr>");
	document.write("</table>");
	document.write("<map name='noflash'>");
	document.write("<area shape='rect' coords='1,-1,104,31' href='/fr/patients_hospitalises.html'>");
	document.write("<area shape='rect' coords='106,0,209,30' href='/fr/profSante3.jsp'>");
	document.write("<area shape='rect' coords='213,1,315,31' href='/fr/etudiants.html'>");
	document.write("<area shape='rect' coords='317,3,419,29' href='/fr/media.html'>");
	document.write("<area shape='rect' coords='423,2,526,29' href='/fr/fournisseurs.html'>");
	document.write("<area shape='rect' coords='530,4,630,29' href='/fr/extranet.html'>");
	document.write("</map>");
      }
      else
      {
	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width=634 height=153>");
	document.write("<param name=movie value='"+path+"images/menu_haut.swf?cat="+flashvar+"'>");
	document.write("<param name=quality value=high>");
	document.write("<param name=bgcolor value=#FFFFFF>");
	document.write("<embed src='"+path+"images/menu_haut.swf' quality=high bgcolor=#FFFFFF  width=634 height=153 type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'>");
	document.write("</embed>");
	document.write("</object>");
      }
}

// Alert box for Test Cookie
function DisplayName()
   {
   if(GetCookie('Flash') != null)
      alert("Welcome back "+GetCookie('Flash'));
   else
      alert("You must set the cookie first.");
   }
   
function DeleteCookie ()
      {
      var exp = new Date();
      exp.setTime (exp.getTime() - 1000000000);  // This cookie is history (changed -1 to make it previous time)
      var cval = GetCookie ('DemoName');
      document.cookie ='Flash' + "=" + cval + "; expires=" + exp.toGMTString();
      document.location.reload();
      }
   

   
function DisplayHomeLink(os)
{
		if(GetCookie('Flash') != null){
			if (os!="Windows NT 4.0") document.write("<br>Cliquez ici pour revenir à la version <a href='#' onClick='DeleteCookie()'>FLASH</a> du site");
			}
		else document.write("<br>Sinon, cliquez ici pour une version <a href='#' onClick='SetTheCookie()'>NON FLASH</a> du site");

}



function DisplayHomeIntro()
{
	if(GetCookie('Flash') != null)
		{
		document.write("<center>");
		document.write("<table width='554' border='0' cellspacing='0' cellpadding='0'><tr>");
		document.write("<td><img border='0' src='images/noflash_intro2.gif'></td>");
		document.write("<td><img border='0' src='images/noflash_intro1.jpg'></td>");
		document.write("<td></td>");
		document.write("</tr></table>");
		document.write("</center>");
		}
	else
		{
		document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width='554' height='293'>");
		document.write("<param name=movie value='images/intro.swf'>");
		document.write("<param name=quality value=high>");
		document.write("<embed src='images/intro.swf' quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width='554' height='293'>");
		document.write("</embed>");
		document.write("</object>");
		}
}

                       

