/*
	jQuery plugin that adds ellipsis() function
*/
(function($) {
	$.fn.ellipsis = function(enableUpdating){
		var s = document.documentElement.style;
		if (!('textOverflow' in s || 'OTextOverflow' in s)) {
			return this.each(function(){
				var el = $(this);
				if(el.css("overflow") == "hidden"){
					var originalText = el.html();
					var w = el.width();
					
					var t = $(this.cloneNode(true)).hide().css({
						'position': 'absolute',
						'width': 'auto',
						'overflow': 'visible',
						'max-width': 'inherit'
					});
					el.after(t);
					
					var text = originalText;
					while(text.length > 0 && t.width() > parseInt(el.css("width"),10)){
						text = text.substr(0, text.length - 1);
						t.html(text + "...");
					}
					el.html(t.html());
					
					t.remove();
					
					if(enableUpdating === true){
						var oldW = el.width();
						setInterval(function(){
							if(el.width() != oldW){
								oldW = el.width();
								el.html(originalText);
								el.ellipsis();
							}
						}, 200);
					}
				}
			});
		} else{return this;}
	};
})(jQuery);
/*
	End jQuery ellipsis plugin
*/

/*
	OnReady stuff
*/
jQuery(document).ready(function($){
      

	//Set up the nav bar
	$("#nav li a").bind("mouseover", function(e){
		var uls = $(this).next("ul");
		var newHTML = "<li style=\"display:none;\"></li>";
		if(uls.length > 0){
			var ul = uls[0]; //Just grab the first one
			newHTML = $(ul).html();
		}
		$("#subnav").html(newHTML);
	});
	
	//apply the ellipsis function to anything using the CSS class "ellipsis"
	var ells = $(".ellipsis");
	ells.ellipsis();
});

var fontMin=8;
var fontMax=18;
function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
	var s;
      if(p[i].style.fontSize) {
         s = parseInt(p[i].style.fontSize.replace("px",""), 10);
      } else {
         s = 12;
      }
      if(s!=fontMax) {
         s += 1;
      }
      p[i].style.fontSize = s+"px";
   }
}
function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
	var s;
      if(p[i].style.fontSize) {
         s = parseInt(p[i].style.fontSize.replace("px",""),10);
      } else {
         s = 12;
      }
      if(s!=fontMin) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px";
   }   
}

