Sondage = {
			 ModuleId : 0,
			 init : function(){
				Sondage.ModuleId = jQuery(".sondageModuleId").val();
				if (document.cookie.indexOf(Sondage.cookieName()) >= 0) {
				    //Cookie found, disable inputs, hide submit button
					jQuery(".cqsondage-submitlink").css("visibility", "hidden");
				    //jQuery(".cq-sondage-list input").attr("disabled", "disabled");
				    jQuery(".cq-sondage-list input").css("visibility", "hidden");
				    pageTracker._trackEvent("Sondage", "Event", "ViewResults");
				} else {
				    //No cookie found, hide results
				    jQuery(".cq-sondage-resultstable, .cq-sondage-question-right .cq-sondage-rowheader").css("visibility", "hidden");
					 pageTracker._trackEvent("Sondage", "Event", "Start");
				}
			 },
			 submit : function() {
				var rows = jQuery(".cq-sondage-question, .cq-sondage-question-light");
				var isValid = true;
				var data = "";
				for (var i=0; i < rows.length; i++) {
					var format_row = Sondage.formatRow(rows[i]);
					if (!format_row){ isValid = false; break; }
					data += format_row + ";";
				}
				if (!isValid) {
					Popup.alert("Vous devez r&eacute;pondre &agrave; toutes les questions.");
					return;
				}
				data = data.substr(0, data.length - 1);
				
				jQuery.post("/Gateway/XML/service.asmx/SondageSubmit", {ModuleID : Sondage.ModuleId, SubmitData : data}, function(ret) {
					Sondage.registerCookie();
					
					Popup.oneliner("Merci pour votre participation!", 2000, function() {
					    //Show results, disable inputs, hide submit button
					    jQuery(".cqsondage-submitlink").css("visibility", "hidden");
					    jQuery(".cq-sondage-resultstable, .cq-sondage-question-right .cq-sondage-rowheader").css("visibility", "visible");
				        //jQuery(".cq-sondage-list input").attr("disabled", "disabled");
						jQuery(".cq-sondage-list input").css("visibility", "hidden");
				        
				        pageTracker._trackEvent("Sondage", "Event", "Submit");
				        
				        //jQuery("#cqsondage-message-label").text("Merci d'avoir répondu à ce sondage ! Revenez la semaine prochaine pour répondre aux questions de notre prochain thème");
					});
				});
			},
			
			formatRow : function(row) {
				var ret = false;
				var options = jQuery('input:checked', row);
				if (options.length > 0) {
					ret = jQuery('.hidlocator input', row).val() + ":";
					options.each(function(i) {
						if (this.checked){
							ret += this.value + ",";
						}
					});
					ret = ret.substr(0, ret.length - 1);
				}
				return ret;
			},
			
			registerCookie : function() {
				var cookie_name = Sondage.cookieName();
				var cookie_value = "True";
				var cookie_expires = new Date();
				cookie_expires.setTime(cookie_expires.getTime() + (100*365*24*60*60*1000)); //Expires in a hundred years.
				cookie_expires = cookie_expires.toGMTString();
				document.cookie = cookie_name + '=' + cookie_value + "; expires=" + cookie_expires;
			},
			
			next : function(anchor) {
			
				var this_row = jQuery("#" + anchor.id).parent();
				while(this_row.get(0).tagName != "TR"){
					this_row = this_row.parent();
				}
				if (validateRow(this_row)) {
					//Show this row's results and show the next row
					this_row.find(".ResultPanel").slideDown("slow");
					var next_row = this_row.next();
					if (next_row.length > 0) {
						next_row.show();
					} else {
						jQuery(".findCmdSubmit").show();
					}
					jQuery("#" + anchor.id).hide();
				} else {
					// alert('<% Response.Write(Localization.GetString("SurveyIncomplete", Me.LocalResourceFile)) %>');
				}
				
			}, 
			
			cookieName : function() {
			    return "_Module" + Sondage.ModuleId + "_CQSondage";
			}
}
