$(document).ready(function() {
						   
	$('#lightbox a').lightBox({fixedNavigation:false});
	$(document).pngFix(); 
	
	// clear search field on focus
	$.fn.search = function() {
		return this.focus(function() {
			if( this.value == this.defaultValue ) {
				this.value = "";
			}
		}).blur(function() {
			if( !this.value.length ) {
				this.value = this.defaultValue;
			}
		});
	};
	$("#s").search();
	
	
	$("#groupmenu ul li ul").hide();
	
	// drop down menu
	$("#nav-one li").hover(
		function(){ $("ul", this).fadeIn("fast"); }, 
		function() { } 
	);
 	if (document.all) {
		$("#nav-one li").hoverClass ("sfHover");
	}
	
	$('a:upload').attr('target', '_blank');
	
	
	$("a.headerswitch[rel='hoofdkliniek']").click(function(event){
		event.preventDefault();
		$("#panelWeidevenne").hide();
		$("#panelHoofdkliniek").show();
		if (!$(this).is("on"))
		{
			$(this).addClass("on");
		}
		$("#header-photo").attr("style", "background: url(/img/home-hoofdkliniek.jpg) no-repeat left center;")
		$("a.headerswitch[rel='weidevenne']").removeClass("on");
	});

	$("a.headerswitch[rel='weidevenne']").click(function(event){
		event.preventDefault();
		$("#panelHoofdkliniek").hide();
		$("#panelWeidevenne").show();
		if (!$(this).is("on"))
		{
			$(this).addClass("on");
		}
		$("#header-photo").attr("style", "background: url(/img/home-weidevenne.jpg) no-repeat left center;");
		$("a.headerswitch[rel='hoofdkliniek']").removeClass("on");
	});
	
});
$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};

//create jquery selector "upload", which selects all upload links
$.extend($.expr[':'],{
	upload: function(a,i,m) {
		if(!a.href) {return false;}
		
		return a.href.indexOf("/upload/") > 0
	}
});

function fnTrapKP(e) { 
	var keynum;
	if(window.event) {
	  keynum = e.keyCode;
	} else if(e.which) {
	  keynum = e.which;
	}
	if (keynum == 13) { 
		e.returnValue = false; 
		e.cancelBubble = true; 
		fnSearch(); 
	} 
}

function checkEmail(strEmail) { 
	return (strEmail.search(/^[\w\.\-_]*[A-Z|a-z|0-9]{1}@([\w\-_]+\.)+[A-Za-z]{2,4}$/) != -1)
}

function fnSearch() {
	var oSearch = document.forms.frmSearch;
	var errLvl = 0;
	if(((oSearch.txtSearch.value == '') || (oSearch.txtSearch.value == 'zoeken...')) || (oSearch.txtSearch.value.length < 3)) { errLvl = 1; }
	if(errLvl != 0) {
		alert('Voer minimaal 3 karakters in.');
	} else {
		document.forms.frmSearch.action = 'search.asp?query=' + oSearch.txtSearch.value;
		oSearch.submit();
	}
}

function toggle(id) {
	
	try {
		
		var _item = document.getElementById(id);
		var subitem = document.getElementById("sub_" + id);
		
		if(subitem.style.display == 'block') {
			subitem.style.display = 'none';
			_item.className = '';
			
		} else {
			subitem.style.display = 'block';
			_item.className = 'menuActive';
		}	
		
	} catch(ex) {}
}

function togglesecond(id) {
	
	try {
		
		var _item = document.getElementById(id);
		
		var seconditem = document.getElementById("second_" + id);
		
		if(seconditem.style.display == 'block') {
			seconditem.style.display = 'none';
			_item.className = '';
		} else {
			seconditem.style.display = 'block';
			_item.className = 'menuActive';
		}
		
	} catch(ex) {}
}
