jQuery(document).ready(function() {
	
	// Show comment form if url ends with #commentForm
	var path = window.top.location.href;
	if (path.indexOf("#commentForm") != -1){
		showCommentFormIfNotExpired();
	}
	
	//	Shows comment form
	jQuery("#commentFormReagerenLink").click(function () {
		showCommentFormIfNotExpired();
	});
	
	jQuery("#commentForm").submit(function () {
		jQuery("#commentFormSubmitLink").attr("disabled","disabled");
		jQuery("#commentFormSubmitLink").attr("class","btn02 disabled");
		jQuery("#agreeTerms").unbind("click");
		jQuery("#agreeTerms").click(function() { return false; });
		jQuery('#commentForm').submit();
		return false;
	});
	
	jQuery("#agreeTerms").click(function () {
		if(!this.checked){
			jQuery("#commentFormSubmitLink").attr("disabled","disabled");
			jQuery("#commentFormSubmitLink").attr("class","btn02 disabled");
		}else{
			jQuery("#commentFormSubmitLink").removeAttr("disabled");
			jQuery("#commentFormSubmitLink").attr("class","btn02");
		}
	}); 
	
	
});

function showCommentFormIfNotExpired(){
	UserDWR.hasAuthenticationExpiredForKnownUser({
		callback:function(expired) {showCommentFormIfNotExpiredCallback(expired);} 
	});
}

function showCommentFormIfNotExpiredCallback(expired){
	if (expired){
		showLoginForReaction();
	}else{
		jQuery("#commentFormContainer").show("slow");
	}
}

//	Top vacansies trefwoord text in search box show/hide function
var topVacansiesSearchBoxDefault = "Trefwoord";

jQuery(document).ready(function() {
	jQuery("#topVacansiesSearchBox").focus(function(){
		if($(this).attr("value") == topVacansiesSearchBoxDefault) {
			$(this).attr("value", "");
		}
	});
	
	jQuery("#topVacansiesSearchBox").blur(function(){
		if($(this).attr("value") == "") {
			$(this).attr("value", topVacansiesSearchBoxDefault);
		}
	});
});
