function nav_overs(id,h,spd){
	$('#'+id+' li').hover(function() {
 		$(this).children('.link a').animate({ marginTop: -h }, spd);	
	}, function() {
		$(this).children('.link a').animate({ marginTop: -0 }, spd);          
	});	
}

function resizeWindow( e ) {
	var newWindowWidth = $(window).width();
	var contWidth = $('.hero').width();
	$('.hero').css('width', newWindowWidth );
}

function checkColor(){
	var clr = $(this).css('color');
	var bkg = $(this).css('background-color');
	$('#welcometext').css('color', clr );
	$('#slides').css('background-color', bkg );
}

function setHeight(id,ht){
	var hgt = $(id).height();
	var cnhgt = hgt + ht;
	$('#content').css('height', cnhgt );

}

timer = null;

function fadeInOpts(id){
	if(timer) clearTimeout(timer);
	$('.subnav').not(id+'subnav').fadeOut('fast');
	$('.jump').not(id).removeClass('act');
	$(id+'subnav').fadeIn(0);
	$(id).addClass('act');
}

function fadeOutOpts(id){
	timer = setTimeout("doFade('"+id+"')",100);
}

function doFade(id){
	$(id+'subnav').hide();
	$(id).removeClass('act');
}

function timedFadeOut(id){
	$('#'+id).jqmHide();
}


$(document).ready(function(){
	nav_overs('nav','20',100);
	nav_overs('register-btn','20',100);
	
	$(window).bind("resize", resizeWindow);
	
	$('#announcements').cycle({ 
    	fx:     'scrollUp', 
    	speed:  'fast',
    	prev: '.prevann',
    	next: '.nextann',
    	timeout: 15000
	});
	$('#slides').cycle({ 
    	fx:     'fade', 
    	speed:  100,
    	random: 1,
    	timeout: 10000,
    	before: checkColor,
    	after: resizeWindow
	});
	
	$('#btnclose').click(function(){  $('#loginform').fadeOut();});
	$('#navlogin').click(function(){  $('#loginform').fadeIn();});
	
	$('.jump').hover(function(){ fadeInOpts('#'+this.id); },function (){ fadeOutOpts('#'+this.id); });
	$('.subnav li').hover(function(){ $(this).addClass('act'); },function (){ $(this).removeClass('act'); });
	$('.subnav form').hover(function(){ $(this).addClass('act'); },function (){ $(this).removeClass('act'); });
});
