var index = 
{
	init: function()
	{
		this.resize(false);
	},
	resize: function(isLoaded)
	{
		isLoaded = (isLoaded === false) ? false : true;
		var b = $("body").width();
		if(!this.resized && b < this.cutoff && b > this.tooSmall)
		{
			var navigationWidth = "150px";
			var midWidth = "500px";
			var sideWidth = "476px";
			var contentWidth = "1225px";

			$("body").css("font-size", "0.7em");

			wait( function() 
			{
				$("div#social-middle").css("width", sideWidth);
				$("div#social-navigation").css("width", sideWidth);
				wait( function()
				{
					$("div#social div#social-middle div#social-content div h3").css("width", "300px");
					$("div#social div#social-middle div#social-content div h3").css("margin-top", "20px");
					$("div#social div#social-middle div#social-content div p").css("width", "300px");
					$("img").each( function()
					{
						$(this).css("width", ($(this).width()*.692) + "px");
					});
					$("div#social-content img").each( function()
					{
						$(this).css("height", ($(this).height()*.692) + "px");
					});
				});
			});
			
			$("div#top-bar-middle ul li a").css("font-size", "1.0em");
						
			$("div#article h1").css("width", "245px");

			$("div#left-gradient").css("width", "50px");
			$("div#logo").css("margin", "0px 0px 0px -17px");
			$("div#logo img").css({width:"300px"});
			$("div#navigation-middle").css("width" , navigationWidth);
			$("div#navigation-middle li a").css("width" , parseInt(navigationWidth)+10+"px");
			$("div#navigation-middle li ul li a").css("width" , parseInt(navigationWidth)-10+"px");
			$("div#navigation-middle li ul li").css("width" , parseInt(navigationWidth)-10+"px");
			$("div#navigation-middle ul").css("width", parseInt(navigationWidth)-16+"px");
			$("ul.navigation_level_1").css("width" , parseInt(navigationWidth)-30+"px");

			$("div#content").css("width", contentWidth);

			$("div#center-column").css("width", midWidth);
			$("div#sponsor-banner").css({width:midWidth, overflow:"hidden"});

			$("div#slideshow").html("");
			var percent = 0.84;
			this.makeSlideshow(this.currentSlideshow, 550*percent, 398*percent);
		}
		else
		{
			if(b < this.tooSmall)
			{
				$("#social-holder").remove();
				$("#slideshow").remove();
				$("#content").css("width", "992px");
			}
		}
		this.resized = true;
	},
	currentSlideshow: false,
	makeSlideshow: function(filePath, width, height)
	{
		if(this.currentSlideshow === false) this.currentSlideshow = filePath;
		wait( function()
		{
			width = width != undefined ? width : 550;
			height = height != undefined ? height : 398;
			var writeID = "slideshow";
			XMLFlashSlideshow_v3(
			{
				id: writeID,
				swf: 'http://www.pallensmith.com/assets/flash/v3flashvideoslideshow/slideshow.swf',
				w: width.toString(),
				h: height.toString(),
				redirect: '',
				usePreloader: 'true',
				xml: index.currentSlideshow,
				preventCache: 'true',
				disableMultipleXML: 'false',
				initXML: ''
			});

		}, "http://www.pallensmith.com/assets/flash/v3flashvideoslideshow/slideshow.js");
	},
	cutoff: 1550,
	tooSmall: 1050,
	resized: false
}






var margeContainer = "marge-movie";
var margeContainerJQ = $("#marge-mask").next();
var marge = true;// : false;
if(marge === true) { $("object").each( function() { $(this).hide(); });		$("embed").each( function() { $(this).hide(); }); }


function closeFlashMovie()
{
	$("object").each( function() { $(this).show(); });
	$("embed").each( function() { $(this).show(); });
	$("#marge-container").html("");
	$("#marge-container").animate({opacity:"hide"}, 500, function() { $(this).remove(); });
	$("#marge-mask").animate({opacity:"hide"}, 500, function () { $(this).remove(); });
}


function hideMargeMask()
{
	wijet.noop();
}


function makeMarge()
{
	if($("#marge-mask").next().length == 1)
	{	
		var extra = 1.1;
		$("object").each( function() { $(this).hide(); });
		$("embed").each( function() { $(this).hide(); });
		var pageWidth = $("#marge-mask").width();
		var pageHeight = $("#marge-mask").height();
		var mWidth = 900;
		var mHeight = 700;
		var factor = pageHeight / mHeight;
		var newWidth = Math.round(mWidth * factor * extra);
		var newHeight = Math.round(pageHeight * extra);
		$("#marge-container").css({width:newWidth+"px", height:newHeight+"px"});
		swfobject.embedSWF("http://www.pallensmith.com/assets/images/marge-takeover/marge-takeover2.swf", margeContainer, newWidth.toString(), newHeight.toString(), "9.0.0");
	}
	
}
