	/**
	 * Initializes jQuery and mootools
	 * jQuery is running in noConflict-mode using $j
	 */

	/* Initialize jQuery */
	$j = jQuery.noConflict();
	
	/* Initialize mootools */
	window.addEvent('domready', function() {
		
		// Create and store colorize object
		Colorize.getInstance().setColored(false);
		Colorize.getInstance().colorizeAll('.colorize');
		
		$j('#page').css('height', '200%');
		$j('#logo div, #info div').addClass('inner');
		$j('#logo').click(function() {
			$j('#page').stop().animate({
				top: '-100%'
			}, 1800, 'easeInOutCubic');
		});
		
		$j('#page').delay(1000).animate({
			top: '-100%'
		}, 1800, 'easeInOutCubic');
		
	});




$j(document).ready(function(){
	form();
	$j('a').mouseover(function(){
		startMoving($j(this));
	});
	$j('a').mouseout(function(){
		stopMoving($j(this));
	});
});

var formElements;

function form(){
	formElements = new Array();
	$j('input[type=text]').each(function(){
		$j(this).val('Standard');
		formElements[$j(this).attr('id')] = $j(this).val();
		$j(this).addClass('default');
		$j(this).blur(function(){
			formFieldBlur(this);
		});
		$j(this).focus(function(){
			formFieldFocus(this);
		});
	});
}

function formFieldFocus(field){
	$j(field).removeClass('default');
}

function formFieldBlur(field){
	$j(field).addClass('default');
	if($j(field).val() == '')
		$j(field).val(formElements[$j(field).attr('id')]);
}

var movingElement = null;

function stopMoving(){
	movingElement.animate({
		left: 0,
		top: 0,
	}, 20);
	movingElement = null;
}

function startMoving(element){
	movingElement = $j(element);
	movingElement.css('position', 'relative');
	move();
}

function move(){
	if(!movingElement)
		return;
	movingElement.animate(
		{
			left: getNumber(),
			top: getNumber(),
			//color: '#' + getColor() + getColor() + getColor()
		}, 20, move
	);
}

function getNumber(){
	var max = 4;
	return Math.random() * max - (max / 2);
}

function getColor(){
	var max = 150;
	var num = Math.floor(Math.random() * max);
	num = num.toString(16);
	if(num.length < 2) num = '0' + num;
	return num;
}
