/*
 * surveyable 1.2 - jQuery survey mode
 *
 * 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 2009-09-24 $
 *
 */
 
//extend the plugin
(function($){

	//define the new for the plugin ans how to call it	
	$.fn.surveyable = function(options) {
		//set default options  
		var defaults = {
			name: 'surveyTaken',
			duration: 'today'
			};

		//call in the default otions
		var options = $.extend(defaults, options);
		//act upon the element that is passed into the design    
		return this.each(function(options) {
			if ( !$.cookie(defaults.name) ) {
				$('#survey').css("display","block");
			} else {
				$('#survey').css("display","none");	
			}
			$('a.close').click(function() {
				$('#survey').css({'display':'none'});
				var today = new Date(); 
				today.setTime(today.getTime() + (1 * 24 * 60 * 60 * 1000));
				$.cookie(defaults.name, 'Done', { path: '/', expires: defaults.duration }); 
				return false;
			});
			$('form').onSubmit(function() {
				$('#survey').css({'display':'none'});
				var today = new Date(); 
				today.setTime(today.getTime() + (1 * 24 * 60 * 60 * 1000));
				$.cookie(defaults.name, 'Done', { path: '/', expires: defaults.duration }); 
				return false;
			});
	
		});
	};
	//end the plugin call 
})(jQuery);


