/**
 * Javascript - jQuery enabled
 * 
 * @package WPFramework
 * @subpackage Media
 */

jQuery.noConflict();

jQuery(document).ready(function(){


// -------------------------------------------------------------------------------------------
// START EDITING HERE
// -------------------------------------------------------------------------------------------

		
	/* Font Replacement */
		Cufon.replace('.hentry h1');
		Cufon.replace('h1', { hover: true });
		Cufon.replace('h2', { hover: true });
		Cufon.replace('h3');
		Cufon.replace('h4');
		Cufon.replace('h5');
		Cufon.replace('h6');
		Cufon.replace('.menu .nav li a', { hover: true });
		Cufon.replace('.meta');
		Cufon.now();
		
	
	// locations image
	jQuery('img.locations').animate({
 		 opacity: '1'
		}, 3000, 'linear');

	
	// activates the lightbox page
	my_lightbox("a[rel^='prettyPhoto'], a[rel^='lightbox']",true);
	

// -------------------------------------------------------------------------------------------
// END EDITING HERE
// -------------------------------------------------------------------------------------------		
});

	jQuery('.nav').supersubs({
		minWidth: 		9,						// requires em unit.
		maxWidth: 		25,						// requires em unit.
		extraWidth: 	0						// 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:		1,						// 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Õs .animate() method 
		speed:			'normal',				// speed of the animation. Equivalent to second parameter of jQueryÕs .animate() method 
		autoArrows:		false,					// if true, arrow mark-up generated automatically = cleaner source code at expense of initialisation performance 
		disableHI:		false					// set to true to disable hoverIntent detection 
	});
	

	/* PrettyPhoto */
	jQuery("a[rel^='lightbox']").prettyPhoto({
		theme: 'light_square' /* light_rounded / dark_rounded / light_square / dark_square */		
	});

	/* Validate form */
	jQuery("#contactform").validate();


	jQuery.extend(jQuery.validator.messages, {
	    required: "Vul dit veld in, a.u.b.",
	    email: "Vul een correct email adres in, a.u.b.",
	});
	


function my_lightbox($elements, autolink)
{	
	var theme_selected = 'light_square';
	
	if(autolink)
	{
		jQuery('a[href$=jpg], a[href$=png], a[href$=gif], a[href$=jpeg], a[href$=.mov] , a[href$=.swf] , a[href*=vimeo.com] , a[href*=youtube.com]').each(function()
		{
			if(!jQuery(this).attr('rel') != undefined && !jQuery(this).attr('rel') != '' && !jQuery(this).hasClass('noLightbox'))
			{
				jQuery(this).attr('rel','lightbox[auto_group]')
			}
		});
	}
	
	jQuery($elements).prettyPhoto({
			"theme": theme_selected /* light_rounded / dark_rounded / light_square / dark_square */																	});
	
	jQuery($elements).each(function()
	{	
		var $image = jQuery(this).contents("img");
		$newclass = 'lightbox_video';
		
		if(jQuery(this).attr('href').match(/(jpg|gif|jpeg|png|tif)/)) $newclass = 'lightbox_image';
			
		if ($image.length > 0)
		{	
			if(jQuery.browser.msie &&  jQuery.browser.version < 7) jQuery(this).addClass('ie6_lightbox');
			
			var $bg = jQuery("<span class='"+$newclass+" '></span>").appendTo(jQuery(this));
			
			jQuery(this).bind('mouseenter', function()
			{
				if ($image.css('opacity') >= 0.1) { jQuery(this).removeClass('preloading'); }
				
				var $height = $image.height(),
					$width = $image.width(),
					$pos =  $image.position(),
					$paddingX = parseInt($image.css('paddingTop')) + parseInt($image.css('paddingBottom')),
					$paddingY = parseInt($image.css('paddingLeft')) + parseInt($image.css('paddingRight'));					
				
				$bg.css({height:$height + $paddingY, width:$width + $paddingX, top:$pos.top, left:$pos.left});
			});
		}
	});	
	
	jQuery($elements).contents("img").hover(function()
	{
		jQuery(this).stop().animate({opacity:0.2},400);
	},
	function()
	{
		jQuery(this).stop().animate({opacity:1},400);
	});
}


jQuery(document).ready(function($) {



	/* Search Watermark */
	var watermark = "Site Search...";
	if ($("#sub-header-search .search").val() == "") {
		$("#sub-header-search .search").val(watermark);
	}
	
	$("#sub-header-search .search")
		.focus(	function() {
			if (this.value == watermark) {
				this.value = "";
			}
		})
		.blur(function() {
			if (this.value == "") {
				this.value = watermark;
			}
		});
		

});
