var enter_email_def; 
$(document).ready(function()
{    
	$('#flashMarquee img').fadeIn();
    $("ul.sf-menu").superfish({ 
            delay:       800
        });    
    
    $("#emailFormDDClose").click(function()
    {        
        $("#emailFormDD").slideUp("fast");    
    });        
    enter_email_def = $("#headerEmailField").attr("value");        
    $("#headerEmailField").focus(function()
    {        
        if ($("#headerEmailField").attr("value") == enter_email_def)        
        {            
            $("#headerEmailField").attr("value", "");        
        }        
        $("#emailFormDD").slideDown("fast");    
    });
    $("#headerEmailField").blur(function()
    {        
        if ($("#headerEmailField").attr("value") == "")        
        {            
            $("#headerEmailField").attr("value", enter_email_def);        
        }
    }); 
    $(".signupEmail").focus(function()
    {        
        if ($(".signupEmail").attr("value") == enter_email_def)        
        {            
            $(".signupEmail").attr("value", "");        
        }        
    });
    $(".signupEmail").blur(function()
    {        
        if ($(".signupEmail").attr("value") == "")        
        {            
            $(".signupEmail").attr("value", enter_email_def);                        
        }                           
    });        
    $('#headerEmailSubmit').click(function()
    {
        if ($("#headerEmailField").attr("value") != enter_email_def)
        {
        $.post("subscribe.php", { name: $('#headerEmailField').attr("value")
                                  ,events: $("#headerEmailEvents").attr("value") 
                                  ,volunteer: $("#headerEmailVolunteer").attr("value") 
                                  ,news: $("#headerEmailNews").attr("value") 
                                  ,legislative: $("#headerEmailLegislative").attr("value") 
                                }
                              ,function(){ $("#emailFormDD").slideUp("fast"); $('#headerSignupForm').hide(); $('#headerThankYou').show();} 
              );                      
        }
        return false;
        
    });
    $('#emailSubmit').click(function()
    {
        if ($(".signupEmail").attr("value") != enter_email_def)
        {
            $.post("subscribe.php", { name: $('#signupEmailBottom').attr("value")}
                              ,function(){ $('#signupForm').hide(); $('#bottomThankYou').show();} 
              );    
        }
        return false;
    });    
    
    $('#flashMarquee').cycle();
    $("#video").dialog({ autoOpen: false, width: 600, modal: true, show: 'scale',  resizable: false, open: stopMarquee, close: stopVideo });         
    $("#slideshow").dialog({ autoOpen: false, width: 875, height: 600, modal: true,  resizable: false });         
});

function openVideoDialog(movieLocation)
{
	var flashvars = {
		skin: "/themes/agassi/flash/whiteSkinOverPlayStopSeekMuteVol.swf",
		callback: "videoSize",
		path: movieLocation
	};
	
	//console.log(movieLocation);
	
	var params = { allowscriptaccess: "always", scale: "noscale", wmode: "transparent" }
	
    swfobject.embedSWF("/themes/agassi/flash/masterVideoPlayer.swf", "videoPlayer", "500", "300", "8.0.0", "/assets/expressInstall.swf", flashvars, params);
    $("#video").dialog('open'); 
    //setVideo(movieLocation);    
    return false;
}

function videoSize(width, height)
{
	var message = "video size called " + width + "x" + height;
	//console.log(message);
	$('#videoPlayer').css('width', width);
	$('#videoPlayer').css('height', height);
	$('#video').css('width', width);
	$('#video').css('height', height);
	$('#video').dialog( 'option' , 'width' , width+36 );
}

function openSlideshowDialog(xmlLocation, imageLocation)
{         
    swfobject.embedSWF("/themes/agassi/flash/slideshow.swf?xmlPath=" + xmlLocation + "&prefixPath=" + imageLocation, "slideshowPlayer", "848", "504", "8.0.0", "/assets/expressInstall.swf", {}, {allowscriptaccess:"always"});
    $("#slideshow").dialog('open'); 
    //setVideo(movieLocation);    
}
function thisMovie(movieName) 
{
    if (navigator.appName.indexOf("Microsoft") != -1) 
    {
        return window[movieName];
    } 
    else 
    {
        return document[movieName];
    }
}
function setVideo(value) 
{
    thisMovie("videoPlayer").setMediaPath(value);
} 
function stopMarquee()
{
    try
    {
        thisMovie("flashMarquee").setStop('null');
    }
    catch(err)
    {
    }
}
function stopVideo()
{
    swfobject.embedSWF("/themes/agassi/flash/media_560_335.swf", "videoPlayer", "560", "335", "8.0.0", "/assets/expressInstall.swf", {}, {allowscriptaccess:"always"});
    return false;
}