//------------------------------------------------------------------------------
// hostile functions                                                            
//------------------------------------------------------------------------------

Hostile =
{
	currentHeight: 0, 
	
	setHeight: function(flashHeight)
	{
		Hostile.currentHeight = flashHeight;
		Hostile.getFlash().style.height = (flashHeight>WindowHeight()) ? flashHeight+'px': '100%';
	},
	
	refreshHeight: function()
	{
		Hostile.setHeight(Hostile.currentHeight);
	},
	
	dispatchScroll: function()
	{
		Hostile.getFlash().onScroll(DocumentY());
	},
	
	dispatchClick: function()
	{
		alert('coucou');
	},
	
	setScroll: function(position)
	{
		self.scrollTo(0,position);
	},
	
	setDeltaScroll: function(delta, page)
	{
		if (page) delta *= WindowHeight();
		var position = DocumentY() +delta;
		self.scrollTo(0,position);
	},
	
	getObjectCenterPosition: function(height)
	{
		return Math.ceil((WindowHeight() - height)/2 + DocumentY());
	},
	
	getFlash: function()
	{
		return document.getElementById("main");
	}
};


//------------------------------------------------------------------------------
// function WindowInfo                                                          
// donne des informations sur la fenêtre (cross-browser)                        
//------------------------------------------------------------------------------

function WindowHeight()
{
	// hauteur de la fenêtre 
	if (typeof(window.innerHeight) == "number") // non ie 
		return window.innerHeight;
	else if (document.documentElement && document.documentElement.clientHeight) // ie6 standards compliant mode 
		return document.documentElement.clientHeight;
	else if (document.body && document.body.clientHeight) // ie4 compatible 
		return document.body.clientHeight;
}



//------------------------------------------------------------------------------
// classe DocumentInfo                                                          
// donne des informations sur le document (cross-browser)                       
//------------------------------------------------------------------------------

function DocumentY()
{
	// position y du document 
	if (typeof(window.pageYOffset) == "number") // netscape 
		return window.pageYOffset;
	else if (document.body && typeof(document.body.scrollTop) == "number") // dom 
		return document.body.scrollTop;
	else if (document.documentElement && typeof(document.documentElement.scrollTop) == "number") // ie6 standards compliant mode 
		return document.documentElement.scrollTop;
}

//------------------------------------------------------------------------------
// Main object                                                                  
//------------------------------------------------------------------------------

Main =
{
	run: function()
	{
		this.include('swfobject.js');
		this.include('swfaddress.js');
		window.onresize = Hostile.refreshHeight;
		window.onscroll = Hostile.dispatchScroll;
	},
	
	include: function(jsFile)
	{
		// with document.write we're sure that the script will be loaded and 
		// executed just after the current script and in the correct order 
		document.write('<script'
			+' type="text/javascript"'
			+' src="js/' +jsFile +'"></script>');
	}
};


//------------------------------------------------------------------------------
// Main initialization                                                          
//------------------------------------------------------------------------------

Main.run();
