/* Author: 

*/

jQuery(document).ready(function() {


    //	=BEGIN: Add/Remove CSS classes on form focus
    //  URL Source: 
      /* Eric R. 2011-09-15: Code from Kevin Whitley & Eric Rasch to help the degree finder change the class upon focus. There seemed to be some conflict with the selectbox behaviour when removing/adding classes. I adjusted Kevin's code a little further and it seems to be working just fine. */
    //	.............................................................. 
    
    
    /* Finds the first selectbox on page load and removes the disabled class */
    // $(".form_data").show(function(){
    //     $(this).find("div").filter(":first").removeClass("disabled");
    // });
    
    
    /* This will change the list item class 'highlight' based on the focus state of the selectbox */
	$(".form_data select").focusin(function(){
	    $(".form_data li").removeClass("highlight");
	    $(this).closest("li").addClass("highlight");
	});

    /* This finds the select boxes that are no longer disabled and removes the class 'disabled' from the parent list item */
    $(".form_data select[disabled=disabled]").change(function(){
      $(this).closest("li").removeClass("disabled");
    });

    //	.............................................................. 
    //	=END: Add/Remove CSS classes on form focus


    //	=BEGIN: Using Twitter APIs (jQuery and JSON)
  	//  URL Source: http://css-tricks.com/build-your-own-social-home/
  	//	.............................................................. 
    /* Removed and replaced by the Facebook social plugin
         $.getJSON('http://twitter.com/status/user_timeline/ericrasch.json?count=2&callback=?', function(data){
       		$.each(data, function(index, item){
       			$('#tweets').append('<dt>' + item.text.linkify() + '</dt><dd>' + relative_time(item.created_at) + '</dd>');
       		});
       	
       	});
       	  	   	
       	function relative_time(time_value) {
       	  var values = time_value.split(" ");
       	  time_value = values[1] + " " + values[2] + ", " + values[5] + " " + values[3];
       	  var parsed_date = Date.parse(time_value);
       	  var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
       	  var delta = parseInt((relative_to.getTime() - parsed_date) / 1000);
       	  delta = delta + (relative_to.getTimezoneOffset() * 60);
       	  
       	  var r = '';
       	  if (delta < 60) {
       		r = 'a minute ago';
       	  } else if(delta < 120) {
       		r = 'couple of minutes ago';
       	  } else if(delta < (45*60)) {
       		r = (parseInt(delta / 60)).toString() + ' minutes ago';
       	  } else if(delta < (90*60)) {
       		r = 'an hour ago';
       	  } else if(delta < (24*60*60)) {
       		r = '' + (parseInt(delta / 3600)).toString() + ' hours ago';
       	  } else if(delta < (48*60*60)) {
       		r = '1 day ago';
       	  } else {
       		r = (parseInt(delta / 86400)).toString() + ' days ago';
       	  }
       	  
       	  return r;
       	}
       	
       	String.prototype.linkify = function() {
       		return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(m) {
       			return m.link(m);
       		});
       	};
    */ 
    
  	//	.............................................................. 
  	//	=END: Using Twitter APIs (jQuery and JSON)
  	
});

