/*
Returns a random hex
*/
var $randomHex = function(min, max){
	min = $pick(min, 0);
	max = $pick(max, 255);
	
	var rgbArray = [];
	for (var i=0; i<3; i++)
		rgbArray[i] = $random(min, max).round();
	
	return rgbArray.rgbToHex();
}

Element.implement({
	/*
	Applies a transition to an element on mouseenter and the oposite on mouseleave
	
	ACCEPTS:
		property: (string) css transition property
		value: (number) transition distance
		[trantition]: (string) transition type
	*/
	addTabPull: function(property, value, transition) {
		var startingValue = this.getStyle(property);
		
		this.set({
			tween: {
				transition: $pick(transition, 'back:out')
			},
			events: {
				mouseenter: function() {
					this.tween(property, value);
				},
				mouseleave: function() {
					this.tween(property, startingValue);
				}
			}
		});
	}
});

window.addEvent('domready', function(){
	//sessvars.$.clearMem();	
	if (!sessvars.hex) sessvars.hex = $randomHex(25, 200);
	$('logo').setStyle('background-color', sessvars.hex);
	
	new LinkAlert('/wp-content/themes/365/js/linkalert/');
	
	if (!Browser.Engine.trident4)
		$$('#menu li').addTabPull('margin-right', 10);
	
	// set up some smoothscrolls
	var docBody = new Fx.Scroll(document.body);
	$$('#footer a').addEvent('click', function(event){
		event.preventDefault();
		docBody.toTop();
	});
	
	var respondAnchor = $('respond-anchor');
	if (respondAnchor){
		respondAnchor.addEvent('click', function(event){
			event.preventDefault();
			docBody.toBottom();
		});
	}
});