﻿var popupTimeout;

$(document).ready(function() {
    
    RenderHomepageFlash();
    FixHtmlImages();
    $("div").ifixpng();
    $("img").ifixpng();
   
});

function RenderHomepageFlash()
{
    var flashvars = {};
	flashvars.xmlPath = "/xml/homepage-flash.xml";

    var params = {};
    params.quality = "high";
    params.wmode = "opaque";
    params.bgcolor = "#000000";
    params.scale = "showall";
    params.align = "middle";
    params.allowFullScreen = "true";
    		
    var attributes = {};
    attributes.id = "Main";
    		
    swfobject.embedSWF("/flash/Main.swf", "homepage-flash-container", "100%", "435px", "10.0.0", "/flash/expressInstall.swf", flashvars, params, attributes);    

    $("div#homepage-html-content-container").css("display", "block");
}

function FixHtmlImages()
{
    $("div#homepage-html-content-container img").ifixpng();
}


function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
    
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function cookieExists(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1, c.length);
            if (c.indexOf(nameEQ) == 0)
                return true;
        }
    }
    return false;
}

function eraseCookie(name) {
    createCookie(name, "", -1);
}


function SetupUnstoppableTourSplash() {  
    if (cookieExists('unstoppabletour')) {
        return;
    }
    createCookie('unstoppabletour', 'cookiecreated', 2);  
    $('div#unstoppable-tour-splash').dialog({
        modal: true,
        height: 607, //598,//585, //640, //668,
        width: 638, //740, //920,
        draggable: false,
        resizable: false,
        open: function() {
            $('.ui-dialog-titlebar').hide();
            $('.ui-widget-content').not('#unstoppable-tour-splash').css({ 'background': 'none', 'border': '0' });
            $('img#unstoppable-splash-close').hover(function() {
                $(this).attr('src', '/images/unstoppable/unstoppable-divclose-btn-on.png');
            }, function() {
                $(this).attr('src', '/images/unstoppable/unstoppable-divclose-btn-off.png');
            });
        }
    });

    $('img#unstoppable-splash-close').click(function() {
        $('div#unstoppable-tour-splash').dialog('close');
        pageTracker._trackEvent('Unstoppable-Tour', 'Close', 'EAS.com Home Page Div State Video');
        s.tl(this, 'o', 'Unstoppable EAS Home Page Div State Video Close');
    });

    popupTimeout = setTimeout(function() { $('div#unstoppable-tour-splash').dialog('close'); }, 30000);
    
}


