// openphoto

function openPhoto(page) {
	window.open(page,'Image','height=535,width=675,resizable=yes,scrollbars=yes');
}


// home

var timer;
function animHome (n)
{
	clearTimeout (timer);

	nMax = 0;
	for (i=5; i>=1; i--) {
		if (document.getElementById('home'+i) != null) {
			nMax = i;
			break;
		}
	}

	if (n>nMax)
		n=1;
	for (i=1; i<=nMax; i++) {
		if (i==n)  {
			document.getElementById('home'+i).style.display = "block";
			document.getElementById('article2'+i).style.backgroundColor = "#DB1249";
			document.getElementById('article2'+i).style.color = "#FFFFFF";
		}
		else {
			document.getElementById('home'+i).style.display = "none";
			document.getElementById('article2'+i).style.backgroundColor = "#FFFFFF";
			document.getElementById('article2'+i).style.color = "#333333";
		}
	}
	timer = setTimeout ("animHome("+(++n)+")",6000);
}

function changeColor (e)
{
	var a = document.getElementsByTagName("a");
	for (i=0; i< a.length; i++) {
		if (a[i].className == "recherchered")
			a[i].className="recherche"; 
	}
	e.className="recherchered";
}


// chat

function ChatValidSupp (idcategorie, idmessage) {
    var retour;
    retour = confirm("Etes-vous sûr de vouloir supprimer cette ligne ?");
    if (retour)
        location.href = "chat-validsuppmessage.asp?idcategorie=" + idcategorie + "&idmessage=" + idmessage;
}
function ChatResizeReponseType() {
    document.getElementById('categories').height = Math.floor((document.body.clientHeight) / 2) - 200;
    document.getElementById('messages').height = Math.floor((document.body.clientHeight) / 2) - 200;
}
function ChatReponseType () {
    texte = document.theForm.idreponsetype.options[document.theForm.idreponsetype.selectedIndex].value;
    document.theForm.message.value = texte;
}
function ChatSynchro (idmessage, idcategorie, question, reponse) {
    var s = document.theForm.idcategorie;
    for (var i = 0; i < s.options.length; i++) {
        if (s.options[i].value == idcategorie) {
            s.options[i].selected = true;
            break;
        }
    }
    document.theForm.question.value = question;
    document.theForm.idreponsetype.options[0].selected = true;
    document.theForm.idmessage.value = idmessage;
    document.theForm.message.value = reponse;
}
function chatResize () {
	if (document.documentElement.clientHeight - 400 > 50) {
		document.getElementById ('messages').height = (document.documentElement.clientHeight - 400)/2;
		document.getElementById ('reponses').height = (document.documentElement.clientHeight - 400)/2;
	}
}
function ChatResize3 () {
    if (document.documentElement.clientHeight - 430 > 50) {
        document.getElementById('reponses').height = (document.documentElement.clientHeight - 430);
    }
}

function scrollToBottom ()
{
	if (document.documentElement.scrollHeight - document.documentElement.clientHeight > 0)
		window.scrollTo (0,document.documentElement.scrollHeight - document.documentElement.clientHeight);
}

function insertEmoticon (text) {
	var txtarea = document.theForm.message;
	text = ' ' + text + ' ';
	if (txtarea.createTextRange && txtarea.caretPos) {
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
		txtarea.focus();
	} 
	else {
		txtarea.value += text;
		txtarea.focus();
	}
}


// savoir plus

function changeSavoirPlus (e,p)
{
	frames['savoirplus'].location.href = p;
	document.getElementById('savoirplus1').style.backgroundColor='#D72154';
	document.getElementById('savoirplus2').style.backgroundColor='#D72154';
	document.getElementById('savoirplus3').style.backgroundColor='#D72154';
    document.getElementById(e).style.backgroundColor='#094C5F';	
}

function adjustIFrameSize (iframeWindow)
{
	if (iframeWindow.document.height) {
		var iframeElement = document.getElementById (iframeWindow.name);
		iframeElement.style.height = iframeWindow.document.height+18 + 'px';
	}
	else if (document.all) {
		var iframeElement = document.all[iframeWindow.name];
		if (iframeWindow.document.compatMode && iframeWindow.document.compatMode != 'BackCompat') {
			iframeElement.style.height = iframeWindow.document.documentElement.scrollHeight + 5 + 'px';
		}
		else {
			iframeElement.style.height = iframeWindow.document.body.scrollHeight + 5 + 'px';
		}
	}
}

function ForumInsertEmoticon (text) {
	var txtarea = document.theForm.chat;
	text = ' ' + text + ' ';
	if (txtarea.createTextRange && txtarea.caretPos) {
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
		txtarea.focus();
	} 
	else {
		txtarea.value += text;
		txtarea.focus();
	}
}


