function wpContent(){
	var self = this;
	self.content_height = 0;
	self.container_offset = 100;
	self.init = function(){
		self.content_height = parseInt($("#page_content").height());
		$("#content_container").css('height',(self.content_height+self.container_offset)+"px");
		$("#pos_container").css('height',self.content_height+"px");
	}
	
	self.init();
}
/* BODY CONTENT FUNCTIONS
*************************************************************/
function bodyContent(){
	var self = this;
	
	self.height_offset = 18;
	self.scroll_amount = 10;
	self.scroll_time = 100;
	self.timer = "";
	
	self.init = function(){
		if($('.body_content').height() > $('.body_copy').height()){
			self.height_offset = $("#page_content h1:eq(0)").height();
			self.setup_scrolling();
		}
	}
	
	self.setup_scrolling = function(){
		var copy_height = parseInt($('.body_content').height());
		var cur_container_height = parseInt($('.body_copy').height());
		var new_height = cur_container_height - self.height_offset;
		var num_pages = Math.ceil(copy_height / new_height);
		
		if(copy_height >= new_height){
			$('.body_content').css('position', 'relative');
			$('.body_content').css('top', '0');
			$('.body_copy').css('position', 'relative');
			$('.body_copy').css('overflow', 'hidden');
			$('.body_copy').css('height', new_height + "px");
			
			$('#page_content').append("<div id='copy_paging'></div>");
			$('#copy_paging').append("<div id='copy_scrolling'></div>");
			$('#copy_scrolling').append("<a href='#' class='up_arrow'>up</a>");
			$('#copy_scrolling').append("<a href='#' class='down_arrow'>down</a>");
			
			$('#copy_scrolling a.up_arrow').click(function(){ return false; });
			$('#copy_scrolling a.down_arrow').click(function(){ return false; });
			
			$('#copy_scrolling a.up_arrow').mousedown(function(){
				clearInterval(self.timer);
				self.timer = setInterval("move_container('down')",self.scroll_time);
				return false;
			});			
			$('#copy_scrolling a.up_arrow').mouseup(function(){
				clearInterval(self.timer);
			});
			
			$('#copy_scrolling a.down_arrow').mousedown(function(){
				clearInterval(self.timer);
				self.timer = setInterval("move_container('up')",self.scroll_time);
				return false;
			});			
			$('#copy_scrolling a.down_arrow').mouseup(function(){
				clearInterval(self.timer);
			});
		}
	}
	
	self.setup_paging = function() {
		var copy_height = parseInt($('.body_content').height());
		var cur_container_height = parseInt($('.body_copy').height());
		var new_height = cur_container_height - self.height_offset;
		var num_pages = Math.ceil(copy_height / new_height);
		
		if(num_pages > 1){
			$('.body_content').css('position', 'relative');
			$('.body_content').css('top', '0');
			$('.body_copy').css('position', 'relative');
			$('.body_copy').css('overflow', 'hidden');
			$('.body_copy').css('height', new_height + "px");
			
			$('#page_content').append("<div id='copy_paging'></div>");
			for(var n=1;n <= num_pages;n++){
				var added_class = (n==1) ? ' active' : '';
				$('#copy_paging').append("<a href='#' class='page_link" + added_class + "'>" + n + "</a>");
			}
			$('#copy_paging a.page_link').click(function(){
				$('#copy_paging a.page_link.active').removeClass('active');
				$(this).addClass('active');
				this_page = parseInt($(this).html());
				new_top = 0-parseInt((this_page-1) * parseInt($('.body_copy').height()));
				$('.body_content').css('top', new_top + "px");
				return false;
			});
		}
	}
}

move_container = function(direction) {
	var copy_height = parseInt($('.body_content').height())+10;
	var new_height = parseInt($('.body_copy').css('height'));
	
	if(direction == 'up'){
		new_top = parseInt($('.body_content').css('top')) - 10;
		if(new_top >= 0-(copy_height - new_height)){
			$('.body_content').css('top', new_top + "px");
		}
	} else {
		new_top = parseInt($('.body_content').css('top')) + 10;
		if(new_top <= 0){
			$('.body_content').css('top', new_top + "px");
		}
	}
}

/* GRID FUNCTIONS
*************************************************************/
function grid() {
  //shortcut for encapsulation
  var self = this;
  
  self.init = function(){
		$('#content_container div.home_entry a.home_entry_link').each(function(){
			if($(this).children('img').length > 0){
				$(this).css('width', $(this).children('img').width() + "px");
				$(this).css('height', $(this).children('img').height() + "px");
				//$(this).css('overflow', "hidden");
			}
		});
		$('#content_container div.home_entry a.home_entry_link').mouseover(function(){
			if($(this).children('img').length > 0){
				gridObj.img_hover($(this));
			}
		});
	}
  self.img_hover = function(a){
		menuObj.hide_all();
		if($(a).children('img').attr('class').length > 0 && $(a).children('span').length == 0){
			$(a).prepend('<span class="' + $(a).children('img').attr('class') + '">' + $(a).children('img').attr('alt') + '</span>');
			img_span = $(a).children('span');
			span_top = parseInt($(a).children('img').height()) /2 - 10;
			img_span.css('text-decoration',  "none");
			img_span.css('width',  $(a).children('img').width() + "px");
			img_span.css('top',  parseInt(span_top) + "px");
		}
	}
}

/* MENU FUNCTIONS
*************************************************************/
function menu() {
  //shortcut for encapsulation
  var self = this;
  self.timer= null;

  self.init = function(){
		$("#navigation .menu_link").each(function(){
			$(this).mouseover(function(){
				menuObj.hide_all();
				$(this).addClass('active');
				clearTimeout(self.timer);
				$(this).parent().children('ul.sub_nav').show();
			});
			$(this).mouseout(function(){
				self.timer = setTimeout("menuObj.hide_all()", 500);
			});
			if($(this).attr("href") == "#"){
				$(this).css('cursor','default').click(function(){
					return false;
				});
			}
		});
		$("#navigation ul.sub_nav").each(function(){
			$(this).mouseover(function(){
				clearTimeout(self.timer);
			});
			$(this).mouseout(function(){
				self.timer = setTimeout("menuObj.hide_all()", 500);
			});
		});
		self.setup_sub_menu();
	}
  self.setup_sub_menu = function(){
	  $('ul.page_tabs ul').hide();
	  $('a.selected').parents().show();
	  $('a.selected').parent().children('ul').show();
  }
  self.hide_all = function(){
		$('#navigation .active').removeClass('active');
		$('#navigation ul.sub_nav').hide();
	}
}

/* VIDEO FUNCTIONS
*************************************************************/

$.fn.media.defaults.flvPlayer= '/_cms/themes/site/default/mediaplayer.swf';
$.fn.media.defaults.flashvars={overstretch: 1, controlbar: 'over'};
$.fn.media.defaults.mp3Player= '/_cms/themes/site/default/modieus.swf';
$.fn.media.defaults.params= {allowFullScreen: "true"};