function vis( obj, what, inline )
{
	var div = null;

	if (! what)
	{
		what = 'hide';
	}

	if (document.getElementById)
	{
		div = document.getElementById(obj);
	}
	else if (document.all)
	{
		div = document.all[obj];
	}
	else if (document.layers)
	{
		div = document.layers[obj];
	}
	
	if ( div.style )
	{
		if ( what == 'show' )
		{
			if ( inline )
			{
				div.style.display = 'inline';
			}
			else
			{
				div.style.display = 'block';
			}
		}
		else
		{
			div.style.display = 'none';
		}
	}
	else if ( div )
	{
		if (what == 'show')
		{
			div.visibility = 'show';
		}
		else
		{
			div.visibility = 'hidden';
		}
	}
}

function classChange( newClass, obj )
{
	var object = null;

	if (document.getElementById)
	{
		object = document.getElementById(obj);
	}
	else if (document.all)
	{
		object = document.all[obj];
	}
	else if (document.layers)
	{
		object = document.layers[obj];
	}

	if ( object )
	{
		object.className = newClass;
	}
}

function switch_tabs( show, list, inline )
{
	for (var i = 0; i < list.length; i++)
	{
		if ( show == list[ i ] )
		{
			vis( show + '_tab', 'show', inline );
			classChange('tabSelected', show);
		}
		else
		{
			vis( list[ i ] + '_tab', 'hide', inline );
			classChange('tab', list[ i ]);
		}
	}
}

function on_b(obj)
{
	obj.style.backgroundColor='#E7E7E3';
	obj.style.cursor='hand';
}

function off_b(obj)
{
	obj.style.backgroundColor='#FFFFFF';
}

/* COOKIES */

/**
 * Read the JavaScript cookies tutorial at:
 *   http://www.netspade.com/articles/javascript/cookies.xml
 */

function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=05 Jan 2010 00:00:00 GMT" : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

function addBookmark(title,url)
{ 
	if (window.sidebar) { 
	window.sidebar.addPanel(title, url,"");
	} else if( document.all ) {
	window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
	return true;
	}
}

function openNewWin(theURL,winName,features)
{
	window.open(theURL,winName,features);
}

function rateOn( id, pos )
{
	for ( i = 1; i <= pos; i++ )
	{
		object = document.getElementById( 'rate_' + id + '_' + i );
		object.src = 'http://wiadomosc.info/portal/icons/star_on.gif';
	}
}

function rateOff( id, c )
{
	if (! c )
	{
		c = 10;
	}

	for ( i = 1; i <= c; i++ )
	{
		object = document.getElementById( 'rate_' + id + '_' + i );
		object.src = 'http://wiadomosc.info/portal/icons/star_off.gif';
	}
}

function rateGenerate( id, address, order, cid, start, title, c )
{
	if (! c )
	{
		c = 10;
	}

	for ( i = 1; i <= c; i++ )
	{
		document.write("<a href='"+address+"?code=rate&amp;cid="+cid+"&amp;vote="+i+"&amp;rid="+id+"&amp;order="+order+"&amp;start="+start+"' title='"+title+"'><img src='http://wiadomosc.info/portal/icons/star_off.gif' id='rate_"+id+"_"+i+"' alt='"+title+"' onmouseover='rateOn("+id+","+i+");' onmouseout='rateOff("+id+","+c+");' /></a>");
	}
}

function replace (inString,oldText,newText)
{
	return (inString.split(oldText).join(newText));
}