// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

// String.prototype.wordCount = function () {return this.replace(/^\s+/, '').replace(/\s$/, '').split(/\s+/).length}

var GAP = function() {
	return {
		validate_email: function(email) {
			return /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(email);
		},
		remove_effect_element : function(obj) {
			obj.element.remove();
		},
		urls: {
			admin_proposal: '/admin/proposal/',
			jury_proposal: '/jury/proposal/',
			wait_img: '/stylesheets/art/loader.gif',
			choice_entry: '/entry/'
		},
		createCookie: function(name,value,days) {
			if (days) {
				var date = new Date();
				date.setTime(date.getTime()+(days*24*60*60*1000));
				var expires = "; expires="+date.toGMTString();
			}
			else var expires = "";
			document.cookie = name+"="+value+expires+"; path=/";
		},
		readCookie: function(name) {
			var nameEQ = name + "=";
			var ca = document.cookie.split(';');
			for(var i=0;i < ca.length;i++) {
				var c = ca[i];
				while (c.charAt(0)==' ') c = c.substring(1,c.length);
				if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
			}
			return null;
		},
		eraseCookie: function(name) {
			createCookie(name,"",-1);
		}
		
	};
}();
