var imgpreload = new Image();
imgpreload.src = "/images/frontdoor.jpg";
var MM_contentVersion = 8;
var MM_FlashCanPlay = false;
var MM_plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( MM_plugin ) 
{
	var words = navigator.plugins["Shockwave Flash"].description.split(" ");
    for (var i = 0; i < words.length; ++i)
    {
	    if (isNaN(parseInt(words[i])))
	        continue;
	    var MM_PluginVersion = words[i]; 
    }
    MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
   && (navigator.appVersion.indexOf("Win") != -1)) {
    document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
    document.write('on error resume next \n');
    document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
    document.write('</SCR' + 'IPT\> \n');
}

Ext.onReady(function()
{
	
	//var afterTime = isAfterTime('200908030600');
	var afterTime = true;
	
    if ( MM_FlashCanPlay ) 
    {
		
		if(afterTime)
		{	
			swfobject.embedSWF('/flash/frontdoor.swf', 'homepage-flash', '940', '520', '7', null, null,
                           {'wmode': 'transparent'}); // wmode: transparent makes the top navigation appear above the movie
		}
		else
		{
        	swfobject.embedSWF('/flash/frontdoor-old.swf', 'homepage-flash', '940', '480', '7', null, null,
                           {'wmode': 'transparent'}); // wmode: transparent makes the top navigation appear above the movie
		}
    } 
    else
    {
        var imgmap = '<map name="frontdoormap">';
        imgmap += '<area shape="rect" coords="792,373,935,516" href="/join-us" />';
        imgmap += '<area shape="rect" coords="640,371,784,515" href="/ad-programs" />';
        imgmap += '<area shape="rect" coords="489,374,634,516" href="/how-it-works" />';
        imgmap += '<area shape="rect" coords="342,373,483,516" href="/map" />';
        imgmap += '<area shape="rect" coords="53,433,278,470" href="/contact">';
        imgmap += '</map>';
        imgmap += "<img src='/images/frontdoor.jpg' width='940' height='480' usemap='#frontdoormap' />'";
	    document.getElementById('homepage-flash').innerHTML = imgmap;
    }
});	

function popWin(url) {
	newwin = window.open(url,'demo','width=850,height=650,top=150,left=300,scrollbars=no,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no');
}

function isAfterTime(expireTime)
{
	// Time delay script
	// S. Partridge 
	// 2009.08.02
	// @expireTime = YYYYMMDDHHmm
	
	var now = new Date();
	var nowYear = now.getFullYear();
	var nowMonth = now.getMonth() + 1;
	var nowDay	= now.getDate();
	var nowHour = now.getHours();
	var nowMin	= now.getMinutes();
	
	if(nowMonth < 10)
	{
		nowMonth = '0' + nowMonth;	
	}
	
	if(nowDay < 10)
	{
		nowDay = '0' + nowDay;	
	}
	
	if(nowHour < 10)
	{
		nowHour = '0' + nowHour;
	}
	
	if(nowMin < 10)
	{
		nowMin = '0' + nowMin;	
	}
	
	var nowFull = nowYear + nowMonth + nowDay + nowHour + nowMin;
	
	//alert(nowDay + ' ' + nowFull + ' = ' + expireTime);
	
	if(nowFull > expireTime)
	{
		return true;
	}
	else
	{
		return false;
	}
	
	
}
