// GENERAL BEHAVIOUR //

$(function() {		
	
	$.each($('.wp-caption img'), function() {
		$(this).one("load",function(){
			var imgWidth = $(this) .width();
			$(this) .parent() .css('width', imgWidth);
		})
		.each(function(){
		if(this.complete) $(this).trigger("load");
		});
	});
	
	$.each($('a.load-img img'), function() {
		$(this) .after('<span class="img-load-wrap"></span>');
	});
	
	$('a.load-img img').one("load",function(){
		$(this) .parent() .find('span.img-load-wrap') .css('display', 'none');
		$(this) .hide() .fadeIn();
	})
	.each(function(){
	if(this.complete) $(this).trigger("load");
	});
	
	$.each($('a.zoom-img img'), function() {
		$(this) .after('<span class="zoom-wrap"></span>');
		$(this) .parent() .find('span.zoom-wrap') .css('display', 'none');
	});
	
	$.each($('a.play-img img'), function() {
		$(this) .after('<span class="play-wrap"></span>');
		$(this) .parent() .find('span.play-wrap') .css('display', 'none');
	});
	
	$.each($('a.read-img img'), function() {
		$(this) .after('<span class="read-wrap"></span>');
		$(this) .parent() .find('span.read-wrap') .css('display', 'none');
	});
	
	$.each($('.pull-right, .pull-left'), function() {
		$(this) .next('p') .replaceWith('<span class="wrap-around">' + $(this).next('p').text() + '</span>');
	});
	
	$('.featured-item:last, div.latest-news-item:last') .css({'border' : 'none', 'marginBottom' : '0px'});
	$.each($('.popular-posts-list, .recent-tweets, .widget-list, .sidebar-widget ul, #sidebar-menu, #sidebar-menu li ul, #sidebar-menu li ul li ul, ul.menu, ul.menu li ul, #big-footer #recentcomments, #big-footer .widget_recent_entries ul, #big-footer .widget_recent_entries ul, #big-footer .widget_alt_style .widget_archive ul, #big-footer .widget_alt_style .widget_categories ul, #big-footer .widget_alt_style .widget_links ul, #big-footer .widget_alt_style .widget_meta ul, #big-footer .widget_alt_style .widget_pages ul'), function() {
		$(this) .find('li:last') .css({'border' : 'none', 'marginBottom' : '0px'});
	});
	
});


// MBIZ SLIDER //

