// JavaScript Document

$(document).ready(function(){

	//target blank for all external links
	$('a[href^=http]').click( function() {
		window.open(this.href);
		return false;
	});
	
	//font size links at top of page
	 // Reset Font Size
    $("a.size2").click(function(){
    $('p').css('font-size', '1.05em');
	$('.sub_content ul').css('font-size', '1.05em');
	$('h2').css('font-size', '3em');
	$('h2').css('font-size', '1.7em');
	$('.movie_left h3').css('font-size', '1.45em');
	return false;
  });
  // Increase Font Size
  $("a.size3").click(function(){
    $('p').css('font-size', '1.5em');
	$('.sub_content ul').css('font-size', '1.5em');
	$('h2').css('font-size', '4.5em');
	$('h2').css('font-size', '2.5em');
	$('.movie_left h3').css('font-size', '2em');
    return false;
  });
  // Decrease Font Size
  $("a.size1").click(function(){
    $('p').css('font-size', '0.8em');
	$('.sub_content ul').css('font-size', '0.8em');
	$('h2').css('font-size', '2em');
	$('h2').css('font-size', '1.4em');
	$('.movie_left h3').css('font-size', '1.2em');
    return false;
  });
  
  //add extra class to last column in top nav 
  $("li.lv1").filter(':last').addClass("last_col");


  // remove extra span tags generated by php in 3rd level top nav
  $("li.lv3").each(function(){
		$(this).html($(this).html().replace(/<span>/g, ""));
		$(this).html($(this).html().replace(/<\/span>/g, ""));	
});
  
  //home page banner rotation
   $('#home_banners').innerfade({ speed: '2000', timeout: 5000, type: 'random_start', containerheight: '155px' });
   
   //home page lightbox stuff 
   $("a.lightBox").click(function(){
		var pageSize = getPageSize();
		$("#screen").css({
			'height': pageSize[1] + 'px',
			'opacity': '0.8'
		}).fadeIn(500);	
		$('#lightbox').fadeIn(500, function() {
				$('#videoArea').fadeIn(500);
				$('#lightbox a.closeBtn').fadeIn(500);
			});
		return false;						  	
});
   
   //home page close lightbox 
   $("a.closeBtn").click(function(){
   $('#videoArea').fadeOut(500);
	$('#lightbox a.closeBtn').fadeOut(500, function() {
		$('#screen').fadeOut(500);
		$('#lightbox').fadeOut(500);
	});
	return false;						  	
});
   
   //close by clicking outside the box 
   $("div#screen").click(function(){
	$('#videoArea').fadeOut(500);
	$('#lightbox a.closeBtn').fadeOut(500, function() {
		$('#screen').fadeOut(500);
		$('#lightbox').fadeOut(500);
	});
	return false;						  	
});
   
   //chat member listings float clear 
	$('div.member_info:nth-child(3n)').after('<div class="clear"></div>')
	
   //chat room download transcript link - prepend with green arrow graphic
    $('a.download_transcript').prepend('<img src="chat/images/download_arrow.gif" style="margin-bottom:-4px;">');
	
	//chat room weekly notes link - prepend with green arrow graphic
    $('a.weekly_notes').prepend('<img src="chat/images/download_arrow.gif" style="margin-bottom:-4px;">');
	
   //chat welcome page section collapse
    $('a.btn_collapse').live('click', function() {
   		$(this).parent('div.group_info_section_title').next('div.group_info_section').hide();
		$(this).replaceWith('<a href="#" class="btn_expand"><img src="chat/images/btn_expand.jpg"></a>');
		return false;
	});
	
	$('a.btn_expand').live('click', function() {
   		$(this).parent('div.group_info_section_title').next('div.group_info_section').show();
		$(this).replaceWith('<a href="#" class="btn_collapse"><img src="chat/images/btn_collapse.jpg"></a>');
		return false;
	});
	
	
	//add green arrow to notes link on chat groups page
    $('a.cg_notes').prepend('<img src="../chat/images/download_arrow.gif" style="margin-bottom:-4px;">');


	//change avatar choices float clear 
	$('img.avatar_choice:nth-child(11n)').after('<div class="clear"></div>')
   
});	
