//------------------------------------------------------------------------------------------
// Programmeur 		: (c) Daniel Lavoie
// Annee			: 2007
// Fichier 			: utils_screen.js
// But 				: librairie des functions retounant des valeurs de l'ecran du visiteur
// Modification		: -
//------------------------------------------------------------------------------------------

function utils_screen_largeur_document() {
    var windowWidth=0;
    if (typeof(window.innerWidth)=='number') {
        windowWidth=window.innerWidth;
    }
    else {
     if (document.documentElement&&
       document.documentElement.clientWidth) {
         windowWidth = document.documentElement.clientWidth;
    }
    else {
     if (document.body&&document.body.clientWidth) {
         windowWidth=document.body.clientWidth;
      }
     }
    }
    return windowWidth;
}

function utils_screen_hauteur_document() {
    var windowHeight=0;
    if (typeof(window.innerHeight)=='number') {
        windowHeight=window.innerHeight;
    }
    else {
     if (document.documentElement&&
       document.documentElement.clientHeight) {
         windowHeight = document.documentElement.clientHeight;
    }
    else {
     if (document.body&&document.body.clientHeight) {
         windowHeight=document.body.clientHeight;
      }
     }
    }
    return windowHeight;
}

function utils_screen_hauteur_page() {
	//return document.body.clientHeight;
	
	var x,y;
    var test1 = document.body.scrollHeight;
    var test2 = document.body.offsetHeight
    if (test1 > test2) // all but Explorer Mac
    {
        x = document.body.scrollWidth;
        y = document.body.scrollHeight;
    }
    else // Explorer Mac;
         //would also work in Explorer 6 Strict, Mozilla and Safari
    {
        x = document.body.offsetWidth;
        y = document.body.offsetHeight;
    }
    return y;
}

function utils_screen_position_scroll_vertial() {
    Docu=document;
    db=!Docu.documentElement.clientWidth?Docu.body:Docu.documentElement  //quirk IE6
    gk=window.Event?1:0/*Gecko*/;
    if (getInternetExplorerVersion()==-1){
    sy=gk?pageYOffset:db.scrollTop; 
      	}
  	else
  		{
  			sy=parent.document.body.scrollTop;
  			} 
                             //scroll v
    return sy;
}
function utils_screen_position_scroll_vertial_noconflict() {
    Docu=document;
    db=!Docu.documentElement.clientWidth?Docu.body:Docu.documentElement  //quirk IE6
    gk=window.Event?1:0/*Gecko*/;

    if (getInternetExplorerVersion()==-1){
    sy=gk?pageYOffset:db.scrollTop; 
      	}
  	else
  		{
  			sy=parent.document.body.scrollTop;
  			}                                //scroll v
    return sy;
}



function utils_screen_position_scroll_vertial_parent() {
	D=parent.document;
	db=!D.documentElement.clientWidth?D.body:D.documentElement //quirk IE6
	gk=window.Event?1:0/*Gecko*/;
	sy=gk?parent.pageYOffset:db.scrollTop;  
	if (getInternetExplorerVersion()==-1){
  sy=gk?parent.pageYOffset:db.scrollTop;  
      	}
  	else
  		{
  			sy=parent.document.body.scrollTop;
  			} 
    return sy;
}

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}


function utils_screen_hauteur_page_parent() {
	//return document.body.clientHeight;
	
	var x,y;
    var test1 = parent.document.body.scrollHeight;
    var test2 = parent.document.body.offsetHeight
    if (test1 > test2) // all but Explorer Mac
    {
        x = parent.document.body.scrollWidth;
        y = parent.document.body.scrollHeight;
    }
    else // Explorer Mac;
         //would also work in Explorer 6 Strict, Mozilla and Safari
    {
        x = parent.document.body.offsetWidth;
        y = parent.document.body.offsetHeight;
    }
    return y;
}
