var foto_st=5;
var comp=1;
var rs=0;
var dbm=0;
function remove_cild(c)
{
	var b=document.getElementById("go_alls");
	var a=document.getElementById(c);
	b.removeChild(a);
	return true;
}
function add_child()
{

}
function remove_insert(b)
{
	++rs;
	if(b==1)
	{
		if(document.getElementById("go_6"))
		{
			remove_cild("go_6");
		}
		if(foto_st==(fotos_array.length))
		{
			foto_st=0;
		}
		document.getElementById("go_alls").innerHTML='<div id="go_0" style="width:0px; float:left; margin:10px;"><a id="f_'+rs+'" href="#" onclick="go_fotos(3,this.id);return false;"><img class="galerija_photo" src="'+fotos_array[foto_st]+'" width="100%" border="0" alt=""></a></div>'+document.getElementById("go_alls").innerHTML
	}
	else
	{
		if(b==2)
		{
			if(document.getElementById("go_0"))
			{
				remove_cild("go_0");
			}
			if((foto_st-5)>0)
			{
				var a=foto_st-5;
			}
			else
			{
				var a=fotos_array.length-(5-foto_st);
			}
			document.getElementById("go_alls").innerHTML=document.getElementById("go_alls").innerHTML+'<div id="go_6" style="width:0px; float:left; margin:10px;"><a id="f_'+rs+'" href="#" onclick="go_fotos(3,this.id);return false;"><img class="galerija_photo" src="'+fotos_array[a-1]+'" width="100%" border="0" alt=""></a></div>';
		}
	}
}
function write_text(a)
{
	if(foto_st-a<0)
	{
		st=fotos_array.length-a+foto_st;
	}
	else
	{
		st=foto_st-a;
	}
	document.getElementById("text").innerHTML=fotos_text_array[st];
}
function auto_start(e,h)
{
	if(e==0)
	{
		remove_insert(h);
	}
	if(h==1)
	{
		if(e<10)
		{
			++e;
			var c=0;
			while(c<6)
			{
				var b=document.getElementById("go_"+c);
				var a=parseInt(b.style.width);
				if(c==0)
				{
					b.style.width=(a+9)+"px";
				}
				else
				{
					if(c==1)
					{
						b.style.width=(a+2)+"px";
					}
					else
					{
						if(c==2)
						{
							b.style.width=(a+2)+"px";
						}
						else
						{
							if(c==3)
							{
								b.style.width=(a-2)+"px";
							}
							else
							{
								if(c==4)
								{
									b.style.width=(a-2)+"px";
								}
								else
								{
									if(c==5)
									{
										b.style.width=(a-9)+"px";
									}
								}
							}
						}
					}
				}
				var b=document.getElementById("go_"+c);
				var a=parseInt(b.style.width);
				++c;
			}
			setTimeout("auto_start("+e+","+h+")",10);
		}
		else
		{
			var g="go_5";
			var f=document.getElementById("go_alls");
			var d=document.getElementById(g);
			f.removeChild(d);
			var c=5;
			while(c>0)
			{
				--c;
				document.getElementById("go_"+c).id="go_"+(c+1);
			}
			write_text(2);
			if(foto_st==(fotos_array.length))
			{
				foto_st=0;
			}
			else
			{
				++foto_st;
			}
			if(dbm==1)
			{
				dbm=0;auto_start(0,1);
			}
			else
			{
				comp=1;
			}
		}
	}
	else
	{
		if(e<10)
		{
			++e;
			var c=1;
			while(c<7)
			{
				var b=document.getElementById("go_"+c);
				var a=parseInt(b.style.width);
				if(c==1)
				{
					b.style.width=(a-9)+"px";
				}
				else
				{
					if(c==2)
					{
						b.style.width=(a-3)+"px";
					}
					else
					{
						if(c==3)
						{
							b.style.width=(a-3)+"px";
						}
						else
						{
							if(c==4)
							{
								b.style.width=(a+3)+"px";
							}
							else
							{
								if(c==5)
								{
									b.style.width=(a+3)+"px";
								}
								else
								{
									if(c==6)
									{
										b.style.width=(a+9)+"px";
									}
								}
							}
						}
					}
				}
				var b=document.getElementById("go_"+c);
				var a=parseInt(b.style.width);
				++c;
			}
			setTimeout("auto_start("+e+","+h+")",10);
		}
		else
		{
			var g="go_1";
			var f=document.getElementById("go_alls");
			var d=document.getElementById(g);
			f.removeChild(d);
			var c=1;
			while(c<6)
			{
				++c;document.getElementById("go_"+c).id="go_"+(c-1)
			}
			write_text(4);
			if(foto_st==0)
			{
				foto_st=fotos_array.length-1;
			}
			else
			{
				--foto_st;
			}
			if(dbm==5)
			{
				dbm=0;
				auto_start(0,2);
			}
			else
			{
				comp=1;
			}
		}
	}
}
function go_fotos(d,c)
{
	if(d==1)
	{
		if(comp==0)
		{
		}
		else
		{
			auto_start(0,1);
		}
		comp=0;
	}
	else
	{
		if(d==2)
		{
			if(comp==0)
			{
			}
			else
			{
				auto_start(0,2);
			}
			comp=0;
		}
		else
		{
			if(d==3)
			{
				var b=document.getElementById(c).parentNode.id;
				if(comp==1)
				{
					comp=0;
					if(b=="go_5")
					{
						dbm=5;
						auto_start(0,2);
					}
					else
					{
						if(b=="go_4")
						{
							auto_start(0,2);
						}
						else
						{
							if(b=="go_3")
							{
								comp=1;
								var a=document.getElementById("hid").value;
								if(foto_st-a<0)
								{
									st=fotos_array.length-a+foto_st;
								}
								else
								{
									st=foto_st-a;
								}
								window.location=fotos_text_link_array[st];
							}
							else
							{
								if(b=="go_2")
								{
									auto_start(0,1);
								}
								else
								{
									if(b=="go_1")
									{
										dbm=1;
										auto_start(0,1);
									}
								}
							}
						}
					}
				}
			}
		}
	}
};


function auto_rotate()
{
	go_fotos(1,'');
	setTimeout("auto_rotate()",5000);
}

addLoadEvent(auto_rotate);

