/** Ouverture d'une nouvelle fenetre */
function popupWindow( link )
{
	window.open( link, '', '' );
}

function popupStaticPage( link, name )
{
	window.open( link, name, 'width=800, height=600, channelmode=no, resizable=no, location=no, menubar=no, status=no, scrollbars=yes, toolbar=no' );
}

function popupStaticResizablePage( link, name )
{
	window.open( link, name, 'width=800, height=600, channelmode=no, resizable=yes, location=no, menubar=no, status=no, scrollbars=yes, toolbar=no' );
}

function popupAide() {
	popupStaticResizablePage('http://www.arteradio.com/forum/posts/list/4300.page','aide');
}

function popupInfo() {
	popupStaticResizablePage('infoscontact.html','infoscontact');
}

function popupLien() {
	popupStaticResizablePage('liens.html','liens');
}

function popupCredit() {
	popupStaticPage('credits.html','credits');
}

function popupCreativeCommons() {
	popupStaticPage('creativecommons.html','creativecommons');
}

function popupDownloadSound( soundId )
{
	var link = '/front.do?method=getSoundDownload&soundId=' + soundId;
	popupDownloadSoundWindow( link, 'soundDownload' )
}

function popupDownloadSoundWindow( link, name )
{
	window.open( link, name, 'width=800, height=350, channelmode=no, resizable=no, location=no, menubar=no, status=no, scrollbars=no, toolbar=no' );
}

function popupSendSoundToFriend( link, name )
{
	window.open( link, name, 'width=800, height=400, channelmode=no, resizable=no, location=no, menubar=no, status=no, scrollbars=no, toolbar=no' );
}

function popupGetSoundPlayerCode( link, name )
{
	window.open( link, name, 'width=800, height=700, channelmode=no, resizable=no, location=no, menubar=no, status=no, scrollbars=no, toolbar=no' );
}

function popupForumConnectionWindow( link, name )
{
	window.open( link, name, 'width=800, height=700, channelmode=yes, resizable=yes, location=yes, menubar=yes, status=yes, scrollbars=yes, toolbar=yes' );
}

function doAsynchronousForumLogin( loginUrl, popupUrl )
{
    var xmlHttpReq = false;
    var self = new Object();
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }

    self.xmlHttpReq.open('POST', loginUrl, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function()
    {
        if (self.xmlHttpReq && self.xmlHttpReq.readyState == 4)
        {
        	if ( popupUrl != null )
        	{
				popupWindow( popupUrl );
			}
        }
    }
    self.xmlHttpReq.send('');
}

function writeCookie( name, value )
{
	var argv = writeCookie.arguments;
	var argc = writeCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape(value) +
	((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
	((path==null) ? "" : ("; path="+path))+
	((domain==null) ? "" : ("; domain="+domain))+
	((secure==true) ? "; secure" : "");
}

function doForumLogoutCookie()
{
	writeCookie( 'jforumAutoLogin', null );
	writeCookie( 'jforumUserId', 1 );
}