jQuery.fn.styleCode=function(){return this.each(function(){var c=jQuery(this).find(".entry pre");
c.data("isStyled")!=true&&c.wrap('<div class="codebg"><div class="codetop"></div></div>').data("isStyled",true)})};
jQuery.fn.collapse=function(){return this.each(function(){jQuery(this).stop().animate({opacity:0,width:0,marginRight:0,padding:0},350)})};
jQuery.fn.expand=function(c){return this.each(function(){jQuery(this).stop().animate({opacity:1,width:c,marginRight:"18px",padding:"0 1px"},350)})};

$(function(){function c(){$(".contactbutton a").parent().parent().addClass("contactactive");
$("#fullscreen").css("display","block").animate({opacity:0.0},1000);
$("#contactview").slideDown(750,function(){$(this).find(".closecontact").fadeIn(500)});
$("#header").animate({marginTop:"430px"},750)}function f(a){if(a<1)a=i;
else if(a>i)a=1;
$("#focusarea").find("li:visible").fadeOut("slow").end().find("li:nth-child("+a+")").fadeIn("slow");
$markers.find("a.active").removeClass("active").end().find("li:nth-child("+
a+") a").addClass("active")}function j(){var a=2+$markers.find("a.active").parent().index();
f(a);
g=setTimeout(j,k)}function l(a){a=a.toLowerCase();
a=="everything"?$("#thumbnails li").expand(m):$("#thumbnails li").not("."+a).collapse().end().filter("."+a).expand(m)}function n(){$("#content .tag-post").each(function(){var a=$(this).offset().top-10,b=$(this).outerHeight(),d=$(window).scrollTop(),p=$(this).find(".postInfo").outerHeight(true),q=$(this).find(".postInfo").offset().left;
if(a-d<0&&a-d>-b&&
a-d<10+p-b)$(this).find(".postInfo").data("fixed","false").css({position:"absolute",right:"0px",left:"auto",bottom:"10px",top:"auto"});
else a-d<0&&a-d>-b?$(this).find(".postInfo").data("fixed","true").css({position:"fixed",left:q+"px",bottom:"auto",top:"10px"}):$(this).find(".postInfo").data("fixed","false").css({position:"absolute",right:"0px",left:"auto",bottom:"auto",top:"0px"});
if($(this).find(".postInfo").data("fixed")=="true"){a=$(this).offset().left+$(this).find(".entry").outerWidth(false)-
$(window).scrollLeft();
$(this).find(".postInfo").css({left:a+o+"px"});
console.log($(window).scrollLeft()+" and "+a)}})}var r=[];
$.preLoadImages=function(){for(var a=arguments.length;
a--;
){var b=document.createElement("img");
b.src=arguments[a];
r.push(b)}};
$.preLoadImages("wp-content/themes/ta/images/earth.jpg","wp-content/themes/ta/images/photo.jpg");
/*$(".contactbutton a").mouseenter(function(){$("#contactinfo").text($(this).text()).fadeIn("fast");
$(this).stop().parent().stop().animate({paddingTop:"7px"},
150).end().animate({opacity:1},100)}).mouseleave(function(){$(this).stop().parent().stop().animate({paddingTop:"10px"},150).end().animate({opacity:0.5},100)});*/
$(".contactbutton ").mouseleave(function(){$("#contactinfo").fadeOut("fast")});
$("#fullscreen").css("opacity",0);
$(".contactbutton a").click(function(a){a.preventDefault();
c()});
$("#scontact").click(function(a){a.preventDefault();
$("html,body").animate({scrollTop:0},750);
c()});
$("#fullscreen, .closecontact").click(function(a){a.preventDefault();

$("#menu").removeClass("contactactive");
$("#fullscreen").delay(200).fadeOut("slow");
$("#contactview").slideUp(750).find(".closecontact").fadeOut(200);
$("#header").animate({marginTop:"0px"},750)});
$("#focusarea").find("li").hide().end().find("li:first").show();
$markers=$("#feature ul.markers");
var i=$("#focusarea").children().length,k=7E3,g=setTimeout(j,k);
$("#focusnext, #focusprev").click(function(a){a.preventDefault();
clearTimeout(g);
a=2*$(this).hasClass("nextslide")+$markers.find("a.active").parent().index();

f(a)});
$markers.delegate("a","click",function(a){a.preventDefault();
clearTimeout(g);
f($(this).parent().index()+1)});
$("#thumbnails li").mouseenter(function(){$(this).find("img").stop().animate({opacity:0.8},750).end().find(".viewcasestudy").fadeIn("fast")}).mouseleave(function(){$(this).find("img").stop().animate({opacity:1},150).end().find(".viewcasestudy").fadeOut("fast")});
$("#filter a").click(function(a){a.preventDefault();
$(this).parent().parent().find("li a").removeClass("active").end().end().end().addClass("active");

window.location.hash="/"+$(this).text().replace(" ","-");
l($(this).text().replace(" ","-"))});
var m=$("#thumbnails li:first").width(),e=window.location.hash;
if(e!=""){e=e.split("/");
l(e[1]);
$("#filter").find(".active").removeClass("active").end().find(".f"+e[1].toLowerCase()).addClass("active")}$("#content").styleCode();
$("div.tag-video").click(function(){$(this).find("span.date").fadeOut("slow")});
var s=$("#content").children().length-1,h=$("#content").children().length-1;
$("#loadmoreposts").click(function(a){a.preventDefault();

$.ajax({method:"get",url:"../wp-content/themes/ta2/getarticles.php",data:"posts="+s+"&offset="+h,beforeSend:function(){},complete:function(){},success:function(b){h+=$("#content").append(b).styleCode().find(".moreposts:last").slideDown(600).find(".categoryicon").delay(600).fadeIn("fast").end().children().length;
h>=totalPosts&&$("#loadmoreposts").fadeOut("fast");
navigator.platform=="iPad"&&$("#content .post.tag-video").hide().filter(".tag-youtube").show()}})});
n();
$(window).scroll(function(){n()});

var o=16;
$(window).resize(function(){$("#content .tag-post").each(function(){if($(this).find(".postInfo").data("fixed")=="true"){var a=$(this).offset().left+$(this).find(".entry").outerWidth(false)-$(window).scrollLeft();
$(this).find(".postInfo").css({left:a+o+"px"});
console.log($(window).scrollLeft()+" and "+a)}})});
$("#content").delegate("div.tag-post div.postInfo .shortURL","click",function(){if($.browser.msie){var a=document.body.createTextRange();
a.moveToElementText(this);
a.select()}else if($.browser.mozilla||
$.browser.opera){var b=window.getSelection();
a=document.createRange();
a.selectNodeContents(this);
b.removeAllRanges();
b.addRange(a)}else if($.browser.webkit){b=window.getSelection();
b.setBaseAndExtent(this,0,this,1)}});
navigator.platform=="iPad"&&$("#content .post.tag-video").hide().filter(".tag-youtube").show()});

