	function block(msg){
		jQuery.blockUI({ message: msg });
	}
	
$(window).load(function(){
	$.blockUI.defaults.css = {};
	var WindowHeight = $(window).height();
	var ContentHeight = 640;
	var paddingTop = (WindowHeight - ContentHeight)/2;
	if(paddingTop > 10)
		$("body").css('padding-top',paddingTop+'px');
	var W = $(window).width();
	$('#background .images ul li img, #background .images ul li').width(W).height('auto');
	var H = $('#background .images ul li img:first').height();
	$('#background .images ul li, #background').height(H);
	$('div.gradient').height(H+1);
	$('#background').width(W).css('margin-left', '-' + W/2 + 'px');
	$("#showcase ul").cycle({
		fx: "scrollVert",
		cleartype: false,
		next: ".next",
		prev: ".prev",
		timeout: 7500,
		speed: 2000,
		pager: '#navi',
		pagerAnchorBuilder: function(idx, slide){
        	// return selector string for existing anchor
        	return '#navi a:eq(' + idx + ')';
    	}
	});
	$("#background .images ul").cycle({
		fx: "scrollHorz",
		next: ".next",
		prev: ".prev",
		timeout: 7500,
		speed: 2000,
		pager: '#navi',
		pagerAnchorBuilder: function(idx, slide){
			// return selector string for existing anchor
        	return '#navi a:eq(' + idx + ')';
		}
	});
	$("#CarouselPlayPause").click(function(){
		if($(this).hasClass('pause')){
			$("#background .images ul, #showcase ul").cycle('pause');
			$(this).removeClass('pause').addClass('paused');
		} else {
			$("#background .images ul, #showcase ul").cycle('resume');
			$(this).removeClass('paused').addClass('pause');
		}
	});
	$('img.login, a.contact, #navi a').click(function(){
		var cls = $(this).attr('class');
		if(cls != 'activeSlide')
			block($('#' + cls));
		$("#background .images ul, #showcase ul").cycle('pause');
		$("#CarouselPlayPause").removeClass('pause').addClass('paused');
		return false;
	});
	$('img.close').live('click', function(){
		$.unblockUI();
		$("#CarouselPlayPause").click();
	});
	$('img.login').hover(function(){
		var src = $(this).attr('src');
		src = src.replace(/login/,'hlogin');
		$(this).attr('src',src);
	}, function(){
		var src = $(this).attr('src');
		src = src.replace(/hlogin/,'login');
		$(this).attr('src',src);
	});
	$('#login form').submit(function(){
		setTimeout(function(){$.unblockUI();}, 1000);
		var action = $(this).attr('action');
		action = action.replace(/subdomain/,$('#subdomain').val());
		$(this).attr('action', action).submit();
		return false;
	});
	$('#contact form').submit(function(){
		var data = $(this).serialize();
		$.ajax({
			url: 'contact.php',
			type: 'POST',
			data: data,
			success: function(msg){block('<div class="pop"><img class="close" src="images/close-16x16.png" height="16" width="16" alt="x" /><h2>Thank You</h2>' + msg + '</div>');}
		});
		return false;
	});
});