	var img_roza_path = 'images/main/roza/';
	var img_path = 'images/';
	var img_menu_path = 'images/menu/';

	var roza_array, ptr_array, menu_array;
	var timeout = 200;
	var need_parent = false;

	//====================================================================================================
	var roza_desc = new Array(
			"'roza01', '500', 'roza01_0', 'roza01_1'",
			"'roza02', '400', 'roza02_0', 'roza02_1'",
			"'roza03', '" + timeout + "', 'roza03_0', 'roza03_1', 'roza03_2'",
			"'roza04', '" + timeout + "', 'roza04_0', 'roza04_1'",
			"'roza05', '400', 'roza05_0', 'roza05_1'",
			"'roza06', '400', 'roza06_0', 'roza06_1'",
			"'roza07', '" + timeout + "', 'roza07_0', 'roza07_1', 'roza07_2'",
			"'roza08', '400', 'roza08_0', 'roza08_1'",
			"'roza09', '400', 'roza09_0', 'roza09_1'",
			"'roza10', '" + timeout + "', 'roza10_0', 'roza10_1', 'roza10_2'"
		);
	
	var ptr_desc = new Array(
		new Array('ptr_rout', 'ptr_rover', 'ptr_rdown'),
		new Array('ptr_lout', 'ptr_lover', 'ptr_ldown')
	)

	var menu_desc = new Array('about', 'club', 'gallery', 'readings', 'faq', 'guests');

	//====================================================================================================
	function init(bneed_parent)
	{
		if(bneed_parent == NaN || bneed_parent == undefined){
			need_parent = false;
			roza_array = preload_roza(roza_desc);
			menu_array = preload_menu(menu_desc);
		}
		else{
			need_parent = bneed_parent == 'child';
		}
		
		ptr_array = preload_ptr(ptr_desc);
	}

	//====================================================================================================
	function preload_menu(menu_desc)
	{
		var res = new Array(menu_desc.length);
		for(var i = 0; i < menu_desc.length; i++){
			res[i] = get_img('img' + menu_desc[i]);
			if(!res[i])
				return 0;
			res[i].menu_name = menu_desc[i];
			res[i].out = new Image();
			res[i].out.src = img_menu_path + menu_desc[i] + '_out.gif';
			res[i].over = new Image();
			res[i].over.src = img_menu_path + menu_desc[i] + '_on.gif';
			res[i].down = new Image();
			res[i].down.src = img_menu_path + menu_desc[i] + '_down.gif';
			res[i].onmouseout = m_out;
			res[i].onmouseover = m_over;
			res[i].onmousedown = m_down;
		}
		return res;
	}
	
	function m_over()
	{
		this.src = this.over.src;
		run_any_roza();
	}
	function m_out()
	{
		this.src = this.out.src;
	}
	function m_down()
	{
		this.src = this.down.src;
		run_any_roza();
	}
	
	//====================================================================================================
	function set_img_src(name, src)
	{
		eval('document.' + name + '.src="' + img_path + src + '"');
		if(need_parent)
			window.parent.run_any_roza()
		else
			run_any_roza();
	}

	//====================================================================================================
	function over_link(obj_id, img_src)
	{
		set_img_src('img' + obj_id, img_src + '.gif');
	}
	
	//====================================================================================================
	function preload_roza(roza_desc){
		var res = new Array(roza_desc.length);
		for(var i = 0; i < roza_desc.length; i++){
			res[i] = eval('create_roza(' + roza_desc[i] + ')');
			if(!res[i]){
				return 0;
			}
		}

		return res;
	}
	
	//====================================================================================================
	function create_roza(){
		var arguments = create_roza.arguments;
		var res = get_roza_img(arguments[0]);
		var n = arguments.length;
		if(res){
			res.timeout = arguments[1];
			res.change_src = change_src;
			res.timer = 0;
			res.roza_make_roza = roza_make_roza;

			res.img_list = new Array(n - 2);
			for(var i = 0; i < res.img_list.length; i++){
				var img = new Image();
				img.src = img_roza_path + arguments[i+2] + '.gif';
				var w = img.width;
				res.img_list[i] = img;
			}
		}
		return res;
	}
	
	//====================================================================================================
	function get_roza_img(img_name)
	{
		return eval(get_roza_img_str(img_name));
	}
	
	//====================================================================================================
	function get_roza_img_str(img_name)
	{
		return (need_parent ? 'window.parent.' : '') + 'document.' + img_name;
	}
	
	//====================================================================================================
	function get_img(img_name)
	{
		return eval('document.' + img_name);
	}
	
	//====================================================================================================
	function roza_make_roza(index){
		if(index == NaN || index == undefined)			
			index = 0;
		n = parseInt(index);
		clearTimeout(this.timer);
		if(index < this.img_list.length){
			this.change_src(index);
			this.timer = setTimeout(get_roza_img_str(this.name) + '.roza_make_roza(' + ++n + ')', this.timeout);
		}
		else{
			this.change_src(0);
		}
		return;
	}
	
	//====================================================================================================
	function getRandom(value)
	{
		var res = Math.floor(Math.random() * (value));
		if(res > value - 1) 
			res = value - 1;
		return res;
	}
	
	//====================================================================================================
	function run_any_roza()
	{
		if(roza_array){
			roza_array[getRandom(roza_array.length)].roza_make_roza();
		}
	}
	
	//====================================================================================================
	function change_src(index)
	{
		this.src = this.img_list[index].src;
//add_test_array(index);
	}
	
	//====================================================================================================
	function preload_ptr(ptr_desc)
	{
		var res = new Array(ptr_desc.length);
		for(var i = 0; i < res.length; i++){
			res[i] = new Array(ptr_desc[i].length);
			for(var j = 0; j < res[i].length; j++){
				res[i][j] = get_img(ptr_desc[i][j]);
			}
		}

		return res;
	}
	
	//====================================================================================================
	function intKeyPress(evt)
	{
		var charCode = (evt.which) ? evt.which : event.keyCode;
		return test_for_int(charCode) | !test_for_enter(charCode);
/*
		if(!test_for_int(charCode)){
	//		alert("Galima ávesti tik skaičius")
			return false
		}
		if (charCode == 13)
			return false;
		return true
*/
	}

	//====================================================================================================
	function test_for_int(charCode)
	{
		return !(charCode > 31 && (charCode < 48 || charCode > 57));
	}
	
	//====================================================================================================
	function test_for_enter(charCode){
		return charCode == 13;
	}
	
	//====================================================================================================
	//====================================================================================================
	//====================================================================================================
	//====================================================================================================
	//====================================================================================================
	//====================================================================================================
	//====================================================================================================










	//====================================================================================================
var test_an = 4;
var test_array = new Array(test_an);
var test_no = 0;
function display_test_array()
{
	for(var i = 0; i < test_an; i++){
		alert(test_array[i]);
	}
	test_no = 0;
}
	//====================================================================================================
function add_test_array(src)
{
	if(test_no < test_an){
		test_array[test_no++] = src;
	}
}
	