// signaler

function Signaler (id,table) {
	if (confirm("Si le contenu de ce message vous paraît aller à l'encontre de la loi et du respect d'autrui, merci de nous alerter.")) {
		document.getElementById("signaler").src = "signaler.asp?Id=" + id + "&Table=" + table;
	}
}

function Citer(id, table) {
    document.getElementById("signaler").src = "forum-citer.asp?Id=" + id + "&Table=" + table;
}

function limitLength (text,length) {
	if (text.value.length>length) 
		text.value = text.value.substr(0,length); 
}

// accueil

function ShowOnglet (i) {
    document.getElementById("Onglet-1").style.display = "none";
    document.getElementById("Onglet-2").style.display = "none";
    document.getElementById("Onglet-3").style.display = "none";
    document.getElementById("Onglet-4").style.display = "none";
    document.getElementById("Onglet-" + i).style.display = "block";
}

function ShowSexo(j, i) {
    document.getElementById("TitreSexo-" + j + "-1").style.fontWeight = "normal";
    document.getElementById("TitreSexo-" + j + "-2").style.fontWeight = "normal";
    document.getElementById("TitreSexo-" + j + "-3").style.fontWeight = "normal";
    document.getElementById("TitreSexo-" + j + "-" + i).style.fontWeight = "bold";

    document.getElementById("Sexo-" + j + "-1").style.display = "none";
    document.getElementById("Sexo-" + j + "-2").style.display = "none";
    document.getElementById("Sexo-" + j + "-3").style.display = "none";
    document.getElementById("Sexo-" + j + "-" + i).style.display = "block";
}

// accueil

function grow2(n) {
    for (i = 1; i <= 10; i++) {
        if (i != n) {
            shrink("imagepop" + i);
        }
    }
    grow("imagepop" + n);
}
function grow(img) {
    var myEffect = new Fx.Morph(img, { duration: 150, transition: Fx.Transitions.linear.easeOut });

    myEffect.start({
        'width': 100,
        'height': 74
    });
}
function shrink(img) {
    var myEffect = new Fx.Morph(img, { duration: 20, transition: Fx.Transitions.linear.easeOut });

    myEffect.start({
        'width': 85,
        'height': 60
    });
}
function ChangeColor2(place, place2) {

    document.getElementById('menu1').style.backgroundImage = 'url(img/fond-menu.jpg)';
    document.getElementById('menu2').style.backgroundImage = 'url(img/fond-menu.jpg)';
    document.getElementById('menu3').style.backgroundImage = 'url(img/fond-menu.jpg)';
    document.getElementById('menu4').style.backgroundImage = 'url(img/fond-menu.jpg)';
    document.getElementById('menu5').style.backgroundImage = 'url(img/fond-menu.jpg)';
    document.getElementById('menu6').style.backgroundImage = 'url(img/fond-menu.jpg)';

    document.getElementById('menu' + place).style.backgroundImage = 'url(img/fond-menu-vert.jpg)';
    document.getElementById('menu' + place2).style.backgroundImage = 'url(img/fond-menu-vert.jpg)';
}

function ChangeColorOnglet(cat, place) {

    document.getElementById('TitreSexo-' + cat + '-1').style.backgroundColor = '#D72154';
    document.getElementById('TitreSexo-' + cat + '-2').style.backgroundColor = '#D72154';
    document.getElementById('TitreSexo-' + cat + '-3').style.backgroundColor = '#D72154';
    document.getElementById('TitreSexo-' + cat + '-' + place).style.backgroundColor = '#094C5F';
}

function AfficheIntro(nCpt) {
    document.getElementById('texte1').style.display = 'none';
    document.getElementById('texte2').style.display = 'none';
    document.getElementById('texte3').style.display = 'none';
    document.getElementById('texte4').style.display = 'none';
    document.getElementById('texte5').style.display = 'none';
    document.getElementById('texte6').style.display = 'none';
    document.getElementById('texte7').style.display = 'none';
    document.getElementById('texte8').style.display = 'none';
    document.getElementById('texte9').style.display = 'none';
    document.getElementById('texte10').style.display = 'none';

    document.getElementById('texte' + nCpt).style.display = 'block';
}

function ChangeColor(place) {
    document.getElementById('onglet1').style.backgroundColor = '#D72154';
    document.getElementById('onglet2').style.backgroundColor = '#D72154';
    document.getElementById('onglet3').style.backgroundColor = '#D72154';
    document.getElementById('onglet4').style.backgroundColor = '#D72154';
    document.getElementById('onglet' + place).style.backgroundColor = '#094C5F';
}
