$(function() {
	//External Popup action
 $('a.ext').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });	

		$('#contact_table td input.contact_frm').focus(function(){
        	$(this).css('border','1px solid #AFAFAF');
		}).blur(function() {
        	$(this).css('border','1px solid #5D0303');
		});
		
		
		$('#contact_table td textarea.contact_frm').focus(function(){
        	$(this).css('border','1px solid #AFAFAF');
		}).blur(function() {
        	$(this).css('border','1px solid #5D0303');
		});


		$('#commentform input#author').focus(function(){
        	$(this).css('border','1px solid #AFAFAF');
		}).blur(function() {
        	$(this).css('border','1px solid #5D0303');
		});
		$('#commentform input#email').focus(function(){
        	$(this).css('border','1px solid #AFAFAF');
		}).blur(function() {
        	$(this).css('border','1px solid #5D0303');
		});
		$('#commentform input#url').focus(function(){
        	$(this).css('border','1px solid #AFAFAF');
		}).blur(function() {
        	$(this).css('border','1px solid #5D0303');
		});
		
		$('#commentform textarea').focus(function(){
        	$(this).css('border','1px solid #AFAFAF');
		}).blur(function() {
        	$(this).css('border','1px solid #5D0303');
		});
		
		//Footer
			// (this needs to be condensed.... *embarrassing*)
 
		$("#footer dl.foot_twitter dt").hover(
		  function () {
			$('span#foot_twitter').stop(true, true).fadeIn('slow');
		  }, 
		  function () {
			$('span#foot_twitter').fadeOut();
		  }
		);

		$("#footer dl.foot_flickr dt").hover(
		  function () {
			$('span#foot_flickr').stop(true, true).fadeIn('slow');
		  }, 
		  function () {
			$('span#foot_flickr').fadeOut();
		  }
		);

		$("#footer dl.foot_pipes dt").hover(
		  function () {
			$('span#foot_pipes').stop(true, true).fadeIn('slow');
		  }, 
		  function () {
			$('span#foot_pipes').fadeOut();
		  }
		);
		$("#footer dl.foot_lastfm dt").hover(
		  function () {
			$('span#foot_last').stop(true, true).fadeIn('slow');
		  }, 
		  function () {
			$('span#foot_last').fadeOut();
		  }
		);		
});

var ie_blows = 0;



(function($) {

  // define public plugin contents
  $.Tache = {
    Data:         [],
    Delete:       function(a) { Delete(a) },
    DeleteAll:    function()  { DeleteAll() },
    Get:          function(a) { Get(a) },
    SetTimeout:   function(a) { SetTimeout(a) },
    Timeout:      600   // 600 seconds = 10 minutes
  };

  // PRIVATE: create a unique identifier
  function CreateID(oAJAX) {
    var sIdentifier = oAJAX.url;
    sIdentifier += ((typeof oAJAX.data == "string") ? oAJAX.data : "");
    sIdentifier += ((typeof oAJAX.dataType == "string") ? oAJAX.dataType : "");
    sIdentifier += ((typeof oAJAX.type == "string") ? oAJAX.type : "");
    return sIdentifier;
  }

  // PUBLIC: delete a single data item
  function Delete(oAJAX) {
    // exit now if we haven't been passed a URL
    if (typeof oAJAX.url != "string") {
      alert("No AJAX URL passed");
      return;
    }

    // delete expired and
    var sIdentifier = CreateID(oAJAX);
    var dtNow = new Date();
    for (var i = $.Tache.Data.length; i > 0; i--) {
      if ((((dtNow.valueOf() - $.Tache.Data[i-1].dtAge.valueOf()) / 1000) > $.Tache.Timeout ) || ($.Tache.Data[i-1].sIdentifier == sIdentifier)) {
          $.Tache.Data.splice(i-1, 1);
      }
    }
  }

  // PUBLIC: delete all cached data
  function DeleteAll() {
    $.Tache.Data = [];
  }

  // PUBLIC: return the data of ajax call either directly from the server or from memory if pre-loaded
  function Get(oAJAX) {
    // exit now if we haven't been passed a URL
    if (typeof oAJAX.url != "string") {
      alert("No AJAX URL passed");
      return;
    }

    // find if the data has been cached has already been called, deleting expired requests as we go
    var sIdentifier = CreateID(oAJAX);
    var dtNow = new Date();
    for (var i = $.Tache.Data.length; i > 0; i--) {
      if ( ((dtNow.valueOf() - $.Tache.Data[i-1].dtAge.valueOf()) / 1000) > $.Tache.Timeout ) {
          // delete expired request
          $.Tache.Data.splice(i-1, 1);
      } else if ($.Tache.Data[i-1].sIdentifier == sIdentifier) {
          oAJAX.success($.Tache.Data[i-1].oData);
          return;
      }
    }

    // the data wasn't found; alter the callback to insert the soon-to-be requested data into the cache
    var oCallback = oAJAX.success;
    oAJAX.success = function(oNewData) {
    $.Tache.Data.push({ sIdentifier: sIdentifier, oData: oNewData, dtAge: new Date() });
      oCallback(oNewData);
    }
    $.ajax(oAJAX);
  }

  // PUBLIC: set the timeout value
  function SetTimeout(iSeconds) {
    $.Tache.Timeout = iSeconds;
  }

})(jQuery);