<?php require "../config.php";
header("Content-Type: application/x-javascript");
?>

/* Optional: Temporarily hide the "tabber" class so it does not "flash"
   on the page as plain HTML. After tabber runs, the class is changed
   to "tabberlive" and it will appear. */

document.write('<style type="text/css">.tabber{display:none;}<\/style>');
function in_array(arry, toFind){
	return ('_|_'+arry.join('_|_')+'_|_').indexOf('_|_'+toFind+'_|_') > -1;
}
function remove_element_array (arry, toRemove) {
	var tmpArray = new Array();
	// --- Rebuild the array
	for (var i = 0; i < arry.length; i++)
	{
		if (arry[i] != toRemove)
		{
			tmpArray[tmpArray.length] = arry[i];
		}
	}
	// --- And set it to the boxlist of map
	return tmpArray;
}
function display_undisplay(fieldset, begin, elemt, link)
{
	var cookie=readCookie("OptionsAffichage");
	var cookies=((cookie==null) ? "conj" : (cookie));
	cookies=cookies.split(/;/);
	for (var i = 0; i < document.getElementById(link).childNodes.length; i++) {
      		if (document.getElementById(link).childNodes[i].className == "twisty")
			twisty=document.getElementById(link).childNodes[i];	
	}

	if (begin == "no")
	{
		var img = document.getElementsByTagName('img');
		for(var i = 0; i < img.length; ++i) {
			if (img[i].className == 'twisty') {
				if (img[i].src.indexOf('images/twisty-do-down.gif') != -1) {
					img[i].setAttribute ('src', 'images/twisty-down.gif');
				} else if (img[i].src.indexOf('images/twisty-do-hidden.gif') != -1) {
					img[i].setAttribute ('src', 'images/twisty-hidden.gif');
				}
			}
		}
	}

	undisplay="unknown";
	if (document.getElementById(fieldset))
	{
		field=document.getElementById(fieldset);
		if (field.style.display == "none")
		{
			if (typeof twisty != "undefined")
				twisty.setAttribute('src', 'images/twisty-do-down.gif');
			if (typeof Effect != "undefined" && begin == "no" && elemt != "conj") {
				Effect.toggle(field.id, "Slide", {duration:.4});
			} else {
				field.style.display="block";
			}
			focused = fieldset + 't';
			if (document.getElementById(focused))
			{
				document.getElementById(focused).focus();
			}
			undisplay="no";
		} else {
			if (typeof twisty != "undefined")
				if(begin == "yes")
					twisty.setAttribute('src', 'images/twisty-hidden.gif');
				else
					twisty.setAttribute('src', 'images/twisty-do-hidden.gif');
			if (typeof Effect != "undefined" && begin == "no" && elemt != "conj") {
                                Effect.toggle(field.id, "Slide", {duration:.4});
                        } else {
				field.style.display="none";
			}
			undisplay="yes";
		}
	}
	if (begin == "no")
	{
		if (undisplay == "no")
		{
			if (!(in_array(cookies, elemt)))
			{
				if (typeof cookies.push != "undefined")
				{
					cookies.push(elemt);
				} else {
					var new_cook=new Array(elemt);
					cookies=cookies.concat(new_cook);
				}
			}
		}
		if(undisplay == "yes")
		{
			if (in_array(cookies, elemt))
			{
				cookies=(remove_element_array(cookies, elemt));
			}
		}
		writeCookie("OptionsAffichage", cookies.join(";"));
	}
}
function addEngine()
{
        if ( typeof window.external == "object" ) {
            try {
                window.external.AddSearchProvider("<?php echo $URL; ?>sensmotdire.xml");
            } catch (e) {
                window.external.AddFavorite("<?php echo $URL; ?>", "sensmotdire");
            }
        } else if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) {
                window.sidebar.addSearchEngine(
                        "<?php echo $URL; ?>sensmotdire.src",
                        "<?php echo $URL; ?>images/sensmotdire.png", "sensmotdire", "General" );
        } else {
                window.sidebar.addPanel("sensmotdire", "<?php echo $URL; ?>", "");
        }
}
function getCookieVal(offset)
{
	var endstr=document.cookie.indexOf (";", offset);
	if (endstr==-1) endstr=document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
function readCookie(nom)
{
	var arg=nom+"=";
	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;
}
function writeCookie(cname, cvalue)
{
	expires=new Date;
	expires.setMonth(expires.getMonth()+1);
	document.cookie=cname + "=" + escape(cvalue) + "; expires=" + expires.toGMTString() + "; SameSite=None; Secure;";
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function attacherAction() {
	if (document.getElementById('close')) {
        	link=document.getElementById('close');
		link.onclick = function() {
			window.close();
                }
        }
	if ( document.getElementById('index') ) { 
		if (document.getElementById) {
			if (document.getElementById('textword')) {
				var options1 = {
					script:"autosuggest.php?",
					varname:"input",
					json: true,
					minchars:1,
					noresults:"Pas de résultat",
					cache:false
				};
				var as1 = new AutoSuggest('textword', options1);
			}
			if (document.getElementById('aabout')) {
				link=document.getElementById('aabout');
				link.onclick = function() {
					window.open(this.href,'about','height=400, width=400, menubar=no, toolbar=no, scrollbars=yes');
					return false;
				}
			}
                	if (document.getElementById('aaddbrowser')) {
                        	link=document.getElementById('aaddbrowser');
                        	link.onclick = function() {
                        	        window.open(this.href,'addbrowser','height=600, width=600, menubar=no, toolbar=no, scrollbars=yes');
                                	return false;
                        	}
                	}
			if (document.getElementById('afaq')) {
                                link=document.getElementById('afaq');
                                link.onclick = function() {
                                        window.open(this.href,'faq');
                                        return false;
                                }
                        }
                        if (document.getElementById('acopyright')) {
                                link=document.getElementById('acopyright');
                                link.onclick = function() {
                                        window.open(this.href,'copyright','height=400, width=400, menubar=no, toolbar=no, scrollbars=yes');
                                        return false;
                                }
                        }
			if (document.getElementById('anews')) {
                                link=document.getElementById('anews');
                                link.onclick = function() {
                                        window.open(this.href,'news');
                                        return false;
                                }
                        }
			if (document.getElementById('aaccess')) {
                                link=document.getElementById('aaccess');
                                link.onclick = function() {
                                        window.open(this.href,'accessibility');
                                        return false;
                                }
                        }
			var as = document.getElementsByTagName('a')
			var cookie=readCookie("OptionsAffichage");
			var cookies=((cookie==null) ? "conj" : (cookie));
			cookies=cookies.split(/;/);
			for(var i = 0; i < as.length; ++i) {
				if (as[i].className == 'hidden') {
					divsearch=as[i].id + "iv";
					if (document.getElementById(divsearch).className)
					{
						var elemt=document.getElementById(divsearch).className
						if (!(in_array(cookies, elemt)))
						{	
							display_undisplay(as[i].id + "iv", "yes", elemt, as[i].id);
						}
					} else {
						display_undisplay(as[i].id + "iv", "yes", "", as[i].id);
					}
					as[i].onclick = function() {
						display_undisplay(this.id + "iv", "no", document.getElementById(this.id + "iv").className, this.id);
						return false;
					}
				}
			}
			if (document.getElementById('conjuguer')) {
				document.getElementById('conjuguer').onclick = function() {
					if(document.getElementById('textword').value != "")
					{
						if (document.getElementById('checkword').checked == true )
						{
							writeCookie("accent", "yes");
						} else {
							writeCookie("accent", "no");
						}
					}
				}
			}
			document.getElementById('textword').focus();
		}
	} else if ( document.getElementById('about') ) {
	        if (document.getElementById) {
        	        var as = document.getElementsByTagName('a');
                	for(var i = 0; i < as.length; ++i) {
                        	if (as[i].id != 'close') {
                                	as[i].onclick = function() {
                                        	window.open(this.href,'','');
	                                        return false;
        	                        }
				}
                        }
                }
	} else if ( document.getElementById('addbrowser') ) {
                if (document.getElementById('aaddbrowser')) {
                        link=document.getElementById('aaddbrowser');
                        link.onclick = function() {
                                addEngine();
                                return false;
                        }
                }
	}
}

addLoadEvent(attacherAction);
<?php
#desactive pour ie5 
#include("prototype.js");
include("bsn.AutoSuggest_c_2.0.js");
include("tabber.js");
?>
