toggleCheckAll = function(D, C, A) {
	var B = Form.getInputs(D, "checkbox", C);
	B.each(function(E) {
		E.checked = A
	});
	return true
};
viewportHeight = function() {
	return self.innerHeight
			|| (document.documentElement.clientHeight || document.body.clientHeight)
};
popup = function(F, B, C, A) {
	var E = Math.floor((screen.height - A) / 2);
	var D = Math.floor((screen.width - C) / 2);
	return window.open(F, B, "top=" + E + ",left=" + D + ",width=" + C
			+ ",height=" + A + ",location=no,resizable=no,scrollbars=no")
};
showAlert = function(A) {
	Ext.MessageBox.show( {
		width : 300,
		height : 100,
		msg : A,
		buttons : Ext.MessageBox.OK
	});
	return true
};
showConfirm = function(A, B) {
	Ext.MessageBox.show( {
		width : 300,
		height : 100,
		msg : A,
		buttons : Ext.MessageBox.YESNO,
		fn : function(C) {
			if (C == "yes") {
				B()
			}
		}
	});
	return true
};
showPopup = function() {
	var A = new Ext.Window( {
		title : "Info",
		autoLoad : {
			url : "/Infos/show/1"
		},
		autoScroll : true,
		modal : true,
		width : 600,
		height : 400,
		buttons : [ {
			text : "Fermer",
			handler : function() {
				A.close()
			}
		} ]
	});
	A.show();
	return true
};
showEula = function(C, A) {
	if (C) {
		var B = new Ext.Window( {
			title : "Conditions d'utilisation",
			autoLoad : {
				url : "/pages/eula"
			},
			autoScroll : true,
			modal : true,
			width : 600,
			height : 400,
			buttons : [ {
				text : "Accepter",
				handler : function() {
					B.close();
					if (A) {
						setTimeout("showRef()", 500)
					}
				}
			}, {
				text : "Refuser",
				handler : function() {
					window.location.href = "/login/declineEula"
				}
			} ]
		});
		B.show()
	} else {
		var B = new Ext.Window( {
			title : "Conditions d'utilisation",
			autoLoad : {
				url : "/pages/eula"
			},
			autoScroll : true,
			modal : true,
			width : 600,
			height : 400,
			buttons : [ {
				text : "Fermer",
				handler : function() {
					B.close()
				}
			} ]
		});
		B.show()
	}
	return true
};
showRef = function() {
	var A = new Ext.Window( {
		title : "Référencement",
		autoLoad : {
			url : "/pages/ref"
		},
		modal : true,
		width : 500,
		height : 250,
		buttons : [ {
			text : "Accepter",
			handler : function() {
				new Ajax.Request("/misc/referencing/1", {
					method : "post"
				});
				A.close()
			}
		}, {
			text : "Refuser",
			handler : function() {
				new Ajax.Request("/misc/referencing/0", {
					method : "post"
				});
				A.close()
			}
		} ]
	});
	A.show();
	return true
};
var dupdate = {
	init : function(A) {
		pe = new PeriodicalExecuter(dupdate.callback, A)
	},
	callback : function() {
		new Ajax.Request("/dupdate", {
			method : "post",
			onComplete : dupdate.setdata
		})
	},
	setdata : function(A) {
		var C = new XML.ObjTree();
		var B = A.responseXML.documentElement;
		objDupdate = C.parseDOM(B);
		if (objDupdate.dupdate.pmessages) {
			$("du_pmessages").update(objDupdate.dupdate.pmessages.number);
			if (objDupdate.dupdate.pmessages.number != "0") {
				$("du_pmessages").addClassName("highlight")
			} else {
				if ($("du_pmessages").hasClassName("highlight")) {
					$("du_pmessages").removeClassName("highlight")
				}
			}
			if (objDupdate.dupdate.pmessages.properties["-sound"] == 1) {
				soundManager.play("new_pmessage")
			}
		}
		if (objDupdate.dupdate.topics) {
			i = 1;
			objDupdate.dupdate.topics.topic.each(function(D) {
				objTopic = $("du_topic_" + i);
				objTopic.update(D["#cdata-section"]);
				objTopic.title = D["-id"];
				i++
			})
		}
		if (objDupdate.dupdate.prospects) {
			$("du_prospects").update(objDupdate.dupdate.prospects.number);
			if (objDupdate.dupdate.prospects.number != "0") {
				$("du_prospects").addClassName("highlight")
			} else {
				if ($("du_prospects").hasClassName("highlight")) {
					$("du_prospects").removeClassName("highlight")
				}
			}
			if (objDupdate.dupdate.prospects.properties["-sound"] == 1) {
				soundManager.play("new_prospect")
			}
		}
		if (objDupdate.dupdate.banners) {
			new Effect.Fade("ads_banner_c", {
				duration : 0.2,
				afterFinish : function() {
					new Effect.Appear("ads_banner_c", {
						duration : 0.2
					});
					i = 1;
					banners = objDupdate.dupdate.banners.banner;
					changeBanner = function(E, D) {
						objBanner = $("du_banner_" + E);
						objBannerImg = $("du_banner_img_" + E);
						objBanner.href = D["-url"];
						objBannerImg.src = "/img/ads/" + D["-image"]
					};
					if (banners.constructor.toString().indexOf("Array") == -1) {
						changeBanner(i, banners)
					} else {
						banners.each(function(D) {
							changeBanner(i, D);
							i++
						})
					}
				}
			})
		}
		if (objDupdate.dupdate.supplier) {
			$("du_supplier_name").update(objDupdate.dupdate.supplier.name);
			$("du_supplier").writeAttribute(
					"onclick",
					"javascript:window.location.href='/actusite/allProducts/"
							+ objDupdate.dupdate.supplier["-id"] + "';");
			$("du_supplier_img").src = "/img/suppliers/"
					+ objDupdate.dupdate.supplier.url
		}
	}
};
var debate = {
	_pe : null,
	_win : null,
	init : function(A) {
		debate._pe = new PeriodicalExecuter(debate.callback, A)
	},
	show : function() {
		if (debate._Win) {
			debate._Win.close()
		}
		debate._Win = new Ext.Window( {
			title : "Débat en direct",
			autoLoad : {
				url : "/debates/index",
				scripts : true
			},
			resizable : false,
			width : 800,
			height : 450,
			listeners : {
				show : function() {
					debate.init(15)
				},
				close : function() {
					debate.stopPe()
				}
			}
		});
		debate._Win.show();
		return true
	},
	showCountdown : function() {
		new PeriodicalExecuter(
				function(A) {
					new Ajax.Request(
							"/debates/countdown",
							{
								method : "post",
								onComplete : function(B) {
									if (B.responseText == "0") {
										A.stop();
										$("debate_countdown")
												.update(
														'Débat en cours<br/><a href="#" onclick="javascript:debate.show();">Ouvrir le débat</a>');
										debate.show()
									} else {
										if (B.responseText == "1") {
											$("debate_countdown")
													.update(
															"<blink>Le débat va commencer dans <strong>"
																	+ B.responseText
																	+ " minute</strong></blink>")
										} else {
											$("debate_countdown")
													.update(
															"Le débat va commencer dans <strong>"
																	+ B.responseText
																	+ " minutes</strong>")
										}
									}
								}
							})
				}, 30)
	},
	showIfStarted : function() {
		new Ajax.Request("/debates/test", {
			method : "post",
			onComplete : function(A) {
				if (A.responseText.charAt(0) == "1") {
					debate.show()
				} else {
					alert("Le débat n'a pas encore commencé !")
				}
			}
		})
	},
	callback : function() {
		new Ajax.Request("/debates/refresh", {
			method : "post",
			onComplete : debate.setdata
		})
	},
	stopPe : function() {
		if (debate._pe != null) {
			debate._pe.stop()
		}
		debate._pe = null
	},
	setdata : function(A) {
		var C = new XML.ObjTree();
		var B = A.responseXML.documentElement;
		objDebate = C.parseDOM(B);
		if (objDebate.debate["-closed"] == "1") {
			debate.stopPe();
			debate._Win.close();
			Ext.MessageBox
					.show( {
						width : 400,
						height : 150,
						msg : "<strong>Ce direct est termin&eacute;.</strong><br />Nous vous remercions de votre participation. Vous pourrez retrouver l’ensemble des &eacute;changes dans la rubrique d&eacute;bats.",
						buttons : Ext.MessageBox.OK,
						fn : function() {
							$("debate-bloc").hide();
							center_iframe.location.href = "/pages/home"
						}
					})
		} else {
			if (objDebate.debate.questions) {
				new Insertion.Bottom("debate_questions",
						objDebate.debate.questions)
			}
			if (objDebate.debate.answers) {
				new Insertion.Top("debate_answers", objDebate.debate.answers)
			}
		}
	}
};
var recorder = {
	_winR : null,
	_onSaveCallback : null,
	open : function(C, A, B) {
		recorder._onSaveCallback = B;
		recorder._winR = new Ext.Window( {
			title : "Enregistrement vidéo",
			autoLoad : {
				url : "/users/recorder/" + C + "/" + A,
				scripts : true
			},
			modal : true,
			width : 350,
			height : 408,
			resizable : false
		});
		recorder._winR.show()
	},
	play : function(B, C, A) {
		recorder._winR = new Ext.Window( {
			title : "Vidéo",
			autoLoad : {
				url : "/users/player/" + B + "/" + C + "/" + A,
				scripts : true
			},
			modal : true,
			width : 350,
			height : 408,
			resizable : false
		});
		recorder._winR.show()
	},
	callback : function(eventType, eventInfo) {
		switch (eventType) {
		case "ServerConnectSuccess":
			break;
		case "Error":
			alert("Erreur : " + eventInfo);
			break;
		case "ButtonCloseOnClick":
			if (eventInfo == "true" && recorder._onSaveCallback) {
				eval(recorder._onSaveCallback + "()")
			}
			recorder._onSaveCallback = null;
			recorder._winR.close();
			break;
		case "VideoSaved":
			eval(recorder._onSaveCallback + "()");
			recorder._onSaveCallback = null;
			recorder._winR.close();
			break;
		case "ServerConnectedFailed":
			break;
		case "CameraNotDetected":
			recorder._winR.close();
			alert("Acune Webcam n'est connecté à l'ordinateur");
			break
		}
	}
};
var fileProgress = {
	_file : null,
	_container : null,
	_id : null,
	_size : null,
	init : function(B, A) {
		fileProgress._file = B;
		fileProgress._container = $(A);
		fileProgress._id = "fp_" + Math.floor(Math.random() * 10000);
		new Insertion.Bottom(
				fileProgress._container,
				'<div id="'
						+ fileProgress._id
						+ '" class="fp_container" style="display: none;"><div class="fp_bg"></div><div id="'
						+ fileProgress._id
						+ '_mask" class="fp_mask"></div><div id="'
						+ fileProgress._id
						+ '_ind" class="fp_indicator">0%</div></div>');
		fileProgress._size = $(fileProgress._id).getWidth();
		Effect.Appear(fileProgress._id)
	},
	setProgress : function(A) {
		dec = A / 100 * fileProgress._size;
		$(fileProgress._id + "_ind").innerHTML = A + "&nbsp;%";
		$(fileProgress._id + "_mask").setStyle( {
			left : dec + "px",
			width : fileProgress._size - dec + "px"
		})
	},
	complete : function() {
		Effect.Shake(fileProgress._id);
		new Insertion.Bottom(fileProgress._container, "<strong>Le fichier "
				+ fileProgress._file.name
				+ " à été uploadé avec succès</strong>")
	}
};
