/*
Copyright 2010, Piotr Opioła
All rights reserved.
http://pageproject.pl
*/

logo_running = false;
menu_item_width = 165;
menu_jump = 20;

var logo_anim = function() {
	
	unlock = function() {
		logo_running = false;
	}
	
	if (!logo_running) {
		logo_gif2 = document.getElementById('logo_gif');
		logo_gif_img = logo_gif2.getElementsByTagName('img')[0];
		logo_gif_img.src = "";
		logo_gif_img.src = "img/logo.gif";
		logo_running = true;
		setTimeout("unlock()", 5000);
	}
}

var show_content_line = function() {
	
	this.seth = function(h) {
		var line = document.getElementById('content_line2');
		var line_img = line.getElementsByTagName('img')[0];
		if (h >= this.maxh) {
			show_content_all();
			line_img.style.height = this.maxh + "px";
			var line_short = document.getElementById('menu_line_short2');
			var line_short_img = line_short.getElementsByTagName('img')[0];
			line_short_img.style.width = "165px";
		} else {
			show_content(parseInt(h/menu_jump));
			line_img.style.height = h + "px";
			h += menu_jump;
			setTimeout("seth.call(this,"+h+")", 10);
		}
	}
	
	this.setw = function(w) {
		var line = document.getElementById('content_line');
		var line_img = line.getElementsByTagName('img')[0];
		if (w >= 660) {
			line_img.style.width = "660px";
			line.style.marginLeft = "330px";
			var line2 = document.getElementById('content_line2');
			var line2_img = line2.getElementsByTagName('img')[0];
			line2_img.style.height = "0px";
			line2.style.visibility = "visible";
			setTimeout("seth(0)", 10);
		} else {
			line_img.style.width = w + "px";
			line.style.marginLeft = (990-w) + "px";
			w += menu_jump;
			setTimeout("setw.call(this,"+w+")", 10);
		}
	}
	
	this.cont = document.getElementById('content');
	this.maxh = cont.offsetHeight - 38;
	this.line = document.getElementById('content_line');
	this.line.style.visibility = "visible";
	this.setw(0);
}

var menu_item_select = function(i) {
	
	this.setw = function(w, maxw) {
		var line_short = document.getElementById('menu_line_short2');
		var line_short_img = line_short.getElementsByTagName('img')[0];
		if (w >= maxw) {
			line_short_img.style.width = maxw + "px";
			show_content_line();
		} else {
			line_short_img.style.width = w + "px";
			w += menu_jump;
			setTimeout("setw.call(this,"+w+","+maxw+")", 10);
		}
	}
	
	this.line_short = document.getElementById('menu_line_short2');
	this.line_short_img = line_short.getElementsByTagName('img')[0];
	this.line_short.style.marginLeft = (330 + menu_item_width * (i-1)) + "px";
	this.line_short_img.style.width = "0px";
	this.line_short.style.visibility = "visible";
	this.w = menu_item_width * (4-i+1);
	this.setw(0,w);
}

function menu_item_deselect(i) {
	line_short = document.getElementById('menu_line_short2');
	line_short.style.visibility = "hidden";
}

function menu_item_mark(i) {
	line_short = document.getElementById('menu_line_short');
	line_short.style.marginLeft = (330 + menu_item_width * (i-1)) + "px";
	line_short.style.visibility = "visible";
}

function menu_item_mark1() {
	menu_item_mark(1);
}

function menu_item_mark2() {
	menu_item_mark(2);
}

function menu_item_mark3() {
	menu_item_mark(3);
}

function menu_item_mark4() {
	menu_item_mark(4);
}

function menu_item_unmark() {
	line_short = document.getElementById('menu_line_short');
	line_short.style.visibility = "hidden";
}

function menu_item_unmark1() {
	menu_item_unmark(1);
}

function menu_item_unmark2() {
	menu_item_unmark(2);
}

function menu_item_unmark3() {
	menu_item_unmark(3);
}

function menu_item_unmark4() {
	menu_item_unmark(4);
}
