// JavaScript Document
function box_go() {
		if(document.getElementById) {
			box_char = 1;
			box_affiche(courant_box)
			courant_box++;
			if(courant_box>=box_message.length){
				courant_box = 0;
			}
		}
	}
	function box_affiche(courant) {
		var pix = box_message[courant].charAt(box_char);
		if(pix=="<"){
			box_flag= 1
		}
		if(pix==">"){
			box_flag= 0
		}
		var texte = box_message[courant].substring(0, box_char);
		document.getElementById("news_box").innerHTML = texte;
		if (box_char < box_message[courant].length){
			box_char++;
			if(box_flag == 1){
				box_affiche(courant)}
			else {
				setTimeout("box_affiche("+courant+")", 50)
			}
		}
		else {
			setTimeout("box_go()", 2000)
		}		
	}


// fonction utilisée par le livre d'or
function addText(instext, index) {
    var mess = document.forms[index].message;
        //IE support
        if (document.selection) {
            mess.focus();
            sel = document.selection.createRange();
            sel.text = instext;
            document.guestbook.focus();
        }
        //MOZILLA/NETSCAPE support
        else if (mess.selectionStart || mess.selectionStart == "0") {
            var startPos = mess.selectionStart;
            var endPos = mess.selectionEnd;
            var chaine = mess.value;

            mess.value = chaine.substring(0, startPos) + instext + chaine.substring(endPos, chaine.length);

            mess.selectionStart = startPos + instext.length;
            mess.selectionEnd = endPos + instext.length;
            mess.focus();
        } else {
            mess.value += instext;
            mess.focus();
        }
    }
	// fonction utilisée par le livre d'or
function addPhoto(instext, index) {
	
	alert(instext);
	var mess=document.forms[index].elm4;
	alert(mess);
	//var mess2 = document.getElementById("message").value;
	//alert(mess2);
        //IE support
        if (document.selection) {
            mess.focus();
            sel = document.selection.createRange();
            sel.text = "<img src='"+instext+"' />";
            document.guestbook.focus();
        }
        //MOZILLA/NETSCAPE support
        else if (mess.selectionStart || mess.selectionStart == "0") {
            var startPos = mess.selectionStart;
            var endPos = mess.selectionEnd;
            var chaine = mess.value;

            mess.value = chaine.substring(0, startPos) + "<img src='"+instext+"' />" + chaine.substring(endPos, chaine.length);

            mess.selectionStart = startPos + instext.length;
            mess.selectionEnd = endPos + instext.length;
            mess.focus();
        } else {
            mess.value += "'"+instext+"' />";
            mess.focus();
        }
    }
function addDoc(instext, title, index) {
	alert(instext);
    var mess = document.forms[index].elm4;
        //IE support
        if (document.selection) {
            mess.focus();
            sel = document.selection.createRange();
            sel.text = "<a href='"+instext+"' target='_blank' >"+title+"</a>";
            document.guestbook.focus();
        }
        //MOZILLA/NETSCAPE support
        else if (mess.selectionStart || mess.selectionStart == "0") {
            var startPos = mess.selectionStart;
            var endPos = mess.selectionEnd;
            var chaine = mess.value;

            mess.value = chaine.substring(0, startPos) + "<a href='"+instext+"' target='_blank' >"+title+"</a>" + chaine.substring(endPos, chaine.length);

            mess.selectionStart = startPos + instext.length;
            mess.selectionEnd = endPos + instext.length;
            mess.focus();
        } else {
            mess.value += "'"+instext+"' />";
            mess.focus();
        }
    }
	
// ALBUM PHOTO
function inCell(cell, newcolor) {
	if (!cell.contains(event.fromElement)) {
		cell.bgColor = newcolor;
	}
}

function outCell(cell, newcolor) {
	if (!cell.contains(event.toElement)) {
		cell.bgColor = newcolor;
	}
}