﻿/**
 * Javascript - jQuery enabled
 * 
 * @package WPFramework
 * @subpackage Media
 */


jQuery(document).ready(function($) {

	$('ul.nav li.page-item-7 ul').wrap("<div class='menuwrap'></div>");
	$('ul.nav li.page-item-4554 ul').wrap("<div class='menuwrap'></div>");
	
	$('ul.nav ul ul').each(function() {
    	$(this).parent().after($(this).find('li').addClass('thirdlevel'));
    	$(this).remove();
	});

	$('ul.nav li ul').prepend("<div class='left'></div>");
	$('body.home div#primary div.entry-content p a').append("<span></span>");
	$('div.oranje_blok div.textwidget a').append("<span>&rsaquo;</span>");
	$('li.morenews a').append("<span></span>");
	
	$('body.pageid-4144 div.wordtube').append("<span class='meervids'>Klik hier voor meer video's</span>");

	
	
	$('.nav').supersubs({
		minWidth: 		12,						// requires em unit.
		maxWidth: 		25,						// requires em unit.
		extraWidth: 	0.769						// extra width can ensure lines don't sometimes turn over due to slight browser differences in how they round-off values
    })
    .superfish({
		hoverClass:		'nav-hover',			// the class applied to hovered list items 
	//	pathClass:		'overideThisToUse',		// the class you have applied to list items that lead to the current page 
	//	pathLevels:		2,						// the number of levels of submenus that remain open or are restored using pathClass 
		delay:			400,					// the delay in milliseconds that the mouse can remain outside a submenu without it closing 
		animation:		{opacity:'show'},		// an object equivalent to first parameter of jQuery痴 .animate() method 
		speed:			'normal',				// speed of the animation. Equivalent to second parameter of jQuery痴 .animate() method 
		autoArrows:		true,					// if true, arrow mark-up generated automatically = cleaner source code at expense of initialisation performance 
		disableHI:		false					// set to true to disable hoverIntent detection 
	});
	
	$('ul.clientsfaderlist').cycle('fade');
	$('ul.polaroidlist').cycle('fade');

	
	

	$(".nav li ul li:last-child a").addClass("last-child");
	$(".nav li.page-item-7 ul li li:last-child a").addClass("last-child");
	$(".nav li.page-item-4554 ul li li:last-child a").addClass("last-child");
	$("div.courtesy ul li:last-child").addClass("last-child");
	$("div.fat-footer div.blok:last-child").addClass("last-child");
	$("div#header_language_list ul li:last-child").addClass("last-child");
	$("ul.courtesyfooter li:last-child").addClass("last-child");
	$("ul.courtesyfooter li:first-child").addClass("first-child");
	
	//$("ul.gridlist li:nth-child(3n)").css("margin-right","0px"); /*remove margin-right on 3rd li item in client and news grid */
	
	$('input.button').hover(function() { /*add :hover selector for IE*/
  	$(this).addClass('hover');
	}, function() {
  	$(this).removeClass('hover');
	});
		
	
/*clear zoekvenster*/
$("#s").focus(function() {
	if( this.value == this.defaultValue ) {
		this.value = "";
	}
}).blur(function() {
	if( !this.value.length ) {
		this.value = this.defaultValue;
	}
});
$("#s2").focus(function() {
	if( this.value == this.defaultValue ) {
		this.value = "";
	}
}).blur(function() {
	if( !this.value.length ) {
		this.value = this.defaultValue;
	}
});
$("ul.courtesyfooter li").not(":last").append("<span class='divider'>|</span>");
$("ul.nav ul ul").remove();

$('ul.clientsfaderlist').cycle('fade');
$('ul.polaroidlist').cycle('fade');  


       
$('div.clientSlider div.wrapper ul').cycle({ 
		fx:     'scrollLeft',
  		speed:   1000, 
        timeout: 6000,/* 初期設定6000 */
        pause:	  1, 
        pager:  '#thumbNav' });

$('#pauseBtn').toggle(function() {

                $('#BB2').cycle('pause');
                $(this).removeClass('play').addClass('pause');

                }, function() {

                $('#BB2').cycle('resume', true);
                $(this).removeClass('pause').addClass('play');
        });


$('#BB2').cycle({ 
		fx:     'slideX',
  		speed:   1000, 
        timeout: 8000,/* 初期設定6000 */
        delay:	 -4500,	
        pause:	  1, 
        pager:  '#thumbNav',
        before:  onBefore, 
    	after:   onAfter
    	    }); 
	function onBefore() { 
	//var imgTitle = $(this).find('img').attr("title");
	//var imgAlt = $(this).find('img').attr("alt");
	$('#vlak').animate({opacity: "hide"}, "slow");   } 
	
	function onAfter() { 
	var imgTitle = $(this).find('img').attr("title");
	var imgAlt = $(this).find('img').attr("alt");
	var imgLink = $(this).find('img').attr("rel");
	var leesMeer = $("#leesmeer_id").text();
    $('#vlak').animate({opacity: "show"}, "slow").html('<h4>' + imgTitle + '</h4>').append('<span class="description"><span class="line"></span>' + imgAlt + '</span>').append('<a class="BBmorelink" href="' + imgLink + '">' + leesMeer+ '<span>&rsaquo;</span></a>');}      



/*label to input*/
$("#field1127").inputLabel(); /*nieuwsbrief*/
$("#input_2_1").inputLabel();
$("#input_2_2").inputLabel();
$("#input_2_3").inputLabel();

$("#input_6_1").inputLabel();
$("#input_6_2").inputLabel();
$("#input_6_3").inputLabel();

$("#input_10_1").inputLabel();
$("#input_10_2").inputLabel();
$("#input_10_3").inputLabel();

$("#input_11_1").inputLabel();
$("#input_11_2").inputLabel();
$("#input_11_3").inputLabel();

$("#field1131").inputLabel();




// validate signup form on keyup and submit
	var validator = $("#gform_2").validate({
		rules: {
			input_1: {
				required: true,
				minlength: 2
					},
			input_2: {
				required: true,
				email: true
			},
			input_3: {
				required: true,
				minlength: 5
				}
		},

		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("alright");
		}
	});
	/*nieuwsbrief*/
var validator = $("#form1014").validate({
		rules: {
			field1127: {
				required: true,
				email: true
			}
		},
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			label.html("&nbsp;").addClass("alright");
		}
	});
