var g_colours=['RED','ORANGE','YELLOW','GREEN','BLUE','INDIGO','VIOLET'];
var order=[0,1,2,3,4,5,6];
shuffle(order);
document.write("<div id='panel'>");
for (var i=0;i<7;i++) {
	var j=order[i];
	document.write("<div class='cell item' id='"+g_colours[j]+"' style='background-color:"+g_colours[j]+";' onClick='cell_clicked(this);'></div>");
}
document.write("</div>");
var g_count=0;
function cell_clicked(image) {
	if (image.id==g_colours[g_count]) {
		hide(image.id);
		g_count++;
		if (g_count==7) open_rock();
	} else {
		show_class('cell'); g_count=0;
	}
}
function shuffle(array) {
  var i,j,temp;
  for (i=array.length-1; i>0; i-=1) {
    j=Math.floor(Math.random()*(i+1));
    temp=array[i]; array[i]=array[j];
    array[j]=temp;
  }
}
function show_class(klass) {
  var arr=document.getElementsByClassName(klass);
  for (var i=0;i<arr.length;i++) {
    var el=arr[i];
    el.style.visibility='visible';
  }
}
function open_rock() {
  var rock=document.getElementById('rock');
  rock.classList.add('move');
}
