/*
                     __                      ___                           __                    
         __         /\ \__                  /\_ \                         /\ \     __            
 __  __ /\_\   _ __ \ \ ,_\  __  __     __  \//\ \       __       __      \_\ \   /\_\     ___   
/\ \/\ \\/\ \ /\`'__\\ \ \/ /\ \/\ \  /'__`\  \ \ \    /'_ `\   /'__`\    /'_` \  \/\ \   / __`\ 
\ \ \_/ |\ \ \\ \ \/  \ \ \_\ \ \_\ \/\ \L\.\_ \_\ \_ /\ \L\ \ /\ \L\.\_ /\ \L\ \  \ \ \ /\ \L\ \
 \ \___/  \ \_\\ \_\   \ \__\\ \____/\ \__/.\_\/\____\\ \____ \\ \__/.\_\\ \___,_\ _\ \ \\ \____/
  \/__/    \/_/ \/_/    \/__/ \/___/  \/__/\/_/\/____/ \/___L\ \\/__/\/_/ \/__,_ //\ \_\ \\/___/ 
                                                         /\____/                  \ \____/       
                                                         \_/__/                    \/___/        
Script : mooRollOver.js
09/2007 - virtualgadjo / chris at virtual-gadjo dot com
revue et corrige 12/2007 pour mootools 1.2

Class toute bte pour ne plus se prendre le chou avec les rollovers simples sur les images
(se charge en prime du preload des images pour viter les temps de latence)

exemple d'instanciation autre que par dfaut

var mesRollOver = new mooRollOver({ imgClass: 'rolling', imgOffString: 'etatoff', imgOnString: 'etaton' });

Have swing
*/

var mooRollOver = new Class({

	Implements: [Events, Options],
	
	options: {
		imgClass		: "rollimg",
		imgOffString	: ".",
		imgOnString		: "-on."
	},

	initialize: function(options, menuimg) {
		this.setOptions(options);
		this.menuimg	= menuimg || [];
		this.preload	= new Asset.images([]) || [];

		$$('img', 'input').each(function(el){
			if (el.getProperty('class').contains(this.options.imgClass))
			this.menuimg.push(el);
			if (el.getProperty('src'))
			this.newImgsrc = el.getProperty('src').replace(this.options.imgOffString.toString(), this.options.imgOnString);
			this.preload.push(this.newImgsrc);
		}.bind(this));

		$$(this.menuimg).each(function(el, i){
			el.addEvents({
				'mouseenter': function() {

					var newsrc = el.getProperty('src').replace(this.options.imgOffString.toString(), this.options.imgOnString);
					el.setProperty('src', newsrc);

				}.bind(this),

				'mouseleave': function() {

					var newsrc = el.getProperty('src').replace(this.options.imgOnString.toString(), this.options.imgOffString);
					el.setProperty('src', newsrc);

				}.bind(this)

			});

		}.bind(this));
	}	
});

//envoyer la class par dfaut
window.addEvent('domready', function(){
	new mooRollOver;
});



/*
Email Clocking

hide from spam bots
http://www.badboy.ro/articles/2005-01-25/index.php

<span class="emailCloak">name(at)server.com</span>

need to implement onload
window.onload = emailCloak;
*/

function emailCloak() {
	if (document.getElementById) {
		var alltags = document.all? document.all : document.getElementsByTagName("*");
		for (i=0; i < alltags.length; i++) {
			if (alltags[i].className == "emailCloak") {
			  	var oldText = alltags[i].firstChild;
			  	var emailAddress = alltags[i].firstChild.nodeValue;
			  	var user = emailAddress.substring(0, emailAddress.indexOf("("));
			  	var website = emailAddress.substring(emailAddress.indexOf(")")+1, emailAddress.length);
			  	var newText = user+"@"+website;
			  	var a = document.createElement("a");
			  	a.href = "mailto:"+newText;
				var address = document.createTextNode(newText);
				a.appendChild(address);
				alltags[i].replaceChild(a,oldText);
			  }
			}
		}
}

