/********************************
www.studio-calico.com - v1.0
(c) Copyright 2009 Calico
contact@studio-calico.com
********************************/

function wop(nompage,pseudo,largeur,hauteur) {
	window.open(nompage+".php","pop","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width="+largeur+",height="+hauteur);
}

function GetId(id) {
	return document.getElementById(id);
}

function changeOpac(opacity, id, where, what, limit, sens) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
	if((opacity==0) && (where=="actualite") && (sens=="moins")) {
		changeContent(where,what,limit);
	}
	else if((opacity==0) && (where=="change_actu") && (sens=="moins")) {
		changeActu(what);
	}
}

function opacity(id, opacStart, opacEnd, millisec,where,what,limit) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "','" +where+ "'," +what+ "," +limit+ ",'moins')",(timer * speed));
			timer++;
		}
	}
	else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++) {
			setTimeout("changeOpac(" + i + ",'" + id + "','','','','plus')",(timer * speed));
			timer++;
		}
	}
}

function ShowInnerHtml(Where, toData) {
	if (document.getElementById) {
		if (document.getElementById(Where)) {
			document.getElementById(Where).innerHTML = toData;
		}
	}
}

function checkForm(formid) {
	theform=document.getElementById(formid);
    if(formid=="form") {
		if(theform.nom.value=="") {alert("Veuillez saisir votre Nom");theform.nom.focus();}
		else if(theform.objet.value=="") {alert("Veuillez saisir un objet pour votre message");theform.objet.focus();}
		else if(theform.msg.value=="") {alert("Veuillez saisir un message");theform.msg.focus();}
		else if((theform.mel.value.indexOf("@")>=0) && (theform.mel.value.indexOf(".")>=0)) {
			  var reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/
			  if(reg.exec(theform.mel.value) == null) alert("L'adresse mail que vous avez entré est invalide");
			  else theform.submit();
		}
		else {alert("L'adresse mail que vous avez entré est invalide");theform.mel.focus();}
    }   
}

function refreshChat(where) {
    setInterval("sendMsgI('"+where+"refresh','','')",3000);
}
