﻿var headerHeight = 121;
var footerHeight = 110; 
var pageTimer = null;
var resizeTimer = null;
	    
$(document).ready(function(){  

    //Set promo close function
    $('#promoClose').click(function(){
        $('#homePromo').hide();
    });
    
    //Check screen size on resize
/*
    $(window).resize(function(){
        //timer to wait for resize to be complete
        resizeFlash();
        if (resizeTimer) clearTimeout(resizeTimer);
        resizeTimer = setTimeout(resizeFlash, 100);
    });
               
    resizeFlash();
    pageTimer = setTimeout(resizeFlash, 200);
    
*/
});

function resizeFlash(){
    if($('#flashMovie').height()>40){
        //Safety check for slow load ie6
        if (pageTimer) clearTimeout(pageTimer);    
        
        //Set dark bg
        if($('.homeContent').length<1){ 
//            $(document.body).css('background', '#272624');
            
            //$('#maxHeight').css('height','auto');
            //$('#aspnetForm').css('height','auto');
        }
        
        //Check screen size
        var screenHeight = $(window).height();
        var screenWidth= $(window).width();
        
        if(screenHeight < 620) screenHeight = 620;    
	    //if(screenWidth < 974) screenWidth = 974;


	    var is_ie6 = ('ActiveXObject' in window && !('XMLHttpRequest' in window));
	    if (is_ie6) {
	        screenHeight += footerHeight;
	    };
	    
	    screenHeight -= (headerHeight + footerHeight);
    	
//	    $('#homeFlashContainer').css('height', screenHeight+'px');
	    $('#homeFlashContainer').css('height', 779+'px');

	    $('#homeFlashContainer').css('width', screenWidth-36+'px');
    	
    	
        $('#maxHeight').css('height','100%');
        $('#aspnetForm').css('height','100%');
        
        var footerY = screenHeight + headerHeight;

		reposition_promodiv(screenHeight);
    }
}

function reposition_promodiv(screenHeight){
    $('#promotion').css('margin-top',screenHeight-240);
}
