

var lastParentHeight=0;
var positionOnglet = null;
var currentIframeId = null;
var activeTabBar = null;
try {
	currentIframeId = window.top.getCurrentIdIframe();
	positionOnglet = window.top.tabbar.getActiveTab().replace('MainTab_','');
	activeTabBar = window.top.tabbar.getActiveTab();
}catch(e){/*alert(e.message)*/}

	
String.prototype.trim = function()
{ return this.replace(/(^\s*)|(\s*$)/g, ""); }

function getPageSize()
{
	//var theHeight = window.innerHeight + window.scrollMaxY;
	var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY) {  
      xScroll = document.body.scrollWidth;
      yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
      xScroll = document.body.scrollWidth;
      yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
      xScroll = document.body.offsetWidth;
      yScroll = document.body.offsetHeight;
    }

    var windowWidth, windowHeight;

    if (self.innerHeight) {  // all except Explorer
      windowWidth = self.innerWidth;
      windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
      windowWidth = document.documentElement.clientWidth;
      windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
      windowWidth = document.body.clientWidth;
      windowHeight = document.body.clientHeight;
    }  
    var pageHeight, pageWidth;

    // for small pages with total height less then height of the viewport
   
    if(yScroll < windowHeight){
      pageHeight = windowHeight;
    } else { 
      pageHeight = yScroll;
    }

    // for small pages with total width less then width of the viewport
    if(xScroll < windowWidth){  
      pageWidth = windowWidth;
    } else {
      pageWidth = xScroll;
    }

    return {pageWidth: pageWidth ,pageHeight: pageHeight , windowWidth: windowWidth, windowHeight: windowHeight};
}



function deplier(ladiv,idActeur, class1, class2)
{
	if ($(ladiv)==null) return;
	if ($(ladiv).style.display=='none') {
		$(ladiv).style.display='';
		if (class1 && class2)
			$(idActeur).className=class1
	}
	else {
		$(ladiv).style.display='none';
		if (class1 && class2)
			$(idActeur).className=class2;
	}
	
	/*
	new Effect.toggle(ladiv,'blind',{duration:0.2,afterFinish:function(){
		if (class1 && class2) {
			if ($(ladiv).style.display == "")
				$(idActeur).className=class1
			else
				$(idActeur).className=class2
		}
	}
	});
	*/
}



function escapeURI(La){
  if(encodeURIComponent) {
    return encodeURIComponent(La);
  }
  if(escape) {
    return escape(La)
  }
}

function unescapeURI(La){
	
  if(decodeURIComponent) {
    return decodeURIComponent(La);
  }
  if(unescape) {
    return unescape(La)
  }
}




function printDIV(divId)
{
	if ($(divId) == null) return;
	try {
		var chInner = $(divId).innerHTML;
		for (var i=0; i < document.styleSheets.length; i++) {
			if(document.createStyleSheet)
				window.printFrame.document.createStyleSheet(document.styleSheets[i].href);
			else {
				window.printFrame.newSS = window.printFrame.document.createElement('link');
				window.printFrame.newSS.rel='stylesheet';
				window.printFrame.newSS.href = document.styleSheets[i].href;
				window.printFrame.document.getElementsByTagName('head')[0].appendChild(window.printFrame.newSS);
			}
		}
		window.printFrame.document.getElementsByTagName("body")[0].innerHTML = "	" + chInner + "	";
		//window.printFrame.document.getElementsByTagName("body")[0].innerHTML = "<textarea>"+chInner+"</textarea>";
		window.printFrame.focus();
		window.printFrame.print();
	}
	catch(e){alert(e.message)}
}
	

function updateParentHeightVertical()
{
	
	try {
		
		var theIframe = window.top.$(window.top.idIframe);
		theIframe.style.height = window.top.heightMenu;
		document.body.style.height = window.top.heightMenu;
		var theHeight = getPageSize().pageHeight;
		
		if (window.top.is_FullScreen) {
			var theTop = window.top.divFullscreen.offsetHeight - window.top.divFullscreenButtons.offsetHeight;
			theIframe.style.height = theTop;
			self.innerHeight = theTop;
			document.body.style.height = theTop;
			return;
		}
		
		
		if (theHeight<window.top.heightMenu)
			theHeight = window.top.heightMenu - 30;
		
		
		if (theHeight != lastParentHeight) {
			theHeight += 30;
			theIframe.style.height = theHeight;
			lastParentHeight = theHeight;
			return;
		}
	}catch(e){
		/*alert("Erreur dans updateParentHeightVertical : "+e.message)*/
	}
	
}

