/* On Page Load */
$(function(){
	resizeContent();
	$('#tweets').animate({bottom : '+=400'}, 1500, 'linear', function() {});
	$('#content').children('div:first').fadeIn();
});

/* On Window Resize */
$(window).resize(function() {resizeContent();});

function resizeContent() {
	$cT = 230;
	$cL = 130;
	$minW = 550;
	$minH = 330;
	$pR = 330;
	$wW = $(window).width();
	$wH = $(window).height();
	$nW = $wW - $cL - $pR;
	$nH = $wH - $cT - 90;
	$('#content').css('width',$nW);
	$('#content').css('height',$nH);
}

function switchSocial(selector) {
	if(selector == '#tweets') {
		if(!$('#tweets').hasClass('active')) {
			$('#facebookStream').animate({bottom : '-=400'}, 500, 'linear', function() {
				$('#facebookStream').fadeOut('fast');
				$('#tweets').fadeIn('fast', function() {
					$('#tweets').animate({bottom : '+=400'}, 1000, 'linear', function() {});
					$('#facebookStream').removeClass('active');
					$('#tweets').addClass('active');
				});
			});
		}
	}
	else if(selector == '#facebookStream') {
		if(!$('#facebookStream').hasClass('active')) {
			$('#tweets').animate({bottom : '-=400'}, 500, 'linear', function() {
				$('#tweets').fadeOut('fast');
				$('#facebookStream').fadeIn('fast', function() {
					$('#facebookStream').animate({bottom : '+=400'}, 1000, 'linear', function() {});
					$('#tweets').removeClass('active');
					$('#facebookStream').addClass('active');
				});
			});
		}
	}
}

function addToFavorites() {
	if(document.all) {window.external.AddFavorite('http://www.digitaltrifecta.com', 'Digital Trifecta');}
	else if(window.sidebar) {window.sidebar.addPanel('Digital Trifecta', 'http://www.digitaltrifecta.com','');}
	else {alert('Not Supported');}
} 

function loadPage(page) {
	$cur = $('#content').attr('ref');
	if($cur != page) {
		$('#content').children('div:first').fadeOut('slow',function() {
			$('#content').children('div:first').remove();
			$.ajax({type:"POST",url: page+".php",data: {},success: function(msg){
				$('#content').html(msg).attr('ref',page);
				$('#content').children('div:first').fadeIn();
		   }});
		});
	}
}
