/* Le COMPTEUR */
document.observe('dom:loaded', function() {
	$$('div.Links').each(function(elmt) {
		elmt.observe('click', function(ev) {
		var id = $(elmt).readAttribute('id');
		var url = $(elmt).down(2).readAttribute('class');
		var thematique = $(elmt).down(1).readAttribute('class');
//		alert(url);
			new Ajax.Request("/ajax/downloadCount.ajax.php", {
			method : 'post',
			postBody: $H({id:id,url:url,theme:thematique,}).toQueryString(),
			asynchronous: false
			});
		});
	});
});



function getHeight() {
        var y = 0;
        if (self.innerHeight) {
                y = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) {
                y = document.documentElement.clientHeight;
        } else if (document.body) {
                y = document.body.clientHeight; }
        return y; }


   function makeEditable(id) {
new Ajax.InPlaceEditor(id, '/ajax/saveEditable.ajax.php?txt='+id, {
  rows:8,
      cols:40,
      loadTextURL: "/ajax/getEditable.ajax.php?e="+id
      });

 }

function fixquote() {
    $("content").innerHTML=$("content").innerHTML.replace(//g,"'");
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Adresse de courriel invalide")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Adresse de courriel invalide")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Adresse de courriel invalide")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Adresse de courriel invalide")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Adresse de courriel invalide")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Adresse de courriel invalide")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Adresse de courriel invalide")
		    return false
		 }

 		 return true					
	}

function validateEmail() {
    var emailID=$("emailAddress");
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Adresse de courriel invalide")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.focus()
		return false
	}
	return true
 }	  		 