(function($){
$.fn.mbizslider = function(options) {
	var defaults = {
		autoRotate: true,
		interval: 1000
	  },
	  settings = $.extend({}, defaults, options);
	
	slidesCount = $('#mbiz-slides .mbiz-slide-bg') .length;
	i = 1;
	
	var mbizSlide = '#mbiz-slides .mbiz-slide-bg';
	
	$(mbizSlide + ':first') .addClass('first');
	$(mbizSlide + ':last') .addClass('last');
	$('#mbiz-slides .mbiz-slide-img') .hide();
	$(mbizSlide + ':not(:first)') .css('display', 'none');
	$('#mbiz-slides .mbiz-slide-info') .css('top', '-370px');
	
	while (i <= slidesCount) {
        $('#mbiz-slider-nav') .append('<span class="mbiz-slider-butt"><img src="wp-content/themes/thedawn/images/mbiz-slider-butt.png" alt="button" /></span>');
		i++;
	}
	
	$(mbizSlide + ':first img.mbiz-slide-bg-img') .one("load",function(){
		if ($(mbizSlide + ':first .mbiz-slide-img img') .length != 0) {
			$(mbizSlide + ':first .mbiz-slide-img img') .one("load",function(){
				showSlides();
			}) .each(function(){
				if(this.complete) $(this).trigger("load");
			});
		} else {
			showSlides();;
		}
		
		function showSlides() {
			$.each($(mbizSlide), function() {
				var mbizSlideBG = $(this) .find('img.mbiz-slide-bg-img') .attr('src');
				$(this) .css("background-image", "url("+mbizSlideBG+")");
			});
			$(mbizSlide + ':first .mbiz-slide-info') .animate({'top' : '10px'}, 600);
			$(mbizSlide + ':first .mbiz-slide-img') .fadeIn(); //.animate({'top' : '0px'}, 600);
			$('.slide-img-has-border .slide-img-border') .css('border', '7px solid #000');
			
			$('#mbiz-slider-nav span:first') .css('backgroundPosition', 'center bottom');
			
			$('#mbiz-slides') .css('backgroundImage', 'none');
			
			// Auto Rotator //
			if(settings.autoRotate) { autoRotate = 1; } else { autoRotate = 0; }
			var $autoR;
			var rotatorInterval = setInterval(function() {
				if (autoRotate) {
					$autoR = $(mbizSlide + ':visible');
					$currNavIndex = $autoR .index();
					$currNav = $('#mbiz-slider-nav span:eq('+$currNavIndex+')');
					
					if ($autoR .hasClass('last')) {
						$autoR = $(mbizSlide + ':first');
						$currNav .css('backgroundPosition', 'center top');
						$currNav = $('#mbiz-slider-nav span:first');
					} else {
						$autoR = $autoR.next();
						$currNav .css('backgroundPosition', 'center top');
						$currNav = $currNav.next();
					}
							
					$(mbizSlide + ':visible .mbiz-slide-info') .animate({'top' : '-370px'}, 100);
					$(mbizSlide + ':visible .mbiz-slide-img') .hide();
					$(mbizSlide + ':visible') .hide();
					
					$autoR .fadeIn();
					$autoR .find('.mbiz-slide-info') .animate({'top' : '10px'}, 300);
					$autoR .find('.mbiz-slide-img') .fadeIn();
					
					$currNav .css('backgroundPosition', 'center bottom');
				}
				
				if(settings.autoRotate) {
					$('#pre-body-area') .hover(function() {
						autoRotate = 0;
					}, function() { autoRotate = 1; });
				}
			
			}, settings.interval);
		} // end function showSlides
		// ------------ //
		
	}) .each(function(){
			if(this.complete) $(this).trigger("load");
		});
	
	$('#mbiz-slider-nav span') .click(function() {
		
		if(settings.autoRotate) {
			$('#pre-body-area') .hover(function() {
				autoRotate = 0;
			}, function() { autoRotate = 1; });
		}
		
		slideIndex = $(this) .index();
		$('#mbiz-slider-nav span') .css('backgroundPosition', 'center top');
		$(this) .css('backgroundPosition', 'center bottom');
		
		$(mbizSlide + ':visible .mbiz-slide-info') .animate({'top' : '-370px'}, 100);
		$(mbizSlide + ':visible .mbiz-slide-img') .hide();
		$(mbizSlide + ':visible') .hide();
			
		$(mbizSlide + ":eq("+slideIndex+")") .fadeIn();
			$(mbizSlide + ":eq("+slideIndex+") .mbiz-slide-info") .animate({'top' : '10px'}, 300);
			$(mbizSlide + ":eq("+slideIndex+") .mbiz-slide-img") .fadeIn();
	});
	
}
})(jQuery);


// Slider fixed image

$(function() {
	
	$('.fixed-slider-loader') .css('display', 'block');
	$('img.fixed-slide-bg-img').one("load",function() {
		$('.fixed-slider-loader') .fadeOut();
		$('img.fixed-slide-bg-img') .remove();
	})
	.each(function(){
	if(this.complete) $(this).trigger("load");
	});
	
});


// LOGIN FROM //

$(function() {
	
	$('#login-button') .click(function() {
		$('#login-box') .slideDown(100);
	});
	
	$('#close-login') .click(function() {
		$('#login-box') .slideUp(100);
	});

});


// LOGO DESCRIPTION //

$(function() {

	$('#logo') .mouseover(function() {
		$('#logo-desc') .stop() .animate({'opacity' : '1', 'marginLeft' : '5px'}, 100);
		$('#logo-desc') .css('display', 'block');
	});
	$('#logo') .mouseout(function() {
		$('#logo-desc') .stop() .animate({'opacity' : '0', 'marginLeft' : '0px'}, 300);
		$('#logo-desc') .css('display', 'none');
	});
});


// MAIN MENU //

$(function() {
	$('#main-menu li ul') .parent() .children('a') .addClass('has-submenu');
	
	$('#main-menu li').hoverIntent(function() {
		$(this) .children('ul') .stop(true, true) .slideDown(100);
	}, function() {
		$(this) .children('ul') .stop(true,true) .slideUp(80);
	});
	
	$('#main-menu li') .find('li.current-menu-item') .parents('li') .addClass('current-parent');
	
	$('#main-menu li ul li ul') .parent() .addClass('sub-has-sub');

});


// SIDEBAR MENU //

