var agt = navigator.userAgent.toLowerCase () ;
opera = (agt.indexOf ("opera") != -1) ;
var showflag=false;
var id=null;
var onname="";

function show(name){
    killtimer();
    if(showflag) hide();        
	m = document.getElementById(name);		
	if (opera){
		m.style.display = "table";	
	}
	else {
		m.style.display = "block";	
	}	
    showflag=true;
    onname=name;            
}

function killtimer(){
    if(id!=null) {
      clearTimeout(id);
      id=null;
    }
    return true;
}

function hide() {
    if(id!=null) killtimer();   
	m = document.getElementById(onname);	
	if(showflag) m.style.display = "none";	
    showflag = false;
    onname = "";
}

function reset() {
    killtimer();
    id = setTimeout('hide()', 1000);
}


function win_open(source,window_name,w,h,sc){
	ws=screen.availWidth;
	hs=screen.availHeight;
	kl=(ws-w)/2;
	if (kl<0){kl=0;}
	kt=(hs-h)/2;
	if (kt<0){kt=0;}
	var window_params = 'status=no,toolbar=no,scrollbars='+sc+',titlebar=yes,menubar=no,resizable=no,width='+w+',height='+h+',left='+kl+',top='+kt+',directories=no,location=no';
	window.open(source, window_name, window_params);
 }

 
 function big_img(){
 if (document.all){
	//IE Opera
    im = event.srcElement;
    im_src=im.getAttribute("src");
    name_im=im_src.slice(im_src.lastIndexOf("/")+1,-4);
    big_im_src=im_src.replace("/small_","/big_");
    win_open("/tpls/big_img.php?im="+big_im_src,"big_im"+name_im,500,400,1);
 }
 else {
    //Mozilla
    window.captureEvents(Event.CLICK);
    window.onclick= handle; 
 }   
}

function handle(e) {
   var retval = routeEvent(e);
   if (retval == true){
      return true;
   }
   else {
      obj=e.target;
      tag_name=obj.tagName;
      if (tag_name!='IMG'){
         return true;
      }
      else {
        im_src=obj.src;
        link_im=obj.parentNode;
        link_im_function=link_im.getAttribute("onclick");
        if (link_im_function!="big_img();"){
           return true;
        }
        else {
           name_im=im_src.slice(im_src.lastIndexOf("/")+1,-4);
           big_im_src=im_src.replace("/small_","/big_");
           win_open("/tpls/big_img.php?im="+big_im_src,"big_im"+name_im,500,400,0,0,1,0);
        }        
      }      
   }
}

