$(document).ready(function () {
/* This is the annimation effect for the homepage  
   floralBk = function () {
      $('#FMA-floral').fadeOut(900);
   }

   carpetBk = function () {
      $('#FMA-carpet').fadeIn(1800);
   }

   beauTxt = function () {
      $('#FMA-btext').fadeIn(2200).delay(2800).fadeOut(800);
   }

   stainTxt = function () {
      $('#FMA-stext').fadeIn(1600).delay(2300).fadeOut(800);
   }

   fmaLanding = function () {
      $('#FMA-landing').fadeIn(1200);
   }

   setTimeout('beauTxt()', 600);
   setTimeout('stainTxt()', 1800);
   setTimeout('floralBk()', 2500);
   setTimeout('carpetBk()', 2600);
   setTimeout('fmaLanding()', 5900);
*/
/*
       $('.slides').cycle({
        fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
        pause: 1,
        speed: 2000,
        timeout: 4000,
        autostop: 2
    });
*/
    $('div.desc').hover(function () {
        $(this).addClass('detailed-desc');
        $(this).removeClass('desc');
        $(this).animate({ "top": "-=90px" }, "fast");
    },
	function () {
	    $(this).animate({ "top": "+=90px" }, "fast", function () {
	        $(this).removeClass('detailed-desc');
	        $(this).addClass('desc');
	    });
	});


	// This is the start of the Always FMA script

	$('#FMA-sceneOne .sceneBkrnd').delay(3400).animate({
	    opacity: 0
	}, 1500, 'easeOutQuad', function () {
	   sceneTwoShort();
	});

$('#frame1-learnMore').delay(3400).animate({opacity: 0});

});

//sceneTwoShort

sceneTwoShort = function () {
    $('#blur-longLeft').animate({
        left: '+=410',
        opacity: 0
    }, {
        duration: 500,
        specialEasing: {
            left: 'linear',
            opacity: 'easeInQuad'
        }
    });

    $('#FMA-sceneTwo #masterpiece-with').animate({
        left: '+=138',
        width: '288'
    }, {
        duration: 800,
        specialEasing: {
            left: 'easeOutQuad',
            width: 'swing'
        }
    });
    $('#blur-longRight').delay(750).animate({
        left: '-=400',
        opacity: 0
    }, {
        duration: 400,
        specialEasing: {
            left: 'linear',
            opacity: 'easeInQuad'
        }
    });

    $('#FMA-sceneTwo #with-gallery').delay(700).animate({
        left: '-=485',
        width: '435'
    }, {
        duration: 800,
        specialEasing: {
            left: 'easeOutQuad',
            width: 'swing'
        },
        complete: function () {

            $('#FMA-sceneThree').delay(3000).animate({
                opacity: 1
            }, 1500, 'easeInQuad', function () {
                
            });

           // setTimeout('sceneThreeShort()', 3000);


        }
    });


};
/*

sceneThreeShort = function () {
    $('#FMA-sceneTwo').animate({
        opacity: 0
    }, 1500, 'easeOutQuad', function () {

    });


};

*/





// sucky text first scene 1 function
oops = function () {

    $('#blur').css({
        top: '200px',
        left: '905px',
        opacity: '1'
    }).delay(1000).animate({
        left: '-=80',
        opacity: 0
    }, {
        duration: 500,
        specialEasing: {
            left: 'linear',
            opacity: 'easeInQuad'
        }
    });

    $('#oops').delay(1000).animate({
        width: '320',
        left: '-=402'
    },
        { duration: 800,
            specialEasing: {
                left: 'easeOutQuad',
                width: 'swing'
            },
            complete: function () {

                $('#FMA-sceneOne .carpet img').delay(300).animate({
                    left: '-=115',
                    top: '+=210'
                }, 1500, 'easeOutQuad' )


            }
        });

}


// Sick version with the spill first then the oops text
oops2 = function () {

    $('#FMA-sceneOne .carpet img').delay(450).animate({
        left: '-=115',
        top: '+=210'
    }, 1000, 'easeOutQuad', function () {

        $('#blur').css({
            top: '200px',
            left: '905px',
            opacity: '1'
        }).delay(650).animate({
            left: '-=80',
            opacity: 0
        }, {
            duration: 500,
            specialEasing: {
                left: 'linear',
                opacity: 'easeInQuad'
            }
        });

        $('#oops').delay(650).animate({
            width: '320',
            left: '-=402'
        },
        { duration: 800,
            specialEasing: {
                left: 'easeOutQuad',
                width: 'swing'
            },
            complete: function () {
                setTimeout('sceneTwo()', 1500);
            }
        });
    });
}

//Scene Two function
sceneTwo = function () {
    $('#FMA-sceneTwo, #FMA-sceneTwo #astric, #FMA-sceneTwo #carpet-lasts,#FMA-sceneTwo #percent-50, #FMA-sceneTwo #with-gallery').css({ opacity: 0 });
    $('#FMA-sceneTwo').show();

    $('#FMA-sceneOne').animate({
        opacity: 0
    }, 2500);

    $('#FMA-sceneTwo').animate({
        opacity: 1
    }, 800, function () {

        $('#FMA-sceneTwo #carpet-lasts').animate({
            opacity: 1
        }, 800, 'easeInQuad');

        $('#FMA-sceneTwo #percent-50').delay(400).animate({
            opacity: 1
        }, 800, 'easeInQuad');

        $('#FMA-sceneTwo #with-gallery').delay(1100).animate({
            opacity: 1
        }, 800, 'easeInQuad', function () {
            setTimeout('sceneThree()', 1800);
        });

    });
}

//Scene Two function
sceneThree = function () {
    $('#FMA-sceneThree #family, #FMA-sceneThree #cta-learnMore, #FMA-sceneThree #testoftime,#FMA-sceneThree #stain-adv,#blur-thin').css({ opacity: 0 });

    $('#FMA-sceneThree').show();

    $('#FMA-sceneTwo').animate({
        opacity: 0
    }, 2000);

    $('#FMA-sceneThree #family').animate({
        opacity: 1
    }, 1200, 'easeInQuad', function () {

        $('#FMA-sceneThree #text-background').animate({
            height: '+=285'
        }, 800, 'easeOutQuad');

        $('#FMA-sceneThree #testoftime').delay(900).animate({
            opacity: 1
        }, 800, 'easeOutQuad');

        $('#FMA-sceneThree #stain-adv').delay(1600).animate({
            opacity: 1
        }, 800, 'easeInQuad', function () {
        /*

            $('#blur-thin').css({ opacity: 1 }).animate({
                left: '+=115',
                opacity: 0
            }, {
                duration: 600,
                specialEasing: {
                    left: 'linear',
                    opacity: 'easeOutQuad'
                }
            });

            */

            $('##FMA-sceneThree #cta-learnMore').animate({
                opacity: 1
            }, {
                duration: 800,
                specialEasing: {
                    opacity: 'easeOutQuad'
                }
            });



        }); //end of 

    });

}



// The function that fires off the whole thing once eveything is downloaded
window.onload = function () {
  /*  $('#blur').delay(400).animate({  
            left: '-=230',
            opacity: 0
        },  { 
            duration: 630,
            specialEasing: {
            left: 'linear',
            opacity: 'easeInQuad'
            }
        });

    $('#inviting').delay(400).animate({ 
            width: '209',
            left: '-=449'
        },
        { duration: 800,
            specialEasing: {
                left: 'easeOutQuad',
            width: 'swing'
        },
            complete: function() {
            oops2();
        }
    });

    */


};
