$(document).ready(function(){
	initSelect();
	initHover();
	initScrollTo();
	initGallery();
	initHeader();
	initOther();
});
function initHover(){
	$('#content div.right-sidebar ul.groups >li, #content ul.block-gallery >li ,#content ul.resources >li').hover(
		function(){$(this).addClass('hover');},
		function(){$(this).removeClass('hover');}
	);
	$("#content ul.left-menu li a").hover(
		function () {$(this).parent().stop().animate({ paddingLeft: "6px" }, 200);}, 
		function () {$(this).parent().stop().animate({ paddingLeft: "0" },200);}
	);
	$('#content ul.resources >li').click(function(){
		var link = $("a.more", $(this));
		if (link != undefined) {
			window.location = $(link).attr("href");
		}
	});
}
function initScrollTo(){
	if ($('#content ul#scroll a').get(0)) {
		$('#content ul#scroll a').click(function(){
			var href = $(this).attr('href');
			var count=href.indexOf('#');
			var id=href.substring(count);
			if ($(id).length)
			{
				$.scrollTo($(id), 500);
			}
			return false;
		});
	}
	if ($("#content a.back").get(0)) {
		//alert('213');
		$("#content a.back").click(function(){
			$.scrollTo($("body"), 500);
			return false; 
		});
	}
	
}
function initGallery(){
	if ($('#content ul.banners a').get(0)) { 
		$('#content ul.banners li a').overlay({ 
		    target: '#gallery', 
	    	    expose: '#f1f1f1' 
		}).gallery({speed: 800}); 
	}
}
function initSelect(){
/*	if ($("#content select").get(0)) $("#content select").selectbox(); 
	if ($("selectct#subject").get(0)) $("select#subject").selectbox();*/
}
/*function initPage(){
	var window_height = $('#main').height();
	if (window_height >1300) window_height=window_height+10;
	$('#le').css({height :window_height+'px', opacity: 0.5});
	$('#re').css({height :window_height+'px', opacity: 0.5});
	$('#te').css('opacity', '0.5');
	$('#be').css('opacity', '0.5');
}*/
var currentSlider = 1;
var countSlider = 3;
var timeout = 3000; 
function initHeader(){
	//setTimeout('rotateImage()',timeout);
}	
function rotateImage(){
	if (currentSlider > countSlider) currentSlider=1;
	var prev = currentSlider-1;
	var next = currentSlider; 
	if (currentSlider == countSlider) next=0;
	$('#header #headline > div:eq('+prev+')').fadeOut('slow', function () {
		$('#header #headline > div:eq('+next+')').fadeIn('slow');
	});
	currentSlider++;	
	setTimeout('rotateImage()',timeout);
}

function initOther() {
	$("select#role").change(function() {
		if ($(this).val() == "Other") {
			$("#otherli").show();
		} else {
			$("#otherli").hide();
		}
	});
}