var shopDialogDiv = null;
var shopDialogTitle = null;
var shopDialogImg = null;
var shopDialogDesc = null;
var shopDialogSend = null;
var shopDialogStock = null;
var shopDialogDest = null;

function shopDialogPlay( imgDiv, title, img, desc, send, stock, dest )
{
	var coord = getCorrectPopCoord(imgDiv, 420, 224);

	shopDialogDiv.style.display = "block";
	
	shopDialogDiv.style.left = coord[0] + "px";
	shopDialogDiv.style.top = coord[1] + "px";
	
	shopDialogTitle.nodeValue = title;
	shopDialogImg.src = img;
	shopDialogImg.style.left = parseInt((150 - shopDialogImg.clientWidth) / 2) + "px";
	shopDialogImg.style.top = parseInt((166 - shopDialogImg.clientHeight) / 2 + 24) + "px";
	
	removeAllNodes(shopDialogDesc, false);
	var i = 0;
	var curTxt = "";
	var descTxt = null;
	while( i < desc.length )
	{
		if( desc.charAt(i) == '\n' )
		{
			var descTxt = document.createTextNode(curTxt);
			shopDialogDesc.appendChild( descTxt );
			curTxt = "";
			var descBr = document.createElement("br");
			shopDialogDesc.appendChild( descBr );
		}
		else
			curTxt += desc.charAt(i);
		i++;
	}
	var descTxt = document.createTextNode(curTxt);
	shopDialogDesc.appendChild( descTxt );
	
	shopDialogSend.nodeValue = send;
	shopDialogStock.nodeValue = "stock : " + stock;
	var destSplit = dest.split( '*' );
	removeAllNodes( shopDialogDest, false );
	if( destSplit[0] == '0' )
	{
		var destTxt = document.createTextNode(" (Tous pays)");
		shopDialogDest.appendChild(destTxt);
	}
	else
	{
		var destTxt1 = document.createTextNode(" (");
		shopDialogDest.appendChild(destTxt1);
		var i = 0;
		while( i < destSplit.length )
		{
			var destImg = document.createElement("img");
			destImg.style.marginRight = "4px";
			destImg.style.marginLeft = "4px";
			if( destSplit[i] == 1 )
				destImg.src = "./data/images/button/fr.gif";
			else if( destSplit[i] == 2 )
				destImg.src = "./data/images/button/su.gif";
			else if( destSplit[i] == 3 )
				destImg.src = "./data/images/button/lu.gif";
			else if( destSplit[i] == 4 )
				destImg.src = "./data/images/button/be.gif";
			else if( destSplit[i] == 5 )
				destImg.src = "./data/images/button/ca.gif";
			shopDialogDest.appendChild(destImg);
			i++;
		}
		var destTxt2 = document.createTextNode(")");
		shopDialogDest.appendChild(destTxt2);
	}
}

function shopDialogStop()
{
	shopDialogDiv.style.display = "none";
}