/*$('.widget_sp_image').cornerz({radius: 10,
									background:"#ffff"
									});*/
$('#secondary .widget, .sticky_vacancy, .vacancyblok, div.aside_contact div.gform_wrapper, body.page-template-08-vacature-php div.page').cornerz({radius: 10,
									background:"#ffffff"
									});
$('.tabNavigation').cornerz({radius: 10,
									background:"#ffffff",
									corners: "tl tr"
									});
$('.tabFoot').cornerz({radius: 10,
									background:"#ffffff",
									corners: "bl br"
									});
/*$('div.aside_contact div.gform_wrapper').cornerz({radius: 10,
							   background:"#fdfdfd"
							});*/

    $('ul.sc_menu li:odd').addClass('odd');
    $('ul.sc_menu li:even').addClass('even');
    
    $('div.textwidget a.dl_link:odd').addClass('odd');
    $('div.textwidget a.dl_link:even').addClass('even');
    
    
    $('#cat, #archive-dropdown, #portfolio-filter, #input_3_9').sSelect();
    //$('#cat, #archive-dropdown, #portfolio-filter, #input_3_9, #field1137').sSelect();


	//Cufon.replace('body.home h1, h1.cufon, h1 span#category-title,h2.vacancytitle, h3,h4', { fontFamily: 'Formata-Regular' });
	Cufon.replace('div.writing p, div.polaroidL div.writing', { fontFamily: 'Bradley Hand ITC TT' });


	

	$(".linkje").hover(function(){
		      $("img",this).css({'top':'-170px'} );
		    }, function() {
		      $("img",this).css({'top':'0px'} );
		});

/*disable input fields in tell a friend form */
//$('#input_4_13').attr('disabled', true); //titel van vacature
//$('#input_4_14').attr('disabled', true); //url van vacature

 
 /*mijn collegas*/
$(function(){
  //Get our elements for faster access and set overlay width
  var div = $('div.sc_menu'),
               ul = $('ul.sc_menu'),
               // unordered list's left margin
               ulPadding = 15;

  //Get menu width
  var divWidth = div.width();

  //Remove scrollbars
  div.css({overflow: 'hidden'});

  //Find last image container
  var lastLi = ul.find('li:last-child');

  //When user move mouse over menu
  div.mousemove(function(e){

    //As images are loaded ul width increases,
    //so we recalculate it each time
    var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;

    var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
    div.scrollLeft(left);
  });
});



var myFilterable = $('#portfolio-list').filterable();
	var mySelect = $('#portfolio-filter');
mySelect.change(function() {
    var index = mySelect[0].selectedIndex;
    var element = mySelect[0].options[index];
    var tag = $(element).attr('value');
    myFilterable.trigger('filter', [ tag ] );
});




    $( ".accordion" ).accordion({ 	header: 'h4',
    								//autoHeight: false,
									collapsible:true,
									active: 1
									//event: "click hoverintent"
									
 });


	$("#tabs_contact").tabs();
	
	$.fn.equalHeight = function(){
   $h2 = $(this).height('auto');
   var maxht = 0;
   for (i=0; i<$h2.length; i++){
      var ht = $h2.eq(i).outerHeight();
      var pad = ht - $h2.eq(i).height();
      $h2.eq(i).data('pad', pad);
      if (maxht < ht){
         maxht = ht;
      }
   }

   for (i=0; i<$h2.length; i++){
      pad = $h2.eq(i).data('pad');
      $h2.eq(i).height(maxht-pad);
   }
   return $(this);
}

//$('body.pageid-118 div.equal').equalHeight();/*boven*/
//$('body.pageid-4541	 div.equal').equalHeight();/*boven*/
 
});	
