// JavaScript Document
jQuery(document).ready(function($) {
	var wwidth = $(window).width();
	if( wwidth < 1250 ){
		$('body').css({'margin-left' : '-150px', 'margin-right' : '-150px'});	
	}
	//Search Box
	$('#s').focusin(function(){
		var sv = $('#s').attr('value'); 
		if( sv == 'Search' ){ 
			$(this).attr('value', '');
		}
	});
	$('#s').focusout(function(){
		var sv = $('#s').attr('value'); 
		if( !sv ){ 
			$(this).attr('value', 'Search');
		}
	});
	$("#Content h1").wrapInner('<span />');
	$("#SwingingGirl").hover(function(){
		SwingIt();
	}, function(){});
	
	function SwingIt(delayT){
		$("#SwingingGirl")
		.animate({
			marginLeft: '-=8',
			marginTop: '-=1'
		}, 500, 'swing', function(){})
		.animate({
			marginLeft: '+=16',
			marginTop: '+=1'
		}, 500, 'swing', function(){})
		.animate({
			marginLeft: '-=8'
		}, 500, 'swing', function(){})
		.delay(delayT);	
	}
	function PeriodicSwing(){
		var maxT = 5;
		var delayT = 2000;
		for(i=0;i<=maxT;i++){
			SwingIt(delayT);
		}
	}
	PeriodicSwing();
	
	$('nav li').hover(function(){
		$(this).addClass('hover');
		
	}, function(){
		$(this).removeClass('hover');
	});
	$('nav li li a').hover(function(){
			$(this).parent().parent().parent().addClass('hover');
			$(this).parent().parent().parent().parent().parent().addClass('hover');
		}, function(){
			$(this).parent().parent().parent().removeClass('hover');
			$(this).parent().parent().parent().parent().parent().removeClass('hover');
	});
	
	$('#HomeHeadliners div, #HomeFtBoxes div').css('cursor', 'pointer').hover(function(){
			var title = $(this).find('a').attr('title');
			$(this).attr('title', title);
			$(this).find('h1').addClass('hover');
	},function(){
			$(this).find('h1').removeClass('hover');														 
	}).click(function(){
		window.location = $(this).find('a').attr('href');
	});
	
	function FooterStick(){
		var wH = parseInt($(window).height());
		var dH = parseInt($('#FooterPattern').height());
		//alert( wH + ' > ' + dH + '?');
		if( wH > dH ){
			var cH = wH - 226 + 'px';
			//alert(cH);
			$('#Container').css({'height' : cH });
			//$('#Footer').css({'position' : 'absolute', 'bottom':'0', 'left':'0'});	
		}
	}
	FooterStick();
});
