/*$("#promoExpand").click(function(){
  
  $("#promoSmall").hide();          
  $("#promoBox").animate( { width:"50%" }, { queue:false, duration:500 } );
  $("#promoLarge").fadeIn("fast");
});
$("#promoShrink").click(function(){
  $("#promoLarge").hide();  
  $("#promoBox").animate( { width:"250px" }, { queue:false, duration:500 } );
  $("#promoSmall").fadeIn("fast");
});    
*/
var enter_email_def; 
var video_loaded = false;
$(document).ready(function()
{    
    /*
    $("#emailFormDDClose").click(function()
    {        
        $("#emailFormDD").slideUp("fast");    
    });  
    */      
    enter_email_def = $("#headerEmailField").attr("value");        
    enter_search_def = $("#SearchForm_SearchForm_Search").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);       
        }
    });             
    $("#SearchForm_SearchForm_Search").blur(function()
    {        
        if ($("#SearchForm_SearchForm_Search").attr("value") == "")        
        {            
            $("#SearchForm_SearchForm_Search").attr("value", enter_search_def);       
        }
    });
    $("#SearchForm_SearchForm_Search").focus(function()
    {        
        if ($("#SearchForm_SearchForm_Search").attr("value") == enter_search_def)        
        {            
            $("#SearchForm_SearchForm_Search").attr("value", "");        
        }                                         
    });     
        
    $("#headerSignupForm").submit(function() 
    {
        if ($("#headerEmailField").attr("value") != enter_email_def)
        {
            
            if($("#headerEmailField").attr("value") == '')
            {
                alert("An E-mail Address is required!")
                //No Email Address :(
            }
            else
            {   
                $.post("subscribe.php", { name: $('#headerEmailField').attr("value")}
                                      ,function(){ $("#emailFormDD").slideUp("fast"); $('#headerSignupForm').hide(); $('#headerThankYou').show();} 
                      );                      
            }
        }    
        else
        {                        
        }
        return false;
        
    });    
    /*    
    $('#emailSubmit').click(function()
    {
        if ($("#headerEmailField").attr("value") != enter_email_def && $("#headerEmailField").attr("value") != '')
        {
            $.post("subscribe.php", { name: $('#signupEmailBottom').attr("value")}
                              ,function(){ $('#signupForm').hide(); $('#bottomThankYou').show();} 
              );    
        }
        return false;
    });    
    */
});

function playVideo(path)
{
    //alert("playingVideo");
    swfobject.embedSWF("/themes/agassigraf/flash/masterVideoPlayer.swf"
                        , "video", "100%", "100%", "9.0.0", "/assets/expressInstall.swf"
                        ,{path: path,skin: "/themes/agassigraf/flash/SkinOverPlaySeekStop.swf",closeButtonPath: '/themes/agassigraf/images/close.png', closeCallback: 'closeVideo',skinBackgroundColor: "0xCCCCCC",skinAutoHide: "true",autoPlay: "true", callback: "videoSize"}
                        ,{wmode: "opaque",allowscriptaccess:"always",scale: "noscale"}
                      ); 
    videoLoaded = true;
    $('#videoContainer').show();                         
    
}
function closeVideo()
{                             
    var duration = 500;
    var easing = 'linear';
    var callback = function(){swfobject.embedSWF("/themes/agassigraf/flash/masterVideoPlayer.swf"
                                            , "video", "100%", "100%", "9.0.0", "/assets/expressInstall.swf"
                                            ,"linear"
                                            ,{wmode: "opaque",allowscriptaccess:"always",scale: "noscale"}
                                            );
                                            $('#videoContainer').hide();
                                            $('#contentWrapper').show();};

    $('#videoContainer').css("background-image", "url()"); 
    $('#videoContainer').animate( { width: 1, height: 1 }, duration, easing, callback);   

}
function videoSize(width, height)
{    
    if(videoLoaded)
    {
        $('#contentWrapper').hide();        
        $('#videoContainer').css("background-image", "url(/themes/agassigraf/images/white_bg.png)"); 
        $('#videoContainer').animate( { width: width, height: height }, { queue:false, duration:500 } );
        videoLoaded = false;
    }
}