/** * hashGenerator.js * * http://www.thewittyrejoinder.com/hashGenerator.php * @version		1.0 * * @license		MIT-style license http://www.opensource.org/licenses/mit-license.php * @author		Matthew (matthew at theWittyRejoinder.com) */
	var Hasher = new Class({		Implements: [Options],		options: {			debug:false		},
		initialize: function(input){
			this.input = input;
			this.log("Creating New Hasher with: " + input);
			$(input).addEvent('keyup', function(e){
				this.sendRequest();
			}.bind(this));
		},
		input: '',
		logItem: 0,
		sendRequest: function(){
			this.log("sending request!");
			var req = new Request({  
				method: 'post',  
				url: 'ajaxHanders/hashGeneratorHandler.php',  
				data: { 'seed' : $(this.input).value},  
				onRequest: function() { 
			},  
				onComplete: function(response) { 
					this.log(response);
					this.log("Here's the text:");
					try{
						myData = JSON.parse(response, function (key, value) {                		$(key).value = value;
                	}.bind(this));
                	} catch(err) { this.log(err + "\n" + err.description); }
				}.bind(this)}).send()  
		},		/**		 * log()  		 * This function is a wrapper for debugging logging. 		 * This function was put into place to test the class in all		 * browsers without the need to replace each and every console.log()		 * statement when moving from FFox.		 */
		log: function(str){			if(this.options.debug){
				try{
					console.log((++this.logItem) + ":\t" + str);
				} catch(err){ 	}
			}		}
	});	/**	 * These events are added to control dynamic styling for the hashGenerator view page.	 */
	window.addEvent('domready', function(){
		var hasher = new Hasher('hash_input');
		$$('.hash_row_0').addEvent('mouseover',function(e){
			this.style.backgroundColor = '#73d4fa';
			this.getChildren()[0].setStyle('font-weight', 'bold');
		});
		$$('.hash_row_1').addEvent('mouseover',function(e){
			this.style.backgroundColor = '#73d4fa';
			this.getChildren()[0].setStyle('font-weight', 'bold');
		});
		$$('.hash_row_0').addEvent('mouseout',function(e){
			this.style.backgroundColor = '#eeeeee';
			this.getChildren()[0].setStyle('font-weight', 'normal');
		});
		$$('.hash_row_1').addEvent('mouseout',function(e){
			this.style.backgroundColor = '#d9e3f6';
			this.getChildren()[0].setStyle('font-weight', 'normal');
		});
		$$('.hash_row_header').addEvent('mouseover',function(e){
			this.getChildren()[0].setStyle('font-weight', 'bold');
		});
		$$('.hash_row_header').addEvent('mouseout',function(e){
			this.getChildren()[0].setStyle('font-weight', 'normal');
		});
	});
	
