function fixPNGs(){
	if(jQuery.browser.msie && jQuery.browser.version < 9)
	{
 		var i;
 		for(i in document.images){
   			if(document.images[i].src)
   			{
  				var imgSrc = document.images[i].src;
  				if((imgSrc.substr(imgSrc.length-4) === '.png' || imgSrc.substr(imgSrc.length-4) === '.PNG') && document.images[i].className!='nofix')
  				{
  					document.images[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='crop',src='" + imgSrc + "')";
  				}
   			}
 		} 
	}
}

function bindOverlayClick()
{
	$('.overlay').click(function() {
		$(this).fadeOut('normal', function() {
			$(this).remove();
		})
		
		$('#login-form').fadeOut('slow');
		
		$(document).unbind('keyup');
	})
	
	$(document).keyup(function(e){
		if(e.keyCode == 27) {
			$('#login-form').fadeOut('slow');
			$('.overlay').fadeOut('normal', function() {
				$(this).remove();
			});
		}
	})
}

function checkHtml5()
{
	var test = document.createElement('input');
	test.setAttribute('type', 'email');
	
	return(test.type !== 'text')
}

$(function() {
	fixPNGs();
	
	if(checkHtml5())
	{
		$('label#label-wachtwoord').hide();
		$('label#label-gebruikersnaam').hide();
	}else{
		$('#login-form').css('height', '180px');
	}
	
	$('#link_login').click(function() {
		
		$('body').append('<div class="overlay"></div>');
		bindOverlayClick();
		$('#login-form').fadeIn('slow', function() {
			$('#login-gebruikersnaam').focus();
		});
		
		return false;
		
	})
	
	  $("#top_content_right").animate({
	   	marginRight: '0px',
	   	'filter' : ''
	  }, 200 );
	  
	  $('#top_content_left').fadeIn('slow');
	  
	// menu
	$('ul#widget_menu_top > li').hover(function() {
		var subul = $(this).find('ul');
		
		if(!$(this).hasClass('active') && subul.length > 0)
		{
			$('ul#widget_menu_top > li.active ul').stop(true, true).fadeOut('fast');
		}
	}, function() {
		$('ul#widget_menu_top > li.active ul').stop(true, true).fadeIn('fast');
	})
	
	var t;
	
	$('#menu_top > ul > li.taal').mouseover(function(){
		clearTimeout(t);
		
		$(this).addClass('hover');
	}).mouseout(function(){
		t = setTimeout('taalRemoveHover()', 1000);
	});
})

	function taalRemoveHover() {
		$('#menu_top ul li.taal').removeClass('hover');
	}
