//splash.js

$(document).ready(function()
{
     
     // check for presence of the splash cookie
    var autoplay = "true";
    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("flashautoplay=") == 0) 
        {       autoplay="false";
                break;
        }
    }
    //if it is not found, infer that autoplay=true then set a new cookie to expire at midnight
    if ( autoplay == "true")
    {
        var date = new Date();
        date.setTime(date.getTime()+(24*60*60*1000));
        date.setHours(0);
        date.setMinutes(0);
        var expires = "; expires="+date.toGMTString();
        document.cookie = "flashautoplay=false"+expires+"; path=/";   
    } 

    
    // create the wrapper for the swf file with the values above
    // assume swfobject
    var flashvars = {
        imagepath: Drupal.settings.splashsettings.imagepath,
        videopath: Drupal.settings.splashsettings.videopath
    };
    var params = {
        play: autoplay
    };


    swfobject.embedSWF(Drupal.settings.splashsettings.player, 
                Drupal.settings.splashsettings.id, 
                Drupal.settings.splashsettings.width, 
                Drupal.settings.splashsettings.height, 
                "9.0.0"
                ,"", 
                flashvars, params);
    


});