$(function() {

	$('#sidebar-menu li ul') .parent() .children('a') .addClass('has-submenu');
	$('#sidebar-menu li').hoverIntent(function() {
		$(this) .children('ul') .stop(true, true) .slideDown(100);
	}, function() {
		$(this) .children('ul') .stop(true,true) .slideUp(80);
	});
	
	$('#sidebar-menu li.current-menu-item') .children('a') .addClass('current-a');
	$('#sidebar-menu li.current-menu-item') .parents('li') .children('a') .addClass('current-parent');
	
	//-----------------//
	
	$('ul.menu li ul') .parent() .children('a') .addClass('has-submenu');
	$('ul.menu li').hoverIntent(function() {
		$(this) .children('ul') .stop(true, true) .slideDown(100);
	}, function() {
		$(this) .children('ul') .stop(true,true) .slideUp(80);
	});
	
	$('ul.menu li.current-menu-item') .children('a') .addClass('current-a');
	$('ul.menu li.current-menu-item') .parents('li') .children('a') .addClass('current-parent');

});


// SHARE THIS //

$(function() {

	$('.share-this-wrap') .mouseover(function() {
		$('#share-social-icons') .stop() .animate({'opacity' : '1', 'marginLeft' : '10px'}, 100);
		$('#share-social-icons') .css('visibility', 'visible');
	});
	$('.share-this-wrap') .mouseout(function() {
		$('#share-social-icons') .stop() .animate({'opacity' : '0', 'marginLeft' : '5px'}, 300);
		$('#share-social-icons') .css('visibility', 'hidden');
	});
});


// PORTFOLIOS //

$(function() {
	
	$('.portfolio-post-wrap .portfolio-post-info') .css('display', 'none');
	
	$('.scrollable') .css('overflow', 'hidden');
	$('#portfolio-nav') .css('display', 'block');
	var portfolioLength = $('.portfolio-page') .length;
	i = 1;
	$('span.portfolio-length').replaceWith("<span class=\"portfolio-length\">OF "+portfolioLength+"</span>");
	
	$('.next-portfolio') .click(function() {
		i++;
		$('.portfolio-count') .contents() .remove();
		$('.portfolio-count') .append(i);
	});
	
	$('.prev-portfolio') .click(function() {
		i--;
		$('.portfolio-count') .contents() .remove();
		$('.portfolio-count') .append(i);
	});
	
	$('.portfolio-post-2columns') .css({'minHeight' : 'none', 'maxHeight' : 'none'});
	$('.text-out-2col') .css({'minHeight' : 'none', 'maxHeight' : 'none'});
	
	$('.portfolio-post-3columns') .css({'minHeight' : 'none', 'maxHeight' : 'none'});
	$('.text-out-3col') .css({'minHeight' : 'none', 'maxHeight' : 'none'});
	
	var portfolio2Length = $('.portfolio-post-2columns') .length;
	i2 = 1;
	if (portfolio2Length > 1) {
		
		while (i2 < portfolio2Length) {
			$(".portfolio-post-2columns:eq("+i2+")") .after('<br class="clear" />');
			i2 = i2 + 2;
		};
		
	};
	
	var portfolio3Length = $('.portfolio-post-3columns') .length;
	i3 = 2;
	if (portfolio3Length > 2) {
		
		while (i3 < portfolio3Length) {
			$(".portfolio-post-3columns:eq("+i3+")") .after('<br class="clear" />');
			i3 = i3 + 3;
		};
		
	};

	$('.portfolio-post-2columns') .hover(function() {
		$(this) .find('div.portfolio-post-info') .show();
	}, function() {
		$('.portfolio-post-info') .stop(true, true) .fadeOut(200);
	});
	
	$('.portfolio-post-3columns') .hover(function() {
		$(this) .find('div.portfolio-post-info') .show();
	}, function() {
		$('.portfolio-post-info') .stop(true, true) .fadeOut(200);
	});
	
});


// TABS //

