//    This script creates a 'Form Dropdown' to slide down over the
//    content in the inserted element. It will close if the user clicks
//    the "Close" button.
//    This script created for thedogtrainingsecret.com by Smart Solutions - 12/9/2009 / DMC.
//     Version 0.1

$(document).ready(function() {
    
    var qFormWidth = 500; // The Width of the Form Dropdown
    var qFormHeight = 500; // The Height of the Form Dropdown
    var topLeftPos = 100; // Top Left Position
    
    var negativeSpace = 25; // Negative Space above element inserted into
    
    var animateDownSpeed = 1000; // Speed (in milliseconds) at which the Form Dropdown is aniamted downward.
    var animateUpSpeed = 350; // Speed (in milliseconds) at which the Form Dropdown is aniamted upward.
    
    var isItThere = readCookie('dtsqFormDonut'); // See if cookie has been written.
    
    if (!isItThere) {
    
        // The HTML to be inserted:
        var theHtml = '<div id="qForm">';
        theHtml += '    <a id="qFormClose" href="#close">X Close</a>';
        theHtml += '    <iframe src="/popupframe.html" width="100%" height="450px" frameborder="0"><p>Your browser does not support frames and is not able to view this content.</p></iframe>';
        theHtml += '</div>';
        
        // Append the HTML to the element:
        $('#themeContainer').append(theHtml);
        
        // Set CSS for the Form Dropdown:
        var qFormCss = {
            position:    'absolute',
            zIndex:        '500',
            top:        '-' + parseInt(qFormHeight + negativeSpace) + 'px',
            left:        topLeftPos + 'px',
            width:        qFormWidth + 'px',
            height:        qFormHeight + 'px',
            border:        'solid 2px #f00',
            background:    '#fff'
        }
        $('#qForm').css(qFormCss);
        
        // Animate the Form Dropdown downward:
        $('#qForm').animate( {top: '25px'}, animateDownSpeed);
        
        createCookie('dtsqFormDonut', true, 365); // Bake a cookie so that this doesn't show again for 365 days.
        
    }
    
    // Animate the Form Dropdown upward when the "close" button is clicked:
    $('a#qFormClose').click(function() {
        $('#qForm').animate(
            {top: '-' + parseInt(qFormHeight + negativeSpace) + 'px'},
            animateUpSpeed,
            function() {
                $('#qForm').remove()
            }
        );
        return false;
    });
    
});
// End of Script