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]; 
  if(d.forms) 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;
}


//MM_showHideLayers('Layer1','','show','LL','','hide')
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  
  for (i=0; i<(args.length-2); i+=3) {
    obj=MM_findObj(args[i],args[i+1])    
    if (obj!=null) { 
        v=args[i+2];
        if (obj.style) { 
            obj=obj.style; 
            v=(v=='show')?'visible':(v=='hide')?'hidden':v;
            v1 = (v=='visible')?'':'none';
            if(obj.display)  obj.display = v1;
            }
        obj.visibility=v; 
    }
    else { //alert('not find '+args[i]) 
         }
   }
}

function MM_setTextOfLayer(objName,x,newText,flEscape) { //v4.01
  if ((obj=MM_findObj(objName,x))!=null) {
    with (obj)
        if (document.layers) {document.write(unescape(newText)); document.close();}
        else innerHTML = unescape(newText);
   return true
  }                
  else{return false}
  
}

//MM_changeProp('Layer1','','style.borderStyle','','DIV');MM_changeProp('Layer1','','color','','DIV')
function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName,x);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function SetBGC(sItemName,oDoc,sColor){
    var oItem,blRez
    blRez = false
    oItem = MM_findObj(sItemName,oDoc)
    if(oItem) {
        if(oItem.style){
            oItem.style.backgroundColor = sColor
        }
        else{
            if(oItem.backgroundColor) oItem.backgroundColor = sColor
            if(oItem.bgColor) oItem.bgColor = sColor
        }
        blRez = true    
    }
    return blRez;
}


 function getX(oObj){
	//	 alert("oObj.clientWidth="+oObj.clientWidth+'\n'+'oObj.scrollWidth='+oObj.scrollWidth)	
		 if(oObj.clientWidth) return oObj.clientWidth
		 if(oObj.scrollWidth) return oObj.scrollWidth
		 return 0
	}
	
	function getY(oObj){
		 if(oObj.clientHeight) return oObj.clientHeight
		 if(oObj.scrollHeight) return oObj.scrollHeight
		 return 0
	}
//'ImgDesc'
function Centered(sObjName){
	var oObj = MM_findObj(sObjName)

	var winW,winH,poW,poH

	myWin = self.top.document.body
	if(!myWin) myWin = self.top

	winW = getX(myWin); winH = getY(myWin);

	poW =  getX(oObj); poH = getY(oObj);
//	alert("oObj="+oObj+"\n poW="+poW+"-"+'poH='+poH+'\n'+'winW='+winW+'-'+'winH='+winH)
	if(winW>0 && winH>0) {
		poW = (winW - poW)/2
		poH = (winH - poH)/2
	}

	if(oObj){
		if(oObj.style) oObj = oObj.style
		oObj.left = poW
		oObj.top = poH
	}
}


function ChangeVis(sObjName,sVisib){
    obj=MM_findObj(sObjName)    
	if(obj){
		if (obj.style) obj=obj.style; 
		if(!sVisib)  {
			v = obj.visibility;
			v = (v=='show' || v=='visible')?'hidden':'visible';
		}
		else {
			v = sVisib;
			v = (v=='show')?'visible':'hidden';
		}
		obj.visibility=v; 

	}
}
