 // Determine the browser (IE or Netscape) using navigator.appName
 var ie = (navigator.appName.toLowerCase().indexOf("microsoft") != -1);
 var ns = (navigator.appName.toLowerCase().indexOf("netscape") != -1);

 // Determine the platform using navigator.platform
 var win = (navigator.platform.toLowerCase().indexOf("win") != -1);
 var mac = (navigator.platform.toLowerCase().indexOf("Mac") != -1);

 var ieflash = 0
// Call this function to set the cookie for the media type
function setCookieFlash(option)
{
  var expiration = new Date()
  var today = new Date()
  expiration.setTime(today.getTime() + 1000*60*60*24*365*30)
  document.cookie='KartooFlash='+option+';path=/;expires='+expiration.toGMTString()
}

function canDetectFlash()
{
 // Determine the browser version
 var browserVer = parseFloat(ie ? navigator.appVersion.substring(navigator.appVersion.toLowerCase().indexOf("msie") + 4) : navigator.appVersion);

 // Return the appropriate value based on the browser, version and platform
 if (ie && win) return (browserVer >= 4.0) // Works in Windows IE 4.0 and better
 if (ie && mac) return (browserVer >= 5.0) // Works in Mac IE 5.0 and better
 if (ns)        return (browserVer >= 3.0) // Works in Netscape 3.0 and better

 // If none of the above conditions matched, the browser is
 // unknown and likely doesn't support detection
 return false;
}

function autodetect()
{

 var weCan = canDetectFlash()

 var swf = 0

 if(weCan)
 {
   //detection netscape
   if(navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"])
   {
     plugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin
     if(plugin && parseInt(plugin.description.substring(plugin.description.indexOf(".")-1)) >= 4)
       swf = 1
   }
   else
   {
     //detection windows
     if(ie &&  navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1)
	     {
       swf = ieflash
     }
   }//end else
 }//end if(weCan)
 return swf
}

function check()
{
  if(document.queryform.q.value=="")
  {
    alert("Entrez un mot ou une expression à rechercher")
    return false
  }
  return true
}
function override(mode)
{
  switch(mode)
  {
    case 1:
      setCookieFlash("F")
      break
    case 2:
      setCookieFlash("H")
      break
  }
  parent.location.reload()
}



function showFlash(mode,no)
{
  var params = "/kartoov4.swf"
  if(mode)
  {
    if(mode==2)
    {
      params += ("?ca="+no)
    }
    else
    {
    	if(!check())
      	return false
    	else
    	{
     		var query = document.queryform.q.value
     		query = escape(query)
     		er=/\+/gi
     	query = query.replace(er,"%2B")

     	var lang
     	if(document.queryform.l[0].checked)
       	lang=1
     	else
       	lang=0
     	params += ("?q="+query+"&m="+document.queryform.m.value+"&l="+lang+"&ai="+document.queryform.ai.value)
    	}
   	}
  }
  else
  {
    params += ("?ai=0")
  }
  
  document.open()
  document.writeln('<HTML><HEAD><TITLE>Kartoo : moteur de recherche &agrave; interface cartographique</TITLE><LINK REL="SHORTCUT ICON" href="http://www.kartoo.com/favicon.ico"></HEAD><BODY bgcolor="#000099" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">')
  document.writeln('<SCRIPT LANGUAGE=JavaScript>')
  document.writeln('<!--')
  document.writeln('var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;')
  document.writeln('// Handle all the the FSCommand messages in a Flash movie')
  document.writeln('function kartoov4_DoFSCommand(command, args) {')
  document.writeln('var kartoov4Obj = InternetExplorer ? kartoov4 : document.kartoov4;')
  document.writeln('window.open(args,\'titre\', \'width=\'+11*screen.width/13+\',height=\'+3*screen.height/4+\', toolbar=0,location=0,directories=0,status=0,scrollbars=1,resizable=1,copyhistory=0,menuBar=0, top=\'+screen.height/8+\', left=\'+screen.width/13+\' \');')
  document.writeln('}')
  document.writeln('// Hook for Internet Explorer ')  
  document.writeln('if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {')  
  document.writeln('document.write(\'<SCRIPT LANGUAGE=VBScript\> \n\');')    
  document.writeln('document.write(\'on error resume next \n\');')  
  document.writeln('document.write(\'Sub kartoov4_FSCommand(ByVal command, ByVal args)\n\');')  
  document.writeln('document.write(\'  call kartoov4_DoFSCommand(command, args)\n\');')  
  document.writeln('document.write(\'end sub\n\');')
	document.writeln('document.write(\'</SCRIPT\> \n\');')
	document.writeln('}')
	document.writeln('//-->')		  
  document.writeln('</SCRIPT>')
	document.writeln('<!-- URL\'s used in the movie-->')
	document.writeln('<A HREF=options.swf></A> <A HREF=menuaide.swf></A> <!-- text used in the movie-->')
	  
  
  document.writeln('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://active.macromedia/flash2/cabs/swflash.cab#version=4,0,0,0" ID=kartoov4 WIDTH=100% HEIGHT=100%>')
  document.writeln('<PARAM NAME=movie VALUE="'+params+'">')
  document.writeln('<PARAM NAME=loop VALUE=false>\n<PARAM NAME=menu VALUE=true>\n<PARAM NAME=quality VALUE=best>\n<PARAM NAME=scale VALUE=exactfit>\n<PARAM NAME=wmode VALUE=opaque>\n<PARAM NAME=bgcolor VALUE=#000099>')
  document.writeln('<EMBED src="'+params+'" loop=false menu=false quality=best scale=exactfit wmode=opaque bgcolor=#000099 WIDTH=100% HEIGHT=100% swLiveConnect=true TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">')
  document.writeln('</OBJECT>')
  document.writeln('</BODY></HTML>')
  document.close()
}
