var NS4 = (document.layers);
var IE4 = (document.all);
var n = 0;
var liv=0;
var searched="";
var fichierdate="";

function searchredir()
{
	var tr = window.location.pathname;
	len = tr.length;
	rs = 0;
	var filenm;
	/*for (i = len; ((i > 0)&&(rs==0)); i--)
	{
		vb = tr.substring(i,i+1);
		if (vb == "/" && rs == 0)
		{
			window.location.replace("index.html?search=1&catalogue="+tr.substring(i+2,len));
			rs = 1;
		}
	}*/
	document.write("<center><a href='../' target=_parent>Home</a><br><img src='http://m1.nedstatbasic.net/n?id=ACMA9Q7SJy8nl3gg+LOZUlt1efQA' border='0' nosave width='18' height='18'></center>");   
	return false;	
}

function alivre(reference,auteur,titre,description,commentaire,prix,photo)
{
	var docu="<b>"+auteur+"</b> "+titre+" "+description;
	if (commentaire!="") {
		docu=docu+"<br><i>"+commentaire+"</i>";
	}
	
	if (searched!="")
	{
		var ndxofsearched=(docu.toUpperCase()).indexOf(searched.toUpperCase())
		if (ndxofsearched==-1)
		{
			return false;
		}
		docu=docu.slice(0,ndxofsearched)+"<font style=\"color:black;background-color:#ffff66\">"+docu.slice(ndxofsearched,ndxofsearched+searched.length)+"</font>"+docu.slice(ndxofsearched+searched.length)
	}
	
	if ((liv%2) == 0)
		document.write("<TABLE bgcolor='#E4D3B9' width='100%'><tr><td>");
	else
		document.write("<TABLE bgcolor='#E4D3C9' width='100%'><tr><td>");
	liv=liv+1;
	document.write(docu);
	document.write("<div align=right>Référence "+reference+"<br>Prix "+prix+" €<br>");
	if (photo==1)
		document.write("<a href='photo/"+reference+".jpg' target='aphoto'>Photo</a><br>");
	//document.write("<a href='javascript:livre(\""+escape(auteur+" "+titre).replace(/\"/,"\\\"")+"\",\""+escape(prix)+"\",\""+escape(reference)+"\",\""+photo+"\")'>Commande / information</a></div><br>");
	document.write("<a href='../mail.html?livre="+escape(auteur+" "+titre)+"&prix="+prix+"&ref="+reference+"&previous="+escape(window.parent.location)+"&date="+fichierdate+"&photo="+photo+"' target='_parent'>Commande / information</a></div><br>");
	document.write("</td></tr></table>");
	
	return false;
}

function findInPage(str) {
  var win = parent.catalo.window;
  var txt, i, found;
 
  if (str == "")
   return false;
  
  if (IE4) {
    txt = win.document.body.createTextRange();

    for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
      txt.moveStart("character", 1);
      txt.moveEnd("textedit");
    }
 
    if (found) {
      txt.moveStart("character", -1);
      txt.findText(str);
      txt.select();
      txt.scrollIntoView();
      n++;
    }
 
    else {
      if (n > 0) {
        n = 0;
        findInPage(str);
      }
   
      else
        alert("Désolé, nous ne trouvons pas ce nom !");
    }
  }
  else
  //if (NS4) {
  {
    if (!win.find(str))
     while(win.find(str, false, true))
        n++;
    else
      n++;
  
    if (n == 0)
      alert("Désolé nous ne trouvons pas ce nom !");
  }
  return false;
}

function initlivre()
{
	liv=0;
	if ((parent==null)||(parent.topcata==null)||(parent.topcata.document.filtre==null)||(parent.topcata.document.filtre.txt==null))
	{
		searched="";
		return false;
	}
	searched=parent.topcata.document.filtre.txt.value;
	if (searched!="")
	{
		document.write("<center>Liste des livres contenant :'<b>"+searched+"</b>'<br>");
		//document.write("<a href='javascript:parent.topcata.filtre.txt.value=\"\";parent.topcata.filtre.submit();'>Montrer tout les livres</a></center><br>");
	}
	return false;
}

function bdp()
{
	if (liv>1)
		document.write("<br><center><i>"+liv+" livres trouvés</i></center>");
	else
		document.write("<br><center><i>"+liv+" livre trouvé</i></center>");
	return false;
}

function livre(description,prix,reference,photo)
{
	window.parent.location="../mail.html?livre="+escape(description)+"&prix="+prix+"&ref="+reference+"&previous="+escape(window.parent.location)+"&date="+fichierdate+"&photo="+photo;
	return true;
}
