_v3_jsHover = function(id, tag) {
	var hEls = document.getElementById(id).getElementsByTagName(tag);
	for (var i=0, len=hEls.length; i<len; i++) {
		hEls[i].onmouseover=function() { this.className+=" jshover"; }
		hEls[i].onmouseout=function() { this.className=this.className.replace(" jshover", ""); }
	}
}
function _v3_menu() { // run only for IE6
	if (window.attachEvent && navigator.userAgent.indexOf("Opera")==-1)
	_v3_jsHover("menu", "li");
}

jQuery(document).ready(function() {
	if( jQuery.browser.msie )
	{
		// Fix DivX IE plugin issue which described at http://labs.divx.com/node/16824
		// Just disable DivX appendChild and insertBefore handlers
		ORIG_appendChild = document.body.appendChild;
		ORIG_insertBefore = document.body.insertBefore;
		document.body.appendChild = function(element){if(!element.tagName) element.tagName='not-video'; res = ORIG_appendChild(element); if(res) return res; else return element;};
		document.body.insertBefore = function(element,reference){if(!element.tagName) element.tagName='not-video'; res = ORIG_insertBefore(element,reference); if(res) return res; else return element;};
	}

	var ignore = false;
	var ignore2 = false;

	jQuery('html').click(function() {
		if ((!ignore) && (!ignore2) && (jQuery('#search_cat:focus').length == 0) && (jQuery('#search_string:focus').length == 0) && ( jQuery('#searchtop').is(':visible') )) {
			jQuery('#searchtop').hide();
		}
	});

	jQuery('#search_activate').mouseenter(function() {
		ignore = true;
	});
	jQuery('#search_activate').mouseleave(function() {
		ignore = false;
	});
	jQuery('#searchtop').mouseenter(function() {
		ignore2 = true;
	});
	jQuery('#searchtop').mouseleave(function() {
		ignore2 = false;
	});

	jQuery('#search_activate').click(function() {
		jQuery('#searchtop').toggle();
		if ( jQuery('#searchtop').is(':visible') ) {
			jQuery('#search_string').focus();
		}
	});

	jQuery('#top_menu li').mouseenter(function() {
		if ( !(jQuery(this).hasClass('search_li')) && ( jQuery('#searchtop').is(':visible') ) ) {
			jQuery('#searchtop').hide();
		}
	});
});

