/*

  This copy of pngFix has been modified by Nathan Manousos to work with jQuery 1.3.1
  I subsituted img[@src$=.png] with img[src$=.png] in two places.

*/


/**
 * --------------------------------------------------------------------
 * jQuery-Plugin "pngFix"
 * Version: 1.1, 11.09.2007
 * by Andreas Eberhard, andreas.eberhard@gmail.com
 *                      http://jquery.andreaseberhard.de/
 *
 * Copyright (c) 2007 Andreas Eberhard
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 *
 * Changelog:
 *    11.09.2007 Version 1.1
 *    - removed noConflict
 *    - added png-support for input type=image
 *    - 01.08.2007 CSS background-image support extension added by Scott Jehl, scott@filamentgroup.com, http://www.filamentgroup.com
 *    31.05.2007 initial Version 1.0
 * --------------------------------------------------------------------
 * @example $(function(){$(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready
 *
 * jQuery(function(){jQuery(document).pngFix();});
 * @desc Fixes all PNG's in the document on document.ready when using noConflict
 *
 * @example $(function(){$('div.examples').pngFix();});
 * @desc Fixes all PNG's within div with class examples
 *
 * @example $(function(){$('div.examples').pngFix( { blankgif:'ext.gif' } );});
 * @desc Fixes all PNG's within div with class examples, provides blank gif for input with png
 * --------------------------------------------------------------------
 */

(function($) {

jQuery.fn.pngFix = function(settings) {

	// Settings
	settings = jQuery.extend({
		blankgif: 'blank.gif'
	}, settings);

	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);

	if (jQuery.browser.msie && (ie55 || ie6)) {

		//fix images with png-source
		jQuery(this).find("img[src$=.png]").each(function() {

			jQuery(this).attr('width',jQuery(this).width());
			jQuery(this).attr('height',jQuery(this).height());

			var prevStyle = '';
			var strNewHTML = '';
			var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : '';
			var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : '';
			var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : '';
			var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : '';
			var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : '';
			var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : '';
			if (this.style.border) {
				prevStyle += 'border:'+this.style.border+';';
				this.style.border = '';
			}
			if (this.style.padding) {
				prevStyle += 'padding:'+this.style.padding+';';
				this.style.padding = '';
			}
			if (this.style.margin) {
				prevStyle += 'margin:'+this.style.margin+';';
				this.style.margin = '';
			}
			var imgStyle = (this.style.cssText);

			strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt;
			strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand;
			strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;';
			strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');';
			strNewHTML += imgStyle+'"></span>';
			if (prevStyle != ''){
				strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>';
			}

			jQuery(this).hide();
			jQuery(this).after(strNewHTML);

		});

		// fix css background pngs
		jQuery(this).find("*").each(function(){
			var bgIMG = jQuery(this).css('background-image');
			if(bgIMG.indexOf(".png")!=-1){
				var iebg = bgIMG.split('url("')[1].split('")')[0];
				jQuery(this).css('background-image', 'none');
				jQuery(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + iebg + "',sizingMethod='scale')";
			}
		});
		
		//fix input with png-source
		jQuery(this).find("input[src$=.png]").each(function() {
			var bgIMG = jQuery(this).attr('src');
			jQuery(this).get(0).runtimeStyle.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + bgIMG + '\', sizingMethod=\'scale\');';
   		jQuery(this).attr('src', settings.blankgif)
		});
	
	}
	
	return jQuery;

};

})(jQuery);


/* http://nixboxdesigns.com/projects/jquery-lavalamp/
 * Copyright (c) 2008, 2009, 2010 Jolyon Terwilliger, jolyon@nixbox.com
 * credits to Guillermo Rauch and Ganeshji Marwaha (gmarwaha.com) for previous editions */
