/**
 * Displays an confirmation box.
 * This function is called while clicking links
 *
 * @param   object   the link
 * @param   object   the sql query to
 *
 * @return  boolean  whether to run the query or not
 */
function confirmLink(theLink, theSqlQuery)
{
    // Confirmation is not required in the configuration file
/*    if (confirmMsg == '') {
        return true;
    }
*/
    var is_confirmed = confirm('Voulez-vous vraiment  ' + theSqlQuery + '\n');
    if (is_confirmed) {
        theLink.href += '&is_js_confirmed=1';
    }

    return is_confirmed;
} // end of the 'confirmLink()' function

function setImage(cc,i)
{
  var photo=document.getElementById('miniPhoto');
  
  // on cache tout
  photo.style.display="none";
   
  // on change la photo
  photo.src= '/images/'+cc+'_'+i+'_norm.jpg';
  
  // on montre tout
  photo.style.display="inline";

  var link=document.getElementById('miniLink');
  link.href="/affimage.php?cc="+cc+"&img="+i;
}

var imgWindow = null ;

function affImage(img,titre)
{
 imgWindow=window.open("","imgWindow","dependant=yes,menubar=no,alwaysRaised=yes,resizable=yes,scrollbars=yes,screenX=0,screenY=0,width=520,height=640");
 if (imgWindow!=null)
 {
   re = /(.*)_norm(.*)/;
   img=img.replace(re, "$1_maxi$2");

//   imgWindow.document.open("text/html", "replace");
   imgWindow.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">');
   imgWindow.document.write('<HTML><HEAD><TITLE>Reco.Vegetaux - '+titre+'</TITLE>');
   imgWindow.document.writeln('<SCRIPT LANGUAGE="JavaScript"><!--');
   imgWindow.document.writeln('function closeWin() {window.close();}');
   imgWindow.document.writeln('if (window.Event) document.captureEvents(Event.ONCLICK);');
   imgWindow.document.writeln('document.onclick = closeWin;');
   imgWindow.document.writeln('// --><'+'/SCRIPT>');

   imgWindow.document.write('</HEAD><BODY bgcolor="#000033" link="#808080">');
   imgWindow.document.write('<P align="center"><A href="Javascript:closeWin()"><IMG border="0" src="'+img+'" alt="'+titre+'"></A></P>');
   imgWindow.document.write('<H2 align="center"><A href="Javascript:closeWin()">'+titre+'</A></H2>');
   imgWindow.document.write('<P align="center"><FONT color="#0080FF"><SMALL>Tous droits r&eacute;serv&eacute;s<br>-<br>Olivier Lejosne, Nicolas Dutartre, Bruno Neveu, Olivier Véron 2004</SMALL></FONT></P>');
   imgWindow.document.write('</BODY></HTML>');

   imgWindow.document.close();
 }
}


function resetFields()
{
	f=document.addForm;
	f.Famille.value='';
	f.Genre.value='';
	f.Espece.value='';
	f.Cultivar.value='';
	f.NomCommun.value='';
	f.Categories.value='';
	f.Ports.value='';
	f.Hauteur.value='';
	f.Diametre.value='';
	f.TypesFeuilles.value='';
	f.Caracteristiques.value='';
	f.Fl1.checked='';
	f.Fl2.checked='';
	f.Fl3.checked='';
	f.Fl4.checked='';
	f.Fl5.checked='';
	f.Fl6.checked='';
	f.Fl7.checked='';
	f.Fl8.checked='';
	f.Fl9.checked='';
	f.Fl10.checked='';
	f.Fl11.checked='';
	f.Fl12.checked='';
	f.AspectFleurs.value='';
	f.Fr1.checked='';
	f.Fr2.checked='';
	f.Fr3.checked='';
	f.Fr4.checked='';
	f.Fr5.checked='';
	f.Fr6.checked='';
	f.Fr7.checked='';
	f.Fr8.checked='';
	f.Fr9.checked='';
	f.Fr10.checked='';
	f.Fr11.checked='';
	f.Fr12.checked='';
	f.AspectFruits.value='';
	f.Expositions.value='';
	f.Sols.value='';
	f.Utilisations.value='';
}

	function show_props(obj, objName) {
	 var res ='';
	 for (var i in obj)
	 {
	  res += objName + "." + i + " = " + obj[i] + '\n'
	 }
	 alert(res);
	 return res
	}
