http://schoolofthought.com/wp-content/themes/SchoolOfThought
	var $j = jQuery.noConflict();
	var animearray = new Array();
	var loaderposnum = 1;
	var isloading = false;
	var currcontainer = 'home';
	var nextcontainer = '';
	var workisloaded = false;
	var aboutisloaded = false;
	var contactisloaded = false;
	var navisopen = false;
	var imagesloaded = 0;
	var about_total = 42;
	var about_loaded = 0;
	var contact_total = 2;
	var contact_loaded = 0;
	// var ishome = true;
	var fb_connect_user;
	var ftorigheight;
	var playerarray = new Array();
	var localuser = 'false';
	var ispitchpage = false;
	
	$j(document).ready(function()
	{
		// SET HOME PAGE IMAGE SHADOWS
		ftorigheight = $j('#footer-bkg').height();
			// alert(ftorigheight);
		$j('#footer-rap').hide();
		$j('#footer-image').hide();
		$j('#progress').animate(
		{
			width: '100%'
		}, 7500);
		$j('p.post-image a').each(function ()
		{
			/*
			$j(this).parent().width($j(this).width());
			$j(this).parent().height($j(this).height());
			$j(this).wrap('<div class="shadow-one3"><div class="shadow-two3"><div class="shadow-three3"><div class="shadow-four3">');
			$j(this).parent().parent().parent().parent().prepend('<div class="corner-a3" /><div class="corner-b3" />');
			*/
		});
		
		// $j('#footer-image').css('opacity', 0);
		
		$j('.homepage-posts-li-pad').each(function ()
		{
			$j('.two-column-paragraph:last-child p:last-child', this).append('<img src="http://schoolofthought.com/wp-content/themes/SchoolOfThought/images/post-icon.png">');
		});
		$j('#loader').fadeOut(0);
		
		// SET BLURB HEIGHT TO BLOG HEIGHT
		// $j('#blurbs').height($j('#homepage-posts ul').height() + 150);
		// $j('#nav-sidebar').height($j('#nav-sidebar').height() + $j('#blurbs').height());
		
		// MAKE HOME BUTTON ACTIVE
		if (ishome == true)
		{
			$j('li#home a').attr('id', 'home_inactive');
			$j('li#home a').addClass('mainActive');
			$j('li#home a').removeAttr("href");
		}
		
		
		// MAIN NAV CLICK
		$j('#global_nav ul a').click(function()
		{
			if (issingle == true)
			{
				return;
			}
			if (!$j(this).hasClass('mainActive') && $j(this).attr('subid') == 'ismain')
			{
				$j('#global_nav ul a').each(function()
				{
					if ($j(this).hasClass('mainActive'))
					{
						var strsplit = $j(this).attr('class').split(' ');
						main_nav_deactivate(this, strsplit[0]);
					}
				});
				var strsplit = $j(this).attr('class').split(' ');
				main_nav_activate(this, strsplit[0]);
				eval(strsplit[0] + "click")();
			}
			return false;
		});
		
		// SORT MENU CLICK
		$j('#homepage-sort a').each(function()
		{
			$j(this).attr({colorbackup:$j(this).css('color')});
			if ($j(this).text()=='ALL')
			{
				activate_sort(this);
			}
		});
		$j('#homepage-sort a').click(function()
		{
			mydelay = 0;
			delay = 150;
			if (!$j(this).hasClass('isActive'))
			{
				mycat = $j(this).text();
				if (mycat == 'WE LIKE')
				{
					mycat = 'LIKE'
				}
				if (mycat == 'ALL')
				{
					$j('#homepage-posts li').each(function()
					{
						if ($j(this).hasClass('isHiding'))
						{
							$j(this).show();
							$j(this).removeClass('isHiding');
						}
					});
				}
				else
				{
					$j('#homepage-posts li').each(function()
					{
						if ($j(this).hasClass(mycat))
						{
							$j(this).show();
							$j(this).removeClass('isHiding');
						}
						else
						{
							if (!$j(this).hasClass('isHiding'))
							{
								$j(this).hide();
								$j(this).addClass('isHiding');
							}
						}
					});
				}
				$j('#homepage-sort a').each(function()
				{
					if ($j(this).hasClass('isActive'))
					{
						deactivate(this);
					}
				});
				activate_sort(this);
			}
			return false;
		});
		
		// SUB NAV CLICK
		$j('#global_nav ul ul a').each(function()
		{
			$j(this).attr({colorbackup:$j(this).css('color')});
		});
		
		$j('#global_nav ul ul a').click(function()
		{
			if (!$j(this).hasClass('isActive'))
			{
				 // some kind of currclass var that handles the difference between current and next scroll pos, in order to calc anime time
				
				var thisclass = $j(this).attr('class');
				$j('html,body').animate({scrollTop: $j('#' + thisclass).offset().top - 30},1500, 'swing');
				$j('#global_nav ul ul a').each(function()
				{
					// $j(this).attr({colorbackup:$j(this).css('color')});
					if ($j(this).hasClass('isActive'))
					{
						deactivate(this);
					}
				});
				activate_work(this);
			}
			return false;
		});
		// SET SUB NAV CLOSED
		submenuHeight = $j('#global_nav ul ul').height();
		$j('#global_nav ul ul').height(0);
		$j('#global_nav ul ul li').each(function ()
		{
			$j(this).css('top', -25);
			$j(this).css('opacity', 0);
		});
		
		// COMMENTS
		$j('.byline a.comments-open-close').click(function()
		{
			$j('.hideshow', this).html('Hide');
			
			currid = $j(this).attr('id');
			if (! $j(this).hasClass('isopen'))
			{
				isloading = true;
				$j('#loader').stop(true, true).fadeIn(250);
				runloader();
				$j.post('http://schoolofthought.com/wp-content/themes/SchoolOfThought/load-comments.php',{postid:$j(this).attr('id')}, function (data)
				{
					$j('.hpc' + currid).html(data);
					
					setsubmitclick();
					
					if ( FB.XFBML.Host.parseDomTree )
						setTimeout( FB.XFBML.Host.parseDomTree, 0 );
						FB.Connect.ifUserConnected(sfc_update_user_details);
						setTimeout(setimgonload, 10);
				});
				$j(this).addClass('isopen');
			}
			else
			{
				var hpcorigheight = $j('.hpc' + currid).height();
				/* $j('#home-container-rap').animate(
				{
					height: $j('#home-container-rap').height() - hpcorigheight
				}, 1000, 'swing');
				
				$j('#page-cont-rap').animate(
				{
					height: $j('#page-cont-rap').height() - hpcorigheight
				}, 1000, 'swing'); */
				$j('.hideshow', this).html('Show');
				$j('.crp' + currid).animate(
				{
					height: 0
				}, 1000, 'swing', function ()
				{
					// $j('#page-cont-rap').height($j('#pagerap').height());
					$j('#blurbs').animate(
					{
						height: $j('#homepage-posts ul').height() + 150
					}, 1000, 'swing');
				});
				$j(this).removeClass('isopen');
			}
			
			return false;
		});
		
		// BLURBS
		$j('.blurbabout').click(function ()
		{
			$j('#global_nav ul a').each(function()
			{
				if ($j(this).hasClass('mainActive'))
				{
					var strsplit = $j(this).attr('class').split(' ');
					main_nav_deactivate(this, strsplit[0]);
				}
			});
			// var strsplit = $j(this).attr('class').split(' ');
			main_nav_activate($j('#global_nav ul a.about'), 'about');
			aboutclick();
			return false;
		});
		
		
		$j('#feature-link').click(function ()
		{
			$j('#global_nav ul a').each(function()
			{
				if ($j(this).hasClass('mainActive'))
				{
					var strsplit = $j(this).attr('class').split(' ');
					main_nav_deactivate(this, strsplit[0]);
				}
			});
			// var strsplit = $j(this).attr('class').split(' ');
			main_nav_activate($j('#global_nav ul a.work'), 'work');
			workclick();
			return false;
		});
		
		
		
		$j('.logo-home').click(function ()
		{
			if (!ishome)
			{
				$j('#global_nav ul a').each(function()
				{
					if ($j(this).hasClass('mainActive'))
					{
						var strsplit = $j(this).attr('class').split(' ');
						main_nav_deactivate(this, strsplit[0]);
					}
				});
				// var strsplit = $j(this).attr('class').split(' ');
				main_nav_activate($j('#global_nav ul a.home'), 'home');
				homeclick();
			}
			return false;
		});
		
		$j('#footer-image').fadeOut();
	});
	
	// MAIN / SORT / SUB MENU / ACTIVATE / DEACTIVATE
	function activate_sort (navref)
	{
		$j(navref).attr({hrefbackup:$j(navref).attr('href')});
		$j(navref).removeAttr("href");
		$j(navref).css({'color' : '#32586a' });
		$j(navref).addClass('isActive');
	}
	function activate_work (navref)
	{
		$j(navref).attr({hrefbackup:$j(navref).attr('href')});
		$j(navref).removeAttr("href");
		$j(navref).css({'color' : '#591200' });
		$j(navref).addClass('isActive');
	}
	
	function main_nav_activate (navref, classref)
	{
		$j(navref).attr({hrefbackup:$j(navref).attr('href')});
		$j(navref).removeAttr("href");
		$j(navref).addClass('mainActive');
		$j(navref).attr('id', classref + '_inactive')
	}
	function main_nav_deactivate (navref, classref)
	{
		$j(navref).removeClass('mainActive');
		$j(navref).attr({href:$j(navref).attr('hrefbackup')});
		// $j(navref).attr({href:'#' + classref.toUpperCase()});
		$j(navref).removeAttr("hrefbackup");
		$j(navref).attr('id', classref + '_rollover')
	}
	
	function deactivate (navref)
	{
		$j(navref).attr({href:$j(navref).attr('hrefbackup')});
		$j(navref).removeAttr("hrefbackup");
		$j(navref).css({'color' : $j(navref).attr('colorbackup') });
		$j(navref).removeClass('isActive');
		// alert('deactivating ' + $j(navref));
	}
	
	function commentadded ()
	{
		// doalert();
		
		
	}
	function twlogoutcallback ()
	{
		$j('#tw-user').hide();
		$j('#comment-user-details').show();
	}
	function fblogoutcallback ()
	{
		$j('#fb-user').hide();
		$j('#comment-user-details').show();
	}
	function locallogout (theid)
	{
		var wpn = 'http://schoolofthought.com/wp-login.php?action=logout&amp;_wpnonce=56a2b27ebb';
		var slice = wpn.slice(wpn.length - 10);
		
		$j.post('http://schoolofthought.com/wp-login.php',{action:'logout', _wpnonce:slice}, function(data)
		{
			localuser = 'false';
			$j('#local-user-rap').animate(
			{
				opacity: 0
			}, 500, 'swing', function ()
			{
				$j(this).hide();
			});
			$j('.comment-user-details').css('opacity', 0);
			$j('.comment-user-details').delay(500).show().animate(
			{
				opacity: 1
			}, 500, 'swing');
		});
		
		
		return false;
	}
	function sfc_update_user_details()
	{
		fb_connect_user = true;
		isfbuser = true;
		// alert('switching');
		
		// update this to handle multiple form areas
		// Show their FB details TODO this should be configurable, or at least prettier...
		if (!$j('#fb-user' + currid).length) {
			
			$j('#comment-user-details' + currid).hide().after("<span class='fb-user' id='fb-user"+currid+"'>" +
			"<fb:profile-pic uid='loggedinuser' facebook-logo='true' size='normal' height='96'><\/fb:profile-pic>" +
			"<span id='fb-msg'><strong>Hi <fb:name uid='loggedinuser' useyou='false'><\/fb:name>!<\/strong><br />You are logged in with your Facebook account. " +
			"<a id='fb-wp-logout"+currid+"' class='"+currid+"' href='#'>Logout<\/a>" +
			"<\/span><\/span>");
		}
		
		/*
		$j('#tw-wp-logout').click(function()
		{
			$j.post('http://schoolofthought.com/wp-login.php',{action:'logout', _wpnonce:'a31bf09de6'}, twlogoutcallback);
			return false;
		});
		*/
		
		$j('#fb-wp-logout' + currid).click(function()
		{
			// $j.post('http://schoolofthought.com/wp-login.php',{action:'logout', _wpnonce:'a31bf09de6'}, fblogoutcallback);
			var thisclass = $j(this).attr('class');
			FB.Connect.logout(function ()
			{
				// alert('logged out');
				fb_connect_user = false;
				$j('.fb-user').hide();
				$j('.comment-user-details').show();
			});
			return false;
		});
	
		// Refresh the DOM
		FB.XFBML.Host.parseDomTree();
	}
	function submitover (id)
	{
		$j('.submit' + id).addClass('submitovercolor');
	}
	function submitout (id)
	{
		$j('.submit' + id).removeClass('submitovercolor');
	}
	function setsubmitclick ()
	{
		$j('.crp' + currid).each(function ()
		{
			var currform = $j('#commentform', this);
			var currlist = $j('#commentlist', this);
			
			var currformname = $j('#commentform input#author', this);
			var currformemail = $j('#commentform input#email', this);
			var currformcomment = $j('#commentform textarea#comment', this);
			
			var currnameerror = $j('#commentform #author-error', this);
			var currmailerror = $j('#commentform #mail-error', this);
			var currcommenterror = $j('#commentform #comment-error', this);
			
			
			
			var isvalid = false;
			
			currform.submit(function ()
			{
				// validate
				// alert(localuser);
				isvalid = false;
				// alert(currformcomment.attr('value'));
				if (currformcomment.attr('value') != "" && currformcomment.attr('value') != undefined)
				{
					currcommenterror.css('visibility', 'hidden');
					if (fb_connect_user)
					{
						// alert('fb user');
						isvalid = true;
					}
					else if (localuser == 'true')
					{
						// alert('local user');
						isvalid = true;
					}
					else
					{
						// alert('anonymous user');
						var namevalid = false;
						var emailvalid = false;
						if (currformname.attr('value') != "")
						{
							namevalid = true;
							currnameerror.css('visibility', 'hidden');
							// alert('name valid');
						}
						else
						{
							// name blank
							// alert('name blank');
							currnameerror.css('visibility', 'visible');
						}
						if (currformemail.attr('value') != "" && currformemail.attr('value').indexOf('@') != -1 && currformemail.attr('value').indexOf('@') != 0)
						{
							emailvalid = true;
							currmailerror.css('visibility', 'hidden');
							// alert('email valid');
						}
						else
						{
							// email invalid
							// alert('mail blank');
							currmailerror.css('visibility', 'visible');
						}
						if (namevalid == true && emailvalid == true)
						{
							// alert('email and name valid');
							isvalid = true;
						}
					}
				}
				else
				{
					currcommenterror.css('visibility', 'visible');
				}
				
				if (isvalid == true)
				{
					var formdata = currform.serializeArray();
					var formurl = 'http://schoolofthought.com/wp-content/themes/SchoolOfThought/comments-ajax.php';
					$j.post(formurl, formdata, function (data)
					{
						currlist.append(data);
					});
				}
				
				return false;
			});
		});
	}
	function setimgonload ()
	{
		// alert('set img load');
		profileimagesloaded = 0;
		totalprofileimages = 0;
		var hpcorigheight = $j('.hpc' + currid).height();
			// $j('.crp' + currid).height(0);
			// $j('.crp' + currid).css('overflow', 'visible');
			
			/*
			$j('#home-container-rap').delay(1000).animate(
			{
				height: $j('#home-container-rap').height() + hpcorigheight
			}, 1000, 'swing');
			
			$j('#page-cont-rap').delay(1000).animate(
			{
				height: $j('#page-cont-rap').height() + hpcorigheight
			}, 1000, 'swing');
			*/
			
			
			$j('.crp' + currid).delay(1000).animate(
			{
				height: hpcorigheight
			}, 1000, 'swing', function ()
			{
				$j('.crp' + currid).height('100%');
				
				
				
				
				// $j('#page-cont-rap').height($j('#pagerap').height());
				
				
				// $j('#home-container-rap').height($j('#home-container-rap').height() + hpcorigheight);
				// $j('#page-cont-rap').height($j('#page-cont-rap').height() + hpcorigheight);
				
				
				
				
				
				
				
				$j('#loader').stop(true, true).fadeOut(250, function()
				{
					isloading = false;
					$j('#lightbox-rap').css('visibility', 'hidden');
				});
				
				
			});
			
			
		
		/* $j('.comment-author img').each(function()
		{
			$j(this).attr('onload', 'profileimageloaded()');
			totalprofileimages++;
		}); */
	}
	function profileimageloaded ()
	{
		// alert('profile image loaded');
		profileimagesloaded++;
		// alert('profileimagesloaded = ' + profileimagesloaded);
		if (profileimagesloaded == totalprofileimages)
		{
			// alert('do show');
			// $j('.hpc' + currid).show(1000);
			
			var hpcorigheight = $j('.hpc' + currid).height();
			// $j('.crp' + currid).height(0);
			$j('.crp' + currid).css('overflow', 'visible');
			
			$j('.crp' + currid).delay(500).animate(
			{
				height: hpcorigheight
			}, 1000, 'swing', null);				
			
			/*
			var hpcorigheight = $j('.hpc' + currid + ' ul.commentlist').height() + $j('.hpc' + currid + ' #respond').height() + 40;
			// $j('.hpc' + currid).height(0);
			$j('.crp' + currid).css('overflow', 'visible');
			
			
			
			
			$j('.hpc' + currid).animate(
			{
				height: hpcorigheight
			}, 1000, 'swing', null);
			
			
			
			
			$j('.crp' + currid).animate(
			{
				height: $j('.hpc' + currid).height()
			}, 1000, 'swing', null);
			*/
			
			
		}
	}
	function fbimageloaded ()
	{
		alert('image loaded fb');
	}
	function loadcommentsuccess (data)
	{
		alert('comments loaded = ' + data);
	}
	
	function checkplayer (obj)
	{
		// alert('the videoplayer '+obj['id']+' has been instantiated');
	}
	function playerReady (obj)
	{
		// alert('the videoplayer '+obj['id']+' has been instantiated');
		
		playerarray[0] = $j("#" + obj['id']);
		
	}
	
	// HOME FUNCTIONS
	function loadhome ()
	{
		currcontainer = 'home';
		// $j('#page-cont-rap').height(0);
		$j('#twitter-feed').height(0);
		$j('#lightbox-rap').css('visibility', 'visible');
		// $j('#home-container').show();
		$j('#blurbs').animate(
		{
			height: $j('#homepage-posts ul').height() + 150
		}, 2000, 'swing');
		
		/* $j('#page-cont-rap').animate(
		{
			height: $j('#feature-spot-bkg').height() + $j('#homepage-sort-menu-rap').height() + $j('#homepage-posts').height() + 235
		}, 4000, 'swing', function ()
		{
			// $j(this).removeClass('zeroout');
			// $j(this).height('100%');
		});
		*/
		
		$j('#home-container-rap').animate(
		{
			height: $j('#feature-spot-bkg').height() + $j('#homepage-sort-menu-rap').height() + $j('#homepage-posts ul').height() + 70
		}, 4000, 'swing', function ()
		{
			// $j(this).removeClass('zeroout');
			$j(this).height('100%');
			$j('#lightbox-rap').css('visibility', 'hidden');
			$j('#footer-rap').show();
			$j('#footer-bkg').show();
			$j('#footer-rap').css('visibility', 'visible');
		});
		if ($j('.twtr-tweet-text').html() != "")
		{
			$j('#twitter-feed').animate(
			{
				height: 392
			}, 1000, 'swing');
		}
		
		
		// $j('#page-cont-rap').height($j('#pagerap').height());
	}
	function homeclick()
	{
		// close current, open this
		$j('#home-container-rap').show();
		nextcontainer = 'home';
		eval(currcontainer + "close")();
		// $j('#page-cont-rap').height(0);
		ishome = true;
		
	}
	function homeclose ()
	{
		// $j('#home-container').hide();
		
		
		// playerarray[0].sendEvent("PLAY", "false");
		
		$j('#home-container-rap').height(0);
		$j('#home-container-rap').hide();
		$j('#footer-rap').hide();
		$j('#footer-bkg').hide();
		
		
		$j('#footer-rap').css('visibility', 'hidden');
		
		
		
		// $j('#vvq-455-flv-1').sendEvent("PLAY", "false");
		// player.sendEvent("PLAY","true");
	
		if (nextcontainer == 'about')
		{
			loadabout();
		}
		else if (nextcontainer == 'contact')
		{
			loadcontact();
		}
	}
	function hideblurbs ()
	{
		$j('#blurbs').height(0);
		// $j('#blurbs').hide();
		
		$j('#twitter-feed').hide();
	}
	
	// WORK FUNCTIONS
	function loadwork ()
	{
		if (!workisloaded)
		{
			$j('#loader').stop(true, true).fadeIn(250);
			isloading = true;
			runloader();
			$j.ajax({ 
				'url':'http://schoolofthought.com/wp-content/themes/SchoolOfThought/work-ajax.php', 
				'success':function (data)
				{
					// alert(data);
					$j('#work-container').html(data);
				}, 
				'complete':function ()
				{
					workloaded();
				}
			});
			
			workisloaded = true;
			
		}
		else
		{
			currcontainer = 'work';
			
			// $j('#work-container').show();
			$j('#work-container-rap').animate(
			{
				height: $j('#workpage-posts').height() + $j('#workpage-header').height() + 120
			}, 3000, 'swing', function ()
			{
				$j('#lightbox-rap').css('visibility', 'hidden');
				$j('#footer-rap').show();
				$j('#footer-bkg').show();
				$j('#footer-rap').css('visibility', 'visible');
			});
			
			/* $j('#page-cont-rap').animate(
			{
				height: $j('#workpage-posts').height() + $j('#workpage-header').height() + 300
			}, 3000, 'swing', function ()
			{
				
			});
			*/
			
			
		}
	}
	function imageloaded ()
	{
		// alert(totalimages);
		imagesloaded++;
		if (imagesloaded == totalimages)
		{
			if (isworkpage != true)
			{
				showwork(1000, 3000);
				
				//fire the fancybox script to get element candidates
				jQuery(document).ready(function() {
					jQuery('a.fancyitem').fancybox({
						'transitionIn'	:	'elastic',
						'transitionOut'	:	'elastic',
						'speedIn'		:	200, 
						'speedOut'		:	200, 
						'scrolling'     :   'no',
						'overlayShow'	:	false
					});
				});
			}
			
			/* $j('#page-cont-rap').delay(1000).animate(
			{
				height: $j('#workpage-posts').height() + $j('#workpage-header').height() + 300
			}, 3000, 'swing', function ()
			{
				
			});
			*/
		}
	}
	function showwork (delaynum, speed)
	{
		$j('#work-container').css('visibility', 'visible');
		$j('#loader').stop(true, true).delay(delaynum).fadeOut(250, function()
		{
			isloading = false;
		});
		
		if (issingle == true)
		{
			workpostheight = $j('#workpage-posts').height() + $j('#workpage-header').height() + 25;
		}
		else
		{
			workpostheight = $j('#workpage-posts').height() + $j('#workpage-header').height() + 120;
		}
		$j('#work-container-rap').delay(delaynum).animate(
		{
			height: workpostheight
		}, speed, 'swing', function ()
		{
			$j('#lightbox-rap').css('visibility', 'hidden');
			$j('#footer-rap').show();
			$j('#footer-bkg').show();
			$j('#footer-rap').css('visibility', 'visible');
			$j('#splash-bkg').fadeOut();
		});
	}
	function workclick()
	{
		opennav();
		ishome = false;
		$j('#work-container-rap').show();
	}
	function opennav ()
	{
		delaynum = 0;
		spacer = 0;
		$j('#lightbox-rap').css('visibility', 'visible');
		// $j('html,body').animate({scrollTop: 0},700, 'swing');
		// $j('html,body').css({scrollTop: 0});
		$j('#global_nav ul ul').animate(
		{
			height: submenuHeight
		}, 800, 'swing', navopen);
		$j('#global_nav ul ul li').each(function ()
		{
			$j(this).delay(delaynum).animate(
			{
				top: spacer,
				opacity:1
			}, 250, 'swing');
			delaynum += 100;
		});
	}
	function navopen ()
	{
		navisopen = true;
		if (ispitchpage != true)
		{
			
			
			hideblurbs();
			eval(currcontainer + "close")();
			// $j('#page-cont-rap').height(0);
			loadwork();
		}
		
		
	}
	function closenav ()
	{
		// $j('html,body').animate({scrollTop: 0},700, 'swing');
		// $j('html,body').css({scrollTop: 0});
				
		$j('#global_nav ul ul').delay(100).animate(
		{
			height: 0
		}, 800, 'swing', hidework);
		
		$j('#global_nav ul ul li').each(function ()
		{
			$j(this).delay(delaynum).animate(
			{
				top: -25,
				opacity:0
			}, 250, 'swing', null);
			delaynum -= 100;
		});
	}
	function hidework ()
	{
		navisopen = false;
		// $j('#work-container').hide();
		$j('#work-container-rap').height(0);
		$j('#work-container-rap').hide();
		$j('#footer-rap').hide();
		$j('#footer-bkg').hide();
		$j('#footer-rap').css('visibility', 'hidden');
		eval("load" + nextcontainer)();
	}
	function workloaded ()
	{
		currcontainer = 'work';
		
		$j('.post-image a').click(function()
		{
			$j('#loader').stop(true, true).fadeIn(250);
			isloading = true;
			runloader();
			if ($j(this).attr('type') == 'swf')
			{
				var offtop = $j(this).parent().offset().top;
				var offleft = $j(this).parent().offset().left;
				var samplew = $j(this).attr('width');
				var sampleh = $j(this).attr('height');
				$j('#lightbox-content').load($j(this).attr('href'), function()
				{
					$j(this).css('visibility', 'hidden');
					sampleloaded(offtop, offleft, samplew, sampleh, 'swf');
				});
			}
			else
			{
				$j('#lightbox-content').html('<img onload="javascript:sampleloaded('+$j(this).parent().offset().top+', '+$j(this).parent().offset().left+','+$j(this).parent().width()+','+$j(this).parent().height()+')" src="' + $j(this).attr('href') + '">');
			}
			return false;
		});
		
		$j('#lightbox-content-rap a').click(function()
		{
			$j('#lightbox-rap').css('visibility', 'hidden');
			$j('#lightbox').css('visibility', 'hidden');
			$j('#close-button').css('visibility', 'hidden');
			$j('#lightbox-content').css('visibility', 'hidden');
			$j('#swfwrap').remove();
			return false;
		});
		
		$j('.post-image a').hover 
		(
			function ()
			{
				// over
				if ($j(this).attr('href'))
				{
				
			
					if (!$j(this).hasClass('over'))
					{
						$j(this).append("<div id='sample-over'><div id='sample-over-copy'>Print Ad<\/div><\/div>");
						var imgw = $j('img', this).width() / 2;
						var imgh = $j('img', this).height() / 2;
						var overw = $j('#sample-over', this).width() / 2;
						var overh = $j('#sample-over', this).height() / 2;
						$j('#sample-over', this).css('left', (imgw + overw) *-1);
						$j('#sample-over', this).css('top', imgh - overh);
						$j('#sample-over-copy', this).html($j(this).attr('rel'));
						$j('#sample-over', this).hide();
						$j('#sample-over', this).css('visibility', 'visible');
						$j(this).addClass('over');
					}
					
					$j('#sample-over', this).stop(true, true).fadeIn(250);
				}
			},
			function ()
			{
				// out
				$j('#sample-over', this).stop(true, true).fadeOut(250);
			}
		);
		
		
		//fancybox hover
		$j('a.fancyitem').hover 
		(
			function ()
			{
				// over
				if ($j(this).attr('href'))
				{
				
			
					if (!$j(this).hasClass('over'))
					{
						$j(this).append("<div id='sample-over'><div id='sample-over-copy'>Print Ad<\/div><\/div>");
						var imgw = $j('img', this).width() / 2;
						var imgh = $j('img', this).height() / 2;
						var overw = $j('#sample-over', this).width() / 2;
						var overh = $j('#sample-over', this).height() / 2;
						$j('#sample-over', this).css('left', (imgw + overw) *-1);
						$j('#sample-over', this).css('top', imgh - overh);
						$j('#sample-over-copy', this).html($j(this).attr('name'));
						$j('#sample-over', this).hide();
						$j('#sample-over', this).css('visibility', 'visible');
						$j(this).addClass('over');
					}
					
					$j('#sample-over', this).stop(true, true).fadeIn(250);
				}
			},
			function ()
			{
				// out
				$j('#sample-over', this).stop(true, true).fadeOut(250);
			}
		);
		//end fancy hover
		
		// $j('#work-container').hide();
		
	}
	function workclose ()
	{
		$j('#global_nav ul ul a').each(function()
		{
			if ($j(this).hasClass('isActive'))
			{
				deactivate(this);
			}
		});
		closenav();
	}
	// WORK SAMPLE FUNCTIONS
	function runloader()
	{
		$j('#loader').css('left', ($j(window).width() / 2) - 20);
		$j('#loader').css('top', ($j(window).height() / 2) - 20);
		if (isloading)
		{
			setTimeout(function(){setloaderpos();}, 100);
		}
	}
	function setloaderpos()
	{
		if (isloading)
		{
			$j('#lightbox-rap').css('visibility', 'visible');
			$j('#loader').css('left', ($j(window).width() / 2) - 20);
			$j('#loader').css('top', ($j(window).height() / 2) - 20);
			$j('#loader').css('background-position', '0 ' + (-38 * loaderposnum) + 'px');
			if (loaderposnum < 11)
			{
				loaderposnum++;
			}
			else
			{
				loaderposnum = 1;
			}
			runloader();
		}
		
	}
	function sampleloaded (reftop, refleft, w, h, type)
	{
		$j('#close-button').css('left', $j('#lightbox-content').width() - 45);
		$j('#close-button').css('visibility', 'hidden');
		var centertop = ($j(window).height() / 2) - ($j('#lightbox').height() / 2);
		var centerleft = ($j(window).width() / 2) - ($j('#lightbox').width() / 2);
		$j('#lightbox').css('top', reftop - $j('html, body').scrollTop());
		$j('#lightbox').css('left', refleft);
		$j('#lightbox').css('opacity', 0);
		
		$j('#loader').stop(true, true).fadeOut(250, function()
		{
			isloading = false;
			var origwidth;
			var origheight;
			if (type != 'swf')
			{
				origwidth = $j('#lightbox img').width();
				origheight = $j('#lightbox img').height();
				$j('#lightbox img').width(w);
				$j('#lightbox img').height(h);
				$j('#lightbox img').animate(
				{
					width: origwidth,
					height: origheight
				}, 500, 'swing', null);
				$j('#lightbox-content').css('visibility', 'visible');
				$j('#lightbox').css('visibility', 'visible');
				$j('#lightbox').animate(
				{
					left: centerleft,
					top: centertop,
					opacity: 1
				}, 500, 'swing', donezooming);
			}
			else
			{
				origwidth = w;
				origheight = h;
				
				// $j('#swfwrap').width(origwidth/3);
				// $j('#swfwrap').height(origheight/3);
				$j('#lightbox-content').css('visibility', 'hidden');
				$j('#lightbox').css('visibility', 'visible');
				/*
				$j('#swfwrap').animate(
				{
					width: origwidth,
					height: origheight
				}, 500, 'swing', null);
				*/
				$j('#lightbox').animate(
				{
					left: centerleft,
					top: centertop,
					opacity: 1
				}, 500, 'swing', donezooming);
				
			}
			
		});
	}
	function donehidingloader ()
	{
		alert('done');
	}
	function donezooming ()
	{
		$j('#close-button').css('visibility', 'visible');
		$j('#lightbox-content').css('visibility', 'visible');
	}
	
	// ABOUT FUNCTIONS
	function loadabout ()
	{
		// alert($j('#page-cont-rap').height());
		// $j('#page-cont-rap').height(0);
		if (!aboutisloaded)
		{
			$j('#loader').stop(true, true).fadeIn(250);
			isloading = true;
			runloader();
			$j.ajax({ 
				'url':'http://schoolofthought.com/wp-content/themes/SchoolOfThought/about-ajax.php', 
				'success':function (data)
				{
					$j('#about-container').html(data);
				}, 
				'complete':function ()
				{
					aboutloaded();
				}
			});
			aboutisloaded = true;
		}
		else
		{
			$j('#lightbox-rap').css('visibility', 'visible');
			// $j('#page-cont-rap').height(900);
			currcontainer = 'about';
			$j('#about-container').show();
			$j('#footer-image').fadeOut(0);
			
			$j('#footer-bkg').height(0);
			$j('#footer-bkg').delay(1000).show(0).animate(
			{
				height: ftorigheight
			}, 500, 'swing',function ()
			{
				$j(this).height('100%');
				// $j('#footer-image').fadeIn(500);
				$j('#footer-image').show();
			});
			$j('#footer-rap').delay(1000).show();
			$j('#about-container-rap').animate(
			{
				height: 4265
			}, 2000, 'swing', function ()
			{
				// $j(this).removeClass('zeroout');
				$j('#lightbox-rap').css('visibility', 'hidden');
				$j('#footer-rap').css('visibility', 'visible');
				// $j('#footer-image').fadeIn(500);
			});
			
		}
	}
	function aboutloaded ()
	{
		currcontainer = 'about';
		$j('#about-container').show();
		$j('#about-container').css('visibility', 'visible');
		/*
		$j('ul#people li').each(function ()
		 {
							 var myparentcopy = $j('.people-copy p', this);
							 $j('.people-icons a',this).mouseover(function ()
							  {
																  myparentcopy.css('color', '#aaa');					  
							  });
								$j('.people-icons a',this).mouseout(function ()
																	 {
																	 myparentcopy.css('color', '#625D4F');					  
																	 });
		 });
		*/
		
	}
	function aboutclick()
	{
		nextcontainer = 'about';
		hideblurbs();
		eval(currcontainer + "close")();
		ishome = false;
	}
	function aboutclose ()
	{
		$j('#about-container').hide();
		$j('#about-container-rap').height(0);
		$j('#footer-rap').hide();
		$j('#footer-bkg').hide();
		$j('#footer-rap').css('visibility', 'hidden');
		if (nextcontainer == 'home')
		{
			loadhome();
		}
		if (nextcontainer == 'contact')
		{
			loadcontact();
		}
	}
	function aboutimgloaded ()
	{
		about_loaded++;
		if (about_total == about_loaded)
		{
			// alert(isaboutpage);
			if (isaboutpage != true)
			{
				showabout(0);
			}
			/* $j('#page-cont-rap').animate(
			{
				height: 900
			}, 1000, 'swing');
			// $j('#page-cont-rap').height(900);
			*/
		}
	}











