/**
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne brian(at)cherne(dot)net
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:10,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev])}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev])};var handleHover=function(e){var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t)}if(e.type=="mouseenter"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob)},cfg.interval)}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob)},cfg.timeout)}}};return this.bind('mouseenter',handleHover).bind('mouseleave',handleHover)}})(jQuery);


/** jquery carousel */
//(function($){$.tiny=$.tiny||{};$.tiny.carousel={options:{start:1,display:1,axis:'x',controls:true,pager:false,interval:false,intervaltime:3000,rewind:false,animation:true,duration:1000,callback:null}};$.fn.tinycarousel=function(options){var options=$.extend({},$.tiny.carousel.options,options);this.each(function(){$(this).data('tcl',new Carousel($(this),options));});return this;};$.fn.tinycarousel_start=function(){$(this).data('tcl').start();};$.fn.tinycarousel_stop=function(){$(this).data('tcl').stop();};$.fn.tinycarousel_move=function(iNum){$(this).data('tcl').move(iNum-1,true);};function Carousel(root,options){var oSelf=this;var oViewport=$('.viewport:first',root);var oContent=$('.overview:first',root);var oPages=oContent.children();var oBtnNext=$('.next:first',root);var oBtnPrev=$('.prev:first',root);var oPager=$('.pager:first',root);var iPageSize,iSteps,iCurrent,oTimer,bPause,bForward=true,bAxis=options.axis=='x';function initialize(){iPageSize=bAxis?$(oPages[0]).outerWidth(true):$(oPages[0]).outerHeight(true);var iLeftover=Math.ceil(((bAxis?oViewport.outerWidth():oViewport.outerHeight())/(iPageSize*options.display))-1);iSteps=Math.max(1,Math.ceil(oPages.length/options.display)-iLeftover);iCurrent=Math.min(iSteps,Math.max(1,options.start))-2;oContent.css(bAxis?'width':'height',(iPageSize*oPages.length));oSelf.move(1);setEvents();return oSelf;};function setEvents(){if(options.controls&&oBtnPrev.length>0&&oBtnNext.length>0){oBtnPrev.click(function(){oSelf.move(-1);return false;});oBtnNext.click(function(){oSelf.move(1);return false;});}if(options.interval){root.hover(oSelf.stop,oSelf.start);}if(options.pager&&oPager.length>0){$('a',oPager).click(setPager);}};function setButtons(){if(options.controls){oBtnPrev.toggleClass('disable',!(iCurrent>0));oBtnNext.toggleClass('disable',!(iCurrent+1<iSteps));}if(options.pager){var oNumbers=$('.pagenum',oPager);oNumbers.removeClass('active');$(oNumbers[iCurrent]).addClass('active');}};function setPager(oEvent){if($(this).hasClass('pagenum')){oSelf.move(parseInt(this.rel),true);}return false;};function setTimer(){if(options.interval&&!bPause){clearTimeout(oTimer);oTimer=setTimeout(function(){iCurrent=iCurrent+1==iSteps?-1:iCurrent;bForward=iCurrent+1==iSteps?false:iCurrent==0?true:bForward;oSelf.move(bForward?1:-1);},options.intervaltime);}};this.stop=function(){clearTimeout(oTimer);bPause=true;};this.start=function(){bPause=false;setTimer();};this.move=function(iDirection,bPublic){iCurrent=bPublic?iDirection:iCurrent+=iDirection;if(iCurrent>-1&&iCurrent<iSteps){var oPosition={};oPosition[bAxis?'left':'top']=-(iCurrent*(iPageSize*options.display));oContent.animate(oPosition,{queue:false,duration:options.animation?options.duration:0,complete:function(){if(typeof options.callback=='function')options.callback.call(this,oPages[iCurrent],iCurrent);}});setButtons();setTimer();}};return initialize();};})(jQuery);


/*
 * Cookie plugin
 */
 
