﻿/*
 * contactable 1.2.1 - jQuery Ajax contact form
 *
 * Copyright (c) 2009 Philip Beel (http://www.theodin.co.uk/)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * Revision: $Id: jquery.contactable.js 2010-01-18 $
 *
 */
 
//extend the plugin
(function ($) {

    //define the new for the plugin ans how to call it	
    $.fn.contactable = function (options) {
        //set default options  
        var defaults = {
            name: 'Name',
            email: 'Email',
            message: 'Message',
            subject: 'A contactable message',
            recievedMsg: 'Thankyou for your message',
            notRecievedMsg: 'Sorry but your message could not be sent, try again later',
            disclaimer: '',
            hideOnSubmit: true,
            id: "1"
        };

        //call in the default otions
        var options = $.extend(defaults, options);
        //act upon the element that is passed into the design    
        return this.each(function () {
            //construct the form
            //$(this).html('');
            //show / hide function
            $('div#contactable' + options.id).toggle(function () {
                $('#overlay').css({ display: 'block' });
                $(this).animate({ "marginLeft": "-=5px" }, "fast");
                $('#contactForm' + options.id).animate({ "marginLeft": "-=0px" }, "fast");
                $(this).animate({ "marginLeft": "+=532px" }, "slow");
                $('#contactForm' + options.id).animate({ "marginLeft": "+=535px" }, "slow");
                if (options.id == "1")
                    $("#contactForm" + options.id).append('<object><param name="wmode" value="window">​<embed wmode="window" id="ifr" src="/Contents/Insurance_841218.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="500" height="300" style="padding:0 0 0 0 ;"></embed></object>');
            },
			function () {
			    $('#contactForm' + options.id).animate({ "marginLeft": "-=535px" }, "slow");
			    $(this).animate({ "marginLeft": "-=532px" }, "slow").animate({ "marginLeft": "+=5px" }, "fast", function () { if (options.id == "1") $("#ifr").remove(); });
			    $('#overlay').css({ display: 'none' });
			});

        });
    };
})(jQuery);


