$(document).ready(function(){
	
	// drop-down menu
	$('#menu > ul > li > ul').each(function() { 
		this.initHeight = $(this).height();
		$(this).height(0);
	});
	
	$('#menu > ul > li').bind('mouseover', function() {
		var $ul = $(this).find('> ul');
		if ($ul.length) {
			$ul.stop(true).animate({height: $ul.get(0).initHeight}, {
				duration: ($ul.get(0).initHeight - $ul.height()) * 5
			});
		}
	});
 
	$('#menu > ul > li').bind('mouseout', function() {
		var $ul = $(this).find('> ul');
		if ($ul.length) {
			$ul.stop(true).animate({height: 0}, {
				duration: $ul.height() * 5,
				complete: function () {
					$ul.hide();
				}
			});
		}
	});
	
	// zebra-table effect
	$('tr:nth-child(odd).not("#calendar")').addClass('odd');
	//$('tr:nth-child(odd)').not("#calendar").addClass('odd');
	
	// unique rules for removing form field value on focus, and return it on blur
	$('input[type=text]').bind('focus',function() {
		if ($(this).val() == $(this).attr('alt')) {
			$(this).val('');
		}
		$(this).addClass('selected');
	});
	
	$('input[type=text]').bind('blur',function() {
		if ($(this).val() == '') {
			$(this).val($(this).get(0).defaultValue);
		}
		$(this).removeClass('selected');
	});
	
	$('input[type=password]').bind('focus',function() {
		$(this).addClass('selected');
	});
	
	$('input[type=password]').bind('blur',function() {
		$(this).removeClass('selected');
	});
	
	if ($.fn.colorbox) {
		$('#gallery div.image a[rel="colorbox"]').colorbox();
	}
	
	// login form dynamic vertical position
	$('#login').css('margin-top','-'+$('#login').height()/2+'px');
	
});
