// JavaScript Document
$(document).ready(function(){
	
	$(".clickable").click(function(){
		var myItem = $(this).find("a");
		var myItemLink = myItem.attr("href");
		window.location.href = myItemLink;
	});
	
	$(".clickable").hover(function(){
			$(this).addClass("bg-grey1");
		}, function(){
			$(this).removeClass("bg-grey1");
		}
	);
	
	var valSubscribe = $("#subscribe").attr("title");
	$("#subscribe").val(valSubscribe);
	
	$("#subscribe").focus(function(){
		if($(this).val()=='Uw e-mailadres...' || $.trim($(this).val())==''){
			$(this).val('');
		}
	});
	
	$("#subscribe").blur(function(){
			if($(this).val()=='Uw e-mailadres...' || $.trim($(this).val())==''){
				$(this).val(valSubscribe);
			}
			
	});	
	
	if($("#article-detail p:first img:first")){
		$("#article-detail p:first").css('margin-top','-15px');
	}
	
	$('#menu-top a').click(function() {
		$('#menu-top a').removeClass('clicked');
		$('#menu-top a').removeClass('active');
		$(this).addClass('clicked');	
	});
	
	$('#menu-top a').hover(function() {
		if($(this).hasClass('active')){
			
		}else{
			$(this).stop().animate({ marginTop: '-5px', height: '48px'}, 200);
		}
		
	}, function() {
		if($(this).hasClass('clicked')){
			
		}else{
			$(this).stop().animate({ marginTop: '0px', height: '43px'}, 150);
		}
	});
	
	$('#menu-left a').hover(function() {
		$(this).stop().animate({ paddingLeft: '5px'}, 150);
	}, function() {
		$(this).stop().animate({ paddingLeft: '0px'}, 150);
	});

});


function ajaxPost(mod,dataurl){
	$.ajax({
		url: dataurl,
		cache: true,
			beforeSend: function(){
				//Loader
				$("#"+mod+"-form .ajax-loader").show();
				$("#submit-"+mod+"").attr("disabled", "disabled");
				$("#input-"+mod+"").attr("disabled", "disabled");
			},
			error: function(XMLHttpRequest, textStatus, errorThrown){
				//Error
				$("#"+mod+"-form .ajax-loader").hide();
				openDialogNotification('ERROR','Error while connecting to server');
				$("#submit-"+mod+"").removeAttr("disabled");
				$("#input-"+mod+"").removeAttr("disabled");
			},
			success: function(data){
				$("#"+mod+"-wrapper").prepend(data);
				$("#"+mod+"-form .ajax-loader").hide();
				$("#input-"+mod+"").removeAttr("disabled");
				$("#submit-"+mod+"").removeAttr("disabled");
				
				$("#"+mod+"-wrapper div."+mod+"-item:first").show("slow",
				function() {
					$("#input-"+mod+"").val("");
				});
			}
	});
}
