var firstresize = true;

function resizeFlash(){
	(function($){
		//alert("resizenormal" + document.location.toString());
		var footerheight = $('#footer').height() + parseInt($('#footer').css('paddingTop'), 10) + parseInt($('#footer').css('paddingBottom'), 10);
		var windowheight = $(window).height();
		var wrapper = $('#wrapper').height();
		var flashheight = windowheight - wrapper - footerheight;
		
		var urlstring = document.location.toString();
		if (urlstring.match('#/home') || (new String(window.location.hash).length==0)) {
			if (firstresize) {
				firstresize = false;
			} else {
				return flashheight;
			}
		}

		if (jQuery('embed, object').size() > 0) {

			if ($("#homepage").size() > 0) {
				//console.log("window height: " +  windowheight +"flash height: " + $('#flashcontent').height()+ "wrapper: " + wrapper + "footer height:" + footerheight);
				if (flashheight > 588) {
					$('#FlashContent, #flashcontent').css('height', parseInt(flashheight) + 'px');
					$('embed, object').attr('height', parseInt(flashheight));
					moveFooter();
					return flashheight;
				}
				else {
					$('#FlashContent, #flashcontent').css('height', 588 + 'px');
					$('embed, object').attr('height', 588);
					moveFooter();
					return 588;
				}
			}
			if ($('.fullFlash').size() > 0) {	
				if (flashheight > 550) {		
					$('#FlashContent, #flashcontent').css('height', parseInt(flashheight) + 'px');
					$('embed, object').attr('height', parseInt(flashheight));
					
					moveFooter();
					return flashheight;
				}
				else {
					$('#FlashContent, #flashcontent').css('height', 550 + 'px');
					$('embed, object').attr('height', 550);
					moveFooter();
					return 550;
				}
			}


		}
	})(jQuery)
}



function resizeFixedFlash(newmaxheight){
	(function($){
		//alert("resizecustom" + document.location.toString());
		
		var footerheight = $('#footer').height() + parseInt($('#footer').css('paddingTop'), 10) + parseInt($('#footer').css('paddingBottom'), 10);
		var windowheight = $(window).height();
		var wrapper = $('#wrapper').height();
		var flashheight = windowheight - wrapper - footerheight;
	
		if (jQuery('embed, object').size() > 0) {
			if ($('.fullFlash').size() > 0) {
				
			
				if (flashheight > newmaxheight) {
					$('#FlashContent, #flashcontent').css('height', parseInt(flashheight) + 'px');
					$('embed, object').attr('height', parseInt(flashheight));
					moveFooter();
					
					
					return flashheight;
				}
				else {
					$('#FlashContent, #flashcontent').css('height', newmaxheight + 'px');
					$('embed, object').attr('height', parseInt(newmaxheight));
					moveFooter();
					return newmaxheight;
				}
			}
			
			
		}
	})(jQuery)
}


function spawn(url, nameW, w, h, showScroll) 
{
	var scrollbars
	
	if ((typeof(showScroll) == "undefined") || (!showScroll))
	{
		scrollbars = 0
	}
	else
	{
		scrollbars = 1
	}
	if (navigator.appVersion.indexOf('4') != -1) 
	{
		// Vars for centering the new window on Version 4 Browsers
		x4 = screen.width/2-(w/2);
		y4 = screen.height/2-(h/2);
		//remove spaces from window name (for IE6)
		nameW = nameW.replace(/ /g, "");
		nameW = nameW.replace(/&/g, "");
		popwin = window.open(url, nameW, 'height='+h+',width='+w+',scrollbars='+scrollbars+',resizable=0,menubar=0,toolbar=0,status=0,location=0,directories=0,left='+x4+',top='+y4+'');
		
	} 
	else 
	{
		popwin = window.open(url, nameW, 'height='+h+',width='+w+',scrollbars='+scrollbars+',resizable=0,menubar=0,toolbar=0,status=0,location=0,directories=0,left=150,top=200');
	}
	if (popwin) {
		popwin.remote = self;
	}
}


jQuery(document).ready(function(){
	(function($){
		
		resizeFlash();
		moveFooter();
	})(jQuery)
});