<!--

browserName = navigator.appName;
browserVer = parseInt(navigator.appVersion);
if ( ( browserName == "Netscape" && browserVer >= 3 ) || ( browserName == "Microsoft Internet Explorer" && browserVer >= 4 ) ) {
        RollVersion = "yes";
} else {
        RollVersion = "no";
}
if ( browserName == "Netscape" && browserVer >= 3 ) {
        FocusVersion = "yes";
} else {
        FocusVersion = "no";
}

function PopFrameUrl(url,w,h) {
	var theparam = 'dependent=yes,z-lock=yes,titlebar=1,location=0,toolbar=no,directories=no,menubar=0,resizable=0,scrollbars=0,status=0,width=' + w + ',height=' + h;
	var pagezikmetalpop = window.open(url,'zikmetal',theparam);
	pagezikmetalpop.focus();
}

function PopFrameUrlNav(url,w,h) {
	var theparam = 'dependent=yes,z-lock=yes,titlebar=1,location=0,toolbar=no,directories=no,menubar=0,resizable=0,scrollbars=1,status=0,width=' + w + ',height=' + h;
	var pagezikmetalpop = window.open(url,'zikmetal',theparam);
	pagezikmetalpop.focus();
}

function confirm_delete(page) {
	confirmation = confirm('Etes-vous sûr de vouloir supprimer cet élément ?');
	if (confirmation) {
		window.location.replace(page);
	}
}

function confirm_valider(page) {
	confirmation = confirm('Etes-vous sûr de vouloir valider ?');
	if (confirmation) {
		window.location.replace(page);
	}
}

function favoris() {
 if ( navigator.appName != 'Microsoft Internet Explorer' ){
          window.sidebar.addPanel("Moteur de recherche French-Spider","http://www.spider-fr.com/","");
     }
  else {
        window.external.AddFavorite("http://www.spider-fr.com/","Moteur de recherche French-Spider");
    }
 }
 
 function multiClass(eltId) {
	arrLinkId = new Array('_0','_1','_2','_3');
	intNbLinkElt = new Number(arrLinkId.length);
	arrClassLink = new Array('current','ghost');
	strContent = new String()
	for (i=0; i<intNbLinkElt; i++) {
		strContent = "menu"+arrLinkId[i];
		if ( arrLinkId[i] == eltId ) {
			document.getElementById(arrLinkId[i]).className = arrClassLink[0];
			document.getElementById(strContent).className = 'on content';
		} else {
			document.getElementById(arrLinkId[i]).className = arrClassLink[1];
			document.getElementById(strContent).className = 'off content';
		}
	}	
}

function getXhr(){
    var xhr = null; 
	if(window.XMLHttpRequest) // Firefox et autres
		xhr = new XMLHttpRequest(); 
	else if(window.ActiveXObject){ // Internet Explorer 
		try {
				xhr = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
			    xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
	}
	else { // XMLHttpRequest non supporté par le navigateur 
	   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
	   xhr = false; 
	} 
    return xhr
}
			
function gestion_fav(id_element,is_ajout){
	var xhr = getXhr();
	// On défini ce qu'on va faire quand on aura la réponse
	xhr.onreadystatechange = function(){
		// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
		if(xhr.readyState == 4 && xhr.status == 200){
			leselect = xhr.responseText;
			// On se sert de innerHTML pour rajouter les options a la liste
			document.getElementById('liste').innerHTML = leselect;
		}
	}

	// Ici on va voir comment faire du post
	xhr.open("POST","http://www.spider-fr.com/raccourci.php",true);
	// ne pas oublier ça pour le post
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	// ne pas oublier de poster les arguments
	// ici, l'id
	if (is_ajout == true) {
		xhr.send("id="+id_element);
	} else {
		xhr.send("action=delete&id="+id_element);
	}
}

function sendData(param, page, myzone){
	var xhr = getXhr();
	// On défini ce qu'on va faire quand on aura la réponse
	xhr.onreadystatechange = function(){
		// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
		if(xhr.readyState == 4 && xhr.status == 200){
			leselect = xhr.responseText;
			// On se sert de innerHTML pour rajouter les options a la liste
			if (document.getElementById) {
				document.getElementById(myzone).innerHTML = leselect;
			} else if (document.all) {
				document.all[myzone].innerHTML = leselect;
			}
			document.getElementById(myzone).style.display = "block";
		}
	}
	// Ici on va voir comment faire du post
	xhr.open("POST",page,true);
	// ne pas oublier ça pour le post
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	// ne pas oublier de poster les arguments
	// ici, l'id
	xhr.send(param);
}

var btn = {
    init : function() {
        if (!document.getElementById || !document.createElement || !document.appendChild) return false;
        as = btn.getElementsByClassName('btn(.*)');
        for (i=0; i<as.length; i++) {
            if ( as[i].tagName == "INPUT" && ( as[i].type.toLowerCase() == "submit" || as[i].type.toLowerCase() == "button" ) ) {
                var a1 = document.createElement("a");
                a1.appendChild(document.createTextNode(as[i].value));
                a1.className = as[i].className;
                a1.id = as[i].id;
                as[i] = as[i].parentNode.replaceChild(a1, as[i]);
                as[i] = a1;
                as[i].style.cursor = "pointer";
            }
            else if (as[i].tagName == "A") {
                var tt = as[i].childNodes;
            }
            else { return false };
            var i1 = document.createElement('i');
            var i2 = document.createElement('i');
            var s1 = document.createElement('span');
            var s2 = document.createElement('span');
            s1.appendChild(i1);
            s1.appendChild(s2);
            while (as[i].firstChild) {
              s1.appendChild(as[i].firstChild);
            }
            as[i].appendChild(s1);
            as[i] = as[i].insertBefore(i2, s1);
        }
        // The following lines submits the form if the button id is "submit_btn"
        btn.addEvent(document.getElementById('submit_btn'),'click',function() {
            var form = btn.findForm(this);
            form.submit();
        });
        // The following lines resets the form if the button id is "reset_btn"
        btn.addEvent(document.getElementById('reset_btn'),'click',function() {
            var form = btn.findForm(this);
            form.reset();
        });
    },
    findForm : function(f) {
        while(f.tagName != "FORM") {
            f = f.parentNode;
        }
        return f;
    },
    addEvent : function(obj, type, fn) {
        if (obj.addEventListener) {
            obj.addEventListener(type, fn, false);
        }
        else if (obj.attachEvent) {
            obj["e"+type+fn] = fn;
            obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
            obj.attachEvent("on"+type, obj[type+fn]);
        }
    },
    getElementsByClassName : function(className, tag, elm) {
        var testClass = new RegExp("(^|\s)" + className + "(\s|$)");
        var tag = tag || "*";
        var elm = elm || document;
        var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
        var returnElements = [];
        var current;
        var length = elements.length;
        for(var i=0; i<length; i++){
            current = elements[i];
            if(testClass.test(current.className)){
                returnElements.push(current);
            }
        }
        return returnElements;
    }
}

btn.addEvent(window,'load', function() { btn.init();} );

//-->
