$(document).ready(function() {

	$("#topdrop li.drop").hoverIntent({
		interval: 0, // milliseconds delay before onMouseOver
		over: drop_show, 
		timeout: 500, // milliseconds delay before onMouseOut
		out: drop_hide
	});
	function drop_show(){
		$(this).addClass('active');
		$(this).find('ul').slideDown('fast');
		//$('#cp .logout').show();
	}
	function drop_hide(){ 
		$(this).removeClass('active');
		$(this).find('ul').slideUp('medium');
		//$('#cp .logout').hide();
	}


$('#password-clear').show();
$('#password-password').hide();
$('#password-clear').focus(function() {
	$('#password-clear').hide();
	$('#password-password').show();
	$('#password-password').focus();
});

$('#password-password').blur(function() {
	if($('#password-password').val() == '') {
		$('#password-clear').show();
		$('#password-password').hide();
	}
});


	// Fancybox - Forms.
	$("a.fancyform").fancybox({
		'titleShow' : false,
		'type' : 'inline',
		'transitionIn' :	'elastic',
		'transitionOut' :	'elastic',
		'speedIn' : 600, 
		'speedOut' : 200,
		'overlayShow' : true,
		'overlayOpacity' : 0.9,
		'overlayColor' : '#000000',
		'centerOnScroll' : 'true'
	});

	// Fancybox - Images
	$(".fancygallery, .fancybox").fancybox({
		'titlePosition' :'over',
		'overlayOpacity' : 0.9,
		'overlayColor' : '#000000',
		'hideOnContentClick' : 'true',
		'transitionIn' : 'elastic',
		'transitionOut' : 'elastic',
		'speedIn' : 600, 
		'speedOut' : 200,
		'titleFromAlt' : 'true',
		'showNavArrows' : 'true'
	});

	// Fancybox - YouTube
	$(".youtube").click(function() {
		$.fancybox({
			'titleShow' : false,
			'padding' : 0,
			'autoScale' : false,
			'transitionIn' : 'none',
			'transitionOut' : 'none',
			'overlayColor' : '#000000',
			'overlayOpacity' : 0.9,
			'title' : this.title,
			'width' : 680,
			'height' : 495,
			'href' : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type' : 'swf',
			'swf' : {'wmode' : 'transparent','allowfullscreen'	: 'true'}
		});
		return false;
	});


	$("#series select").change(function() {
//        //var getValue = $(this).val();
	$(this).fancybox({
		'width': 1024,
		'height': 600,
		'type': 'iframe',
		'href' : 'http://www.fotball.no/System-pages/TabellTermin/?tournamentId=' + $(this).val(),
		'onComplete' : function() {
			$("#fancybox-inner").css({'overflow-x':'hidden'}); 
			},
		'onClosed': function() {
			parent.location.reload(true); // Need to fix this, page reload isn't a good idea, but it works for now:)
			//$('#series select option:first').attr('selected', 'selected');
			//$("#series select option:first").attr('selected');
		}
	});

});


}); 

