--- /dev/null
+var cards = new Array ();
+cards[0] = 1;
+cards[1] = 1;
+cards[2] = 1;
+cards[3] = 1;
+cards[4] = 1;
+
+function flip(n, cont)
+{
+
+ var img = "img#c" + n;
+ var width = $(img).width();
+ var height = $(img).height();
+ $(img).animate ({
+ 'width': "0px",
+ 'left': (width >> 1) + "px",
+ 'height': height + "px"}, 150);
+
+ $(img).queue (function(next) {
+ if (cards[n] == 0) {
+ $(img).attr("src", "carte" + n + ".png");
+ } else {
+ $(img).attr("src", "dos.png");
+ };
+ next();
+ });
+
+ $(img).animate ({
+ 'width': width + "px",
+ 'left': "0px",
+ 'height': height + "px"}, 150);
+
+ $(img).queue (function(next) {
+ cards[n] = 1 - cards[n];
+ $("div#d" + n).html(cards[n]);
+ next();
+ });
+
+ if (cont !== undefined){
+ $(img).queue (function(next) {
+ cont();
+ next();
+ });
+ };
+}
+
+function update_res() {
+ var acc = 0;
+ for(i = 4; i >= 0; i--){
+ acc = 2*acc + cards[i];
+ };
+ $("div#rescontent").html("= " + acc);
+}
+
+function set_to_int(n)
+{
+ var i;
+ var a = n;
+ var tmp = new Array();
+ for (i = 0; i < 5; i++) {
+ tmp[i] = a & 1;
+ a = a >> 1;
+ };
+ $("div#rescontent").queue(function() {
+ $(this).dequeue();
+ });
+
+ for(i = 0; i < 5; i++) {
+ $("div#rescontent").queue(new Function("next", "if(" + tmp[i] + " != cards[" + i +"]) {flip(" + i + ");}; next();" ));
+ };
+
+ $("div#rescontent").queue(function (next) {
+ $("img").promise().done(function(){
+ update_res();
+ next();
+ });
+ });
+
+ $("div#rescontent").delay(1000);
+
+}
+function count(from, to){
+ var i;
+ for (i = from; i <= to; i++){
+ set_to_int(i);
+ }
+
+}
+function hide_hints() {
+ $("div#all_digits").toggle();
+ $("div#result").toggle();
+
+}
+
+hide_hints();
\ No newline at end of file