$(function() {
	
	$.each($('.tabs-style1 .tabs-navigation'), function() {
		$(this) .find('li:first') .addClass('current-tab');
	});
	
	$.each($('.tabs-style1 .tabs-content, .tabs-style1 .tabs-content-nostyle'), function() {
		$(this) .children('br') .remove();
		$(this) .children('div:not(:first)') .hide();
	});
	
	$('.tabs-style1 .tabs-nav li') .click(function() {
		
		var clickedTab = $(this) .find('a') .attr('title');
		
		$(this) .parent() .children('.tabs-nav li') .removeClass('current-tab');
		$(this) .addClass('current-tab');
		
		$(this) .parent() .parent() .parent() .find('.tabs-content, .tabs-content-nostyle') .children('div') .slideUp(50);
		$(this) .parent() .parent() .parent() .find('.tabs-content .'+clickedTab) .slideDown(100);
		$(this) .parent() .parent() .parent() .find('.tabs-content-nostyle .'+clickedTab) .slideDown(100);
		
		return false;
		
	});
	
});


// H5 TABS //

$(function() {
	
	$('.tabs-posts .fancy-header a:first') .addClass('current-title');
	
	$('.tabs-posts .tabs-content') .children('div:not(:first)') .hide();
	
	$('.tabs-posts .fancy-header a') .click(function() {
		
		var clickedTab = $(this) .attr('title');
		
		$(this) .parent() .children('a') .removeClass('current-title');
		$(this) .addClass('current-title');
		
		$(this) .parent() .parent() .parent() .find('.tabs-content') .children('div') .hide();
		$(this) .parent() .parent() .parent() .find('.tabs-content .'+clickedTab) .slideDown();
		
		return false;
		
	});
	
});


// Toggles //

$(function() {
	
	$('.faq-block') .children('p, br') .remove();
	$('.faq-answer, .toggle-content') .css('display', 'none');
	
	$.each($('.toggle-block'), function() {
		$(this) .children('br') .remove();
	});
	
	$('.faq-q, .toggle-t') .click(function() {
		$(this) .toggleClass('toggle-open');
		$(this) .next('.faq-answer, .toggle-content') .slideToggle(100);
	});
	
	$('.toggle-block .box-title-style-1, .toggle-block .box-title-style-2') .click(function() {
		$(this) .next('.toggle-block .box-text') .slideToggle(100);
	});
	
	$('.toggle-block .box-title-style-1, .toggle-block .box-title-style-2') .hover(function() {
		$(this) .prev('span.handle') .css('display', 'block');
	}, function() {
		$(this) .prev('span.handle') .css('display', 'none');
	});
	
});


// Zoom, paly, read, flickr icons //

$(function() {
	
	$('a.zoom-img') .hover(function() {
		$(this) .find('span.zoom-wrap') .css('display', 'block');
		$(this) .find('span.zoom-wrap') .hide() .slideDown(250);
	}, function() {
		$(this) .find('span.zoom-wrap') .slideUp(200);
	});
	$('a.play-img') .hover(function() {
		$(this) .find('span.play-wrap') .css('display', 'block');
		$(this) .find('span.play-wrap') .hide() .slideDown(250);
	}, function() {
		$(this) .find('span.play-wrap') .slideUp(200);
	});
	$('a.read-img') .hover(function() {
		$(this) .find('span.read-wrap') .css('display', 'block');
		$(this) .find('span.read-wrap') .hide() .slideDown(250);
	}, function() {
		$(this) .find('span.read-wrap') .slideUp(200);
	});
	
	$('.video-lightbox') .hover(function() {
		$(this) .find('span.play-lightbox-wrap') .css('opacity', '0.8');
	}, function() {
		$(this) .find('span.play-lightbox-wrap') .css('opacity', '0.6');
	});
	
});


// FOOTER //

$(function() {
	
	var footer1Length = $('.col-option1 .footer-column') .length;
	var footer2Length = $('.col-option2 .footer-column') .length;
	var footer3Length = $('.col-option3 .footer-column') .length;
	var footer4Length = $('.col-option4 .footer-column') .length;
	var footer5Length = $('.col-option5 .footer-column') .length;
	
	i1footer = 0;
	i2footer = 1;
	i3footer = 2;
	i4footer = 3;
	i5footer = 4;
	
	if (footer1Length > 1) {
		while (i1footer < footer1Length) {
			$(".col-option1 .footer-column:eq("+i1footer+")") .after('<br class="clear" />');
			i1footer = i1footer + 1;
		};
	};
	
	if (footer2Length > 2) {
		while (i2footer < footer2Length) {
			$(".col-option2 .footer-column:eq("+i2footer+")") .after('<br class="clear" />');
			i2footer = i2footer + 2;
		};
	};
	
	if (footer3Length > 3) {
		while (i3footer < footer3Length) {
			$(".col-option3 .footer-column:eq("+i3footer+")") .after('<br class="clear" />');
			i3footer = i3footer + 3;
		};
	};
	
	if (footer4Length > 4) {
		while (i4footer < footer4Length) {
			$(".col-option4 .footer-column:eq("+i4footer+")") .after('<br class="clear" />');
			i4footer = i4footer + 4;
		};
	};
	
	if (footer5Length > 5) {
		while (i5footer < footer5Length) {
			$(".col-option5 .footer-column:eq("+i5footer+")") .after('<br class="clear" />');
			i5footer = i5footer + 5;
		};
	};
	
	$('.col-option5-4 .footer-column:eq(3)') .css('width', '354');
	$('.col-option54- .footer-column:eq(0)') .css('width', '354');
	$('.col-option4-3 .footer-column:eq(2)') .css('width', '440');
	$('.col-option43- .footer-column:eq(0)') .css('width', '440');
	
});


