$(function() {
	var t;
	var options = {
	    resizeLgImages:     true,
	    displayNav:         true,
	    handleUnsupported:  'remove',
	    keysClose:          ['l', 27], // c or esc
	    autoplayMovies:     false
	};
	
	Shadowbox.init(options);
	$('.top_nav').each(function() {
		if ($(this).attr('rel') != 'undefined') {
			var p = $(this).position();
			//alert(p.left);
			$('#sub_'+$(this).attr('rel')).css('left', p.left+'px');
		}
	});
	/*$('.top_nav').mouseover(function() {
		var id = $(this).attr('rel');
		
		$('#sub_'+id).show();
	})
	$('.top_nav').mouseout(function() {
		var id = $(this).attr('rel');
		
		$('#sub_'+id).slideUp('slow');
	})
	$('.subs').mouseover(function() {
		var id = $(this).attr('rel');
		
		$('#nav_'+id).addClass('nav_hover');
	})
	$('.subs').mouseout(function() {
		var id = $(this).attr('rel');
		
		$('#nav_'+id).removeClass('nav_hover');
	})*/
	$('.top_nav').hover(function() {
		var id = $(this).attr('rel');
		
		$('#sub_'+id).show();
	}, function() {
		var id = $(this).attr('rel');
		
		t = setTimeout('hide_menu('+id+')',100);
	});
	$('.subs').hover(function() {
		var id = $(this).attr('rel');
		
		$('#nav_'+id).addClass('nav_hover');
		clearTimeout(t);
	}, function() {
		var id = $(this).attr('rel');
		
		$('#nav_'+id).removeClass('nav_hover');
		$(this).hide();
	});
	$('.login').hover(function() {
		$(this).children('#form').slideDown('fast');
	}, function() {
		$(this).children('#form').slideUp('fast');
	});
	$('.logout').hover(function() {
		$(this).children('#form').slideDown('fast');
	}, function() {
		$(this).children('#form').slideUp('fast');
	});
	$('.fade_me').hover(function() {
		$(this).fadeTo('fast', 0.6);
	}, function() {
		$(this).fadeTo('fast', 1);
	});
	$('.event_info').each(function(){
		$(this).hide();
		$(this).children('.event_info').css('zIndex', 1000);
		$(this).css('zIndex', 100);
		$($(this).parent()).hover(function(){
			$(this).children('.event_info').fadeIn(100);
		}, function(){
			$(this).children('.event_info').fadeOut(100);
		});
    });
    $('.slider').mobilyslider({
		content: '.slider_content',
		children: 'div',
		transition: 'horizontal',
		animationSpeed: 300,
		autoplay: true,
		autoplaySpeed: 8000,
		pauseOnHover: false,
		bullets: true,
		arrows: true,
		prev: 'prev',
		next: 'next'
	});
	$('.bday_control .next').click(function() {
		if ($('.people').css('left') != '-'+(($('.student_bday').length - 5) * 121)+'px') {
			$('.people').animate({
			    left: '-=121'
			}, 300);
		}
	});
	$('.bday_control .prev').click(function() {
		if ($('.people').css('left') != '0px') {
			$('.people').animate({
			    left: '+=121'
			}, 300);
		}
	});
	$('.disp_show').click(function() {
		$(this).children('.disp_no').slideToggle('fast');
	});
	$('.sel_arrow').each(function() {
		var width = $(this).parent().css('width');
		$(this).css('width', width);
	})
	$('.sel_arrow_red').each(function() {
		var width = $(this).parent().css('width');
		$(this).css('width', width);
	})
	$('.p_content .right').css('height', ($('.p_content').css('height')));
	$('.p_content').resize(function() {
		$('.p_content .right').css('height', ($('.p_content').css('height')));
	});
})

function hide_menu(id) {
	$('#sub_'+id).hide();
}
function leitaValue()
{
	if(document.getElementById("topSearch").value == "Leit aš nemanda eša efni")
	{
		document.getElementById("topSearch").value = "";
	}
}
function classAlmenn()
{
	if(document.getElementById("almenn").className != "almennSel")
	{
		document.getElementById("almenn").className = "almennSel";
		document.getElementById("student").className = "student";
		document.getElementById("topSearch").name = "search";
	}
}

function classStudent()
{
	if(document.getElementById("student").className != "studentSel")
	{
		document.getElementById("student").className = "studentSel";
		document.getElementById("almenn").className = "almenn";
		document.getElementById("topSearch").name = "sSearch";
	}
}
function go(loc){
	return window.location=loc;
}
