$.fn.cycle.updateActivePagerLink = function(pager, currSlideIndex) { 
    $(pager).find('li').removeClass('slideshow-active') 
        .filter('li:eq('+currSlideIndex+')').addClass('slideshow-active'); 
}; 

$.fn.cycle.transitions.none = function($cont, $slides, opts) {
	var css = { top: 0, left: 0 }
	opts.fxFn = function(curr,next,opts,after){
		$.fn.cycle.commonReset(curr,next,opts,after);
		$([curr,next]).css(css);
		$(next).show();
		$(curr).hide();
		after();
	};
};

$(document).ready(function() {	
	$('input[type="text"], textarea')
	.focus(function() {
		if (this.value === this.defaultValue) {
			this.value = '';
		}
	})
	.blur(function() {
		if (this.value === '') {
			this.value = this.defaultValue;
		}
	});

	$("#newsletterform").submit(function(event) {
		event.preventDefault(); 
		
	    var $form = $(this),
	        pemail    = $form.find('input[name="nlinput"]').val();
	    
	    $form.find('input[name="nlsubmit"]').hide();
	     
		$.post('post-newsletter.php', { email: pemail } ,
			function(data) {
				$.prompt(data);
				
				if(data.indexOf('Bedankt') != -1)
				{
					$form.find('input[name="nlinput"]').val('Vul hier uw e-mail adres in om het laatste nieuws en aanbiedingen...');
				}
				
				$form.find('input[name="nlsubmit"]').show();
			}
		);
	});

	$("#searchform").submit(function(event) {
		event.preventDefault(); 
if($('#homesearch').val() == '') {
			}
			else {
				window.location='/zoeken/'+$('#homesearch').val();
			}

	    //$.prompt("<img src=\"template/img/logo.png\" alt=\"\" width=\"265\" height=\"44\" /><br /><h1>Zoekfunctie is niet beschikbaar</h1><p>Op dit momement wordt het zoeken nog niet ondersteund. Onze excuses voor het ongemak.</p>"); 
	});
	
	$('#homesearch').autocomplete("/autocomplete.php", {
		delay:10,
		minChars:2,
		matchSubset:1,
		matchContains:1,
		cacheLength:10,
		onItemSelect:selectItem,
		onFindValue:findValue,
		formatItem:formatItem,
		autoFill:true,
		resultsClass: 'ac_results_home',
		width: 198
	});

    $('.activator').click(function(){
    });
    $('#boxclose').click(function(){
        $('#box').animate({'top':'-600px'},500,function(){
            $('#overlay').fadeOut('fast');
        });
    });
	$('.openimage').click(function() {
		
		$("#box").css('background-image',"url('/quickverts/" + $(this).attr('title') +  "')");

        $('#overlay').fadeIn('fast',function(){    	
        	$('#box').animate({'top':'150px'},500);
            
        });

		return false;
	})

});

