/*$("#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 enter_fname_def; 
var enter_lname_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);       
        }
    });
	
	
    enter_fname_def = $("#headerFNameField").attr("value"); 
	$("#headerFNameField").focus(function()
    {        
        if ($("#headerFNameField").attr("value") == enter_fname_def)        
        {            
            $("#headerFNameField").attr("value", "");        
        }          
    });
    $("#headerFNameField").blur(function()
    {        
        if ($("#headerFNameField").attr("value") == "")        
        {            
            $("#headerFNameField").attr("value", enter_fname_def);        
        }
    }); 
	
    enter_lname_def = $("#headerLNameField").attr("value"); 
	$("#headerLNameField").focus(function()
    {        
        if ($("#headerLNameField").attr("value") == enter_lname_def)        
        {            
            $("#headerLNameField").attr("value", "");        
        }          
    });
    $("#headerLNameField").blur(function()
    {        
        if ($("#headerLNameField").attr("value") == "")        
        {            
            $("#headerLNameField").attr("value", enter_lname_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 && $("#headerFNameField").attr("value") != enter_fname_def && $("#headerLNameField").attr("value") != enter_lname_def)
        {
            
        var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
 
        var emailaddressVal = $("#headerEmailField").val();
        if(emailaddressVal == '') {
        alert("An email address is required!")
        }
 
        else if(!emailReg.test(emailaddressVal)) {
        alert("A valid email address is required!")
        }
        
        
        
        
			else if($("#headerFNameField").attr("value") == '')
            {
                alert("An First Name is required!")
                //No First Name :(
            }
			else if($("#headerLNameField").attr("value") == '')
            {
                alert("An Last Name is required!")
                //No Last Name :(
            }
            else
            {   
                $.post("subscribe.php", { name: $('#headerEmailField').attr("value")
                                  ,fname: $("#headerFNameField").attr("value") 
                                  ,lname: $("#headerLNameField").attr("value") }
                                      ,function(){ $("#emailFormDD").slideUp("fast"); $('#headerSignupForm').hide(); $('#headerThankYou').show();} 
                      );                      
            }
        }    
        else
        { 
        	alert("All fields are required!")                       
        }
        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;
    }
}