//console.log();
(function(jQuery) {
jQuery.fn.lavaLamp = function(o) {
	o = jQuery.extend({
				target: 'li', 
				fx: 'swing',
				speed: 200, 
				click: function(){return true}, 
				startItem: '',
				autoReturn: true,
				returnDelay: 0,
				setOnClick: true,
				homeTop:0,
				homeLeft:0,
				homeWidth:0,
				homeHeight:0,
				returnHome:false,
				autoResize:false
				}, 
			o || {});
	
	// parseInt for easy mathing
	function getInt(arg) {
		var myint = parseInt(arg);
		return (isNaN(myint)? 0: myint);
	}

	if (o.autoResize)
		jQuery(window).resize(function(){
			jQuery(o.target+'.selected').trigger('mouseenter');
		});

	return this.each(function() {
		// ensures parent UL or OL element has some positioning
		if (jQuery(this).css('position')=='static')
			jQuery(this).css('position','relative');

		// create homeLava element if origin dimensions set
		if (o.homeTop || o.homeLeft) { 
			var $home = jQuery('<'+o.target+' class="homeLava"></'+o.target+'>').css({ left:o.homeLeft, top:o.homeTop, width:o.homeWidth, height:o.homeHeight, position:'absolute' });
			jQuery(this).prepend($home);
		}

		var path = location.pathname + location.search + location.hash, $selected, $back, $lt = jQuery(o.target+'[class!=noLava]', this), delayTimer, bx=0, by=0;

		// start $selected default with CSS class 'selected'
		$selected = jQuery(o.target+'.selected', this);
		
		// override $selected if startItem is set
		if (o.startItem != '')
			$selected = $lt.eq(o.startItem);

		// default to $home element
		if ((o.homeTop || o.homeLeft) && $selected.length<1)
			$selected = $home;

		// loop through all the target element a href tags and
		// the longest href to match the location path is deemed the most 
		// accurate and selected as default
		if ($selected.length<1) {
			var pathmatch_len=0, $pathel;
	
			$lt.each(function(){ 
				var thishref = $('a:first',this).attr('href');
				//console.log(thishref+' size:'+thishref.length);
				if (path.indexOf(thishref)>-1 && thishref.length > pathmatch_len )
				{
					$pathel = $(this);
					pathmatch_len = thishref.length;
				}
	
			});
			if (pathmatch_len>0) {
				//console.log('found match:'+$('a:first',$pathel).attr('href'));
				$selected = $pathel;
			}
			//else 
				//console.log('no match!');
		}
	
		// if still no matches, default to the first element
		if ( $selected.length<1 )
			$selected = $lt.eq(0);

		// make sure we only have one element as $selected and apply selected class
		$selected = jQuery($selected.eq(0).addClass('selected'));
			
		// add mouseover event for every sub element
		$lt.bind('mouseenter', function() {
			//console.log('mouseenter');
			// help follower behave if returnDelay is set
			if(delayTimer) {clearTimeout(delayTimer);delayTimer=null;}
			move(jQuery(this));
		}).click(function(e) {
			if (o.setOnClick) {
				$selected.removeClass('selected');
				$selected = jQuery(this).addClass('selected');
			}
			return o.click.apply(this, [e, this]);
		});
		
		// creates and adds to the container a follower element with absolute positioning
		$back = jQuery('<li class="follower"><div class="left-f"></div><div class="bottom-f"></div><div class="corner-f"></div></li>').css('position','absolute').prependTo(this);

		// setting css height and width actually sets the innerHeight and innerWidth, so
		// compute border and padding differences on styled follower element to fit them in also.
		bx = getInt($back.css('borderLeftWidth'))+getInt($back.css('borderRightWidth'))+getInt($back.css('paddingLeft'))+getInt($back.css('paddingRight'));
		by = getInt($back.css('borderTopWidth'))+getInt($back.css('borderBottomWidth'))+getInt($back.css('paddingTop'))+getInt($back.css('paddingBottom'));

		// set the starting position for the lavalamp hover element: .back
		if (o.homeTop || o.homeLeft)
			$back.css({ left:o.homeLeft, top:o.homeTop, width:o.homeWidth, height:o.homeHeight });
		else
		{
			$back.css({ left: $selected.position().left, top: $selected.position().top, width: $selected.outerWidth()-bx, height: $selected.outerHeight()-by }); 
		}

		// after we leave the container element, move back to default/last clicked element
		jQuery(this).bind('mouseleave', function() {
			//console.log('mouseleave');
			var $returnEl = null;
			if (o.returnHome)
				$returnEl = $home;
			else if (!o.autoReturn)
				return true;
		
			if (o.returnDelay) {
				if(delayTimer) clearTimeout(delayTimer);
				delayTimer = setTimeout(function(){move($returnEl);},o.returnDelay);
			}
			else {
				move($returnEl);
			}
			return true;
		});

		function move($el) {
			if (!$el) $el = $selected;

			$back.stop()
			.animate({
				left: $el.position().left,
				top: $el.position().top,
				width: $el.outerWidth()-bx,
				height: $el.outerHeight()-by
			}, o.speed, o.fx);
		};
	});
	
};
})(jQuery);


// Make sure html element gets class "js"
document.documentElement.className = "js";

// hack to fix loader in IE6
$(document).ready(function() {
 $('.loader').css('filter', 'alpha(opacity=50)');
});
		 
