function newWindow(newContent, width, height)
{
    var winContent = window.open(newContent, '_blank', 'width='+width+', height='+height+', resizable');
    if( !winContent ) { return; } //browser is blocking popups
}

/* links to new window */
function replacelinks()
{
    var hostname = 'http://' + location.hostname + '/';
    var links = $$('a');

    for(i=0;i<links.length;i++)
    {
        if(links[i].href.substr(0,(hostname.length)) != hostname && links[i].href.substr(0,1) != '#')
        {
            links[i].target = '_blank';
        }
    }
}

/* cookies handler for the tabs preferences */
function setCookie(c_name,value,expiredays)
{
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" + escape(value) +
    ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
    
    /* refresh the page for the new article list view */
    location.reload(true);
}

/* scroller */
var currentImage = 0;

function moveToPrevious(element, width)
{
    if(currentImage > 0)
    {
        new Effect.Move(element, { x: width, y: 0, transition: Effect.Transitions.sinoidal });
        currentImage--;
    }
}

function moveToNext(element, width, totalImages, viewSize)
{
    if(currentImage < totalImages-viewSize)
    {
        new Effect.Move(element, { x: -width, y: 0, transition: Effect.Transitions.sinoidal });
        currentImage++;
    }
}

function expandLaunchcenter()
{
    if($('launchcenterWrapper').style.height == '291px')
    {
        $('launchcenterWrapper').style.height = '50px';
        $('launchcenter').style.height = '50px';
        $('launchcenter').style.cursor = 'pointer';
    	$('launchcenter_player').style.display = 'none';
    	if ((/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)) || (/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent)))
    	{
    	    $('launchcenter_player').style.visibility = 'hidden !important';
    	}
    	$$('#launchcenter .button').each(function(o){o.style.display = 'none';});
    } else {
    	$('launchcenterWrapper').style.height = '291px';
    	$('launchcenter').style.height = '291px';
    	$('launchcenter').style.cursor = 'normal';
    	$('launchcenter_player').style.display = 'block';
    	if ((/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)) || (/Chrome[\/\s](\d+\.\d+)/.test(navigator.userAgent)))
    	{
    	    $('launchcenter_player').style.visibility = 'visible !important';
    	}
    	$$('#launchcenter .button').each(function(o){o.style.display = 'block';});
    }
}