var welcomeflowercount = 0;

function language_onclick(newlangid) {
	alert("set language: " + newlangid);
  }

function body_onload() {
	if (!setCookieVerify("cc", Math.random(), 1, '/')) {
		var n = document.getElementById("notification_content");
		if (n != null) {
			n.innerHTML = getString(1);
			n = document.getElementById("notification_container");
			if (n != null) n.className = "unhidden";
		  }
	  }
//	document.body.removeChild(document.getElementById('conash3D0'));
	move_creatures_soon();
	move_order_here_soon();
  }

function main_menu_shared_activate(index, title, style) {
	var td = document.getElementById("main_menu_title");
	if (td != null) {
		td.innerHTML = title;
		td.className = "main_menu_title_" + style;
		}
	for (i = 1; i < 7; i++) {
		var img = document.getElementById("main_menu_toot_" + i);
		if (img != null) img.src = ((i == index) ? root + "main/images/toot" + index + ".gif" : "/pixel.gif");
	  }
  }

function main_menu_toot_mouseover(selectedindex, index, title) {
	main_menu_shared_activate(index, title, ((selectedindex == index) ? "selected" : "over"));
  }

function main_menu_logo_mouseover(selectedindex, title) {
	main_menu_shared_activate(0, title, ((selectedindex == 0) ? "selected" : "over"));
  }

function main_menu_toot_mouseout(index, selectedtitle) {
	main_menu_shared_activate(index, selectedtitle, "selected");
  }

function MoveNextWelcomeFlower(previousid) {
	nextid = (previousid + 1) % 23;
	e = document.getElementById("welcomeflower_" + nextid);
	if (e != null) {
		var i = (self.outerWidth / 6) + Math.round(Math.random() * (self.outerWidth / 1.5));
		e.style.left = "" + i + "px";
		i = (self.outerHeight / 6) + Math.round(Math.random() * (self.outerHeight / 1.7));
		e.style.top = "" + i + "px";
	  }
/*
	e = document.getElementById("welcomeflower_" + Math.round((nextid + 12) % 23));
	if (e != null) {
		e.style.left = "-100px";
	  }
*/
  setTimeout("MoveNextWelcomeFlower(" + nextid + ")", 200 + Math.round(Math.random()*800));
  }
	
function WelcomeFlowerClick(sender) {
	sender.style.left = "-100px";
	welcomeflowercount++;
	e = document.getElementById("welcomeflowercount");
	if (e != null) {
		e.innerHTML = welcomeflowercount;
	  }
  }

/* moving creatures */

var mbi = null;
var mbx = 0;
var mby = 0;
var mb_space_y = 30;
var mb_creatures_moved = false;
var creature_max = 5;

function move_creature_object(o) {
	if (o == null) return false;
	if (mov_anyactive()) return false;
	var i;
	var box = document.getElementById("tuut_container");
	if (box == null) return false; // could not find container
	var r = mov_getposition(box);
	var mov = mov_find(o);
	if (mov == null) {
		mov = mov_add(o);
		mov.speed = 1;
	  }
	mov.move(mov.emptyx(r[0], r[0] + r[2], 96), 96, 96, box);
  }

function move_creature(index) {
	move_creature_object(document.getElementById("tuut_" + index));
  }

function move_random_creature_loop() {
	move_creature(Math.round(Math.random() * creature_max));
  move_creatures_soon();
  }

function move_creatures_soon() {
	setTimeout(move_random_creature_loop, Math.random() * 12000);
  }

function move_order_here() {
	object = document.getElementById("order_here");
	if (object == null) return false;
	var mov = mov_find(object);
	if (mov == null) mov = mov_add(object);
	mov.speed = 1;
  mov.move(46, 170, null, null);
  }

function move_order_here_soon() {
	setTimeout(move_order_here, 10000);
  }

function hide(o) {
	if (o != null) {
	  o.className = o.className + " hidden";
	  }
  }

var overlayid = 0;

function comment_add(pageid, langid) {
	overlayid++;
	loadcontent(root + "content/ajax.php?&randomkey=" + Math.random() + "&langid=" + langid + "&comment_add_getcontent=1&comment_pageid=" + pageid + "&overlayid=" + overlayid, addhtml);
  }

function order_send(langid) {
	overlayid++;
	loadcontent(root + "content/ajax.php?&randomkey=" + Math.random() + "&langid=" + langid + "&order_getcontent=1&overlayid=" + overlayid, addhtml);
  }