// ABOUT FUNCTIONS
function loadcontact ()
{
	if (!contactisloaded)
	{
		$j('#loader').stop(true, true).fadeIn(250);
		isloading = true;
		runloader();
		$j.ajax({ 
				'url':'http://schoolofthought.com/wp-content/themes/SchoolOfThought/contact-ajax.php', 
				'success':function (data)
				{
				$j('#contact-container').html(data);
				}, 
				'complete':function ()
				{
				contactloaded();
				}
				});
		contactisloaded = true;
	}
	else
	{
		$j('#lightbox-rap').css('visibility', 'visible');
		currcontainer = 'contact';
		$j('#contact-container').show();
		$j('#contact-container-rap').animate(
										   {
										   height: 700
										   }, 1000, 'swing', function ()
										   {
										   $j('#lightbox-rap').css('visibility', 'hidden');
										   $j('#footer-rap').css('visibility', 'visible');
										   });
		
	}
}
function contactloaded ()
{
	currcontainer = 'contact';
	$j('#contact-container').show();
	$j('#contact-container').css('visibility', 'visible');
	
}
function contactclick()
{
	nextcontainer = 'contact';
	hideblurbs();
	eval(currcontainer + "close")();
	ishome = false;
}
function contactclose ()
{
	$j('#contact-container').hide();
	$j('#contact-container-rap').height(0);
	$j('#footer-rap').hide();
	$j('#footer-bkg').hide();
	$j('#footer-rap').css('visibility', 'hidden');
	
	if (nextcontainer == 'home')
	{
		loadhome();
	}
	if (nextcontainer == 'about')
	{
		loadabout();
	}
}
function contactimgloaded ()
{
	contact_loaded++;
	if (contact_total == contact_loaded)
	{
			showcontact(0);
		
	}
}
	




	function init ()
	{
		$j('#progress').stop().width('100%');
		
		$j('#splash-bkg').delay(1000).animate(
		{
			opacity: 0
		}, 1500);
		$j('#splash-rap').fadeOut();
		
		if (ispitchpage != true)
		{
			$j('#global_nav').delay(2000).animate(
			{
				height: 173
			}, 500, 'swing', function ()
			{
				$j(this).removeClass('zeroout');
				$j(this).height('100%');
			});
		}
		else
		{
			$j('#global_nav').delay(2000).animate(
			{
				height: 1
			}, 500, 'swing', function ()
			{
				$j(this).removeClass('zeroout');
				$j(this).height('100%');
				opennav();
			});
		}
		
		
		
		
		
		/*
		$j('#page-cont-rap').delay(3000).animate(
		{
			height: $j('#feature-spot-bkg').height() + $j('#homepage-sort-menu-rap').height() + $j('#homepage-posts').height() + 235
		}, 4000, 'swing', function ()
		{
			$j(this).removeClass('zeroout');
			
			
			
			// $j(this).height('100%');
		});
		*/
		if (issingle == true)
		{
			if (ishomepage == true)
			{
				showhome(2500, 0);
			}
			else
			{
				workloaded();
				showwork(2500, 1500);
			}
		}
		else if (isaboutpage == true)
		{
			showabout(2500);
		}
		else if (isworkpage == true)
		{
			workloaded();
			showwork(2500, 1500);
		}
		else
		{
			showhome(2500, 2000);
		}
	}
	function showhome (delaynum, speed)
	{
		if (issingle != true)
		{
			$j('#blurbs').delay(delaynum).animate(
			{
				height: $j('#homepage-posts ul').height() + 150
			}, speed, 'swing');
			
			if ($j('.twtr-tweet-text').html() != "")
			{
				$j('#twitter-feed').delay(delaynum + 500).animate(
				{
					height: 392
				}, 1000, 'swing');
			}
			
			
		}
		
		$j('#home-container-rap').delay(delaynum + 500).animate(
		{
			height: $j('#feature-spot-bkg').height() + $j('#homepage-sort-menu-rap').height() + $j('#homepage-posts').height() + 70
		}, speed + 2000, 'swing', function ()
		{
			// $j(this).removeClass('zeroout');
			$j('#footer-rap').show();
			$j('#splash-bkg').fadeOut();
			$j(this).height('100%');
		});
		
		
	}
	
	function showabout (delaynum)
	{
		// alert('showing about = ' + delaynum);
		$j('#loader').stop(true, true).fadeOut(250, function()
		{
			isloading = false;
		});
		$j('#footer-bkg').height(0);
		$j('#footer').css('visibility', 'hidden');
		$j('#about-container-rap').delay(delaynum).animate(
		{
			height: 4265
		}, 1000, 'swing', function ()
		{
			// $j(this).removeClass('zeroout');
			$j('#lightbox-rap').css('visibility', 'hidden');
			// $j('#footer-image').css('display', 'inline');
			$j('#footer-rap').css('visibility', 'visible');
			$j('#footer-rap').show();
			$j('#splash-bkg').fadeOut();
		});
		
		$j('#footer').delay(delaynum + 1000).css('visibility', 'visible');
		
		$j('#footer-bkg').delay(delaynum + 1000).show(0).animate(
		{
			height: ftorigheight
		}, 500, 'swing',function ()
		{
			$j(this).height('100%');
			// $j('#footer-image').fadeIn(500);
		});
		
		
		
		
	}
	
function showcontact (delaynum)
{
	$j('#loader').stop(true, true).fadeOut(250, function()
										   {
										   isloading = false;
										   });
	$j('#footer-bkg').height(0);
	$j('#footer').css('visibility', 'hidden');
	$j('#contact-container-rap').delay(delaynum).animate(
													   {
													   height: 700
													   }, 1000, 'swing', function ()
													   {
													   $j('#lightbox-rap').css('visibility', 'hidden');
													   // $j('#footer-rap').css('visibility', 'visible');
													   // $j('#footer-rap').show();
													   $j('#splash-bkg').fadeOut();
													   });
	
	// $j('#footer').delay(delaynum + 1000).css('visibility', 'visible');
	
	/* $j('#footer-bkg').delay(delaynum + 1000).show(0).animate(
															 {
															 height: ftorigheight
															 }, 500, 'swing',function ()
															 {
															 $j(this).height('100%');
															 });
	*/
	
	
	
}

	
	
	
	
	
	
	
	
	
	
	
	

	
