
$(document).ready(function() {

	$.backstretch("kp_img/bgfast.jpg");

	$('h1').click(function(){
		location.href='index.php';
		return false;
	})		

	//$(document).pngFix();
	SetForm();
	SetZoom();
	
	//SetEqualHeights( $('.fixcol') );

	//---------------------------------------
	
	$('#mlr-alert').hide();

	$('input.subm').hover(function() {
	  $(this).addClass('hover');
	}, function() {
	  $(this).removeClass('hover');
	});

	$('#frm_cnt').ajaxForm({
			beforeSubmit: BeforeSendCnt,
			success		: SendSuccesCnt,
			clearForm	: false
	});

	function BeforeSendCnt(resp, stat)  {
		$('#loader').addClass('loading');
		$('#frm_cnt input[value=]').addClass('empt');
	}	
	
	function SendSuccesCnt(resp, stat)  {
		
		$('#loader').removeClass('loading');
		
		var json = eval('(' + resp + ')');
		
		if (json.send=='yes') {
			//--- als bericht verzonden is melding geven en alles resetten
			$('#inline_alert').html(json.msg);
			$('a#mlr-alert').trigger('click');
			//$('#mlr-alert').html(json.msg).fadeIn('slow', function(){ setTimeout( "$('#mlr-alert').fadeOut('slow')" ,3000)  });
			$('#frm_cnt input').removeClass('empt');
			$('#frm_cnt').resetForm();
			SetForm();
		}else{
			//--- als er een error is deze zichtbaar maken
			$('#frm_cnt input.empt').clearingInput();
			$('#frm_cnt input').removeClass('empt');
			$('#inline_alert').html(json.msg);
			$('a#mlr-alert').trigger('click');
		}		
		
	}

	//---------------------------------------	

	$('ul#swapimg img').click(function(){
		var capt = $(this).attr('alt');
		$('#caption').html(capt);
	})	

	$(".tip").tipTip();
	
});

//--------------------------------------------------

function SetZoom() {
	$('a.zoom').colorbox({opacity:0.5});
	$("a#mlr-alert").colorbox({opacity:0.5, width:"350px", inline:true, href:"#inline_alert"});
}

function SetForm() {
	$('input:text:[value=""]').clearingInput();
	$('textarea').clearingInput();
}

//--------------------------------------------------

function SetEqualHeights(wrap) {

	if($("#midwrap img").length) {
		//--- if we have images lets wait until they're all loaded
		$("#midwrap img").load(function() {    
			var count;
			var noImages = $("#midwrap img").length;
			
			for ( count=1 ; count<=noImages ; count++) {
			
				if(count === noImages) { 
				//-------------------------------------------
					tallest = 0;
					
					wrap.each(function() {
						
						hg = $(this).height();
						
						if(hg > tallest) {
							tallest = hg;
						}
					});				
					wrap.height(tallest);
				//-------------------------------------------
				}
			};
			
		}());	
		
	}else{
		//---- if we dont have images lets get to work
		tallest = 0;
		
		wrap.each(function() {
			
			hg = $(this).height();
			
			if(hg > tallest) {
				tallest = hg;
			}
		});				
		wrap.height(tallest);	
		
	}
	
}

//--------------------------------------------------

function loadimg(image,wrap) {		
	var img = new Image();
	$(img).load(function () {   
		$(this).hide();
		wrap.find('.imgholder').append(this);
		$(this).fadeIn(600);
	})
	.attr('src', image);
 }

//--------------------------------------------------
