Andrew Shanley

// FUNCTIONS

function removeSelected() {
  $('header h1 a').removeClass('selected');
  $('nav li a').removeClass('selected');
}


$(document).ready(function() {

  // Twitter script
  $('#tweets').tweet({
    username: "andyshan",
    join_text: null,
    avatar_size: null,
    count: 3,
    auto_join_text_default: ", I said...",
    auto_join_text_ed: ", I said...",
    auto_join_text_ing: ", I was...",
    auto_join_text_reply: ", I replied to",
    auto_join_text_url: ", I was checking out",
    loading_text: "Dagnammit! Grabbing my tweets now............."
  });

  // Header transitions and controls
  $('header h1 a').click(function() {
    if (!$(this).hasClass('selected')) {
      $('#container').addClass('background-lines');
      $('#arrows-what-i-did').css('opacity', '0');
      removeSelected();
      $('#container').flip({
        direction: 'tb',
        color: 'white',
        speed: 300,
        content: $('#container').load('/resource/page-component/introduction.php #introduction'),
        onEnd: function() {
          if (!$('html').is('.ie6, .ie7, .ie8')) {
            $('#tweets li').fadeTo(250, 1, function() {});
          }
          $('#arrows-left, #arrows-right').fadeTo(250, 1.0, function() {});
          $('header h1 a').addClass('selected');
        }
      });
    }
    return false;
  });

  // Navigation transitions and controls
  $('nav li a').click(function() {
    var clientName = $(this).parent().attr('class');
    if (!$(this).hasClass('selected')) {
      $('#arrows-left, #arrows-right').fadeTo(100, 0, function() {});
      if (!$('html').is('.ie6, .ie7, .ie8')) {
        $('#tweets li').fadeTo(250, 0.3, function() {});
      }
      removeSelected();
      $('#arrows-what-i-did').fadeTo(0, 0, function() {});
      $('nav li.' + clientName + ' a').addClass('selected');
      $('#container').flip({
        direction: 'tb',
        color: 'white',
        speed: 300,
        content: $('#container').load('/client/' + clientName + '.php'),
        onEnd: function() {
          $('#container').removeClass('background-lines');
          $('#arrows-what-i-did').fadeTo(0, 1.0, function() {});
          // Initialize slider script
          $('#slider').bxSlider({});
          // Google Analytics for event handlers (Ajax content)
          // _trackEvent(category, action, opt_label, opt_value)
          _gaq.push(['_trackEvent', 'ClientViewed', clientName]);
        }
      });
    }
    return false;
  });


  // loads in client information and screenshots should the address (URL) change
  $('a').click(function() {
    $.address.value($(this).attr('href'));
  });

  $.address.externalChange(function(event) {
    // check if it's not in the root (if it has a '#/' present
    if (location.href.indexOf("#/") != -1) {
      var clientName = $(location).attr('hash').replace('#/client/', '').replace('.php', '');

      $('#arrows-left, #arrows-right').fadeTo(100, 0, function() {});
      removeSelected();
      $('#arrows-what-i-did').fadeTo(0, 0, function() {});
      $('nav li.' + clientName + ' a').addClass('selected');
      $('#container').flip({
        direction: 'tb',
        color: 'white',
        speed: 300,
        content: $('#container').load('/client/' + clientName + '.php'),
        onEnd: function() {
          $('#container').removeClass('background-lines');
          $('#arrows-what-i-did').fadeTo(0, 1.0, function() {});
          // Initialize slider script
          $('#slider').bxSlider({});
          if (!$('html').is('.ie6, .ie7, .ie8')) {
            $('#tweets li').fadeTo(250, 0.3, function() {});
          }
          // Google Analytics for event handlers (Ajax content)
          // _trackEvent(category, action, opt_label, opt_value)
          _gaq.push(['_trackEvent', 'ClientViewed', clientName]);
        }
      });
    }
  });
});
// FUNCTIONS
function removeSelected () {
	$('header h1 a').removeClass('selected');
	$('nav li a').removeClass('selected');
}