// Contact Form //

$(function() {
	
	var templatePath = $('.contact-form') .attr('title');
	$.each($('.contact-form'), function() {
		$(this) .attr('title', '');
	});
	
	$('.submitemail') .click(function(visitoremail) {
		
		var $this = $(this) .parent() .parent();
		
		var visitorname = $this .find('input.visitorname') .val();
		var visitoremail = $this .find('input.visitoremail') .val();
		var visitormessage = $this .find('textarea.visitormessage') .val();
		var thedawnfield = $this .find('input.theDawnfield') .val();                                                                                  
		
		var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
		//var validEmail = emailPattern.test(visitoremail); gabi
		
		var validEmail = visitoremail;
		
		
		if (visitorname.length < 2 || visitorname == 'Name') {
			$this .find('input.visitorname') .effect('shake', { times:2, distance:10 }, 100);
			$this .find('input.visitorname') .animate({'borderColor' : '#cc0f16'}, 500, function() {
				$this .find('input.visitorname') .delay(1000) .animate({'borderColor' : '#e1e4e9'}, 500);
			});
			var nameValid = 'NO';
		} else if (visitoremail == '' || validEmail == false) {
			$this .find('input.visitoremail') .effect('shake', { times:2, distance:10 }, 100);
			$this .find('input.visitoremail') .animate({'borderColor' : '#cc0f16'}, 500, function() {
				$this .find('input.visitoremail') .delay(1000) .animate({'borderColor' : '#e1e4e9'}, 500);
			});
			var emailValid = 'NO';
		} else if (visitormessage.length < 2) {
			$this .find('textarea.visitormessage') .effect('shake', { times:2, distance:10 }, 100);
			$this .find('textarea.visitormessage') .animate({'borderColor' : '#cc0f16'}, 500, function() {
				$this .find('textarea.visitormessage') .delay(1000) .animate({'borderColor' : '#e1e4e9'}, 500);
			});
			var messageValid = 'NO';
		}
		
		if ( nameValid != 'NO' && emailValid != 'NO' && messageValid != 'NO' && thedawnfield == '' ) {
			
			$this .find('.contact-form-loader') .show();
			
			$.ajax({
				type: 'POST',
				url: templatePath+'/lib/scripts/sendEmail.php',
				data: 'visitorname=' + visitorname + '&visitoremail=' + visitoremail + '&visitormessage=' + visitormessage,
				
				success: function(contactResults) {
					$this .find('div.response') .html(contactResults) .slideDown();
					$this .find('.contact-form-loader') .hide();
				}
			
			});
		}
	});
});


// Twitter Widget //

