// © ATELIER 33 / ALL RIGHTS RESERVED / 2008 / http://www.atelier33.com / contact@atelier33.com
// Toute copie complete ou partielle de ce code est interdite ;) -=]U-R[=-
//=============================================================================================\\
//                                          COMMON LIB                                         \\
//=============================================================================================\\
//----------------------
//MISC
//----------------------
function AddToBMK()
{
	browserName = navigator.appName; browserVer = parseInt(navigator.appVersion);
	if (browserName=="Microsoft Internet Explorer" && browserVer>=4){window.external.AddFavorite(location.href, document.title);}
	else {alert(ExpBMK);}
}
//----------------------

function PrintIt() {
    if (document.all) {
        if (navigator.appVersion.indexOf("5.0") == -1) {
            var OLECMDID_PRINT = 6;
            var OLECMDEXECOPT_DONTPROMPTUSER = 2;
            var OLECMDEXECOPT_PROMPTUSER = 1;
            var WebBrowser = "<OBJECT ID=\"WebBrowser1\" WIDTH=0 HEIGHT=0 CLASSID=\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\"></OBJECT>";
            document.body.insertAdjacentHTML("beforeEnd", WebBrowser);
            WebBrowser1.ExecWB(6, 2);
            WebBrowser1.outerHTML = "";
        } else {
            self.print();
        }
    } else {
        self.print();
    }
}
//----------------------
function Monify(value)
{ var str = "" + Math.round(value*100); var len = str.length; return (str=="0")?"":(str.substring(0,len-2)+"."+str.substring(len-2,len));}
//----------------------
function FullScreen(){var winWi=screen.availWidth-10; var winHei=screen.availHeight-20; self.resizeTo(winWi, winHei); self.moveTo(3, 3);}
//----------------------
//CHECK
//----------------------
function CountChar(pvTxtLen, pvCounterBox){var pvAct=eval(pvCounterBox+"="+pvTxtLen);}
//----------------------
function check_empty(text){return (text.length > 0);} 
//----------------------
function check_list(box){	if(box.options.length==0){return false;} else {return true;}}
//----------------------
function check_email(adresse)
{
 if ((adresse == "") || (adresse.indexOf ('@') == -1) || (adresse.indexOf ('.') == -1))
      return false;
    return true;
}
//----------------------
function check_int(DaBox, IsPositif, IsZero)
{
	var DaAction=eval("DaVal=DaBox.value"); DaVal=DaVal.replace(" ","");
	var AllowNum="0123456789"; var bInt=true; var iChar=0; var sChar="";
	var msg="";
	
	if(!check_empty(DaVal)){return false;}
	

	for(iChar=0; iChar<DaVal.length; iChar++)
		{
		sChar=DaVal.charAt(iChar); 
		//if(iChar==0 && parseInt(sChar)==0){return false; break;}		
		bInt=(AllowNum.indexOf(sChar, 0)>=0)
		//msg+=iChar+" | "+sChar+" | "+bInt+"\n";
		if(!bInt){return false; break;}
		}
	//alert(msg)
	
	if(IsPositif && DaVal<0){return false;}
	if(!IsZero && DaVal==0){return false;}
	if(IsZero && DaVal==0){DaVal=0}	
	if (isNaN(DaVal)){return false;} else {DaAction=eval("DaBox.value=DaVal"); return true;}
}
//----------------------
function check_float(DaBox, IsPositif, IsZero)
{
	var DaAction; 
	DaAction=eval("DaVal=DaBox.value"); DaVal=DaVal.replace(" ",""); DaVal=DaVal.replace(",",".");	
	DaVal=parseFloat(DaVal);
	
	if(IsPositif && DaVal<0){return false;}
	if(!IsZero && DaVal==0){return false;}
	if(IsZero && DaVal==0){DaVal=0}	
	if (isNaN(DaVal)){return false;} else {DaAction=eval("DaBox.value=DaVal"); return true;}
}
//----------------------
function check_len(pvName, pvForm)
{
	var pvTxtLen=eval(pvForm+"."+pvName+".value.length");
	var pvTxtLenMax=eval(pvForm+"."+pvName+"LM.value");
	var pvAct=eval(pvForm+"."+pvName+"CW.value="+pvTxtLen);
	if (parseInt(pvTxtLen)>parseInt(pvTxtLenMax)){return false;} else {return true;}
}
//----------------------
function check_url(DaUrl,DaType)
{
	var e; 
	switch (DaType)
	{
		case "VALIDE"	:			 
			 e=new RegExp("^(http://|https://){0,1}[A-Za-z0-9][A-Za-z0-9\-\.]+[A-Za-z0-9]\.[A-Za-z]{2,}[\43-\176]*$");
			 //alert(DaUrl); alert(e.test(DaUrl));
			 if (!e.test(DaUrl)){return false;} else {return true;}
			break;
   	default				: 
			if(DaUrl!=""){winUrl=window.open(DaUrl,'URL','menubar=yes,scrollbars=yes,resizable=yes,status=yes,width=500,height=500');}
			break;       
	}	
}
//----------------------
function check_tel(DaBox, IsOblg)
{
	//VARS
	var sMsg=""; var temp=""; var DaAct=""; var bCheck=false;	var reg=/^\d+$/
	//TO LOWER CASE
	temp=eval("DaBox.value.toLowerCase()"); 
	if(IsOblg){bCheck=true;}	else {if(temp!=""){bCheck=true;}}	
	if(bCheck)
		{
		temp=temp.replace(/[abcdefghijklmnopqrstuvwxyz]/gi,"");
		temp=temp.replace(/[ ]/gi,"");
		temp=temp.replace(/[\.]/gi,"");	
		temp=temp.replace(/[\\]/gi,"");
		temp=temp.replace(/[\/]/gi,"");	
		temp=temp.replace(/[\[\]]/gi,"");
		temp=temp.replace(/[-,;?!:&=+#<>]/gi,"");
		temp=temp.replace(/[*°\(\)%]/gi,"");
		DaAct=eval("DaBox.value=temp");
		//REG EXP CHECK	+ OUTPUT		
		if((reg.exec(temp)==null) || (temp.length<10)){return false;}
		else 																					{return true;}
		}
	else
		{return true}
}
//----------------------
function check_date(d) 
{	
	var e; var j=0; var m=0; var a=0;
	//jj/mm/aa ou jj/mm/aaaa
	//EMPTY ?
	if (d==""){return false;}
	
	//10 ALPHA ?
	if (d.length!=10){return false;}
		
	//REG EXP ?
	e=new RegExp("^[0-9]{1,2}\/[0-9]{1,2}\/([0-9]{2}|[0-9]{4})$");
	if (!e.test(d))	{	return false;}
	else
			{
				//GRAB jj mm aaaa || aa
				j=parseInt(d.split("/")[0], 10); m=parseInt(d.split("/")[1], 10); a=parseInt(d.split("/")[2], 10);
				//COMPLETE aa
				if (a<1000){if (a < 89){a+=2000;} else {a+=1900;}}
				//ANNEE BISEXTILE
				if (a%4==0 && a%100!=0 || a%400==0){fev=29;} else {fev=28;}
				//NB JOURS
				nbJours=new Array(31,fev,31,30,31,30,31,31,30,31,30,31);
				//CHECK jj mm aaaa
				return (m>=1 && m<=12 && j>=1 && j<=nbJours[m-1]);
		 }
}
//----------------------
function check_url(DaUrl,DaType)
{
	var e; 
	switch (DaType)
	{
		case "VALIDE"	:			 
			 e=new RegExp("^(http://|https://){0,1}[A-Za-z0-9][A-Za-z0-9\-\.]+[A-Za-z0-9]\.[A-Za-z]{2,}[\43-\176]*$");
			 //alert(DaUrl); alert(e.test(DaUrl));
			 if (!e.test(DaUrl)){return false;} else {return true;}
			break;
   	default				: 
			if(DaUrl!=""){winUrl=window.open(DaUrl,'URL','menubar=yes,scrollbars=yes,resizable=yes,status=yes,width=500,height=500');}
			break;       
	}	
}
//----------------------
function check_FldrName(DaFld, DaForm)
{
	//VARS
	var Dis=eval(DaForm); var sMsg=""; var temp="";

	//TO LOWER CASE
	init=eval("Dis."+DaFld+".value.toLowerCase()");
	temp=init;

	//REPLACE	
	temp=temp.replace(/[\\']/gi,"");
	temp=temp.replace(/[\\"]/gi,"");
	temp=temp.replace(/[’]/gi,"");
	temp=temp.replace(/[`]/gi,"");
	temp=temp.replace(/[àâä@]/gi,"a");
	temp=temp.replace(/[éèêë]/gi,"e");
	temp=temp.replace(/[îï]/gi,"i");
	temp=temp.replace(/[ôö]/gi,"o");
	temp=temp.replace(/[ùûü]/gi,"u");
	temp=temp.replace(/[ç]/gi,"c");		
	temp=temp.replace(/[ ]/gi,"-");
	temp=temp.replace(/[\.]/gi,"-");	
	temp=temp.replace(/[\\]/gi,"");
	temp=temp.replace(/[\/]/gi,"");	
	temp=temp.replace(/[\[\]]/gi,"");
	temp=temp.replace(/[,;?!:&=+#<>]/gi,"");
	temp=temp.replace(/[*°\(\)%]/gi,"");
	temp=temp.toLowerCase();
		
	//MSG
	sMsg ="Des corrections ont été apportées au nom du raccourci :\n\n";
	sMsg+=init+"\n\n"+"DEVIENT\n\n"+temp.toLowerCase();		
	
	//OUTPUT
	if (temp!=init){alert(sMsg); DaAct=eval("Dis."+DaFld+".value=temp");}	
}
//----------------------
//OTHER STUFF
//----------------------
function ReloadOpener(){opener.location.reload(true)}
//----------------------
function ReloadPage(){self.location.reload(true)}
//----------------------
function ReloadParent(){parent.location.reload(true)}
//----------------------
function SelfMoveTo(DaX, DaY){self.moveTo(DaX, DaY)}
//----------------------
function SelfResizeTo(DaX, DaY){self.resizeTo(DaX, DaY);}
//----------------------
//DHTML 
//----------------------
function GetDivTxt(DaTxt,which,DaAct)
{
	oWhich=GetDaID(which); window.focus(); 
	switch (DaAct)
	{
		case "APPEND"	: oWhich.innerHTML+=DaTxt;; break;
		default			: oWhich.innerHTML=DaTxt; break;       
	}	
}
//----------------------
function GetDaID(which)
{
	if (!document.getElementById|document.all){return}
	else
		{
		if (document.getElementById){oWhich = eval ("document.getElementById('" + which + "')")}
		else						{oWhich = eval ("document.all." + which)}
		}
	//window.focus(); 
	return oWhich;
}
//----------------------
function GetVis(which, DaVis)
{
	if(which!="")
	{	
		oWhich=GetDaID(which); //window.focus(); 
		if(DaVis!="")	{oWhich.style.display=DaVis;}
		else					{if (oWhich.style.display=="none"){oWhich.style.display="";} else {oWhich.style.display="none";}}		
	}
}
//----------------------------
function SwitchClass01(DaDiv, DaClass, DaType)
{
	if (DaClass==""){DaClass="txtgr01";}
	switch (DaType)
	{
		case "ROW01"	: oWhich=GetDaID(DaDiv); oWhich.className=DaClass; break;
		default			: break;
	}	
}
//----------------------------
function GetParentDiv(which)
{
	//window.parent.document.getElementById
	if (!window.parent.document.getElementById|window.parent.document.all){return}
	else
		{
		if (window.parent.document.getElementById){oWhich=eval("window.parent.document.getElementById('" + which + "')")}
		else						{oWhich=eval ("window.parent.document.all." + which);}
		}
	//window.focus(); 
	return oWhich;
}
//----------------------------
function HideDiv(which){oWhich=GetDaID(which); window.focus(); oWhich.style.display="none";}
//----------------------------
function ShowDiv(which){oWhich=GetDaID(which); window.focus(); oWhich.style.display="";}
//----------------------------
function GetPosX(which)
{
	if (which.offsetParent)	{return (which.offsetLeft + GetPosX(which.offsetParent));}
	else										{return (which.offsetLeft);}
} 
//----------------------------	
function GetPosY(which)
{
	if (which.offsetParent)	{return (which.offsetTop + GetPosY(which.offsetParent));}
	else										{return (which.offsetTop);}
}
//----------------------------
//POP UP
//----------------------------
function Pop(pvPage, pvWName)
{
 if (pvPage!="" && pvWName!="") {winView=window.open (pvPage, pvWName,'menubar=yes,scrollbars=yes,resizable=yes,status=yes,width=330,height=200');}
 else							{alert(ExpNoParam)}
}
//----------------------
function PopImg(pvType, pvImg, pvTitre)
{
	var xOffSet=30; var yOffSet=60;

	w=open("",'image','width=400,height=580,toolbar=no,scrollbars=yes,resizable=yes');   
	w.document.write("<HTML><HEAD><TITLE>"+pvTitre+"</TITLE></HEAD>");
	w.document.write("<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+"+xOffSet+",580); window.focus();} else { setTimeout('checksize()',50) } }</"+"SCRIPT>");
	//w.document.write("<SCRIPT language=javascript>function checksize()  { if (document.images[0].complete) {  window.resizeTo(document.images[0].width+"+xOffSet+",document.images[0].height+"+yOffSet+"); window.focus();} else { setTimeout('checksize()',50) } }</"+"SCRIPT>");
	w.document.write("<BODY onload='checksize()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0><IMG src='"+pvImg+"' border=0>");
	w.document.write("");
	w.document.write("</BODY></HTML>");
	w.document.close();
}
//----------------------------
function GetPopUp(which, DaUrl, DaWidth, DaHeight, DaAnchID, DaPopDiv)
{	
	//alert(DaPopDiv);
	if(DaPopDiv)
		{	
		//CHECK	
		if (!DaWidth>0){DaWidth=320;}
		if (!DaHeight>0){DaHeight=250;}
		//SCREEN
		var winWi=document.body.offsetWidth; var winHei=document.body.offsetHeight;
		var popWi=DaWidth+20; var popHei=DaHeight+20;
		/*
		var popLeft=GetPosX(GetDaID(DaAnchID))+20; if (popLeft<0 || popLeft>(winWi-popWi)){popLeft=parseInt(winWi/2)};
		var popTop=GetPosY(GetDaID(DaAnchID))-parseInt(popHei/2); if (popTop<0){popTop=parseInt(winHei/3)};
		*/
		var popLeft=GetPosX(GetDaID(DaAnchID))+20; 
		if (popLeft<0 || popLeft>(winWi-popWi) || popLeft>(parseInt((winWi/2)-(DaWidth/2))) ){popLeft=parseInt((winWi/2)-(DaWidth/2))};
		
		var popTop=GetPosY(GetDaID(DaAnchID))-parseInt(popHei/2); 
		if (popTop<0){popTop=parseInt(winHei/3)};
		
		//POPCONTENT
		DaContent ="<div align='right'>";
		DaContent+="<img src='/app_pix/adm_mep/b_popmove.gif' vspace='0' hspace='0' border='0' align='absmiddle' alt='Deplacer'></a>&nbsp;";
		DaContent+="<a href='javascript:HideDiv(\"DivPop\");'><img src='/app_pix/adm_mep/b_popclose.gif' vspace='0' hspace='0' border='0' align='absmiddle' alt='Fermer'></a>";
		DaContent+="</div>";	
		DaContent+="<iframe id='divpopcontent' name='divpopcontent' src='"+DaUrl+"' width='100%' height='100%' scrolling='auto' frameborder='0' marginwidth='0' marginheight='0'></iframe>";
		//ACTION	
		oWhich=GetDaID(which);	
		oWhich.style.width=popWi; oWhich.style.height=popHei;
		oWhich.style.left=popLeft; oWhich.style.top=popTop;
		oWhich.innerHTML=DaContent;	
		ShowDiv(which);	
		}
	else
		{
		DaWidth=parseInt(DaWidth)+30; DaHeight=parseInt(DaHeight)+30;
		winView=window.open (DaUrl, DaAnchID,'menubar=yes,scrollbars=yes,resizable=yes,status=yes,width='+DaWidth+',height='+DaHeight+'');
		}
}
//----------------------
//CHECKBOXES
//----------------------
function ManageCheckBox01(DaBox, DaNum, DaCheck)
{
	for(i=1; i<=DaNum; i++){eval(DaBox+i+'.checked='+DaCheck);}
}
//----------------------
//LISTBOXES
//----------------------
function GeneListDel(pvBox)  {
   for(var i=0; i<pvBox.options.length; i++)  
   	{ if(pvBox.options[i].selected && pvBox.options[i].value!=""){pvBox.options[i]=null; i--;} }
}
//----------------------
function GeneListAdd1(pvBox, pvValue,pvTxt) 
{	
	var bFlag=true;
	var no=new Option(); no.value=pvValue; no.text=pvTxt;
		
	try {eval("var BoxTo=parent.document."+pvBox);}
	catch (e) {if(e!=""){bFlag=false;}}
	
	if(!bFlag)
	{
		bFlag=true;
		try {eval("var BoxTo=opener.document."+pvBox);}
		catch (e) {if(e!==""){bFlag=false;}}
	}	
	if(!bFlag){alert("Windows conversation error : "+e.description)}
	else {BoxTo.options[BoxTo.options.length]=no;}
}
//----------------------
function GeneListAddX(pvFBox, pvTBox) 
 {
   for(var i=0; i<pvFBox.options.length; i++)
   	{
     if(pvFBox.options[i].selected && pvFBox.options[i].value!="")
	 	{
        var NewOpt=new Option(); NewOpt.value=pvFBox.options[i].value; NewOpt.text=pvFBox.options[i].text;
        pvTBox.options[pvTBox.options.length]=NewOpt;
     	}
	}
}
//----------------------
function GeneListFocus(pvBox){for(var i=0; i<pvBox.options.length; i++){pvBox.options[i].selected=true;}}
//----------------------
function GeneListMove(pvFrom, pvTo) 
 {
   for(var i=0; i<pvFrom.options.length; i++)  
   	{
     if(pvFrom.options[i].selected && pvFrom.options[i].value!="")
	 	{
        var NewOpt=new Option(); 
		NewOpt.value=pvFrom.options[i].value; NewOpt.text=pvFrom.options[i].text; 
		pvTo.options[pvTo.options.length]=NewOpt;
     	}
	}
}
//----------------------
/*
function SortD(box)  
{
  var temp_opts = new Array()
  var temp = new Object()
  // Load temp array
  for(var i=0; i<box.options.length; i++)  {
    temp_opts[i] = box.options[i]
  }

  //sort temporary
  for(var x=0; x<temp_opts.length-1; x++)  {
    for(var y=(x+1); y<temp_opts.length; y++)  {
      if(temp_opts[x].text > temp_opts[y].text)  {
        temp = temp_opts[x].text
        temp_opts[x].text = temp_opts[y].text
        temp_opts[y].text = temp
      }
    }
  }

  for(var i=0; i<box.options.length; i++)  {
    box.options[i].value = temp_opts[i].value
    box.options[i].text = temp_opts[i].text
  }
}
function RToBox(RVal,RTxt,ToForm) {	var Dis=eval(ToForm); Dis.FAID.value=RVal; Dis.FANAME.value=RTxt;}
//----------------------
function RToList(RVal,RTxt,ToBox) 
{	
	var no=new Option(); no.value=RVal; no.text=RTxt;
	ToBox.options[ToBox.options.length]=no;
}
//----------------------
function RToTxt01(RVal,ToForm, ToBox) 
{	
	var AddMsg=eval(RVal+".value"); var DaForm=eval(ToForm)
	with(DaForm)
	{
		if (Msg.createTextRange) 
      	{
			//var text;
			Msg.focus(Msg.caretPos);
			Msg.caretPos=document.selection.createRange().duplicate();
			
			if(Msg.caretPos.text.length>0)
			{
				//gère les espace de fin de sélection. Un double-click sélectionne le mot
				//+ un espace qu'on ne souhaite pas forcément...
				var sel = Msg.caretPos.text;
				var fin = '';
				while(sel.substring(sel.length-1, sel.length)==' ')
				{
					sel = sel.substring(0, sel.length-1)
					fin += ' ';
				}
				//Msg.caretPos.text = startTag + sel + endTag + fin;
				Msg.caretPos.text=AddMsg;
			}
			else
			{
				//Msg.caretPos.text = startTag+defaultText+endTag;
				Msg.caretPos.text=AddMsg;
			}
		}
	}
}
//----------------------
function RToList22(RVal,RTxt) 
{	
	ToBox=opener.FormMailer.Dlist1;
	
	alert(ToBox.options.length);
	
	var no=new Option(); 
	no.value=RVal; 
	no.text=RTxt;
	ToBox.options[ToBox.options.length]=no;
}
//----------------------
function move(fbox,tbox) 
 {
   for(var i=0; i<fbox.options.length; i++)  {
     if(fbox.options[i].selected && fbox.options[i].value != "")  {
        var no = new Option();
        no.value = fbox.options[i].value
        no.text = fbox.options[i].text
        tbox.options[tbox.options.length] = no;
     }
   }
   //SortD(tbox);
}
*/
//----------------------------
//IMG
//----------------------------
function ImgLineAdd(DaForm, DaName)
{	
	var RegExp=/-NUM-/gi;
	var iMax=eval("parseFloat(DaForm.Max"+DaName+".value)+1");	//alert(iMax);
	var DaModel=eval("DaForm."+DaName+"LineModel.value");
	var DaLine=DaModel.replace(RegExp,iMax);
	oWhich=GetDaID("DivImg"); oWhich.innerHTML+=DaLine;
	DaAct=eval("DaForm.Max"+DaName+".value=iMax");
}
//----------------------------
function ImgLineFormat(DaForm, DaSep, DaName)
{	
	var i=0; var DaVal=""; 
	DaAct=eval("DaForm.All"+DaName+".value=''");
	var iMax=eval("parseFloat(DaForm.Max"+DaName+".value)"); //alert(iMax)	
	for (i=1; i<iMax+1 ; i++)
	{	DaVal=eval("DaForm."+DaName+i+".value");	if (DaVal!=""){DaAct=eval("DaForm.All"+DaName+".value+='"+DaVal+DaSep+"'");}	}
}
//----------------------------
//FILES
//---------------------------
function FileRename(pvPath, pvSubPath, pvName)
{
	var Dis=eval(DaForm); 
	alert(ExpNewFileNameCond);
	FileNewName=prompt(ExpNewFileName, "");
	if (FileNewName!="" && FileNewName!=null){Dis.act.value="RENAME"; Dis.method="get"; Dis.NewFile.value=FileNewName; Dis.File.value=DaFile; Dis.submit();}
}
//---------------------------
function FileFlash(pvPath, pvWi, pvHei)
{
	var pvCode=""	
	pvCode='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" ';
	pvCode+='width="'+pvWi+'" ';
	pvCode+='height="'+pvHei+'" ';
	pvCode+='hspace="0" vspace="0" >';
  	pvCode+='<param name="movie" value="'+pvPath+'" />';
	pvCode+='<param name="quality" value="high" />';
	pvCode+='<param name="SCALE" value="exactfit" />';
	pvCode+='<embed src="'+pvPath+'" width="'+pvWi+'" height="'+pvHei+'" ';
	pvCode+='hspace="0" vspace="0" quality="high" ';
	pvCode+='pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" scale="exactfit"></embed>';
	pvCode+='</object>';
	
	document.write(pvCode);
}
//---------------------------
//OLD
//---------------------------
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];}}
}
//----------------------
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
//----------------------
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//----------------------
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//----------------------