
star1 = typeof star1 == "undefined" ? "/swift_data/source/images/star-a.png" : star1;
star2 = typeof star2 == "undefined" ? "/swift_data/source/images/star-b.png" : star2;
star3 = typeof star3 == "undefined" ? "/swift_data/source/images/star-c.png" : star3;

function UkazMenu ( which )
{
	var div = document.getElementById ( "podmenu1" );
	var i = 1;

	while ( i < 20 && div != null )
	{
		div.style.display = i == which ? "block" : "none";

		i++;

		div = document.getElementById ( "podmenu" + i );
	}
}

function SkryMenu ()
{
	var div = document.getElementById ( "podmenu1" );
	var i = 1;

	while ( i < 20 && div != null )
	{
		div.style.display = "none";

		i++;
		
		div = document.getElementById ( "podmenu" + i );
	}	
}

function UkazSkryReci(force_hide)
{
	var div = document.getElementById ( "mutf" );

	if (div == null)
		return;

	if (force_hide)
		div.style.display = "none";
	else
		div.style.display = div.style.display == "block" ? "none" : "block";
}

function SkryReci()
{
	UkazSkryReci(true);
}

function fbs_click ( url, title )
{
	u=url;
	t=title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');

	return false;
}

function twi_click ( url, title )
{
	u=url;
	t=title;
	window.open('http://twitter.com/home?status=' + encodeURIComponent(t) + ' - ' + encodeURIComponent(u), 'twitter', '');

	return false;
}

function _OpenWindow ( url, w, h, b_scrollbars, b_resizable )
{
	var twidth = w;
	var theight = h;
	
	var i_scrollbars = b_scrollbars ? 1 : 0;
	var i_resizable = b_resizable ? 1 : 0;
	
	if(twidth > screen.width - 40) twidth = screen.width - 40;
	if(theight > screen.height - 40) theight = screen.height - 40;
	
	var pos_x = (screen.width - twidth - 10)/2;
	var pos_y = (screen.height - theight - 29)/2;
	
	if(typeof(okno) == "undefined" || okno.closed)
		okno = window.open(url,'okno','status=no,menubar=0,toolbar=0,location=0,scrollbars=' + i_scrollbars + ',screenX='+pos_x+',screenY='+pos_y+',left='+pos_x+',top='+pos_y+',width='+twidth+',height='+theight+',resizable=' + i_resizable );
	else okno.location.href = url;

	okno.focus();
}

function UkazGaleriu ( url )
{
	_OpenWindow ( url, 660, 750, true, false );
}

function UkazVideo ( url )
{
	_OpenWindow ( url, 440, 300, true, false );
}

function HviezdaPovodna ()
{
	Hviezda ( this );
}

function Hviezda ( obj )
{
	if ( obj != null && typeof obj.tagName != "undefined" && obj.tagName.toLowerCase () == "a" )
	{
		var rat = true;
		var actual = parseInt ( String ( obj.getAttribute ( "rel" ) ) );
		var l = Math.floor ( actual );
		var m = l == actual ? 0 : ( l + 1 );			
	}else
	{
		obj = this;
	}
	
	var div = obj.parentNode;
	
	if ( div == null ) return;

	var star = star1;

	for ( var i=1; i<=div.childNodes.length; i++ )
	{
		var child = div.childNodes[i-1];
		var img = child.firstChild;

		if ( rat )
		{			
			star = star2;
			if ( i <= l )
			{
				star = star1;
			}else if ( i == m )
			{
				star = star3;
			}	
		}

		img.src = star;

		if ( rat != 1 && child == obj )
		{
			star = star2;		
		}
	}
}

function UkazVelkuIkonu(nr)
{
	var ml = -41;

	var div = document.getElementById ( "velka_ikona" );
	var child = div.firstChild;

	child.innerHTML = icon_text[nr-1];
	div.style.marginLeft = ( ( ( nr - 1 ) * 63 ) + ml ) + "px";
	div.style.display = "block";
}

function SkryVelkuIkonu ( obj )
{
	var div = document.getElementById ( "velka_ikona" );

	div.style.display = "none";
}

function _SetupVotes ()
{
	var div = document.getElementById ( "hlasovanie" );

	if ( div == null ) return;

	for ( var i=0; i<div.childNodes.length; i++ )
	{
		var child = div.childNodes[i];

		if ( typeof child.tagName == "undefined" || child.tagName.toLowerCase () != "a" ) continue;

		var relAttribute = String(child.getAttribute("rel"));

		child.onmouseover = Hviezda;
		child.onmouseout = HviezdaPovodna;
	}
}

function _SetupAnchors ()
{
	var anchors = document.getElementsByTagName ( "a" );

	for ( var i = 0; i < anchors.length; i++ )
	{
		var anchor = anchors[i];

		var relAttribute = String(anchor.getAttribute("rel"));

		if (anchor.getAttribute("href"))
		{
			if ( relAttribute.match ( /^UkazGaleriu/ ) || relAttribute.match ( /^UkazVideo/ ) )
			{
				eval ( "anchor.onclick = function () { " + relAttribute + "; return false; }" );

				anchor.href = "javascript:void(0)";
			}
		}
	}
	
	_SetupVotes ();
}

function OnLoad ()
{
	_SetupAnchors ();
}

if ( window.addEventListener )
{
	window.addEventListener ( "load", OnLoad, false );
}else if ( window.attachEvent )
{
	window.attachEvent ( "onload", OnLoad );
}else
{
	window.onload = function () { OnLoad (); }
}