function initShopDialog()
{
	shopDialogDiv = document.createElement("div");
	
	shopDialogDiv.style.width = "420px";
	shopDialogDiv.style.height = "224px";
	shopDialogDiv.style.position = "absolute";
	shopDialogDiv.style.borderColor = "#08289F";
	shopDialogDiv.style.background = "#84B8E5";
	shopDialogDiv.style.borderStyle = "double";
	shopDialogDiv.style.display = "none";
	
	setOpacity( shopDialogDiv, 92 );
	
	var divTitleHR = document.createElement("hr");
	divTitleHR.style.borderColor = "#08289F";
	divTitleHR.style.borderStyle = "double";
	divTitleHR.style.margin = "0px";
	divTitleHR.style.height = "3px";
	divTitleHR.style.top = "20px";
	divTitleHR.style.width = "100%";
	divTitleHR.style.position = "absolute";
	shopDialogDiv.appendChild( divTitleHR );
	var divImgHRRight = document.createElement("div");
	divImgHRRight.style.borderColor = "#08289F";
	divImgHRRight.style.borderStyle = "double";
	divImgHRRight.style.margin = "0px";
	divImgHRRight.style.top = "20px";
	divImgHRRight.style.width = "1px";
	divImgHRRight.style.left = "150px";
	divImgHRRight.style.height = "166px";
	divImgHRRight.style.position = "absolute";
	shopDialogDiv.appendChild( divImgHRRight );
	var divImgHR = document.createElement("hr");
	divImgHR.style.borderColor = "#08289F";
	divImgHR.style.borderStyle = "double";
	divImgHR.style.margin = "0px";
	divImgHR.style.height = "3px";
	divImgHR.style.top = "192px";
	divImgHR.style.width = "100%";
	divImgHR.style.position = "absolute";
	shopDialogDiv.appendChild( divImgHR );
	var divSendHRRight = document.createElement("hr");
	divSendHRRight.style.borderColor = "#08289F";
	divSendHRRight.style.borderStyle = "double";
	divSendHRRight.style.margin = "0px";
	divSendHRRight.style.left = "300px";
	divSendHRRight.style.width = "3px";
	divSendHRRight.style.top = "192px";
	divSendHRRight.style.height = "34px";
	divSendHRRight.style.position = "absolute";
	shopDialogDiv.appendChild( divSendHRRight );
	
	// Title
	var titleDiv = document.createElement("div");
	titleDiv.style.width = "100%";
	titleDiv.style.textAlign = "center";
	titleDiv.style.fontFamily = "times";
	titleDiv.style.fontWeight = "bold";
	titleDiv.style.fontSize = "16px";
	titleDiv.style.color = "#02229A";
	shopDialogTitle = document.createTextNode("Title");
	titleDiv.appendChild( shopDialogTitle );
	
	// Image
	shopDialogImg = document.createElement("img");
	shopDialogImg.style.position = "absolute";
	shopDialogDiv.appendChild( shopDialogImg );
	
	// Description
	shopDialogDesc = document.createElement("div");
	shopDialogDesc.style.width = "246px";
	shopDialogDesc.style.top = "26px";
	shopDialogDesc.style.left = "162px";
	shopDialogDesc.style.position = "absolute";
	shopDialogDesc.style.textAlign = "left";
	shopDialogDesc.style.fontFamily = "times";
	shopDialogDesc.style.fontWeight = "bold";
	shopDialogDesc.style.fontSize = "14px";
	shopDialogDesc.style.color = "#02229A";
	descTxt = document.createTextNode("Desc");
	shopDialogDesc.appendChild( descTxt );
	
	// Send
	var sendDiv = document.createElement("div");
	sendDiv.style.width = "300px";
	sendDiv.style.top = "200px";
	sendDiv.style.position = "absolute";
	sendDiv.style.textAlign = "center";
	sendDiv.style.fontFamily = "times";
	sendDiv.style.fontWeight = "bold";
	sendDiv.style.fontSize = "14px";
	sendDiv.style.color = "#02229A";
	shopDialogSend = document.createTextNode("Send");
	sendDiv.appendChild( shopDialogSend );
	
	shopDialogDest = document.createElement("i");
	sendDiv.appendChild( shopDialogDest );
	
	// Stock
	var stockDiv = document.createElement("div");
	stockDiv.style.width = "120px";
	stockDiv.style.left = "300px";
	stockDiv.style.top = "200px";
	stockDiv.style.position = "absolute";
	stockDiv.style.textAlign = "center";
	stockDiv.style.fontFamily = "times";
	stockDiv.style.fontWeight = "bold";
	stockDiv.style.fontSize = "14px";
	stockDiv.style.color = "#02229A";
	shopDialogStock = document.createTextNode("Stock");
	stockDiv.appendChild( shopDialogStock );
	
	shopDialogDiv.appendChild( titleDiv );
	shopDialogDiv.appendChild( shopDialogDesc );
	shopDialogDiv.appendChild( sendDiv );
	shopDialogDiv.appendChild( stockDiv );
	document.getElementById('map_map_int').appendChild( shopDialogDiv );
}