function mouseMove (evt) {
	var x = 0;
	var y = 0;
	var plusX = 0;
	var plusY = 0;
	if (document.layers) {
		x = evt.x;
		y = evt.y;
		plusX = window.pageXOffset;
		plusY = window.pageYOffset;
	} else	if (document.all) {
		x = event.clientX;
		y = event.clientY;
		plusX = document.body.scrollLeft;
		plusY = document.body.scrollTop;
	} else if (document.getElementById) {
		x = evt.clientX;
		y = evt.clientY;
		plusX = window.pageXOffset;
		plusY = window.pageYOffset;
	}
	if(document.getElementById("MENU_INFO"))
	{
		document.getElementById("MENU_INFO").style.left = (x+plusX-150)+"px";
		document.getElementById("MENU_INFO").style.top = (y+plusY+20)+"px";
	}
	
} 
///////////////////////////////////////////////////////////////
if (document.layers)
	document.captureEvents(Event.MOUSEMOVE); 
if (document.layers || document.all) 
	document.onmousemove = mouseMove; 
if (document.addEventListener) 
	document.addEventListener('mousemove', mouseMove, true);
///////////////////////////////////////////////////////////////
function changepen(ID_Pen)
{
	document.getElementById("PEN_ENCRIER").src="http://www.sudo-k.com/RESSOURCE/MESSENGER/ENCRE/encrier_"+ID_Pen+".jpg";
	document.getElementById("SEND_MESSAGE_FORM").elements["PEN_STYLE"].value=ID_Pen;
}
///////////////////////////////////////////////////////////////
function PreviousPaper()
{
	NumberPaper=document.getElementById("PAPER_INFO_FORM").elements["CPMT_PAPER_STYLE"].value;	
	CurrentPaper=document.getElementById("SEND_MESSAGE_FORM").elements["PAPER_STYLE"].value;
	
	//detection du papier suivant
	ListUserPaper = new Array();
	IndexCurrentPaper=0;
	for(i=0;i<NumberPaper;i++)
	{
		ListUserPaper[i]=document.getElementById("PAPER_INFO_FORM").elements["USER_PAPER_STYLE_"+i].value;	
		if(ListUserPaper[i]==CurrentPaper)
		{
			IndexCurrentPaper = i;	
		}
	}
	
	if(IndexCurrentPaper==0)
	{
		Previous_Paper = ListUserPaper[NumberPaper-1];	
	}else
	{
		Previous_Paper = ListUserPaper[IndexCurrentPaper-1];	
	}

	document.getElementById("PAPER_ICON").src="http://www.sudo-k.com/RESSOURCE/MESSENGER/PAPER/paper_"+Previous_Paper+"_icon.jpg";
	document.getElementById("SEND_MESSAGE_FORM").elements["PAPER_STYLE"].value=Previous_Paper;
	
	//alert('Nombre de papier:'+NumberPaper+' Papier courant:'+CurrentPaper+' Papier precedent:'+Previous_Paper+' IndexCurrentPaper:'+IndexCurrentPaper);
}
///////////////////////////////////////////////////////////////
function NextPaper()
{
	NumberPaper=document.getElementById("PAPER_INFO_FORM").elements["CPMT_PAPER_STYLE"].value;	
	CurrentPaper=document.getElementById("SEND_MESSAGE_FORM").elements["PAPER_STYLE"].value;
	
	//detection du papier suivant
	ListUserPaper = new Array();
	IndexCurrentPaper=0;
	for(i=0;i<NumberPaper;i++)
	{
		ListUserPaper[i]=document.getElementById("PAPER_INFO_FORM").elements["USER_PAPER_STYLE_"+i].value;	
		if(ListUserPaper[i]==CurrentPaper)
		{
			IndexCurrentPaper = i;	
		}
	}

	if(ListUserPaper[IndexCurrentPaper]==ListUserPaper[NumberPaper-1])
	{
		Previous_Paper = ListUserPaper[0];	

	}else
	{
		Previous_Paper = ListUserPaper[IndexCurrentPaper+1];	
	}

	document.getElementById("PAPER_ICON").src="http://www.sudo-k.com/RESSOURCE/MESSENGER/PAPER/paper_"+Previous_Paper+"_icon.jpg";
	document.getElementById("SEND_MESSAGE_FORM").elements["PAPER_STYLE"].value=Previous_Paper;
	//alert('Nombre de papier:'+NumberPaper+' Papier courant:'+CurrentPaper+' Papier precedent:'+Previous_Paper+' IndexCurrentPaper:'+IndexCurrentPaper);
}
///////////////////////////////////////////////////////////////
function PreviewMessage()
{
	
	Message=document.getElementById("SEND_MESSAGE_FORM").elements["MESSAGE"].value;
	ID_Pen =document.getElementById("SEND_MESSAGE_FORM").elements["PEN_STYLE"].value;
	Paper =document.getElementById("SEND_MESSAGE_FORM").elements["PAPER_STYLE"].value;
	
	content='<table width="700px"  border="0" cellpadding="0" cellspacing="0" style="word-break: break-all;">';
	content=content+'		  <tr>';
	content=content+'			<td width="67" height="100" background="../RESSOURCE/MESSENGER/PAPER/paper_'+Paper+'_corner_left.jpg">&nbsp;</td>';
	content=content+'				<td rowspan="2" valign="top" background="../RESSOURCE/MESSENGER/PAPER/paper_'+Paper+'_center.jpg">';
	content=content+'				  <table width="100%" height="50" border="0" cellpadding="0" cellspacing="0">';
	content=content+'					  <tr>';
	content=content+'						<td background="../RESSOURCE/MESSENGER/PAPER/paper_'+Paper+'_up.jpg" align="left">&nbsp;';
	content=content+'						</td>';
	content=content+'						<td background="../RESSOURCE/MESSENGER/PAPER/paper_'+Paper+'_up.jpg" align="right">&nbsp;';
	content=content+'						</td>';
	content=content+'					  </tr>';
	content=content+'				  </table>';
	content=content+'				 <span class="pen_'+ID_Pen+'"><br><br><pre><div style="width:380pt; word-wrap:breakword;">'+Message+'</div></pre></span>';
	content=content+'				</td>';
	content=content+'				<td width="67" height="100" background="../RESSOURCE/MESSENGER/PAPER/paper_'+Paper+'_corner_right.jpg">&nbsp;</td>';
	content=content+'			  </tr>';
	content=content+'			  <tr>';
	content=content+'				<td background="../RESSOURCE/MESSENGER/PAPER/paper_'+Paper+'_left.jpg">&nbsp;</td>';
	content=content+'				<td background="../RESSOURCE/MESSENGER/PAPER/paper_'+Paper+'_right.jpg">&nbsp;</td>';
	content=content+'			  </tr>';
	content=content+'		<tr>';
	content=content+'		<td height="54" colspan="3" ID="MESSAGE_PREVIEW_CADRE_FOOTER" background="../RESSOURCE/MESSENGER/PAPER/paper_'+Paper+'_footer.jpg">&nbsp;</td>';
	content=content+'		</tr>';
	content=content+'</table>';
	
	
	document.getElementById("MESSAGE_PREVIEW").innerHTML=content;	


}
//////////////////////////////////////////////////////////////////////
function ShopClickItem(ID_Item)
{
	//alert('item:'+ID_Item);
	
	if(ID_Item>1000&&ID_Item<2000)
	{
		document.getElementById("IMAGE_SHOP").style.background='url(\'RESSOURCE/SHOP/shop_pen.jpg\')';
	}
	if(ID_Item>2000&&ID_Item<3000)
	{
		document.getElementById("IMAGE_SHOP").style.background='url(\'RESSOURCE/SHOP/shop_paper.jpg\')';
	}
	if(ID_Item>3000&&ID_Item<4000)
	{
		document.getElementById("IMAGE_SHOP").style.background='url(\'RESSOURCE/SHOP/shop_bonnus.jpg\')';
	}
	if(ID_Item>4000&&ID_Item<5000)
	{
		document.getElementById("IMAGE_SHOP").style.background='url(\'RESSOURCE/SHOP/shop_mode.jpg\')';
	}
	
	document.getElementById("FORM_SHOP").elements["ID_ITEMS"].value=ID_Item;
	//document.getElementById("FORM_SHOP_DIV").innerHTML=content;	
	//makeRequest("http://www.sudo-k.com","FORM_SHOP_DIV");
	makeRequest("http://www.sudo-k.com/AJAX_QUERRY/shop.php?ID_ITEMS="+ID_Item,"FORM_SHOP_DIV");
	
}
//////////////////////////////////////////////////////////////////////
function ShowRanking(ID_User)
{
	makeRequest("http://www.sudo-k.com/AJAX_QUERRY/ranking.php?ID_USER="+ID_User,"CLASSEMENT_USER");
}
//////////////////////////////////////////////////////////////////////
function SearchRanking()
{
	//alert(document.getElementById("SEARCH_USER").value);
	Login = document.getElementById("SEARCH_USER").value;
	document.getElementById("ERROR_SEARCH").innerHTML="";
	makeRequest("http://www.sudo-k.com/AJAX_QUERRY/ranking.php?LOGIN="+Login,"CLASSEMENT_USER");
	makeRequest("http://www.sudo-k.com/AJAX_QUERRY/ranking.php?LOGIN="+Login+"&ERROR="+Login,"ERROR_SEARCH");
}
//////////////////////////////////////////////////////////////////////
function Win(time)
{
	alert('win:'+time);
}
//////////////////////////////////////////////////////////////////////
function UseBonnus(ID_Bonnus)
{
	//alert('del bonnus'+ID_Bonnus);
	makeRequestBackground("http://www.sudo-k.com/AJAX_QUERRY/bonnus_update.php?USE_BONNUS="+ID_Bonnus);
}
//////////////////////////////////////////////////////////////////////
function ShowMenuInfobulle(Text)
{
	
	//position_x = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x+document.body.scrollLeft;
	//position_y = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y+document.body.scrollTop;
	

	document.getElementById("MENU_INFO").innerHTML = Text;
	document.getElementById("MENU_INFO").style.visibility = 'visible'
	//document.getElementById("MENU_INFO").style.left = position_x -20 ;
	//document.getElementById("MENU_INFO").style.top = position_y + 10; 
}
//////////////////////////////////////////////////////////////////////
function HideMenuInfobulle()
{
	document.getElementById("MENU_INFO").innerHTML="";
	document.getElementById("MENU_INFO").style.visibility="hidden";
}
//////////////////////////////////////////////////////////////////////
function UpdateContents(http_request,updatediv) {
	if(http_request.readyState == 4 )
	{
		//alert(updatediv+"Contenu:"+http_request.responseText);
		document.getElementById(updatediv).innerHTML=http_request.responseText;
	}
}
//////////////////////////////////////////////////////////////////////
function makeRequest(url,updatediv) {

	var http_request = false;

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
			// Voir la note ci-dessous à propos de cette ligne
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	
	if (!http_request) {
		alert('Abandon :( Impossible de créer une instance XMLHTTP');
		return false;
	}
	http_request.onreadystatechange = function() { UpdateContents(http_request,updatediv); };
	http_request.open('GET', url, true);
	http_request.send(null);
}
//////////////////////////////////////////////////////////////////////
function makeRequestBackground(url,updatediv) {

	var http_request = false;

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
			// Voir la note ci-dessous à propos de cette ligne
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	
	if (!http_request) {
		alert('Abandon :( Impossible de créer une instance XMLHTTP');
		return false;
	}
	http_request.open('GET', url, true);
	http_request.send(null);
}
//////////////////////////////////////////////////////////////////////
function CCounter(ID_Div,MaxValue,InitValue,Speed,Step,Nom){
	
	this.m_InitValue=InitValue;
	this.m_MaxValue=MaxValue;
	this.m_ID_Div=ID_Div;
	this.m_Speed=Speed;
	this.m_Count=0;
	this.m_Step=Step;
	this.nom=Nom;
	
	this.Count = function()
	{
		if(this.m_Count<=this.m_MaxValue)
		{
			document.getElementById(this.m_ID_Div).innerHTML=this.m_Count;
			this.m_Count+=this.m_Step;
			setTimeout(this.nom+".Count()", this.m_Speed);
		}else
		{
			document.getElementById(this.m_ID_Div).innerHTML=this.m_MaxValue;
			this.OnStop();
		}
	}
	
	this.StartCounter = function() 
	{ 
		document.getElementById(this.m_ID_Div).innerHTML=this.m_InitValue;
		this.m_ID_Counter_Interval= setTimeout(this.nom+".Count()", this.m_Speed);
	}
}
//////////////////////////////////////////////////////////////////////
function InitVieu(PositionX,PositionY,Text)
{
	//positiony=document.body.width;
	document.getElementById('VIEU').style.top=300+"px";
	//document.getElementById('VIEU').style.left=positiony+"px";
	document.getElementById('VIEU_TEXT').innerHTML=Text+document.getElementById('VIEU').style.left;
	
	
	//alert(Text);
}