function updateParentHeight()
{	
	if (window.parent == null) return;
	if (window.top.directionMenu == 'v') {
		updateParentHeightVertical();
		return;
	}
	enableAllTabs();
	try {
		if (currentIframeId==null)
			currentIframeId = window.top.getCurrentIdIframe();
		if (positionOnglet==null)
			positionOnglet = window.top.tabbar.getActiveTab().replace('MainTab_','');
		var theIframe = window.top.$(currentIframeId);
		if (activeTabBar==null)
			activeTabBar = window.top.tabbar.getActiveTab();
		theIframe.style.height = "500";
		document.body.style.height = "500";
		
		if (window.top.is_FullScreen) {
			var theTop = window.top.divFullscreen.offsetHeight - window.top.divFullscreenButtons.offsetHeight;
			theIframe.style.height = theTop;
			self.innerHeight = theTop;
			document.body.style.height = theTop;
			return;
		}		
		var theHeight = getPageSize().pageHeight;

		if (theHeight != lastParentHeight)
			theHeight += 30;
		theIframe.style.height = theHeight;
		window.top.tabbar.adjustSizeCurrent(activeTabBar);
		lastParentHeight = theHeight;
		return;
		
	}catch(e){
		/*alert("Erreur dans updateParentHeight : "+e.message)*/
	}
}




function disableAllTabs()
{
	try {
		for (var id in window.top.tabbar.tabsId) {
			if (id != activeTabBar)
				window.top.tabbar.disableTab(id,true);
		}
	}catch(e) {/*alert(e.message)*/};
}

function enableAllTabs()
{
	try {
		for (var id in window.top.tabbar.tabsId)
			window.top.tabbar.enableTab(id,true);
	}catch(e) {/*alert(e.message)*/};
}





