function checkEmail(email){var pattern=/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;var emailVal=$("#"+email).val();return pattern.test(emailVal);}
$(function(){$("#newsletter button").click(function(){$('form#newsletter').submit(function(){return false;});var formAction=$("form#newsletter").attr("action");var id="xtluyy";var emailId=id+"-"+id;if(!checkEmail(emailId)){$('#error-message').show();return;}
var str=$("form#newsletter").serialize();var serialized=str+"&action="+formAction;$.ajax({url:"/wp-content/themes/humaan/js/proxy.php",type:"POST",data:serialized,success:function(data){if(data.search(/invalid/i)!=-1){alert('The email address you supplied is invalid and needs to be fixed before you can subscribe to this list.');}
else
{$("#newsletter, #error-message").hide();$("#confirmation").fadeIn("slow");}}});});});$('span.email').each(function(){var spt="#"+$(this).attr("id");var at=/ at /;var dot=/ dot /g;var addr=$(spt).text().replace(at,"@").replace(dot,".");$(spt).after('<a class="email" href="mailto:'+addr+'" title="Send an email">'+addr+'</a>').hover(function(){window.status="Send a letter!";},function(){window.status="";});$(spt).remove();});(function($){$.randomImage={defaults:{path:'wp-content/themes/humaan/art/facts/',humanImages:['beard.png','heart.png','muscles.png','cell.png','blink.png','intestine.png','hair.png','sneeze.png','bears.png','giraffe.png','lungs.png','buttons.png'],humaanImages:['bigideas.png','attire.png','forhumans.png','digital.png','unique.png','featured.png','henry.png','clients.png','identity.png','lifeline.png','collaborate.png']}}
$.fn.extend({randomImage:function(config){var config=$.extend({},$.randomImage.defaults,config);return this.each(function(){var image1Names=config.humanImages;var image2Names=config.humaanImages;var imageNames1Size=image1Names.length;var imageNames2Size=image2Names.length;var lotteryNumber1=Math.floor(Math.random()*imageNames1Size);var lotteryNumber2=Math.floor(Math.random()*imageNames2Size);var winnerImage1=image1Names[lotteryNumber1];var winnerImage2=image2Names[lotteryNumber2];if($(this).hasClass('human')){var fullPath=config.path+winnerImage1;alt="Interesting Human Fact";}else{var fullPath=config.path+winnerImage2;alt="Interesting Humaan Fact";}
if($(this).is(':empty')){$(this).append('<img src="'+fullPath+'" alt="'+alt+'" />');}else{$(this).append('<img class="newimage" style="display:none" src="'+fullPath+'" alt="Interesting Human Fact" />');$(this).find('.newimage').ready(function(){$('#sub-footer .fact img').not('.newimage').delay(400).fadeOut(100,function(){$(this).remove();$('.newimage').removeClass().fadeIn(400,function(){$('#loading').fadeOut(200,function(){$('#loading').remove();});});});});}});}});})(jQuery);$(document).ready(function(){$('nav a').hoverIntent(function(){$(this).animate({'top':'-18px'},200);},function(){$(this).animate({'top':'-36px'},200,function(){$(this).css('top',0);});});$('#elements').cycle({fx:'scrollLeft',easing:'easeOutQuint'});$('#logo').hoverIntent(function(){$('#elements').cycle('pause').after('<div id="home-icon"><img src="/wp-content/themes/humaan/art/home.png" alt="Back Home" /></div>');$('#home-icon img').animate({'left':'15'},300);},function(){$('#home-icon img').animate({'left':'-40'},300,function(){$('#home-icon').remove();});$('#elements').cycle('resume');});if($('#hero').length>0){if($(window).width()>1024){$('#hero').after('<a href="" id="prev" title="Previous Feature">Previous</a><a href="" id="next" title="Next Feature">Next</a>');}
$('#hero').after('<div id="hero-nav"></div>').cycle({fx:'scrollHorz',speed:2000,timeout:8000,easing:'easeInOutQuint',prev:'#prev',next:'#next',pager:'#hero-nav',manualTrump:false});$('#hero-nav a').each(function(){$(this).addClass('nav-'+$(this).text());});$('#hero').hover(function(){$(this).cycle('pause');},function(){if(!$(this).hasClass('pause')){$(this).cycle('resume');}});$('#hero-nav a, #next, #prev').click(function(){$('#hero').addClass('pause').cycle('pause');});}
function scrolltext(){$(window).scroll(function(){if(!$('#find-out-more').hasClass('active')){$('#we').bind().css({"marginTop":-($(window).scrollTop())+"px"},"slow");}});}
scrolltext();$('#find-out-more').click(function(){$(this).addClass('active');$('#we').animate({'marginTop':'-952'},800);$('#headline .inner').delay(1000).animate({'height':420},400,function(){$('#testimonials').cycle({speed:3000,timeout:9000,random:1});$('#testimonials .item').each(function(){diff=(280-$(this).height())/2;$(this).css({'margin-top':diff});});});$('#extra, #testimonials').delay(1200).fadeIn(1000);$(this).fadeOut();return false;});$('#showcase .column img, #ideas-insights .column img, #posts .column img').after('<span class="image" style="display: none;"></span>');$('#showcase .column a, #ideas-insights .column a, #posts .column a').not('.more').hoverIntent(function(){$(this).parents('.column').find('.image').fadeIn();},function(){$(this).parents('.column').find('.image').fadeOut();});$('#connect a, #blog-rss').each(function(){$(this).hoverIntent(function(){$(this).find('.icon').animate({'top':'-50px'},200);},function(){$(this).find('.icon').animate({'top':'-100px'},200,function(){$(this).css('top',0);});});});$('#contactForm button, #humaan-map a').append('<span class="hover"></span>').each(function(){var $span=$('> span.hover',this).css('opacity',0);$(this).hoverIntent(function(){$span.stop().fadeTo(400,1);},function(){$span.stop().fadeTo(400,0);});});$('#featured-post img, #featured-post h1 a, #featured-post p a').hoverIntent(function(){$('#view-post-btn span').fadeTo(400,1);},function(){$('#view-post-btn span').fadeTo(400,0);});$('#featured-post .comments').hoverIntent(function(){$(this).fadeTo(400,.8);},function(){$(this).fadeTo(400,1);});$('#searchform input').focus(function(){$('#searchform div').addClass('active');});$('#searchform input').blur(function(){$('#searchform div').removeClass('active');});$("#contactForm label, #newsletter label, #searchform label").not('.error').inFieldLabels();$("#newsletter").validate();if($(window).width()>1024){$('#container').append('<a href="#container" id="back-to-top">Back to top</a>');function topbtn(){if($(window).scrollTop()<50){if(!$('#back-to-top').hasClass('hidden')){$('#back-to-top').addClass('hidden').fadeOut();}}else{if($('#back-to-top').hasClass('hidden')){$('#back-to-top').removeClass('hidden').fadeIn();}}}
$('#back-to-top').click(function(){$('html, body').animate({scrollTop:0},1000);return false;});topbtn();}
$('#post-info .share').click(function(){$('#post-info #sharing').slideToggle();return false;});$(window).scroll(function(){topbtn();if($(window).height()>$('#post-info .inner').height()&&($('#post-content').height()>800)){var diff=$('#post').height()+$('#post').offset().top-($('#post-info .inner').offset().top+$('#post-info .inner').height());topdist=$(window).scrollTop()-$('#post').offset().top;closebottom=$('#post').height()-$('#post-info .inner').height();$('#post-info').css('height',$('#post').height());if(diff>0&&($('#post').offset().top+30<$(window).scrollTop())){$('#post-info .inner').css('position','fixed');}else if(diff>0&&($('#post').offset().top+30>$(window).scrollTop())){$('#post-info .inner').css('position','absolute');}else if(diff<0){if($(window).scrollTop()>($("#post").height()+$('#post').offset().top)-$('#post-info .inner').height()+30){$('#post-info .inner').css('position','absolute').addClass('stuck');}else{$('#post-info .inner').css('position','fixed').removeClass('stuck');}}}});$('#blog-page #container, #single.blog #container').wrap('<div id="wrapper" />');$('#humaan-map a').click(function(){if(!$(this).hasClass('clicked')){$('#humaan-map img').fadeOut(1200);$(this).addClass('clicked');}else{$('#humaan-map img').fadeIn(1200);$(this).removeClass('clicked');}
return false;});$('#sub-footer .fact').randomImage();$('#reload').click(function(){$('#sub-footer').append('<span id="loading"><span></span></span>').find('#loading').fadeIn(200,function(){$('#sub-footer .fact').randomImage();});});$('#post-nav div a').each(function(){$(this).attr('title',$(this).text());});$('form#contactForm').validate({submitHandler:function(form){$('form button').replaceWith('<div id="button">');$('.field.large').after('<div id="sending">');var name=$("#name").val();var email=$("#email").val();var message=$("#message").val();var dataString='name='+name+'&email='+email+'&message='+message;$.ajax({type:"POST",url:"/wp-content/themes/humaan/contactform.php",data:dataString,success:function(){$('#sending').delay(600).fadeOut();$('#contactForm').append("<h3 style='display:none'><strong>Email sent!</strong> If required, we'll respond shortly.</h3>");$('#contactForm h3').delay(600).fadeIn();}});return false;}});if($('#twitterfeed').length>0){$("#twitterfeed").tweet({username:"wearehumaan",count:3,template:function(i){return i["text"]+i["time"]},loading_text:"loading tweets..."});}else if($('#tweets').length>0){$("#tweets").tweet({username:"wearehumaan",count:1,template:function(i){return i["text"]+i["time"]},loading_text:"loading tweets..."});}});
