/****************************************************************************************************************/
var actualposition = null;
var scrollH = 0;	// scrollY
var windowH = 0;	// largeur de la fenêtre

var isIE = false;
var isFF = false;

var strChUserAgent = navigator.userAgent;
var intSplitStart = strChUserAgent.indexOf("(",0);
var intSplitEnd = strChUserAgent.indexOf(")",0);
var strChStart = strChUserAgent.substring(0,intSplitStart);
var strChMid = strChUserAgent.substring(intSplitStart, intSplitEnd);
var strChEnd = strChUserAgent.substring(strChEnd);

if((strChMid.indexOf("MSIE 7") != -1) || (strChMid.indexOf("MSIE 6") != -1))
    isIE = true;
else 
    isFF = true;

function showmodal(divtoshow)
{
	// cache tous les controls de type select de la page (dropdown list)
	selects = document.getElementsByTagName('select');
	for(i = 0; i < selects.length; i++) {
		selects[i].style.visibility = 'hidden';
	}
	
	var modbox = document.getElementById(divtoshow);
	var shad = document.getElementById('shad');
	
	//shad.style.height = window.outerHeight + 'px';
	
	hauteur();
	
	/*alert(scrollH);
	alert(scrollW);
	alert(windowH);
	alert(windowW);*/
	
	/*alert(document.body.clientHeight);
	
	alert(window.innerHeight);
	alert(window.scrollMaxX);
	window.scrollMaxY;
	*/
	
	//alert(window.scrollMaxY + windowH);
	
	//shad.style.height = document.body.clientHeight + 'px';
	//shad.style.height = document.body.clientWidth;
	
	// IE
	if(isIE)
	    shad.style.height = scrollH + windowH + 'px';
	else
	    shad.style.height = window.scrollMaxY + windowH + 'px';
	
	//shad.width = '100%';//window.outerHeight + 'px';
    //alert(window.outerHeight);
	//actualposition = document.documentElement.scrollTop;
    //alert(document.innerHTML.height);
    //alert(document.pageXOffset);
    //alert(window.self.style.height);
    //alert(document.documentElement.scrollBottom);
	//document.body.style.overflow = 'hidden';
	//modbox.innerHTML = document.getElementById(divtoshow).innerHTML;
	shad.style.display = 'block';
	modbox.style.display = 'block';
	//document.getElementsByTagName('html')[0].style.overflow = 'hidden';
	//window.scrollTo(0,actualposition);
	
	// Centrage de la fenetre
	if(modbox.style.width.replace('px','') != '')
        modbox.style.left = ((largeur_fenetre() - parseInt(modbox.style.width.replace('px',''))) / 2) + 'px';
    else
        modbox.style.left = (largeur_fenetre() / 2) + 'px';
        
	window.scrollTo(0,0);
        
    /*
    if(modbox.style.height.replace('px','') != '')
    {
        modbox.style.top = ((hauteur_fenetre() - parseInt(modbox.style.height.replace('px',''))) / 2) + 'px';
    }
    else
    {
        modbox.style.top = (hauteur_fenetre() / 2) + 'px';
    }*/
}
/****************************************************************************************************************/
function largeur_fenetre()
{
	if (window.innerWidth) return window.innerWidth;
	else if (document.body && document.body.offsetWidth) return document.body.offsetWidth;
	else return 0;
}
/****************************************************************************************************************/
function hauteur_fenetre()
{
	if (window.innerHeight) return window.innerHeight;
	else if (document.body && document.body.offsetHeight) return document.body.offsetHeight;
	else return 0;
}
/****************************************************************************************************************/
function hauteur()
{
    if(isIE)
    {
        /*alert(document.documentElement.scrollTop);
        alert(document.body.scrollTop);
        alert(document.body.clientHeight);
        alert(document.documentElement.clientHeight);
        alert(document.scrollHeight);
        alert(document.body.scrollHeight);
        alert(document.documentElement.scrollHeight);*/
        windowH = document.documentElement.scrollHeight;

        /*scrollH = document.documentElement.scrollTop;
		scrollH = document.body.scrollTop;
	    windowH = document.body.clientHeight;*/
    }
    else
    {
	    windowH = window.innerHeight;
    }
}
/****************************************************************************************************************/
function closemodal(divtoclose)
{
	//var modbox = document.getElementById('modbox');
	var modbox = document.getElementById(divtoclose);
	var shad = document.getElementById('shad');
	
	// affiche tous les controls de type select de la page (dropdown list)
	selects = document.getElementsByTagName('select');
	for(i = 0; i < selects.length; i++) {
		selects[i].style.visibility = 'visible';
	}
	
	//modbox.innerHTML = '';
	//modbox.style.width = '';
	//modbox.style.marginLeft = '';
	modbox.style.display = 'none';
	shad.style.display = 'none';
	document.body.style.overflow = '';
	document.getElementsByTagName('html')[0].style.overflow = '';
	window.scrollTo(0,actualposition);
}
/****************************************************************************************************************/
