

//***************************************************
// 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.85});
	$("a#mlr-alert").colorbox({opacity:0.85, width:"420px", inline:true, href:"#inline_alert"});
	//--- colorbox used for collezione collection
	$("a#triggerme").colorbox({
		opacity: 0.85, 
		inline: true, 
		href: "#inline_alert",
		onClosed: function(){$('#inline_alert').html('');}
	});	
	
}

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

//***************************************************
// jQuery Goodness
//***************************************************
//jQuery.easing.def = "easeInOutQuint";

$(document).ready(function() {
		
	$('.sitewrap.top h1').click(function(e){
		location.href='/';
		e.preventDefault();
	}).css('cursor','pointer');
	
	
	SetForm();
	SetZoom();

	
	$('#banner').innerfade();
	
	$('.pane .col').each(function(){
		if($(this).children(':first-child').is('h3')){
			$(this).addClass('xpad');
		}
	});
	
	//------------------------------------------------ GALLERY
	
	$('#gallery li').each(function(){
		$('a:first',this).addClass('ontop');
	});
	
	var listheight = $('#gallery li:first').height();	
	
	$('#gallery li:not(".act") em').css({'top':listheight});
	
	$('#gallery li').not('.act').hover(function(){
		capt = $('em',this);
		var hght = capt.height()+6;		
		capt.stop().animate({'top':listheight-hght}, 250);
	},function(){
		capt.stop().delay(500).animate({'top':listheight}, 400);
	}).css({'cursor':'pointer'});
	
	
	//------------------------------------------------ SEND CONTACTFORM

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

	//------------------------------------------------ SEND CONTACT FORM

	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
	});
	
	//*********************************************
	// prevent default
	//*********************************************			
	$('a.noclick').bind('click',function(e){
		e.preventDefault();
	});
	
	//*********************************************
	// default tabs
	//*********************************************			
	$('ul.navtabs').tabs('div.panes > div.pane', { 
		effect: 'fade'	
	});
	
	//*********************************************
	// newslist zijkolom
	//*********************************************	
	$('#newslist li').click(function(){
		var url = $(this).find('a.readmore').attr('href');
		window.location = url;
	}).css({'cursor':'pointer'});

	
});
