///////////////////////////////////////////////
// indicates the language used "FR" or "EN"
var language;

////////////////////////////////////////////////
// création d'une nouvelle fenêtre pour afficher
// les informations détaillées sur un site bois
var windowContent = "";
var windowSynthese = "";
var  isOKApplet = "n";


var windowFrame = null;
var windowID = 0;


function newListe( content )
{
	//alert('[ENTER:newListe]');
	//windowContent = content;
	
	if (language == 'FR')
		windowWindow = 'ListeSites.asp?'+ content ;
	else
		windowWindow = 'SitesList.html';

	topW = (screen.height - 400) / 2
	leftW = (screen.width -700) /2

	windowFrame = window.open( windowWindow, "", "scrollbars,width=700, height=400, left=" + leftW +", top=" + topW +"");
	//windowFrame.moveTo( 0, 0); 
	//windowFrame.resizeTo( screen.availWidth, screen.availHeight / 2);
}

function newSite( id, type )
{
	//alert('[ENTER:newSite]');
	//windowContent = content;
	if (type == '0' || type == '1')
	{
		winWidth = 700;
		winHeight = 400;
	}
	else
	{
		winWidth = 700;
		winHeight = 300;
	}	


	if (language == 'FR')
		windowWindow = 'detail.asp?id=' + id + '&type=' + type;
	else
		windowWindow = 'detail_en.asp?id=' + id + '&type=' + type;
	
	topW = (screen.height - 400) / 2
	leftW = (screen.width - 600) /2


	windowFrame = window.open( windowWindow, "_blank", "scrollbars,width=" + winWidth + ", height=" + winHeight + ", left=" + leftW +", top=" + topW +"");
	//windowFrame.moveTo( screen.availWidth * 0.25, screen.availHeight * 0.05); 
	//windowFrame.resizeTo( screen.availWidth * 0.8, screen.availHeight * 0.95);
}

function getContent( )
{
	//alert('[ENTER:getContent]');
	if (opener == null)
		document.write( "<H3>La fenêtre parente introuvable<H3>");
	else if (opener.windowContent == null)
		document.write( "<H3>Détails du site introuvables<H3>");
	else
		//alert(opener.windowContent) ;
		document.write( opener.windowContent);
}

function newTab( code)
{
	//alert( code);
	codeTab = code;
	//document.write( codeTab);
	//history.go( 0);
}

function getSynthese( )
{
	// attente de resultat de l'applet
		// ecriture des données

/*	if(  document.applets("TabSynthese") == "[object]" )
	{
		history.go( 0);
		return;
	}
*/
	//while( isOKApplet == "n")
	//alert(isOFApplet);
	appletCharg();
	

}

function siteSelected( )
{
	//alert('[ENTER:siteSelected]');
	if (opener == null)
		document.write( "<H3>La fenêtre parente introuvable<H3>");
	else if (opener.document.applets["CarteBois"] == null){
		document.write( "<H3>L'applet de la fenêtre parente introuvable<H3>");
		//alert('erreur');
	}
	else{
		//alert('cest là');
		opener.document.applets["CarteBois"].showContent( windowID);
	}
}

function isOK( is)
{

	isOKApplet = is;
}

function appletCharg()
{
// alert ("isOKApplet = " + isOKApplet )

	if( isOKApplet == "n")
	{
		setTimeout("appletCharg()",100);
	}
	else
	{	
		//window.document.applets("TabSynthese").getCode();
		window.document.applets[0].getCode();
		window.document.write( codeTab);
	}
}