var site_url;
var width=250;
var height=110;

function init(url,w,h)
{
	site_url = url;
	if (w != undefined)
		width = w;
	if (h != undefined)
		height = h;		
}

function popup(titre,msg)
{
	moo.alert(titre, msg);
}

function connexion()
{
	var login = $('#user')[0].value;
	var pass = $('#pass')[0].value;
	 $.ajax({
   				type: "POST",
   				url: site_url + 'connexion.php',
   				data:'login='+ login + '&pass=' + pass,
   				success: responseConnexion
   			}
 			);
 return false;
}

function responseConnexion(r)
{
	if (r.indexOf('connected') >= 0)
	{
		top.location = site_url;
		return;
	}
	$('#span_message')[0].innerHTML =  r + '<br /><input type="button" class="nicebutt" onclick="tb_remove();" value="ok" class="nicebutt" />';
	tb_show('','#TB_inline?keepThis=true&width='+width+'&height='+height+'&inlineId=message',false);
	$('#TB_ajaxContent').css({overflow:'hidden'});
	return;
}


function guess_sub()
{
	var login = $('#pseudo')[0].value;
	var mail = $('#mail')[0].value;
	var options = $('#country')[0].options;
    for(i=0 ; i<options.length ; i++)
	  if(options[i].selected)
	    {
			var country = $('#country')[0].value;
			break;    	
	    }
	
	 $.ajax({
   				type: "POST",
   				url: site_url + 'guess.php',
   				data:'login='+ login + '&mail=' + mail + '&country=' + country,
   				success: responseGuess
   			}
 	);
 return false;
}

function responseGuess(r)
{
	$('#span_message')[0].innerHTML = r + '<br /><br /><input type="button" class="button" onclick="tb_remove();" value="ok" class="nicebutt" />';
	tb_show('','#TB_inline?keepThis=true&width='+width+'&height=140&inlineId=message',false);
	$('#TB_ajaxContent').css({overflow:'hidden'});
	return;
}

//window.addEvent('domready',init);