// hover animations home              
		$(document).ready(function() {
			$('#grid-recentwork, #grid-updates').hover(function(){
				$(".link-more", this).stop().animate({opacity:'1'},50,'easeOutQuad');
			}, function() { //mouse out
				$(".link-more", this).stop().animate({opacity:'0'},300,'easeOutQuad');
			});

			$('.wn-content li a, .m-content ul li a').hover(function(){
				$("img", this).stop().animate({opacity:'0.8'},50,'easeOutQuad');
			}, function() { //mouse out
				$("img", this).stop().animate({opacity:'1'},300,'easeOutQuad');
			});

// hover animations portfolio
			$('.pt-item').hover(function(){
				$(".pt-hover", this).stop().animate({opacity:'0.85'},150,'easeOutQuad');
			}, function() { //mouse out
				$(".pt-hover", this).stop().animate({opacity:'0'},500,'easeOutQuad');
			});

// specific hovers for nav
			$('#new-navigation li').hover(function(){
				$(this).stop().animate({opacity:'1'},100,'easeOutQuad');
			}, function() { //mouse out
				$(this).stop().animate({opacity:'0.7'},500,'easeOutQuad');
			});
			$('#right-nav .nav-followus a, #right-nav .nav-clientlogin a').hover(function(){
				$(this).stop().animate({opacity:'1'},100,'easeOutQuad');
			}, function() { //mouse out
				$(this).stop().animate({opacity:'0.7'},500,'easeOutQuad');
			});
// footer icons

			$('.c-icon-facebook, .c-icon-twitter, .c-icon-flickr').hover(function(){
				$('span', this).stop().animate({opacity:'1'},100,'easeOutQuad');
			}, function() { //mouse out
				$('span', this).stop().animate({opacity:'0'},500,'easeOutQuad');
			});

// tabs

			$('#rw-tabs a').hover(function(){
				$('span', this).stop().animate({opacity:'1'},100,'easeOutQuad');
			}, function() { //mouse out
				$('span', this).stop().animate({opacity:'0'},500,'easeOutQuad');
			});

// fx for searchfield
			$('.search-field').hover(function(){
				$(this).stop().animate({opacity:'1'},100);
			}, function() { //mouse out
				$(this).stop().animate({opacity:'0.5'},500);
			});
			$('.search-field form fieldset input').focus(function(){
				$('.search-field').addClass('demandOpacity');
			});
			$('.search-field form fieldset input').blur(function(){
				$('.search-field').css({opacity:1}).removeClass('demandOpacity').delay(100).animate({opacity:'0.5'},500);
			});

// misc hovers
			$('.footer-links ul').hover(function(){
				$('.footer-links ul').stop().animate({opacity:'0.3'},300);
				$(this).stop().animate({opacity:'1'},300);
			}, function() { //mouse out
				$('.footer-links ul').stop().animate({opacity:'1'},300);
				$(this).stop().animate({opacity:'1'},500);
			});

// social hovers, combine later
			$('#social-panel a.bigb-facebook').hover(function(){
				$(this).stop().animate({opacity:'1'},50);
				$('.link-fb').stop().animate({opacity:'1'},50);
			}, function() { //mouse out
				$(this).stop().animate({opacity:'0.5'},300);
				$('.link-fb').stop().animate({opacity:'0.5'},300);
			});
			$('#social-panel a.bigb-twitter').hover(function(){
				$(this).stop().animate({opacity:'1'},50);
				$('.link-tw').stop().animate({opacity:'1'},50);
			}, function() { //mouse out
				$(this).stop().animate({opacity:'0.5'},300);
				$('.link-tw').stop().animate({opacity:'0.5'},300);
			});
			$('#social-panel a.bigb-flickr').hover(function(){
				$(this).stop().animate({opacity:'1'},50);
				$('.link-fl').stop().animate({opacity:'1'},50);
			}, function() { //mouse out
				$(this).stop().animate({opacity:'0.5'},300);
				$('.link-fl').stop().animate({opacity:'0.5'},300);
			});
			$('#social-panel a.bigb-lastfm').hover(function(){
				$(this).stop().animate({opacity:'1'},50);
				$('.link-lf').stop().animate({opacity:'1'},50);
			}, function() { //mouse out
				$(this).stop().animate({opacity:'0.5'},300);
				$('.link-lf').stop().animate({opacity:'0.5'},300);
			});
			$('#social-panel a.bigb-linkedin').hover(function(){
				$(this).stop().animate({opacity:'1'},50);
				$('.link-li').stop().animate({opacity:'1'},50);
			}, function() { //mouse out
				$(this).stop().animate({opacity:'0.5'},300);
				$('.link-li').stop().animate({opacity:'0.5'},300);
			});	

                $('.praises-ul li').hover(function(){
                        $(this).stop().animate({backgroundColor:'#d4d4d4'},150,'easeOutQuad');
                        }, function(){
                        $(this).stop().animate({backgroundColor:'#eaeaea'},200,'easeOutQuad');
                    });

                $('.spc-a').hover(function(){
                        $(this).stop().animate({backgroundColor:'#000',color:'#fff'},150,'easeOutQuad');
                        }, function(){
                        $(this).stop().animate({backgroundColor:'#e3e5e9',color:'#000'},200,'easeOutQuad');
                    });

		
		});