$(document).ready(function(){

	// Twitter script
	$('#tweets').tweet({
			username: "andyshan",
			join_text: null,
			avatar_size: null,
			count: 3,
			auto_join_text_default: ", I said...",
			auto_join_text_ed: ", I said...",
			auto_join_text_ing: ", I was...",
			auto_join_text_reply: ", I replied to",
			auto_join_text_url: ", I was checking out",
			loading_text: "Dagnammit! Grabbing my tweets now............."
	});
	
	// Header transitions and controls
	$('header h1 a').click(function() {
		if (!$(this).hasClass('selected')) {
			$('#container').addClass('background-lines');
			$('#arrows-what-i-did').css('opacity','0');
			removeSelected();
			$('#container').flip({
				direction:'tb',
				color:'white',
				speed: 300,
				content: $('#container').load('/resource/page-component/introduction.php #introduction'),
				onEnd: function(){
					if (!$('html').is ('.ie6, .ie7, .ie8')) {
  					$('#tweets li').fadeTo(250, 1, function() {
						});
					}
					$('#arrows-left, #arrows-right').fadeTo(250, 1.0, function() {
   				});
					$('header h1 a').addClass('selected');
				}
			});	
		}
		return false;	
	});

	// Navigation transitions and controls
	$('nav li a').click(function() {
		var clientName = $(this).parent().attr('class');
		if (!$(this).hasClass('selected')) {
			$('#arrows-left, #arrows-right').fadeTo(100, 0, function() {
			});
			if (!$('html').is ('.ie6, .ie7, .ie8')) {
				$('#tweets li').fadeTo(250, 0.3, function() {
				});
			}
			removeSelected();
			$('#arrows-what-i-did').fadeTo(0, 0, function() {
			});
			$('nav li.' + clientName + ' a').addClass('selected');
			$('#container').flip({
				direction:'tb',
				color:'white',
				speed: 300,
				content: $('#container').load('/client/' + clientName + '.php'),
				onEnd: function(){
					$('#container').removeClass('background-lines');
					$('#arrows-what-i-did').fadeTo(0, 1.0, function() {
					});
					 // Initialize slider script
					$('#slider').bxSlider({
       		});
					// Google Analytics for event handlers (Ajax content)
					// _trackEvent(category, action, opt_label, opt_value)
					_gaq.push(['_trackEvent', 'ClientViewed', clientName]);
				}
			});
		}
		return false;	
	});
	
	
	// loads in client information and screenshots should the address (URL) change
	$('a').click(function() {  
		$.address.value($(this).attr('href'));  
	}); 	
	
	$.address.externalChange(function(event) {
		// check if it's not in the root (if it has a '#/' present
		if (location.href.indexOf("#/") != -1) {
			var clientName = $(location).attr('hash').replace('#/client/', '').replace('.php', '');

			$('#arrows-left, #arrows-right').fadeTo(100, 0, function() {
			});
			removeSelected();
			$('#arrows-what-i-did').fadeTo(0, 0, function() {
			});
			$('nav li.' + clientName + ' a').addClass('selected');
			$('#container').flip({
				direction:'tb',
				color:'white',
				speed: 300,
				content: $('#container').load('/client/' + clientName + '.php'),
				onEnd: function(){
					$('#container').removeClass('background-lines');
					$('#arrows-what-i-did').fadeTo(0, 1.0, function() {
					});
					 // Initialize slider script
					$('#slider').bxSlider({
       		});
					if (!$('html').is ('.ie6, .ie7, .ie8')) {
						$('#tweets li').fadeTo(250, 0.3, function() {
						});
					}
					// Google Analytics for event handlers (Ajax content)
					// _trackEvent(category, action, opt_label, opt_value)
					_gaq.push(['_trackEvent', 'ClientViewed', clientName]);
				}
			});
		}	
	});
});