// JavaScript Document

//*************************************  Library/tools-swapimage.js  *******************************
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//*************************************  Library/tools.js *******************************
function getQueryString(key)
{
query = parent.location.search;
//alert("Maintenance - query = "+ query + " query.length = "+ query.length);
if (query.length > 3)
	{		
		query = query.substring(1, query.length); 
		for(var i=0; i < query.split("&").length; i++)
		{
			subQuery = query.split("&")[i];
			subQueryKey = subQuery.split("=")[0];
			subQueryValue = subQuery.split("=")[1];
			if (subQueryKey.toLowerCase()==key.toLowerCase())
			{

				var result ; 
				//result =decodeURIComponent(subQueryValue);
				result = unescape(subQueryValue); 
				//result = decodeURI(subQueryValue); 
				return result;
			}
		}
	}
	else
	{
		return "";
	}
}


//***************************************************************************
// affichage dynamique d'images
//--------------------------------------------------------------------------
function resizeImagePourc(image_ClientId, pourc) {
	//*******************************************************
    //****** NB : PERSO : mieux vaut utiliser les CSS pour 
	//******  	plus de simplicité et pas de dysfonctionnement avec firefox
	//*******************************************************
	
	//resize an image by x pourcentage ex.  pourc = 5 (-> +5%)  ; pourc = -5.5  (-> -5.5%)
    //alert(image_ClientId);
    var myControl = document.getElementById(image_ClientId);

	//-------------------------
    var width;
    if (myControl.style.width.indexOf("p", 0) > -1) 
	{
        width = myControl.style.width.substring(0, myControl.style.width.indexOf("p", 0));
    }
    else 
	{
        width = myControl.style.width;
    }
	if (width=="" || width==0)  // si le width n'a pas été trouvé dans le style alors on le cherche directement dans la balise width
	{ 
		width = myControl.width; 		
	}
  
  	//-------------------------
    var height;
    if (myControl.style.height.indexOf("p", 0) > -1) 
	{
        height = myControl.style.height.substring(0, myControl.style.height.indexOf("p", 0));
    }
    else 
	{
        height = myControl.style.height;
    }
	if (height=="" || height==0)  // si le width n'a pas été trouvé dans le style alors on le cherche directement dans la balise width
	{ 
		height = myControl.height; 
		
	}
    
	//alert("In-width = "+width+"|"+"In-height = "+height);

	//-------------------------
    //change dimension of the image
    width = Math.round(width * (1 + pourc / 100));
    myControl.style.width = width;
	//myControl.width = width;
	
    height = Math.round(height * (1 + pourc / 100));
    myControl.style.height = height;
	//myControl.height = height;
	
	//alert("Out-width = "+width+"|"+"Out-height = "+height);

}

function ShowImage(image_ClientId, width, height) {
    var myControl = document.getElementById(image_ClientId);
    //alert(myControl.width + " " + myControl.height)
    myControl.width = width; myControl.height = height;
}
function HideImage(image_ClientId) {
    var myControl = document.getElementById(image_ClientId);
    //alert(  myControl.width + " "+myControl.height)
    myControl.width = 0; myControl.height = 0;
}




//***************************************************************************
// Affiche la page sous forme de popup et focus dessus
//--------------------------------------------------------------------------
function popitup(url,heightpopup,widthpopup)
{
	popitup(url,heightpopup,widthpopup,'no','yes','yes','name');
}	

function popitup(url, heightpopup, widthpopup, location, resizable, scrollbars, name) {	
	newwindow= window.open(url,name,'height='+heightpopup+',width='+widthpopup+',location ='+location+',resizable ='+resizable+',scrollbars='+scrollbars);
		 if (window.focus) {newwindow.focus();}

}