var containerId = new Array("#main", "#footer");
var maxSize = 1280;
var minSize = 950;
var margin = 50;

$(window).load(function() {
	$('#page-loading').css('display', 'none');
	resizeBackground();
});

$(window).resize(function() {
	resizeBackground();
});

function isIE(){
	return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
}

function resizeBackground(){
	var	windowWidth = 0,
		marginTotal = margin * 2;
	var	newSize, width;
	
	if (parseInt(navigator.appVersion) > 3){
		if (navigator.appName == "Netscape")
			windowWidth = window.innerWidth;
		if (navigator.appName.indexOf("Microsoft") != -1)
			windowWidth = document.body.offsetWidth;
	}

	$('#cse-search-box').hide(600);
	
	if($('#main').outerWidth() + marginTotal < windowWidth){ //make larger
		if(windowWidth > maxSize)
			newSize = maxSize;
		else
			newSize = windowWidth - marginTotal;
	}
	else if($('#main').outerWidth() > windowWidth){ //make smaller
		if(windowWidth < minSize)
			newSize = minSize;
		else
			newSize = windowWidth - marginTotal;
	}
	
	$('#main').animate({height: getDocHeight()});

	if(!isNaN(newSize)){
		$('#main').animate({width: newSize}, 750);
	}

	if(!isIE())
		$('#footer').animate({width: newSize}, 750);
}

function getDocHeight(){
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

function getDomain(url){
	var nodes = url.split('/');
	
	if(nodes.length > 2 && nodes[0].substring(0, 4) == 'http')
		return nodes[2];

	return null;
}

