// PCToday Dynamic Weather Header
$(document).ready(function(){
						   
	// clear out calendar link
	$('.calendar').children('a').remove();
	
	// remove value onclick
	$('#searchField').click(function(){$(this).attr('value','')});
	
	// fix up summaries...
	$('.summaryContainer a img, .summaryContainer img').addClass('lfloat');
	$('.summaryContainer a img[src*="/cgi-bin"]').removeClass('lfloat');
	$('span').removeAttr('style');
	$('.summaryContainer a img').parent('a').attr('rel','box');
	$('.summaryContainer a img[src*="/cgi-bin"]').parent('a').removeAttr('rel');
	
	// article pages ...
	$('.article img[align=right]').addClass('rfloat').removeAttr('align');
	$('.article img[align=left]').addClass('lfloat').removeAttr('align');
	
	// load weather graphic
	$('#weather').load('http://www.pct.edu/pctoday/includes/1.0/weather.asp',function(we){
		$(this).css({'background':we,'opacity':'0'}).animate({'opacity':'1'});
		$(this).html(' ');
		$('.article + .f50').css({'height':'auto'}); //temporary IE fix for footer floating over .f50
	});
	
	// widgets
	$('.tabs').css({'zIndex':'10'});
	$('.tabs li:first > a, .tabs li:last > a').css({'background':'url(/cgi-bin/images/nav_hide.gif) right center no-repeat','paddingRight':'15px','cursor':'pointer'}).removeAttr('href');
	
	// weather widget
	$('.tabs li:first a').each(function(){
		
		$('.tabs li:first a').toggle(function(){
			$(this).css({'background':'url(/cgi-bin/images/nav_up.gif) right center no-repeat'});
			$('#weather').append('<div id="wi0"></div>');
			$('#wi0').css({'width':'19.5%','background':'#fff','opacity':'.5','position':'absolute','bottom':'0','left':'0','zIndex':'0','filter':'alpha(opacity=50)'});
			$('#wi0').animate({'height':'140px'});
			loadWeather();
		},function(){
			$(this).css({'background':'url(/cgi-bin/images/nav_hide.gif) right center no-repeat'});
			$('#wi0').animate({'height':'0'},function(){$(this).remove();});
		});
	});
	
	//Photo Galleries
	$('.tabs li:last a').each(function(){
		$('.tabs li:last a').toggle(function(){
			$(this).css({'background':'url(/cgi-bin/images/nav_up.gif) right center no-repeat'});
			$('#weather').append('<div id="wi4"></div>');
			$('#wi4').css({'width':'19.5%','background':'#fff','opacity':'.6','position':'absolute','bottom':'0','right':'5px','zIndex':'0','filter':'alpha(opacity=60)'});
			$('#wi4').animate({'height':'70px'});
			loadGallery();
		},function(){
			$(this).css({'background':'url(/cgi-bin/images/nav_hide.gif) right center no-repeat'});
			$('#wi4').animate({'height':'0'},function(){$(this).remove();});
		});
	});
	
	//$('.summaryContainer a img').css({'border':'1px solid #f00'});
	$(".summaryText a[rel^='box'], .boxgallery a").each( function (){initbox(this);});
});

function loadWeather(){
	$('#wi0').load('http://www.pct.edu/pctoday/includes/1.0/weatherGadget.asp', function(){
		//$('table',this).addClass('compact').css({'margin':'0 0 25px 0','fontSize':'9px','border':'none'}).children('tbody').children('tr').children('td').css({'padding':'0'})
	});
}
function loadGallery(){
	$('#wi4').load('http://www.pct.edu/pctoday/includes/1.0/galleryGadget.asp', function(){
		$('#wi4').css({'textAlign':'center'});
		$('#wi4 h5 ').css({'padding':'0 5px'});
		$('#wi4 ul ').css({'padding':'0 10px','listStyleType':'none'});
		$('#wi4 ul li').css({'fontSize':'11px','paddingBottom':'3px'});
	});
}