// Browser specific code. Or in other words, IE6/IE7/IE8-specific fuck you code. 

$(document).ready(function() {

jQuery.each(jQuery.browser, function(i) {
if ( $.browser.msie ) {
$('#r_slideshow #r_slideshow_violator').css('filter', 'alpha(opacity=0)');
$('#mid-home-slider, .home #next2, .home #prev2').hover(function(){
				$('#r_slideshow #r_slideshow_violator').stop().animate({opacity:'1',bottom:'11px'},300, function() {
$(this).css('filter', ' ');
});
			}, function() { //mouse out
				$('#r_slideshow #r_slideshow_violator').stop().animate({opacity:'0',bottom:'2px'},500);
			});
}else{
$('body').addClass('noie');
			$('#slide-next, #slide-prev').hover(function(){
				$(this).stop().animate({opacity:'1'},300);
			}, function() { //mouse out
				$(this).stop().animate({opacity:'0.1'},500);
			});
$('#mid-home-slider, .home #next2, .home #prev2').hover(function(){
				$('#r_slideshow #r_slideshow_violator').stop().animate({opacity:'1',bottom:'11px'},300);
			}, function() { //mouse out
				$('#r_slideshow #r_slideshow_violator').stop().animate({opacity:'0',bottom:'2px'},500);
			});
  }
 });


// Fade in the page
$(".noie .oc-inner").delay(150).animate({opacity:'1'},500);

// Make it destroyable
    $("div.loader").click(function () {
      $(this).fadeOut();
    });

// Create loader (only on normal click, disable the fx on ctrl-click
$("#logo a, .our-work .control-prev a, .our-work .control-next a,#new-navigation a,.nav-clientlogin a,#rw-tabs a,#work-content a,#footer a,.m-content a,#home-grey-updates a").click(function(e) {
  if(e.ctrlKey) {
    console.log("Ctrl+Click");
    // your code goes here...
  } else {
      $("div.loader").fadeIn().delay(4000).fadeOut();
  }
}); 



// Expand Panel
	$("#open").click(function(){
		$("div#social-panel").animate({marginTop: "0px"}, 700,'easeInOutBack' );
		$("div#social-panel li, div.social-panel-txt").animate({ opacity: "1"}, 500 );	
	});	
	
// Collapse Panel
	$("#close").click(function(){
		$("div#social-panel").animate({ marginTop: "-96px"}, 1000, 'easeInOutBack' );	
		$("div#social-panel li, div.social-panel-txt").animate({ opacity: "0"}, 700 );	
	});		
	
// Switch buttons
	$(".nav-followus a").click(function () {
		$(".nav-followus a").toggle();
	});

		
// search submit function

$("#search-input").attr('autocomplete', 'off');

$("#search-input").keyup(function() {

	var name = $(":input#search-input:text").val();

  $.ajax({
     type: "GET",
     url: "/assets/inc/ajax-search.php",
     data: "we_lv_search_zoeken=" + name + "&we_from_search_zoeken=1&submit=search",
     success: function(msg){
      // alert( "Data Saved: " + msg );
       $('#success').html(msg); 
     }
   });
 });



  });
	







/**
 * Plugin: jquery.zWeatherFeed
 * (c) Copyright 2010, Zazar Ltd
 * 
 *
 **/