function execScript(divid)
{ var liste = $(divid).getElementsByTagName("script"); for (var j=0; j<liste.length; j++)
{ eval(liste[j].innerHTML);}
}
function changeCSSProperty(classe, propriete, valeur)
{ if (!document.styleSheets)
return; var cssRules = 'cssRules'; if (document.all)
cssRules = 'rules'; for (var sSheet=0; sSheet < document.styleSheets.length; sSheet++)
{ for (var rule=0; rule < document.styleSheets[sSheet][cssRules].length; rule++)
{ var currentClass = new String(document.styleSheets[sSheet][cssRules][rule].selectorText); currentClass = currentClass.toLowerCase(); if (currentClass == classe.toLowerCase())
{ document.styleSheets[sSheet][cssRules][rule].style[propriete] = valeur;}
}
}
}
function recupValeurCSS(classe,propriete)
{ if (!document.styleSheets)
return ""; var cssRules = 'cssRules'; if (document.all)
cssRules = 'rules'; for (var sSheet=0; sSheet < document.styleSheets.length; sSheet++)
{ for (var rule=0; rule < document.styleSheets[sSheet][cssRules].length; rule++)
{ var currentClass = document.styleSheets[sSheet][cssRules][rule].selectorText.substring(1); if (currentClass == classe)
{ return(document.styleSheets[sSheet][cssRules][rule].style[propriete])
}
}
}
}
function ajouter(select1, select2)
{ var usersGroups = document.getElementById(select1); var users = document.getElementById(select2); var compteselect=0; for (yo=0; yo<users.length ; yo++)
if (users.options[yo].selected)
compteselect++; if (compteselect==0)
{ return;}
for (yo=0; yo<users.length;yo++)
{ if (users.options[yo].selected)
{ nouvel_element = new Option(users.options[yo].text,users.options[yo].value,false,false); usersGroups.options[usersGroups.length] = nouvel_element; users.options[yo] = null;}
}
ajouter(select1,select2);}
function setHeight(ladiv1,ladiv2)
{ taille = $(ladiv1).offsetHeight; $(ladiv2).style.height = $(ladiv2).offsetHeight + taille;}
function getValues(idForm)
{ var chValue = ""; var formulaire = $(idForm)
var liste = formulaire.getElementsByTagName("input"); for (var k=0; k<liste.length; k++)
{ if ((liste[k].type=="radio")||(liste[k].type=="checkbox"))
{ if ((liste[k].checked)&&(liste[k].name!=""))
chValue = chValue + liste[k].name +"="+(liste[k].value)+"&";}
else
if (liste[k].name!="")
chValue = chValue + liste[k].name +"="+(liste[k].value)+"&";}
liste = formulaire.getElementsByTagName("select"); for (var k=0; k<liste.length; k++)
chValue = chValue + liste[k].name +"="+(liste[k].value)+"&"; if ((chValue.substr(((chValue.length)-1), 1)) == "&")
chValue = chValue.substr(0,((chValue.length)-1)); return(chValue);}
function imprime_zone(commande, obj)
{ var zi = document.getElementById(obj).innerHTML; var f = window.open("/common/vierge.asp", "ZoneImpr", "height=500, width=600,	toolbar=0, menubar=0, scrollbars=1, resizable=1, status=0, location=0, left=10, top=10"); alert(f); f.document.getElementsByTagName("body")[0].innerHTML += "	" + zi + "	"; f.window.print(); f.window.close(); return true;}
var ns4 = (document.layers)? true:false; var ie4 = (document.all)? true:false; var dom = (document.getElementById)? true:false; var PreloadFlag = false; function getWindowSize()
{ var MySize = new Array(); if (window.innerWidth)
MySize[0] = window.innerWidth; else
MySize[0] = document.body.clientWidth; if (window.innerHeight)
MySize[1] = window.innerHeight; else
MySize[1] = document.body.clientHeight; return MySize;}
function getLeft(MyObject)
{ if (dom || ie4)
{ if (MyObject.offsetParent)
return (MyObject.offsetLeft + getLeft(MyObject.offsetParent)); else
return (MyObject.offsetLeft);}
if (ns4)
{ return (MyObject.x);}
}
function getTop(MyObject)
{ if (dom || ie4)
{ if (MyObject.offsetParent)
return (MyObject.offsetTop + getTop(MyObject.offsetParent)); else
return (MyObject.offsetTop);}
if (ns4)
{ return (MyObject.y);}
}
function getHeight(DivId)
{ if (dom)
return (document.getElementById(DivId).offsetHeight); if (ie4)
return (document.all[DivId].clientHeight); if (ns4)
return (document.layers[DivId].clip.height);}
function getWidth(DivId)
{ if (dom)
return (document.getElementById(DivId).offsetWidth); if (ie4)
return (document.all[DivId].clientWidth); if (ns4)
return (document.layers[DivId].clip.width);}
function ExtractClip(MyString)
{ var MyClip = new Array(); if (MyString == "")
{ MyClip[0] = 0; MyClip[1] = 0; MyClip[2] = 0; MyClip[3] = 0;}
else
{ MyClip = MyString.split("rect(")[1].split(" "); for (var i=0;i<MyClip.length;i++)
{ MyClip[i] = parseInt(MyClip[i]);}
}
return MyClip;}
function getClip(DivId)
{ var MyClip = new Array(); var MyString = ""; if (dom)
{ MyString = document.getElementById(DivId).style.clip; MyClip = ExtractClip(MyString);}
else if (ie4)
{ MyString = document.all[DivId].style.clip; MyClip = ExtractClip(MyString);}
else if (ns4)
{ MyClip[0] = document.layers[DivId].clip.top; MyClip[1] = document.layers[DivId].clip.right; MyClip[2] = document.layers[DivId].clip.bottom; MyClip[3] = document.layers[DivId].clip.left;}
var MyVal = ""
for (var i=0;i<MyClip.length;i++)
{ MyVal = MyVal + " " + MyClip[i];}
return MyClip;}
function SetToXY(DivId,Coordinates)
{ if (dom)
{ document.getElementById(DivId).style.left = Coordinates[0]; document.getElementById(DivId).style.top = Coordinates[1];}
if (ie4)
{ document.all[DivId].style.posLeft = Coordinates[0]; document.all[DivId].style.posTop = Coordinates[1];}
if (ns4)
{ document.layers[DivId].pageX = Coordinates[0]; document.layers[DivId].pageY = Coordinates[1];}
}
function SetToAnchor(AnchorId,AnchorName,DivId)
{ var MyCoordinates = new Array(); var MyAnchor; if (dom)
{ MyAnchor = document.getElementById(AnchorId);}
else if (ie4)
{ MyAnchor = document.all[AnchorId];}
else if (ns4)
{ MyAnchor = document.anchors[AnchorName];}
MyCoordinates[0] = getLeft(MyAnchor); MyCoordinates[1] = getTop(MyAnchor); SetToXY(DivId,MyCoordinates); return MyCoordinates;}
function SetClip(DivId,MyClip)
{ if (dom)
{ document.getElementById(DivId).style.clip = "rect("+MyClip[0]+"px "+ MyClip[1]+"px "+ MyClip[2]+"px "+ MyClip[3]+"px)";}
else if (ie4)
{ document.all[DivId].style.clip = "rect("+MyClip[0]+"px "+ MyClip[1]+"px "+ MyClip[2]+"px "+ MyClip[3]+"px)";}
else if (ns4)
{ document.layers[DivId].clip.top = MyClip[0]; document.layers[DivId].clip.right = MyClip[1]; document.layers[DivId].clip.bottom = MyClip[2]; document.layers[DivId].clip.left = MyClip[3];}
}
function Show(DivId)
{ if (dom)
{ document.getElementById(DivId).style.visibility = "visible";}
else if (ie4)
{ document.all[DivId].style.visibility = "visible";}
else if (ns4)
{ document.layers[DivId].visibility = "show";}
}
function Hide(DivId)
{ if (dom)
{ document.getElementById(DivId).style.visibility = "hidden";}
else if (ie4)
{ document.all[DivId].style.visibility = "hidden";}
else if (ns4)
{ document.layers[DivId].visibility = "hide";}
}
function PreloadImages()
{ var MyArguments = PreloadImages.arguments; var MyImages = new Array(); if (document.images)
{ for(var i=0; i<MyArguments.length; i++)
{ MyImages[i]= new Image(); MyImages[i].src = MyArguments[i];}
PreloadFlag = true;}
}
function ChangeImages()
{ var MyArguments = ChangeImages.arguments; var ImgName; for(var i=0; i<MyArguments.length; i+=2)
{ ImgName = MyArguments[i]; document.images[ImgName].src = MyArguments[i+1];}
}
Array.prototype.inArray = function(val)
{ for(var a2 = 0; a2 < this.length; ++a2)
{ if(this[ a2] == val)
return true;}
return false;}
/*
document.getElementsByClassName = function(className)
{ var elts = document.getElementsByTagName('*'); var classArray = new Array(); for (var j = 0; j < elts.length; ++j)
{ if (elts[j].getAttribute('class') && elts[j].getAttribute('class').split(' ').inArray(className))
{ classArray.push(elts[j]);}
}
return classArray;}
*/


