function chImg(obj){
	obj.src = frame.src;
	}
function chImgOut(obj){
	obj.src = frameoff.src;
	}

// submenu
var flsub = 0;
function menu(obj, n){
	if(flsub != 1){
		if(obj.className != 'curent'){
		obj.className = 'on';
		obj.style.backgroundImage="url(../images/sub"+n+".jpg)";
		}
	if(obj.childNodes[1]){	
	obj.childNodes[1].style.display = 'block';
	flsub = 1;}}
	}
	
function menuhide(obj, n){
		if(obj.className != 'curent'){
		obj.className = 'off';
		obj.style.backgroundImage="none";
		}
	if(obj.childNodes[1]){	
	obj.childNodes[1].style.display = 'none';
	flsub = 0;}
	}

function subBg(obj){
	obj.className = 'subon';}
function subBgOut(obj){
	obj.className = 'suboff';}
//   ------- submenu


// trailer

function remove_loading() {
this.clearInterval(t_id);
var targelem = document.getElementById('loader_container');
targelem.style.display='none';
targelem.style.visibility='hidden';
var t_id = setInterval(animate,60);
}


function gettrailobj(){
if (document.getElementById)
return document.getElementById("preview_div").style
}

function gettrailobjnostyle(){
if (document.getElementById)
return document.getElementById("preview_div")
}

function truebody(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


function hidetrail(){	
	gettrailobj().display= "none";
	document.onmousemove=""
	gettrailobj().left="-500px"
	clearTimeout(timer);
}

function showtrail(imagename,title,width,height){
	i = imagename
	t = title
	w = width
	h = height
	timer = setTimeout("show('"+i+"',t,w,h);",1);
}
function show(imagename,title,width,height){
 
    var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth - offsetfrommouse[0]
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	if( (navigator.userAgent.indexOf("Konqueror")==-1  || navigator.userAgent.indexOf("Firefox")!=-1 || (navigator.userAgent.indexOf("Opera")==-1 && navigator.appVersion.indexOf("MSIE")!=-1)) && (docwidth>650 && docheight>500)) {
		( width == 0 ) ? width = defaultimagewidth: '';
		( height == 0 ) ? height = defaultimageheight: '';
			
		width+=30
		height+=55
		defaultimageheight = height
		defaultimagewidth = width
	
		document.onmousemove=followmouse; 

		
		newHTML = '<div class="border_preview" style="width:400px;height:200px;"><div id="prevhead"><strong>'+title+'</strong></div><div id="loader_container">загрузка</div>';
		
		
    	newHTML = newHTML + '<div class="preview_temp_load"><img onload="javascript:remove_loading();" src="'+ imagename + '" border="0"></div>';
		newHTML = newHTML + '</div></div>'; 
		
			

		gettrailobjnostyle().innerHTML = newHTML;
		gettrailobj().display="block";
	}
}

function followmouse(e){

	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	if (typeof e != "undefined"){
		if (docwidth - e.pageX < defaultimagewidth + 2*offsetfrommouse[0]){
			xcoord = e.pageX - xcoord - defaultimagewidth - 30; // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < defaultimageheight + 2*offsetfrommouse[1]){
			ycoord += e.pageY - Math.max(0,(2*offsetfrommouse[1] + defaultimageheight + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}

	} else if (typeof window.event != "undefined"){
		if (docwidth - event.clientX < defaultimagewidth + 2*offsetfrommouse[0]){
			xcoord = event.clientX + truebody().scrollLeft - xcoord - defaultimagewidth - 30; // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (defaultimageheight + 2*offsetfrommouse[1])){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(2*offsetfrommouse[1] + defaultimageheight + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;

		}
	}
	gettrailobj().left=xcoord+"px"
	gettrailobj().top=ycoord+"px"

}

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;
  }

var countstr = 0;

function init(){
	if(document.getElementById('tabz')){
		box = document.getElementById('tabz')
		var abox = new Array
		var i = 0;
		var node;
		var tr = 0;
		var cc = 0;
		var nodz = 0;
		
		while(node = box.childNodes[i++]){
			if(node.className == 'floatleft'){
				poz = findPosY(node)
				if(cc != 0){
					if(tr != poz){
						tr = poz
						strz = 'flz'+nodz;
						
						node.setAttribute('id', strz);
						countstr++;
						nodz++;
						}
					} else{
						tr = poz
						}
				cc++;
				}
			}

		for(z=0; z<countstr; z++){
			strz = 'flz'+z;
			obz = document.getElementById(strz);
			
			var theBR = document.createElement('BR');
			theBR.setAttribute('clear','all');
						
			box.insertBefore(theBR, obz);
			}
		
		}
	}