(function($){

	var row = 'odd';

	$.fn.weatherfeed = function(locations, options) {	
	
		// Set pluign defaults
		var defaults = {
			unit: 'c',
			image: true,
			highlow: true,
			wind: true,
			showerror: true
		};  
		var options = $.extend(defaults, options); 
		
		// Functions
		return this.each(function(i, e) {
			var $e = $(e);
			
			// Add feed class to user div
			if (!$e.hasClass('weatherFeed')) $e.addClass('weatherFeed');

			// Check and append locations
			if (!$.isArray(locations)) return false;
			var count = locations.length;
			if (count > 10) count = 10;
			var locationid = '';
			for (var i=0; i<count; i++) {
				if (locationid != '') locationid += ',';
				locationid += "'"+ locations[i] + "'";
			}

			// Cache results for an hour to prevent overuse
			now = new Date()
					
			// Create Yahoo Weather feed API address
			var query = "select * from weather.forecast where location in ("+ locationid +") and u='"+ options.unit +"'";
			var api = 'http://query.yahooapis.com/v1/public/yql?q='+ encodeURIComponent(query) +'&rnd='+ now.getFullYear() + now.getMonth() + now.getDay() + now.getHours() +'&format=json&callback=?';

			// Send request
			//$.getJSON(api, function(data) {
			$.ajax({
				type: 'GET',
				url: api,
				dataType: 'json',
				success: function(data) {

					if (data.query) {
			
						if (data.query.results.channel.length > 0 ) {
							
							// Multiple locations
							var result = data.query.results.channel.length;
							for (var i=0; i<result; i++) {
							
								// Create weather feed item
								_callback(e, data.query.results.channel[i], options);
							}
						} else {

							// Single location only
							_callback(e, data.query.results.channel, options);
						}
					} else {
						if (options.showerror) $e.html('<p>Weather information unavailable</p>');
					}
				},
				error: function(data) {
					if (options.showerror)  $e.html('<p>Weather request failed</p>');
				}
			});

		});
	};

	// Function to each feed item
	var _callback = function(e, feed, options) {
		var $e = $(e);

		// Format feed items
		var wd = feed.wind.direction;
		if (wd>=348.75&&wd<=360){wd="N"};if(wd>=0&&wd<11.25){wd="N"};if(wd>=11.25&&wd<33.75){wd="NNE"};if(wd>=33.75&&wd<56.25){wd="NE"};if(wd>=56.25&&wd<78.75){wd="ENE"};if(wd>=78.75&&wd<101.25){wd="E"};if(wd>=101.25&&wd<123.75){wd="ESE"};if(wd>=123.75&&wd<146.25){wd="SE"};if(wd>=146.25&&wd<168.75){wd="SSE"};if(wd>=168.75&&wd<191.25){wd="S"};if(wd>=191.25 && wd<213.75){wd="SSW"};if(wd>=213.75&&wd<236.25){wd="SW"};if(wd>=236.25&&wd<258.75){wd="WSW"};if(wd>=258.75 && wd<281.25){wd="W"};if(wd>=281.25&&wd<303.75){wd="WNW"};if(wd>=303.75&&wd<326.25){wd="NW"};if(wd>=326.25&&wd<348.75){wd="NNW"};
		var wf = feed.item.forecast[0];
		
		// Determine day or night image
		wpd = feed.item.pubDate;
		n = wpd.indexOf(":");
		tpb = _getTimeAsDate(wpd.substr(n-2,8));
		tsr = _getTimeAsDate(feed.astronomy.sunrise);
		tss = _getTimeAsDate(feed.astronomy.sunset);

		if (tpb>tsr && tpb<tss) { daynight = 'd'; } else { daynight = 'n'; }

		// Add item container
		var html = '<div class="weatherItem '+ row +'"';
		if (options.image) html += ' style="background-image: url(/assets/interface/weather/'+ feed.item.condition.code + daynight +'.gif); background-repeat: no-repeat;"';
		html += '>';
		
		// Add item data
		//html += '<span class="weatherCity">'+ feed.location.city +'</span>';
		html += '<span class="weatherCity">Wijk Aan Zee</span>';
		html += '<span class="weatherTemp">'+ feed.item.condition.temp +'&deg;</span>';
		html += '<span class="weatherDesc">'+ feed.item.condition.text +'</span>  ';
		if (options.highlow) html += '<span class="weatherRange">'+ wf.high +'&deg; | '+ wf.low +'&deg;</span>';
		if (options.wind) html += '<span class="weatherWind">Wind: '+ wd +' '+ feed.wind.speed + feed.units.speed +'</span>';
		if (options.link) html += '<span class="weatherLink"><a href="'+ feed.item.link +'">Read full forecast</a></span>';
		
		html += '</div>';

		// Alternate row classes
		if (row == 'odd') { row = 'even'; } else { row = 'odd';	}
		
		$e.append(html);
	};

	// Get time string as date
	var _getTimeAsDate = function(t) {
		
		d = new Date();
		r = new Date(d.toDateString() +' '+ t);

		return r;
	};
})(jQuery);



	
// Init code
	
// jquery initialize:
        	$(function() {
                    $('ul#nav').lavaLamp();
        	});
//console.log();

            $(document).ready(function(){ 
                $(document).pngFix(); 
            }); 

            $(window).load(function()
            {
                $('.control-prev, .control-next').fadeIn();
            })
