﻿function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}
function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  var topSearch=document.getElementById("topSearch");
  var inputList=topSearch.getElementsByTagName("select")//document.getElementsByName
  
  for(i=0; i<inputList.length; i++)
  {
	  if (args[2]!="hide")
	    inputList[i].style.visibility="hidden";
	  else
	    inputList[i].style.visibility="visible";
  }
  
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}


function scrolTop()
{return document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop;}
function scrolLeft()
{return document.body.scrollTop?document.body.scrollLeft:document.documentElement.scrollLeft;}
function show(event,_this,mess) {
    event = event || window.event;
    var t1="<img src='" + _this   + "' width='250' height='250' ><br>"+mess+"";
	var mouseY=event.clientY;
	var mouseX=event.clientX;
	if (mouseX>735) mouseX=mouseX-250-10;
    document.getElementById("a1div").innerHTML =t1;
    document.getElementById("a1div").style.top   = scrolTop() + mouseY +10 + "px";
	document.getElementById("a1div").style.left =scrolLeft() + mouseX +10 + "px";
	document.getElementById("a1div").style.display = "block";
}
function hide(_this) {
     document.getElementById("a1div").innerHTML = "";
	 document.getElementById("a1div").style.display = "none";
}

document.getElementsByTagName("img").onerror=function(){this.src='/img/nopic.gif'};

function picresize(obj,MaxWidth,MaxHeight){
    obj.onload=null;
    img=new Image();
    img.src=obj.src;
    if (img.width>MaxWidth && img.height>MaxHeight){
        if (img.width/img.height>MaxWidth/MaxHeight) {
            obj.height=MaxWidth*img.height/img.width;
            obj.width=MaxWidth;
        }else {
            obj.width=MaxHeight*img.width/img.height;
            obj.height=MaxHeight;
        }
    }else if (img.width>MaxWidth) {
        obj.height=MaxWidth*img.height/img.width;
        obj.width=MaxWidth;
    }else if (img.height>MaxHeight) {
        obj.width=MaxHeight*img.width/img.height;
        obj.height=MaxHeight;
    }else{
        obj.width=img.width;
        obj.height=img.height;
    }
}
window.onerror =function(){ return true; }
