// Script permettant la gestion de l'affichage des albums web
	var charexp = /[a-z]|[0-9]/i;
	var cdigit = /^\d*$/;

	function IsValid(pattern, str)
	{
		return pattern.test(str);
	}

	function adjustVSpaceImg(objBody, objImage, iMinSpacement)
	{
		rcts = objBody.getClientRects();
		bodyHeight = rcts[0].bottom - rcts[0].top;
		imgHeight = objImage.height;
		if (imgHeight < bodyHeight)
		{	
			iVSpace = (bodyHeight - imgHeight) / 2 - iMinSpacement;
			if (iVSpace < 0) iVSpace = iMinSpacement;
			objImage.vspace = iVSpace;
		}
		else 
			objImage.vspace = iMinSpacement;
	}

	function adjustVSpaceImgFox(objBody, objImage, iMinSpacement)
	{
		objImage.vspace = iMinSpacement;
	}


	// Cette fonction est utilisé afin de savoir si une frame portant un certain nom existe et si son url correspond à la page sFrameExpectedURL
	// Si bLoadIfWrongURL == 1 alors la frame est remplacée, rechargée donc avec l'url contenue dans sFrameExpectedURL
	// Si bLoadIfWrongURL == 0 et que la vue est loadée, renvoie l'objet même si l'url n'est pas la même ! -----> function IsThatPage(oWindow, sExpectedPageURL)
	// permet de vérifier l'url de la page
	// Renvoie un objet du type window si la frame existe sinon renvoie null
	// sFrameExpectedURL ne doit pas commencer par .. ou par / voir plus bas pourquoi (1)
	function getFrameObjectWithName(objCurWindow, sFrameNameToFind, sFrameExpectedURL, bLoadIfWrongURL)
	{
		var oWindow = null;

		if (objCurWindow.parent == null) return oWindow;

		idxFrameNumber = -1;
		var frm = objCurWindow.parent.frames;

		if (frm == null) return oWindow;

		for (i=0; i < frm.length; i++) 
		{	
			sFrameName = "" + frm(i).name;
			if (sFrameName == sFrameNameToFind)
			{
				//alert("'" + sFrameName.valueOf() + "' | " + frm(i).location);
				oWindow = frm(i);
				idxFrameNumber = i;
				break;
			}
		}

		if (idxFrameNumber >= 0)
		{
			sActualLocation = "" + frm(idxFrameNumber).location;
				
			iLen = sFrameExpectedURL.length;
			if (iLen > 0)
			{
				if (sActualLocation.length > iLen)
					sActualLocation = sActualLocation.substr((sActualLocation.length - iLen) , iLen );

				if ( (sActualLocation != sFrameExpectedURL) & (bLoadIfWrongURL == 1))
				{
					// (1) Construit l'url à partir du chemin de la page appelant ce script
					// sFrameExpectedURL ne doit pas commencer par .. ou par /
					var sRefPath = "" + window.location;
					var arrayItem = sRefPath.split("/");
					var iSize = arrayItem.length;
					var sNewUrl = "";
					var sTmp = "";
					for (i=0; i<(iSize-1);i++)
					{
						sTmp = "" + arrayItem[i] + "/";
						sNewUrl += sTmp;
					}
					sNewUrl += sFrameExpectedURL;
					frm(idxFrameNumber).location.replace(sNewUrl);
				}
			}

			return oWindow;
		}

		return null;
	}

	function IsThatPage(oWindow, sExpectedPageURL)
	{
		sActualLocation = "" + oWindow.location;
			
		iLen = sExpectedPageURL.length;
		if (iLen > 0)
		{
			if (sActualLocation.length > iLen) 
				sActualLocation = sActualLocation.substr((sActualLocation.length - iLen) , iLen );
			if (sActualLocation != sExpectedPageURL) 
				return false;
		}
		else
			return false;

		return true;
	}

	function IsLoaded(oWindow)
	{
		bRet = false;

		if (oWindow == null) return bRet;
		if (oWindow.document == null) return bRet;

		sStatus = "" + oWindow.document.readyState;
		if (sStatus == "complete") bRet = true;
		return bRet;
	}

	// ---------------------------------------------------------------------
	// Gestion du Drag and Drop dans la colonne de sélection
	// ---------------------------------------------------------------------
	var bSrcDragElement = 0;
	var objSrcDragElement = new Object;
	var bDestDragElement = 0;
	var objDestDragElement = new Object;
	var dummyObjDragged;

	function imgDragStart()
	{
		if (bSrcDragElement == 0)
		{
			bSrcDragElement = 1;
			bDestDragElement = 0;

			// get what is being dragged:
			objSrcDragElement = window.event.srcElement;

			// store the source of the object into a string acting as a dummy object so we don't ruin the original object:
			dummyObjDragged = objSrcDragElement.outerHTML;

			// post the data for Windows:
			var dragData = window.event.dataTransfer;

			// set the type of data for the clipboard:
			dragData.setData('URL', window.event.srcElement.src);

			// allow only dragging that involves moving the object:
			dragData.effectAllowed = 'linkMove';

			// use the special 'move' cursor when dragging:
			dragData.dropEffect = 'move';
		}
	}

	function imgDragEnd()
	{
		bSrcDragElement = 0;
		bDestDragElement = 0;

		window.event.dataTransfer.clearData();
	}

	function imgDragOver()
	{
		if (bSrcDragElement == 1)
		{
			if (objSrcDragElement != event.srcElement)
			{
				objDestDragElement = event.srcElement;
				bDestDragElement = 1;

				// tell onOverDrag handler not to do anything:
				window.event.returnValue = false;
			}
		}
	}

	function imgDragEnter()
	{
		// allow target object to read clipboard:
		window.event.dataTransfer.getData('URL');
	}
	// ---------------------------------------------------------------------
	// ---------------------------------------------------------------------


	// ---------------------------------------------------------------------
	// Filters Functions
	// ---------------------------------------------------------------------
	function fadeOut( obj,  transit)
	{
		obj.style.filter="blendTrans(duration=transit)";
		// Make sure the filter is not playing.
		if (obj.filters.blendTrans.status != 2)
		{
			obj.filters.blendTrans.apply();
			obj.style.visibility="hidden";
			obj.filters.blendTrans.play();
		}
	}

	function fadeIn( obj,  transit)
	{
		obj.style.filter="blendTrans(duration=transit)";
		// Make sure the filter is not playing.
		if (obj.filters.blendTrans.status != 2)
		{
			obj.filters.blendTrans.apply();
			obj.style.visibility="visible";
			obj.filters.blendTrans.play();
		}
	}

	// ---------------------------------------------------------------------
	// Browser Functions
	// ---------------------------------------------------------------------
	function IsMSIE(iMinVersion)
	{
		var bIsMSIE = false;
		var sLookForBrowser = "MSIE";
		var sUserAgent = "" + navigator.userAgent;
		var iPosAppName = sUserAgent.indexOf(sLookForBrowser);

		if(iPosAppName > -1)
		{
			bIsMSIE = true;
			iStart = iPosAppName + sLookForBrowser.length;
			iLength = sUserAgent.length - iStart;

			sVersion = sUserAgent.substr(iStart, iLength); 
			sVersion = sVersion.replace(" ", "");

			//alert(parseInt(sVersion));

			if (parseInt(sVersion) >= iMinVersion) return true;
		}

		return false;
	}

	function IsObject(obj)
	{
		if (obj == "[object]") return true;
		return false;
	}

	// Bloque le clique droit sur les pages, encore faut-il ajouter cette function comme handler dans le body sur onmouseclick
	function RightClickHandler()
	{
		if (window.event.button == 2)
		{
			alert("Right Click is disabled !\nTo copy an image, use drag and drop.");
			event.returnValue = true;
		}
	}

	function ContextMenuHandler()
	{
		alert("Context Menu is disabled !");
		event.returnValue = false;
	}

// --------------------------------------------------------------------------------------------------------
// peut être utiles mais pas encore testé, fonctionne d'après l'auteur sur MSIE, FireFox et Safary
// --------------------------------------------------------------------------------------------------------
	function findPosX(obj)
	  {
		var curleft = 0;
		if(obj.offsetParent)
			while(1) 
			{
			  curleft += obj.offsetLeft;
			  if(!obj.offsetParent)
				break;
			  obj = obj.offsetParent;
			}
		else if(obj.x)
			curleft += obj.x;
		return curleft;
	  }

	  function findPosY(obj)
	  {
		var curtop = 0;
		if(obj.offsetParent)
			while(1)
			{
			  curtop += obj.offsetTop;
			  if(!obj.offsetParent)
				break;
			  obj = obj.offsetParent;
			}
		else if(obj.y)
			curtop += obj.y;
		return curtop;
	  }
// --------------------------------------------------------------------------------------------------------
