var win = window;
var n   = 0;

function findInPage(str) {

   var txt, i, found;
   var listEls = document.getElementsByTagName("span");

   for (i = listEls.length - 1 ; i >= 0 ; i--){
      if (listEls[i].name == '__surligne__'){
         var innerHTML = listEls[i].innerHTML;
         listEls[i].outerHTML = innerHTML;
      }
   }
   if (str == "")
     return false;

   if (document.all){
      txt = document.body.createTextRange();
      while ( txt.findText(str) != false) {
          txt.moveStart("character", -1);
          txt.moveEnd("textedit");
          txt.findText(str);
          txt.pasteHTML('<span name="__surligne__"style="color:black;background-color:C1DDA0">' +str+ '</span>');
      }
   }else{
      if (!win.find(str))
         while(win.find(str, false, true))
            n++;
      else
         n++;
   }
   return false;
}

function check1() {
missinginfo = "";
if (document.form1.compatibility_user.value == "") {
missinginfo += "\n     -  Your name";
}
if (document.form1.compatibility_name.value == "") {
missinginfo += "\n     -  the title of the game";
}
if (document.form1.compatibility_version.value == "") {
missinginfo += "\n     -  the emu version";
}
if ( document.form1.compatibility_play[0].status == '' ) {
	if ( document.form1.compatibility_play[1].status == '' ) {
		if ( document.form1.compatibility_play[2].status == '' ) {
missinginfo += "\n     -  is it playable?";
}
}
}
if (document.form1.compatibility_comments.value == "") {
missinginfo += "\n     -  a comment"; }
if (missinginfo != "") {
missinginfo ="You forgot :\n" +
missinginfo;
alert(missinginfo);
return false;
}
else return true;
}



function storeCaret(text)
{
}

function AddText(startTag,defaultText,endTag) 
{
 if (document.form1.compatibility_comments.createTextRange) 
 {
  var text;
  document.form1.compatibility_comments.focus(document.form1.compatibility_comments.caretPos);
  document.form1.compatibility_comments.caretPos = document.selection.createRange().duplicate();
  if(document.form1.compatibility_comments.caretPos.text.length>0)
  {
   document.form1.compatibility_comments.caretPos.text = startTag + document.form1.compatibility_comments.caretPos.text + endTag;
  }
  else
  {
   document.form1.compatibility_comments.caretPos.text = startTag+defaultText+endTag;
  }
 }
 else document.form1.compatibility_comments.value += startTag+defaultText+endTag;
}

function AddTextuk(startTag,defaultText,endTag) 
{
 if (document.form1.compatibility_comments_uk.createTextRange) 
 {
  var text;
  document.form1.compatibility_comments_uk.focus(document.form1.compatibility_comments_uk.caretPos);
  document.form1.compatibility_comments_uk.caretPos = document.selection.createRange().duplicate();
  if(document.form1.compatibility_comments_uk.caretPos.text.length>0)
  {
   document.form1.compatibility_comments_uk.caretPos.text = startTag + document.form1.compatibility_comments_uk.caretPos.text + endTag;
  }
  else
  {
   document.form1.compatibility_comments_uk.caretPos.text = startTag+defaultText+endTag;
  }
 }
 else document.form1.compatibility_comments_uk.value += startTag+defaultText+endTag;
}


function swap_m(img_name,to_what,nochange) {
		var swap, towhat;
		swap	= eval('document.images.'+img_name);
		towhat='/_img/'+to_what+'.gif';
		swap.src	= towhat;
}

function PrintNews(data){
window.open('print_news.php3?news='+data,'Imprimer','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=0,width=620,height=450,left=0,top=0');}


function checkcommentaire() {
missinginfo = "";
if (document.form1.pseudo.value == "") {
missinginfo += "\n     -  votre nom";
}
if (document.form1.commentaire.value == "") {
missinginfo += "\n     -  Commentaire"; }
if (missinginfo != "") {
missinginfo ="Pour ajouter un commentaire, veuillez ajouter :\n" +
missinginfo;
alert(missinginfo);
return false;
}
else return true;
}


function checkenvoie() {
missinginfo = "";
if (document.form2.pseudo.value == "") {
missinginfo += "\n     -  votre nom";
}
if (document.form2.email.value == "") {
missinginfo += "\n     -  email du ou des destinataires"; }
if (missinginfo != "") {
missinginfo ="Pour envoyer cette nouvelle, veuillez ajouter :\n" +
missinginfo;
alert(missinginfo);
return false;
}
else return true;
}


function checkEmail(valeur)
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valeur))
	{
		return true;
	}
	if (valeur!="")
	{
		alert("Attention : l'adresse e-mail ne semble pas valide !")
		return false;
	}
}


function showActVisu(a,evt) {
	var img = a.childNodes[0];
	var aFromLeft = 40+Math.floor((document.body.scrollWidth-780)/2)+(img.y?2:0);
	var evtOffset = (evt.offsetY?evt.offsetY:-3);
	var clkOffsetTop = (evt.y?evt.y:img.y)-evtOffset-3;
	if(!oDivTranspVisu) oDivTranspVisu = document.getElementById('DivTranspVisu');
	if(!oDivVisu) oDivVisu = document.getElementById('DivVisu');
	var vis = oDivVisu.childNodes[0];
 	vis.src = img.src.replace("actu2_","actu_");
	oDivTranspVisu.style.left = (aFromLeft-4)+'px';
	oDivTranspVisu.style.top = (clkOffsetTop+5)+'px';
	oDivVisu.style.left = aFromLeft+'px';
	oDivVisu.style.top = clkOffsetTop+'px';
	oDivTranspVisu.style.display = '';
	oDivVisu.style.display = '';
}

function hideZoomVisu() {
	if(oDivVisu) oDivVisu.style.display = 'none';
	if(oDivTranspVisu) oDivTranspVisu.style.display = 'none';
}


var oDivVisu;
var oDivTranspVisu;

function handlelang1InputOver(o,txt) {
	o.style.borderColor='#CFF500';
	if(txt==o.value) {
		o.value = "";
	}
	o.focus();
}

function handlelang1InputOut(o,txt) {
	if(''==o.value) o.value = txt;
	o.style.borderColor='';
}

function handlelang13InputOver(o,txt) {
	o.style.borderColor='#CFF500';
	if(txt==o.value) {
		o.value = "";
	}
	o.focus();
}

function handlelang13InputOut(o,txt) {
	if(''==o.value) o.value = txt;
	o.style.borderColor='';
}