//AFTER DOM FINISHED THEN RUN THIS
$(document).ready(function() {

	//var footerHeight = $("#footer").height();
	//var new_top=($(window).height()-footerHeight);
	//$('#footer').css({top:new_top+'px'});

	//WINDOW RESIZE EVENT
	
	$(window).resize(function(){
		var windowHeight = $(window).height();
		if(windowHeight>800){
			adjust_footer();
		}
	});
	
    $(document).pngFix(); 
    
	//$('#content').css({position:'relative'});//hack for wmode bug on FF
});


function getHeightFromFlash(flashheight){
	//alert("flashheight:"+flashheight);
	var space = 50;
	var headerHeight = $("#header").height();
	var menuHeight = $("#menu").height();
	var footerHeight = $("#footer").height();
	var totalHeight = headerHeight + menuHeight + flashheight + footerHeight + space;
	var windowHeight = $(window).height();
	var totoContentHeight = 0;
	//alert("getHeightFromFlash ::"+totalHeight+" - "+windowHeight);
	if(flashheight >= 530){
		if( totalHeight > windowHeight){
			//$("#content").height(flashheight);
			$("#flashcontent").height(flashheight+space);
			$("#footer").css('top', (headerHeight + menuHeight + flashheight + space)+'px').fadeIn();	
		}else{
			$("#content").height(flashheight+space);
			$("#flashcontent").height(flashheight+space);
			adjust_footer();
		}
	}else{
		//$("#content").height(530);
		$("#flashcontent").height(530);
		//alert(windowHeight-footerHeight-headerHeight-menuHeight);
		if((windowHeight-footerHeight-headerHeight-menuHeight)>=530){
			$("#footer").css('top', (windowHeight-footerHeight)+'px').fadeIn();	
		}else{
			$("#footer").css('top', (headerHeight + menuHeight + 530+space)+'px').fadeIn();	
		}
		
	}
}

function adjust_footer(){
	var headerHeight = $("#header").height();
	var menuHeight = $("#menu").height();
	var footerHeight = $("#footer").height();
	var new_top=Number(($(window).height()-footerHeight));
	var contentHeight = $("#flashcontent").height();
	var totalContentHeight = Number(contentHeight+headerHeight+menuHeight);
	//alert("adjust_footer ::"+totalContentHeight+" - "+new_top + " - " + footerHeight);
	if(new_top>totalContentHeight){
		//$("#footer").css('display','block').animate({opacity:1, top:new_top+'px'});
		$("#footer").css('top',new_top+'px').fadeIn();	
	}else{
		$("#footer").css('top',totalContentHeight+'px').fadeIn();	
	}
}

function populateImages(){
	$('#pics').cycle({ 
		fx:    'fade', 
		speed:  2500,
		timeout: 6000
	 });
}