

//***************************************************
// setting zoom and form clearance
//***************************************************

function SetZoom() {
	//--- add a colorbox wrapper for custom alerts
	var colorwrap = $("<div />").css({display: "none"});
	var color = $("<div />").attr("id", "inline_alert").appendTo(colorwrap);
	var trigger = $("<a />").attr("href", "#").attr("class", "triggerme").attr("id", "triggerme").css({display: "none"});
	$('body').append(colorwrap);
	$('body').append(trigger);
	
	//--- setup the colorboxzoom itself
	$('a.zoom').colorbox({opacity:0.5});
	$("a#mlr-alert").colorbox({opacity:0.5, width:"400px", inline:true, href:"#inline_alert"});
	//--- colorbox used for collezione collection
	$("a#triggerme").colorbox({
		opacity: 0.5, 
		inline: true, 
		href: "#inline_alert",
		onClosed: function(){$('#inline_alert').html('');}
	});	
	
}

function SetForm() {
	$('form.clear input.txt').clearingInput();
	$('form.clear textarea').clearingInput();
}

jQuery.easing.def = "easeInOutQuint";

//***************************************************
// jquery goodness
//***************************************************
$(document).ready(function() {	

	SetZoom();
	SetForm();

	//*********************************
	// SEND CONTACTFORM
	//*********************************
	$('input.subm').hover(function() {
	  $(this).addClass('hover');
	}, function() {
	  $(this).removeClass('hover');
	});
	
	$('input.subm').bind('click',function(){
		$(this).parent().addClass('loading');							 
	});	
	

	function BeforeSendCnt()  {
		$('input:text[value=""]').addClass('empt');
	}	
	
	function SendSuccesCnt(json,stat,xhr,frm)  {
				
		$('.loader').removeClass('loading');
		
		if (json.err=='no' && json.msg!='') {
		
			$('#inline_alert').html(json.msg);
			$('#triggerme').trigger('click');
			$('input',frm).removeClass('empt');
			frm.resetForm();
			SetForm();
		
		}else{ // als er een error is deze zichtbaar maken
						
			$('.clear input.empt').clearingInput();
			$('input',frm).removeClass('empt');
			$('#inline_alert').html(json.msg);
			$('#triggerme').trigger('click');
		
		}		
		
	}
	
	$('.ajaxform').ajaxForm({
			beforeSubmit: BeforeSendCnt,
			success: SendSuccesCnt,
			dataType: 'json',
			clearForm: false
	});
	
 
	//*********************************
	// NO CLICK PREVENT DEFAULT
	//*********************************
	$('a.noclick,a.noswitch').bind('click',function(e){
		e.preventDefault();
	});


	//*********************************
	// MAILCHIMP NEWSLETTER
	//*********************************

	$('#subscription').submit(function() {
		
		$('#newsletter .loader').show();
		
		$.ajax({
			url: 'kp_ajax/mailchimp.php',
			data: 'ajax=true&email=' + escape($('#email').val()),
			success: function(msg) {
				$('#newsletter .loader').hide();
				$('#inline_alert').html(msg);
				$('#triggerme').trigger('click');
			}
		});
	
		return false;
	});
	
	
	//*********************************
	// STANDARD TABLE STUFF
	//*********************************
	$('table.tblstd').each(function(){
		$('tr:first',this).addClass('thead');
		$('tr:odd',this).addClass('odd')
	});

	
	//*********************************

});







