var enter_email_def; 
var enter_fname_def; 
var enter_lname_def;
$(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;
        
    });
    
});

function playSlideshow(path)
{                        
    var width = '700px';
    var height = '416px';
    
    swfobject.embedSWF("/themes/agassiventures/flash/slideshow.swf"
                        ,"slideshow", width, height, "9.0.0", "/assets/expressInstall.swf"
                        ,{path: path, closeButtonPath: '/themes/agassiventures/images/close.png', closeCallback: 'closeSlideshow',closeButtonX: '750',closeButtonY: '45'}
                        ,{wmode: "opaque",allowscriptaccess:"always",scale: "noscale"}
                      );

    $('.slideshowThumb').hide();                 
    $('#slideshowContainer').animate( { width: width, height: height }, { queue:false, duration:500 } );                      
    SlideshowLoaded = true;
    
}
function closeSlideshow()
{                             
    var duration = 500;
    var easing = 'linear';
    var callback = function(){swfobject.embedSWF("/themes/agassiventures/flash/slideshow.swf.swf"
                                            , "Slideshow", "100%", "100%", "9.0.0", "/assets/expressInstall.swf"
                                            ,"linear"
                                            ,{wmode: "opaque",allowscriptaccess:"always",scale: "noscale"}
                                            );
                                            $('#slideshowContainer').hide();                                            
                                            $('.slideshowThumb').show(); 
    };

    $('#slideshowContainer').css("background-image", "url()"); 
    $('#slideshowContainer').animate( { width: 1, height: 1 }, duration, easing, callback); 
}

function playVideo(path)
{                      
    swfobject.embedSWF("/themes/agassiventures/flash/masterVideoPlayer.swf"
                        , "video", "100%", "100%", "9.0.0", "/assets/expressInstall.swf"
                        ,{path: path,skin: "/themes/agassiventures/flash/SkinOverPlaySeekStop.swf",closeButtonPath: '/themes/agassiventures/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/agassiventures/flash/masterVideoPlayer.swf"
                                            , "video", "100%", "100%", "9.0.0", "/assets/expressInstall.swf"
                                            ,"linear"
                                            ,{wmode: "opaque",allowscriptaccess:"always",scale: "noscale"}
                                            );
                                            $('#videoContainer').hide();                                            
                                            $('.videoThumb').show(); 
    };

    $('#videoContainer').css("background-image", "url()"); 
    $('#videoContainer').animate( { width: 1, height: 1 }, duration, easing, callback); 
}
function videoSize(width, height)
{                                
    if(videoLoaded)
    {
        $('.videoThumb').hide();                 
        $('#videoContainer').animate( { width: width, height: height }, { queue:false, duration:500 } );
        videoLoaded = false;
    }
}
