﻿/*
	А в челюсть кулаком ноги с разворота?
*/


var ColorTimer = null;
var CurrentColor = new Array();
var CountDown = true;
var saveColor = new Array();
var zzz = 0;
var huyarit = 0;
var creation_f = '1';

//cookie_detect_creation();

function cookie_detect_creation() {
	ac = getCookie('line_creation');
	if (ac) {
		if (ac == '0') {
			document.getElementById('creation_div').innerText='разморозить';
			creation_f = '0';
		}
	}
}


var randColors = new Array();
randColors[0] = "#ffeab1";
randColors[1] = "#ecad35";
randColors[2] = "#ffba00";
randColors[3] = "#ff6000";
randColors[4] = "#d55000";
randColors[5] = "#3f3f3f";
randColors[6] = "#b0bb38";
randColors[7] = "#6cc6d1";
randColors[8] = "#00c9a6";
randColors[9] = "#ff006c";
randColors[10] = "#ffacc3";
//randColors[11] = "#5a9300";
randColors[11] = "#3f3f3f";


function prov() {
	if (window.name !== '') {
		getColors(window.name);
	} else {
		cookie_detect();
	}
}

function getRandomColor(id) {
	var rnd = Math.round(Math.random()*11);
	var col = randColors[rnd];
	var id = id.replace('p', '');
	var id = id*1;
	saveColor[id] = rnd;
	return col;
}

function AlterColor (id) {
	if (creation_f !== '0') {
		var logodiv = document.getElementById (id);
		if (logodiv) logodiv.style.backgroundColor = getRandomColor (id);
		setTimeout('saveColors()', 2000);
	}
}





function getColors(a) {
	saveColor = a.split('x');
	for (var i=0;i<11;i++) {
		var id = "p"+i;
		var logodiv = document.getElementById (id);
		var col_id = saveColor[i];
		if (logodiv) {
			logodiv.style.backgroundColor = randColors[col_id];
		}
	}
}







function saveColors() {
 var name = "line_scheme"
 var tmp = saveColor.join('x');
 window.name = tmp;
 set_cookie(tmp);
}




function cookie_detect() {
	a = getCookie('line_scheme');
	if (a) {
		getColors(a);
	}
}


function getCookie(name) {
      var prefix = name + "=";
      var cookieStartIndex = document.cookie.indexOf(prefix);
      if (cookieStartIndex == -1) return null;
      var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
      if (cookieEndIndex == -1) cookieEndIndex = document.cookie.length;
      return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}


function set_cookie(value) {
	var name = "line_scheme";
 	var expires = new Date();
 	expires.setTime(expires.getTime() + (1000 * 86400 * 365));
 
	if (!expires) {
		expires = new Date();
	}
	document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() +  "; path=/";
}

//window.onload = prov;
provDiv();
var interval = setInterval('provDiv()', 100);

function provDiv() {
	var controldiv = document.getElementById ('control');
	var controldiv2 = document.getElementById ('creation_div');
	if ((controldiv != null) && (controldiv2 != null)) {
		clearInterval(interval);
		cookie_detect_creation();
		prov();
	}
}













function creation() {
	var creation_f2 = creation_f;
	if (creation_f2 == '0') {
		var value2 = '1';
		creation_f = '1';
		document.getElementById('creation_div').innerText='заморозить';
	} else {
		var value2 = '0';
		creation_f = '0';
		document.getElementById('creation_div').innerText='разморозить';
	}
	var name2 = "line_creation";
 	var expires2 = new Date();
 	expires2.setTime(expires2.getTime() + (1000 * 86400 * 365));
 
	if (!expires2) {
		expires2 = new Date();
	}
	document.cookie = name2 + "=" + escape(value2) + "; expires=" + expires2.toGMTString() +  "; path=/";
}



function start_the_rockin() {
tancpol = document.getElementById("dance");
tancpol.style.width = "100%";
tancpol.style.height = "800px";
}

function stop_the_dance() {
tancpol = document.getElementById("dance");
tancpol.style.width = "1px";
tancpol.style.height = "1px";
tancpol.innerText="";
}