function selectAll(idSelect)
{
	var theSelect=$(idSelect);
	for (var i=0; i<theSelect.options.length; i++)
		theSelect.options[i].selected = true;
}




function OnlyNumber(e)
{
	var IE5 = false;
	if (!e) var e = window.event;
	if (e.keyCode) { IE5= true; code = e.keyCode;}
	else if (e.which) code = e.which ;
	if (code < 48 || code > 57)
	{
		if (code != 46) {
			if(IE5) e.returnValue = false;
			else e.preventDefault();
		}
	}
}


//************************************************************************
function $() {
  var results = [], element;
  for (var i = 0; i < arguments.length; i++) {
    element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);
    results.push(element);
  }
  return results.length < 2 ? results[0] : results;
}
//************************************************************************



function setImgTagXsl(url)
{
	var taille = "";
	if (url.indexOf('/22/') > -1) taille='22';
	if (url.indexOf('/16/') > -1) taille='16';
	if (taille != '')
		return "<img src='"+url+"' align='absmiddle' border='0' height='"+taille+"' width='"+taille+"' class='pngHack'/>&nbsp;"
	return "<img src='"+url+"' align='absmiddle' border='0' class='pngHack'/>&nbsp;"
}


 
function getAbsoluteLeft(htmlObject){
 var xPos = htmlObject.offsetLeft;
 var temp = htmlObject.offsetParent;
 while(temp != null){
 xPos+= temp.offsetLeft;
 temp = temp.offsetParent;
}
 return xPos;
}
 
function getAbsoluteTop(htmlObject){
 var yPos = htmlObject.offsetTop;
 var temp = htmlObject.offsetParent;
 while(temp != null){
 yPos+= temp.offsetTop;
 temp = temp.offsetParent;
}
 return yPos;
}
 