$(document).ready(function() {
	$('#banner').cycle({ 
    	fx:      'fade', 
    	speed:    1000, 
    	timeout:  6000 
	});
	
	$('#navigation #middle ul li.haschild').mouseenter(function() {
		/*
		$(this).children('ul').slideDown("fast");
		$(this).children('ul').css("width", $(this).width());
		$(this).css("z-index", "5");
		$(this).css("opacity", "0.9");
		*/
		
		
		$(this).children('ul').each(function(){
			$(this).slideDown("fast");
			$(this).css("width", $(this).parent().width());
			count = 0;
			jQuery(this).children().each(function(){
				count += jQuery(this).outerHeight();
			});
			//jQuery(this).height(count);
			jQuery(this).attr("height",count);
		});
		$(this).css("z-index", "50");
		$(this).css("opacity", "0.9");
	});
	
	$('#navigation #middle ul li').mouseleave(function() {
		$(this).children('ul').hide();
		$(this).css("z-index", "auto");
		$(this).css("opacity", "1");
	});
	
	//$('#bottombar #mijn-project').click(function() {
		$('#mijn-project2').click(function() {
		if (!$('#inlog').is(':visible') && !$('#inlog #mijn-project').is(':visible')) {
			
			$('#inlog #mijn-project').show();
			//$('#bottombar #mijn-project').addClass("active");
			$('#mijn-project2').addClass("active");
			$('#bottombar').addClass("open");
			$('#inlog #medewerkers').hide();
			$('#inlog').slideToggle("slow");
			$('#close').fadeIn();
			
		} else if ($('#inlog').is(':visible') && !$('#inlog #mijn-project').is(':visible')) {
			$('#inlog #mijn-project').fadeIn();
			//$('#bottombar #mijn-project').addClass("active");
			$('#bottombar #mijn-project2').addClass("active");
			$('#bottombar').addClass("open");
			$('#inlog #medewerkers').hide();
			//$('#bottombar #medewerkers').removeClass("active");
			jQuery(this).removeClass("active");
		} else if ($('#inlog').is(':visible') && $('#inlog #mijn-project').is(':visible')) {
			$('#inlog').slideToggle("slow");
			//$('#bottombar #mijn-project').removeClass("active");
			jQuery(this).removeClass("active");
			$('#bottombar').removeClass("open");
			$('#close').fadeOut();
		}
	});
	
	$('#medewerkers2').click(function() {
		//$('#bottombar #medewerkers').click(function() {
		if (!$('#inlog').is(':visible') && !$('#inlog #medewerkers').is(':visible')) {
			$('#inlog #medewerkers').show();
			//$('#bottombar #medewerkers').addClass("active");
			jQuery(this).addClass("active");
			$('#bottombar').addClass("open");
			$('#inlog #mijn-project').hide();
			$('#inlog').slideToggle("slow");
			$('#close').fadeIn();
		} else if ($('#inlog').is(':visible') && !$('#inlog #medewerkers').is(':visible')) {
			$('#inlog #medewerkers').fadeIn();
			//$('#bottombar #medewerkers').addClass("active");
			jQuery(this).addClass("active");
			$('#bottombar').addClass("open");
			$('#inlog #mijn-project').hide();
			//$('#bottombar #mijn-project').removeClass("active");
			$('#mijn-project2').removeClass("active");
		} else if ($('#inlog').is(':visible') && $('#inlog #medewerkers').is(':visible')) {
			$('#inlog').slideToggle("slow");
			//$('#bottombar #medewerkers').removeClass("active");
			jQuery(this).removeClass("active");
			$('#bottombar').removeClass("open");
			$('#close').fadeOut();
		}
	});
	
	$('#close').click(function() {
		$('#inlog').slideToggle("slow");
		//$('#bottombar #medewerkers').removeClass("active");
		$('#medewerkers2').removeClass("active");
		//$('#bottombar #mijn-project').removeClass("active");
		$('#mijn-project2').removeClass("active");
		$('#bottombar').removeClass("open");
		$('#close').fadeOut();
	});
	
	/*$('#wrapper #main #rechts #searchform #s').attr('value', 'Kernwoord');*/
	$('#wrapper #main #rechts #searchform #s').attr('onblur', 'def(this)');
	$('#wrapper #main #rechts #searchform #s').attr('onfocus', 'res(this)');
	
	
	$('#wrapper #main #links #menu-disciplines li.current-menu-ancestor').children('.sub-menu').show();
	$('#wrapper #main #links #menu-disciplines li > a').click(function() {
		$(this).next('.sub-menu').slideToggle();
	});
	
	$('#functie').attr('disabled', 'disabled');
	setUrlVars();
	
	$('#refs .ref').mouseenter(function() {
		$(this).children('.excp').clearQueue();
		//$(this).children('.excp').css('opacity', 0);
		//$(this).children('.excp').show();
		$(this).children('.excp').animate({opacity: 1}, 1000);
		//$(this).children('.excp').fadeIn();
	});
	
	$('#refs .ref').mouseleave(function() {
		$(this).children('.excp').clearQueue();
		//$(this).children('.excp').css('opacity', 1);
		$(this).children('.excp').animate({opacity: 0}, 1000);
		//$(this).children('.excp').fadeOut();
	});

	$("input[type=file]").filestyle({ 
		image: "/kloet/file.png",
		imageheight : 23,
		imagewidth : 25,
		width : 380
	});
	
	/** Lightbox */
	jQuery('.gallery-icon a').lightBox();
	jQuery('.entry-content a>img').each(function(){
		jQuery(this).parent().lightBox();
		jQuery(this).parent().addClass('lightbox-link');
	});
	/*
    var latlng = new google.maps.LatLng(51.924151, 4.40636);
    var myOptions = {
      zoom: 11,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    
    var encodedPath = 'gl|{HahjZrE{Gl@rAbBoAj@tBgE|CmD|DqEbDj@~DFvAw@xB_Ar@}ErBsAlAqFtKqPzYc@jAuBnKo@xBe@j@ua@x\\iAf@k@BYU]GcAZ_@p@KjBNhA^v@\\Tb@dA`IpU`@x@vAnF|@jEfA~GbB~PlA`Kn@~DlAvFxBhHjHzSp@zBxErSpIjXD`@lV~x@lHnU`B`HjAbKPfGAzEYlFc@lEoAbGu@lCwIvVkDvNyAjJ{@fL_@jJEzDDdK`E|xA`Ahc@VjWRrh@d@dKfBzOra@xoCp@dGnApSjA|F|DmDr@Qn@TdA|@lCxDlPtL|Bt@nIzEtG~CZj@v@p@xF`CtUnMp@DZCLKZa@nAuDV]p@GtAh@v@Nd@fDdBfRbAf^LrCNn@^vFrJx@';
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    var flightPlanCoordinates = google.maps.geometry.encoding.decodePath(encodedPath);
	var decodedLevels = decodeLevels("B??@@??@??@??@?@??@????????A??????@?????@?????????A???@???@??@??????A????A??@??@??????@?????@??@?????@B");
    var flightPath = new google.maps.Polyline({
		path: flightPlanCoordinates,
		levels: decodedLevels,
		strokeColor: "#FF0000",
		strokeOpacity: 1.0,
		strokeWeight: 2
	});
	flightPath.setMap(map);
	
	function decodeLevels(encodedLevelsString) {
	var decodedLevels = [];

	for (var i = 0; i < encodedLevelsString.length; ++i) {
		var level = encodedLevelsString.charCodeAt(i) - 63;
		decodedLevels.push(level);
	}
	return decodedLevels;
	}*/
});


function def(p) {
	if(p.value == "") {
		p.value = p.defaultValue;
	}
}
function res(p){
	if (p.defaultValue == p.value)
		p.value = "";
}

function setUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    var veld = document.getElementById('functie');
	if (veld) veld.value = vars["functie"];
}

function phpscript(outputString) {
	alert("roep aan");
	alert(outputString);
  }