(function($){
	
	$.fn.twitterwidget = function(options) {
		var defaults = {
			twitterUser: 'mohdbiz',
			tweetsCount: 3
		},
		settings = $.extend({}, defaults, options);
		
		if ($('.recent-tweets') .length != 0) {
			triggerTwitter();
		}

		function triggerTwitter() {
			$('.recent-tweets') .empty();
			$('.recent-tweets') .parent() .find('h4') .css('position', 'relative');
			$('.recent-tweets') .parent() .find('h4') .append('<span class="tweets-load"></span>');
			
			var numofTweets = settings.tweetsCount;
			numofTweets = numofTweets -1;

			$(window).load(function () {
			$.getJSON( 'http://twitter.com/statuses/user_timeline/'+settings.twitterUser+'.json?callback=?&count=10',
				function(data) {
					$.each(data, function(i) {
						var tweet = data[i].text;
						tweet = tweet.replace(/(http:\/\/\S+)/g, '<a href="$1">$1</a>');
						tweet = tweet.replace(/(@\S+)/g, '<a href="http://twitter.com/$1">$1</a>');
						tweet = tweet.replace('@', '');
						
						var tweetDate = data[i].created_at;
						tweetDate = tweetDate.split(' ');
						var tweetFullDate = tweetDate[3] +' - '+tweetDate[0] +' '+ tweetDate[1] +' '+ tweetDate[2] +', '+ tweetDate[5];
						tweetDate = tweetDate[1] +' '+ tweetDate[2];
						
						var tweetID = data[i].id;
						var tweetStatus = 'http://twitter.com/'+settings.twitterUser+'/status/'+tweetID;
						
						$('#sidebar-content .recent-tweets, #big-footer .recent-tweets') .append('<li>'+tweet+'<span class="recent-tweets-date"><a href="'+tweetStatus+'" title="'+tweetFullDate+'">'+tweetDate+'</a></span></li>');
						
						if ( i == numofTweets ) return false;
					})
					$('.recent-tweets') .hide() .slideDown();
					$('.recent-tweets') .parent() .find('.tweets-load') .hide();
					$('.recent-tweets') .find('li:last') .css({'border' : 'none', 'marginBottom' : '0px'});
				}
			);
			});
		}
	}
	
})(jQuery);


// Flickr Widget //

$(function() {

	if($('.flickr-photos') .length != 0) {
		
		$('.flickr-photos') .parent() .find('h4') .css('position', 'relative');
		$('.flickr-photos') .parent() .find('h4') .append('<span class="flickr-load"></span>');
		
		triggerFlickr();
	}
	
	function triggerFlickr() {
	
	if ($('.flickr-photos') .attr('title')) {
		var flickrUserInput = $('.flickr-photos') .attr('title');
		var flickrId = flickrUserInput.split('/')[0];
		var numofFlickrPhotos = flickrUserInput.split('/')[1];
		numofFlickrPhotos = numofFlickrPhotos -1;
		var groupPhotos = flickrUserInput.split('/')[2];
		var pool_public;
		if (groupPhotos == 'group') { pool_public = 'groups_pool'; } else { pool_public = 'photos_public'; }
	}

	if (flickrId == '') {
		$('.flickr-photos') .parent() .find('.flickr-load') .hide();
		$('#sidebar-content .flickr-photos, #big-footer .flickr-photos') .html('<p>Please set a flickr user!</p>');
	}
	else { $(window).load(function () {
		$.getJSON( 'http://api.flickr.com/services/feeds/'+pool_public+'.gne?id='+flickrId+'&lang=en-us&format=json&jsoncallback=?', function(data) {
			
			$.each(data.items, function(i, item) {
				var photoTitle = item.title;
				var photoSrc = (item.media.m).replace("_m.jpg", "_s.jpg");
				var photoURL = item.link;
				$('#sidebar-content .flickr-photos, #big-footer .flickr-photos') .append('<li><a class="flickr-img load-img" target="_blank" href="'+photoURL+'" title="View on flickr: '+photoTitle+'"><img src="'+photoSrc+'" width="75" height="75" /><span class="flickr-wrap"></span><span class="img-load-wrap"></span></a></li>');
				
				if ( i == numofFlickrPhotos ) return false;
			})
			
			$('.flickr-photos') .hide() .slideDown();
			$('span.flickr-wrap') .css('display', 'none');
			$('.flickr-photos') .parent() .find('.flickr-load') .hide();
			
			$('.flickr-photos a.load-img img').one("load",function(){
				$(this) .parent() .find('span.img-load-wrap') .css('display', 'none');
				$(this) .hide() .fadeIn();
			})
			.each(function(){
			if(this.complete) $(this).trigger("load");
			});
			
			$('a.flickr-img') .hover(function() {
				$(this) .find('span.flickr-wrap') .css('display', 'block');
			}, function() {
				$(this) .find('span.flickr-wrap') .css('display', 'none');
			});
			
			$('.flickr-photos') .find('li:last') .css({'border' : 'none', 'marginBottom' : '0px'});
		
		});
	});
	}
	}
	
});


$(function() {
	// when header-intro is disabled - ie bug fix
	$headerIntro = $('#pre-body-area') .html();
	if ( $headerIntro == '' ) {
		$('#pre-body-area') .css('display', 'none');
	}
});
