// fixPNG(); http://www.tigir.com/js/fixpng.js (author Tigirlas Igor)
function fixPNG(element)
{
	if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
	{
		var src;
		
		if (element.tagName=='IMG')
		{
			if (/\.png$/.test(element.src))
			{
				src = element.src;
				element.src = "/images/empty.gif";
			}
		}
		else
		{
			src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i)
			if (src)
			{
				src = src[1];
				element.runtimeStyle.backgroundImage="none";
			}
		}
		
		if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
	}
}

function ImgShw(ID, width, height, alt) {
	var scroll = "no";
	var top=0, left=0;
	if(width > screen.width-10 || height > screen.height-28) scroll = "yes";
	if(height < screen.height-28) top = Math.floor((screen.height - height)/2-14);
	if(width < screen.width-10) left = Math.floor((screen.width - width)/2-5);
	width = Math.min(width, screen.width-10);
	height = Math.min(height, screen.height-28);
	var wnd = window.open("","","scrollbars="+scroll+",resizable=yes,width="+width+",height="+height+",left="+left+",top="+top);
	wnd.document.write(
		"<html><title>" + alt + "</title><head>"+
		"<"+"script type=\"text/javascript\">"+
		"function KeyPress()"+
		"{"+
		"	if(window.event.keyCode == 27) "+
		"		window.close();"+
		"}"+
		"</"+"script>"+
		"<title></title></head>"+
		"<body topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" onKeyPress=\"KeyPress()\">"+
		"<img src=\""+ID+"\" border=\"0\" alt=\""+alt+"\" />"+
		"</body></html>"
	);
	wnd.document.close();
}

function click_popupAuthForm(element) {
	
	var form = layer('popup-auth-form');
	
	if(form.isExist()) {
		
		if(element._active == true) {
			form.css.display = 'none';
			element._active = false;
			element.className = 'btn btn_on';
		} else {
			form.css.display = 'block';
			element._active = true;
			element.className = 'btn btn_off';
		}
	}
}



function click_popupSearchForm(element) {
	
	var form = layer('popup-auth-form1');
	
	if(form.isExist()) {
		
		if(element._active == true) {
			form.css.display = 'none';
			element._active = false;
			element.className = 'btn1 btn_on1';
		} else {
			form.css.display = 'block';
			element._active = true;
			element.className = 'btn1 btn_off1';
		}
	}
}

var gSelectedBar = false;
var gSelectedTextBar = false;

function onclick_barItem(el) {
	if (el.className!='selected'){
		el.className = 'selected';
		if(gSelectedBar) gSelectedBar.className = '';
		gSelectedBar = el;
		l = layer('text_' + el.id);
		if(l.isExist()) {
			l.css.display = 'block';
			if(gSelectedTextBar) gSelectedTextBar.css.display = 'none';
			gSelectedTextBar = l;
		}
	}
}

function openPopup1() {
	l = layer('popup-1-bar'); 
	if(l.isExist()) l.css.display = 'block';
	
	l1 = layer('divText');
	l2 = layer('divScrollTextCont');
	if(l1.isExist() && l2.isExist()) {
		if(l1.getHeight() - l2.getHeight() <= 0 && oBegun.css) oBegun.css.display = 'none';
	}
}


function openPopup21() {
	closePopup22();
	l = layer('popup-2-bar-1'); 
	if(l.isExist()) l.css.display = 'block';
	l = layer('popup-2-btn-2'); 
	if(l.isExist()) l.css.zIndex = '8';
}

function closePopup21() {
	l = layer('popup-2-bar-1');
	l.css.display = 'none';
	l = layer('popup-2-btn-2'); 
	if(l.isExist()) l.css.zIndex = '10';
}

function openPopup22() {
	closePopup21();
	l = layer('popup-2-bar-2'); 
	if(l.isExist()) l.css.display = 'block';
	l = layer('popup-2-btn-1'); 
	if(l.isExist()) l.css.zIndex = '8';
}

function closePopup22() {
	l = layer('popup-2-bar-2');
	l.css.display = 'none';
	l = layer('popup-2-btn-1'); 
	if(l.isExist()) l.css.zIndex = '10';
}

var gSelectTimeouts = new Array();

function selectP_mouseover(name) {
	
	if(gSelectTimeouts[name]) {
		for(i = 0; i < gSelectTimeouts[name].length; i++)
			clearTimeout(gSelectTimeouts[name][i]);
			gSelectTimeouts[name] = new Array();
	} else gSelectTimeouts[name] = new Array();
	var hBlock = layer('input_' + name + '_block');
	if(hBlock.isExist()) {
		hBlock.object.className = 'popup-select popup-select-active';
	}
}

function selectP_mouseout(name) {
	
	gSelectTimeouts[name][gSelectTimeouts[name].length] = setTimeout('selectP_close(\'' + name + '\')', 200);
}

function selectP_close(name) {
	var hBlock = layer('input_' + name + '_block');
	if(hBlock.isExist()) {
		hBlock.object.className = 'popup-select';
	}
}

function selectP_click(name, id, text) {
	
	var hBlock = layer('input_' + name + '_block');
	if(hBlock.isExist()) {
		hBlock.object.className = 'popup-select';
	}	
	
	var hPole = layer('input_' + name + '_pole');
	if(hBlock.isExist()) {
		hPole.object.value = id;
	}	

	var hPrompt = layer('input_' + name + '_prompt');
	if(hPrompt.isExist()) {
		hPrompt.object.value = text;
	}	

}

function initFilter(inputs) {
	
	for(i = 0; i < inputs.length; i++) {
		
		var hPopup = layer('ipopup_' + inputs[i]);
		if(hPopup.isExist()) {
			var hOneInput = layer('ipopup_' + inputs[i] + '_one');
			if(hOneInput.isExist()) {
				//hOneInput.css.width = (hPopup.getWidth() + 8) + 'px';
			}
			var hPrompt = layer('input_' + inputs[i] + '_prompt');
			if(hPrompt.isExist()) {
				//hPrompt.css.width = (hPopup.getWidth() - 12) + 'px';
			}
			hPopup.object.className = 'pre-popup';
		}
	}
}

function test_height (ob){
	if (obex = document.getElementById(ob)){
		obex_test = document.getElementById("footer");
		raz = obex_test.offsetTop - obex.offsetTop - 200;
		if (raz<obex.clientHeight){
			minus = obex.clientHeight - 14;
			obex.style.marginTop = "-"+minus+"px";
		}
	}
}