jQuery.cookie=function(a,b,c){if(arguments.length>1&&String(b)!=="[object Object]"){c=jQuery.extend({},c);if(b===null||b===undefined){c.expires=-1}if(typeof c.expires==="number"){var d=c.expires,e=c.expires=new Date;e.setDate(e.getDate()+d)}b=String(b);return document.cookie=[encodeURIComponent(a),"=",c.raw?b:encodeURIComponent(b),c.expires?"; expires="+c.expires.toUTCString():"",c.path?"; path="+c.path:"",c.domain?"; domain="+c.domain:"",c.secure?"; secure":""].join("")}c=b||{};var f,g=c.raw?function(a){return a}:decodeURIComponent;return(f=(new RegExp("(?:^|; )"+encodeURIComponent(a)+"=([^;]*)")).exec(document.cookie))?g(f[1]):null}

$(document).ready(function() {

	/* This is basic - uses default settings */
	
	$("a#logoutButton").fancybox();
    $("a#loginButton").fancybox();
	

//Speed of the slideshow
    var speed = 1000;
    var hovertime = 10; // time in seconds to stay on each panel 
    var idletime = 10; // time in seconds that user is idle before cycle begins again 
    var idletimer = 0; // store our idle timer id so we can keep refreshing it 

    
    
    //Mouse over, pause it, on mouse out, resume the slider show
    $('#slider').hover(
    
        function() {
            clearInterval(run);
        }, 
        function() {
            run = setInterval('newsscoller(0)', speed); 
        }
    ); 
    // scrolling banners
    
    var api = $("#scroll").scrollable({
        items: '#tools',
        size: 1,
        circular:true
        // use the navigator plugin
        })  
        .autoscroll({ 
            steps: 1, 
            interval: hovertime*1000, 
            autopause: true
            
             
        })
        .navigator({
        	api: true,
        	navi:'.navi2'	
        });

    

        // if the user clicks the panel 
    $('div.scrollable').click(function() { 
        // pause the autoplay to let them navigate manually 
        api.stop(); 
         
        // everytime they click we want to refresh our timer, so we must delete the old one 
        if (idletimer) {window.clearTimeout(idletimer);} 
         
        // set a timer which will return the panel to autoplay after no activity 
        idletimer = window.setTimeout(function() { 
            api.stop(); 
        }, idletime*1000); 
     
    });

	
});
$(function(){
    
   // $('#serviceBlockHolder').tinycarousel();
    
	/*
	 * Valid _blank function
	 */
	
    
	$('a[rel*=external],a[rel*=nofollow]').click(function() {
		window.open(this.href);
		return false;
	});
	
	$("select, input:checkbox, input:radio, input:file").uniform();
	/*
	 * Valid popup function
	 */
	
	$('a[rel*=share]').click(function() {
		var windowTitle = $(this).attr('title');
		window.open($(this).attr('href'), windowTitle, 'width=550,height=420,scrollbars=no');
		return false;
	});
if ($('#banner_right').length != 0)
{
    // header images cycle
    $('#banner_right').cycle({ fx:'fade',timeout: 5000,pagerEvent:'mouseenter.cycle',after: checkQuote, pager:  '#banner_nav',pagerAnchorBuilder: paginate});function paginate(ind, el){if (ind == 0) return '<a href="'+$('#banner_image img:eq(0)').attr('rel')+'" id="tab1">'+$('#banner_image img:eq(0)').attr('alt')+'</a>';else if (ind == 1) return '<a href="'+$('#banner_image img:eq(1)').attr('rel')+'" id="tab2">'+$('#banner_image img:eq(1)').attr('alt')+'</a>';else if (ind == 2) return '<a href="'+$('#banner_image img:eq(2)').attr('rel')+'" id="tab3">'+$('#banner_image img:eq(2)').attr('alt')+'</a>';else if (ind == 3) return '<a href="'+$('#banner_image img:eq(3)').attr('rel')+'" id="tab4">'+$('#banner_image img:eq(3)').attr('alt')+'</a>';}
    function checkQuote(curr, next, opts) {

        $('#banner_quote div').removeClass('active');
        $('#quote'+(opts.currSlide+1)).addClass('active');
    }
 }   
    function dump(obj) {
    var out = '';
    for (var i in obj) {
        out += i + ": " + obj[i] + "\n";
    }

    document.write(out);

    // or, if you wanted to avoid alerts...

    var pre = document.createElement('pre');
    pre.innerHTML = out;
    document.body.appendChild(pre)
}

	if ($('#tweetsWidget').length != 0)
     {
   	/* http://tweet.seaofclouds.com/ */
	
    
    $("#tweetsWidget").tweet({
			username: "PDC_Veghel",
            count: 3,
             avatar_size: 32,
            loading_text: "loading tweets…",
            template: "{text}{time}"
    });
    
}
    // largest height()
	var maxHeight1 = 0;
	
	$(".dashboardModule").each(function(){
	      if ($(this).height() > maxHeight1) {
	            maxHeight1 = $(this).height();
	      }
	});
	$(".dashboardModule").height(maxHeight1);


   
    
    //Social media icoontjes highlight
    $('footer.contactus_footer').children().hover(
		function() {
			$(this).siblings().stop().fadeTo(100,0.5);
		},
		function() {
			$(this).siblings().stop().fadeTo(300,1);
		}
	);
	
	 //header menu
    $('ul.topnav li').hoverIntent({over: makeTall,out: makeShort});
    
    function makeTall()
    {
    	
    	$(this).addClass('hoverLine').find('ul.subnav').slideDown('fast');
    	$(this).find('.topArrow').show();
    }
    
    function makeShort()
    {
    	$(this).removeClass('hoverLine').find('ul.subnav').slideUp('fast');
    	$(this).find('.topArrow').hide();
    }   
    
    $("#contactForm").submit(function(){
        if ($('input[name=verificationCode]:checked').length>0) {
            $('.formLabelCaptcha').html('Controle om spam bots te voorkomen *');
            $('#s3capcha').css('border','1px solid #CCCCCC');
            return true;
        } else {
            $('#s3capcha').css('border','1px solid red');
            $('.formLabelCaptcha').html('Controle om spam bots te voorkomen *<label for="contactEmail" class="error">Klik op het icoon wat overeenkomt met de naam</label>');
            return false;
        }
       // return false;
    });
     $("#contactForm").validate({
        messages: {
			companyName: {
                required: 'Vul naam bedrijf in'
            },
            contactName: {
                required: 'Vul contact naam in'
            },
            contactEmail: {
				required: 'Vul hier uw e-mailadres in',
                email: 'Vul een geldig e-mailadres in'
			},
            contactComments: {
                required: 'Vul uw opmerking in'
            }
		},
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
		if ( element.is(":radio") )
			error.appendTo( element.parent().next());
		else if ( element.is(":checkbox") )
			error.appendTo ( element.next() );
		else
			error.appendTo( element.parent().next() );
		}
		
    });
    
    
    
    $("#newsletterForm").validate({
        messages: {
			company: {
                required: 'Vul naam bedrijf in'
            },
            lastname: {
                required: 'Vul achternaam in'
            },
            emailaddress: {
				required: 'Vul hier uw e-mailadres in',
                email: 'Vul een geldig e-mailadres in'
			}
		},
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
		if ( element.is(":radio") )
			error.appendTo( element.parent().next());
		else if ( element.is(":checkbox") )
			error.appendTo ( element.next() );
		else
			error.appendTo( element.parent().next() );
		}
		
    });
    
    $("#companyForm").validate({
        messages: {
			pco_companyname: {
                required: 'Vul naam bedrijf in'
            },
            
            pco_address: {
                required: 'Vul adres in'
            },
            pco_zipcode: {
                required: 'Vul postcode in'
            },
            pco_city: {
                required: 'Vul plaatsnaam in'
            },
            pco_phone: {
                required: 'Vul telefoon in'
            },
            pco_email: {
				email: 'Vul een geldig e-mailadres in'
			}
		},
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
		if ( element.is(":radio") )
			error.appendTo( element.parent().next());
		else if ( element.is(":checkbox") )
			error.appendTo ( element.next() );
		else
			error.appendTo( element.parent().next() );
		}
		
    });
    $("#userForm").validate({
        messages: {
			
            pcu_contact: {
                required: 'Vul contact naam in'
            },
            pcu_email: {
				required: 'Vul hier uw e-mailadres in',
                email: 'Vul een geldig e-mailadres in'
			}
		},
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
		if ( element.is(":radio") )
			error.appendTo( element.parent().next());
		else if ( element.is(":checkbox") )
			error.appendTo ( element.next() );
		else
			error.appendTo( element.parent().next() );
		}
		
    });
    $("#userForm2").validate({
    	rules: {
			pcu_password: {
				required: true,
				minlength: 6
			},
			pcu_password_repeat: {
				required: true,
				minlength: 6,
				equalTo: "#pcu_password"
			}
		},
        messages: {
			pcu_password: {
                required: 'Vul wachtwoord in',
                minlength: 'Wachtwoord moet minimaal 6 karakters lang zijn'
            },
            pcu_password_repeat: {
                required: 'Herhaal wachtwoord',
                minlength: 'Wachtwoord moet minimaal 6 karakters lang zijn',
                equalTo: 'Wachtwoorden zijn niet gelijk'
            }
		},
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
		if ( element.is(":radio") )
			error.appendTo( element.parent().next());
		else if ( element.is(":checkbox") )
			error.appendTo ( element.next() );
		else
			error.appendTo( element.parent().next() );
		}
		
    });
     $("#employeeForm").validate({
     	
        messages: {
			pem_firstname: {
                required: 'Vul voornaam in'
            },
            pem_lastname: {
                required: 'Vul achternaam in'
            },
            pem_address: {
                required: 'Vul adres in'
            },
            pem_zipcode: {
                required: 'Vul postcode in'
            },
            pem_city: {
                required: 'Vul plaatsnaam in'
            },
            pem_email: {
				required: 'Vul hier uw e-mailadres in',
                email: 'Vul een geldig e-mailadres in'
			},
			pem_birthday: {
                required: 'Vul geboortedatum in'
            },
			pem_gender: {
                required: 'Selecteer geslacht'
            }
		},
    
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
			if ( element.is(":radio") )
			{
				error.appendTo( element.parent().parent().prev());
			}
			else if ( element.is(":checkbox") )
			{
				error.appendTo ( element.parent().prev() );
			}
			else
			{
				
				if(element.hasClass('errorLeft'))
				{
					error.appendTo( element.parent().prev() );
				}
				else
				{	
					error.appendTo( element.parent().next() );
				}
			}
		}
		
    });
    
    
    $("#employeeFormLink").validate({
        messages: {
			pem_link_code: {
                required: 'Vul koppelcode in'
            },
            pce_employeenumber: {
                required: 'Vul werknemer nummer in'
            }
		},
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
		if ( element.is(":radio") )
			error.appendTo( element.parent().next());
		else if ( element.is(":checkbox") )
			error.appendTo ( element.next() );
		else
			error.appendTo( element.parent().next() );
		}
		
    });
    
    
    $("#comTraning").validate({
        messages: {
			petr_datefrom: {
                required: 'Start datum is verplicht'
            }
		},
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
		if ( element.is(":radio") )
			error.appendTo( element.parent().next());
		else if ( element.is(":checkbox") )
			error.appendTo ( element.next() );
		else
			error.appendTo( element.parent().next() );
		}
		
    });
    $("#trajectForm").validate({
        messages: {
			pvs_string: {
                required: 'Vul zoektermen in.'
            }
		},
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
		if ( element.is(":radio") )
			error.appendTo( element.parent().next());
		else if ( element.is(":checkbox") )
			error.appendTo ( element.next() );
		else
			error.appendTo( element.parent().next() );
		}
		
    });
     $("#searchForm").validate({
        messages: {
			search: {
                required: 'Vul zoektermen in.'
            }
		},
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
		if ( element.is(":radio") )
			error.appendTo( element.parent().next());
		else if ( element.is(":checkbox") )
			error.appendTo ( element.next() );
		else
			error.appendTo( element.parent().next() );
		}
		
    });
     $("#vacancyForm").validate({
     	
        messages: {
			pva_date: {
                required: 'Vul datum in'
            },
            pva_reference: {
                required: 'Vul referentie in'
            },
            pva_title: {
                required: 'Vul titel in'
            },
            pva_city: {
                required: 'Vul locatie of standplaats in'
            },
            pva_tags: {
                required: 'Vul kenmerken in'
            },
            pva_description_small: {
                required: 'Vul samenvatting in'
            },
            pva_description_big: {
                required: 'Vul omschrijving in'
            }
		},
    
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
			if ( element.is(":radio") )
			{
				error.appendTo( element.parent().parent().prev());
			}
			else if ( element.is(":checkbox") )
			{
				error.appendTo ( element.parent().prev() );
			}
			else
			{
				
				if(element.hasClass('errorLeft'))
				{
					error.appendTo( element.parent().prev() );
				}
				else
				{	
					error.appendTo( element.parent().next() );
				}
			}
		}
		
    });
    $( "#sortable1, #sortable2" ).sortable({
			connectWith: ".connectedSortable"
		}).disableSelection();
	
	
	$('#sickForm').submit(function() {
		var result = $('#sortable2').sortable('toArray');
		$('#sickArray').val(result);
 		return true;
	});
	$('#outForm').submit(function() {
		var result = $('#sortable2').sortable('toArray');
		$('#outArray').val(result);
 		return true;
	});
	$('#jobForm').submit(function() {
		var result = $('#sortable2').sortable('toArray');
		$('#jobArray').val(result);
 		return true;
	});
	$('#reiForm').submit(function() {
		var result = $('#sortable2').sortable('toArray');
		$('#reiArray').val(result);
 		return true;
	});
	$('#tabs').tabs();
	
	$('.datepicker').datepicker($.datepicker.regional['nl']);
	
	$('#tabs-2').delegate('.generatedDate','focusin',function(){
		$(this).datepicker($.datepicker.regional['nl']);
	});
	$('#delFile2').click(function(){
		$('#deleteFileLine2').animate({ opacity: 0.5 }, 100);
		$('#delFile2').hide();
		$('#deleteFile2').val('1');
    });
    $('#delFile3').click(function(){
    	$('#deleteFileLine3').animate({ opacity: 0.5 }, 100);
		$('#delFile3').hide();
        $('#deleteFile3').val('1');
    });
    $('#cancel').click(function(){
        $.fancybox.close();
        return false;
    });
    
    $('#logout').click(function(){
        $('#logoutForm').submit();
    });
    
    $('.loginButton').click(function(){
    
   
        //e.preventDefault();
        $.post("/authenticate-parser.html", { 
                'username': $('input[name=username]').val(), 
                'password': $('input[name=password]').val()
        },
         function(oResponse){
            if (oResponse.success==1) {
                $('form[name=loginForm]').submit();
            } else {
                $('#loginResponseMessage').html(oResponse.message);
            }
         }, "json");
        return false;
    });
    
    
    $("img.lazy").lazyload({effect:"fadeIn"});
    
     /*$.getJSON("/serviceimages", function(data) {
        $(document).ready(function(){
            $("#serviceBlockHolder").agile_carousel({
                carousel_data: data,
                carousel_outer_height: 230,
                carousel_height: 200,
                slide_height: 200,
                carousel_outer_width: 480,
                slide_width: 160,
                number_slides_visible: 3,
                transition_time: 330,
                //timer: 2000,
                //control_set_1: "previous_button,next_button"//,
                control_set_1: "group_numbered_buttons"//,
               // persistent_content: "<p class='persistent_content'>Agile Carousel Example: Multiple Slides Visible</p>"       
            });
        });
    });*/
    
    $("#browsable").scrollable({circular: false}).navigator().autoscroll({ autoplay: false });

	
		$( "#accordion" ).accordion({
    		icons: false,
    		autoHeight: false
		});
		$('#eventTitleBlock').click(function() {
  			$('#eventArchiveBlock').toggle('fast', function() {
   
  			});
		});
		

	
    
});
/* Dutch (UTF-8) initialisation for the jQuery UI date picker plugin. */
/* Written by Mathias Bynens <http://mathiasbynens.be/> */
$(function($){
	$.datepicker.regional['nl'] = {
		closeText: 'Sluiten',
		prevText: '←',
		nextText: '→',
		currentText: 'Vandaag',
		monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni',
		'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
		monthNamesShort: ['jan', 'feb', 'maa', 'apr', 'mei', 'jun',
		'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
		dayNames: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
		dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'],
		dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
		weekHeader: 'Wk',
		dateFormat: 'dd-mm-yy',
		firstDay: 1,
		isRTL: false,
		showMonthAfterYear: false,
		yearSuffix: ''};
	$.datepicker.setDefaults($.datepicker.regional['nl']);
});


