// ***********************************************************************************
// script (c) and written by Radek HULAN
// http://hulan.cz/
// ***********************************************************************************

// use like onclick="return openwin(this.href)"
function openwin(url) {
  if( window.open(url,'','width=800,height=600,left=0,top=0,scrollbars=yes,location=yes,resizable=yes') ) return false; else return true;
}

function myToolTip() {
	$('#kategoriekol a').mouseenter( function(e) {
		$('#kolocatinfo').show().html($(e.target).attr('rel'));
	});
	$('#kategoriekol a').mouseleave( function(e) {
		$('#kolocatinfo').hide();
	});
}

function loginBox(t) {
	$("#search-box").hide();
	if (t == "show") {
		$("#login-box").slideToggle().mouseleave( function(){ $(this).hide();} ); 
		$("#header,#mainmenu").mouseleave( function(){searchBox('hide')} );
		
	} else 
		$("#login-box").hide();
}

function searchBox(t) {
	$("#login-box").hide();
	if (t == "show") {
		$("#search-box").slideToggle().mouseleave( function(){ $(this).hide();} ); 
		$("#header,#mainmenu").mouseleave( function(){searchBox('hide')} );
	} else 
		$("#search-box").hide();
}

function bindMenu1Events() {
	$("#menu11").mouseenter( function(){showMenu(1,1);} );
	$("#menu12").mouseenter( function(){showMenu(1,2);} );
	$("#menu13").mouseenter( function(){showMenu(1,3);} );
	$("#menu14").mouseenter( function(){showMenu(1,4);} );
}
function bindMenu2Events() {
	$("#menu21").mouseenter( function(){showMenu(2,1);} );
	$("#menu22").mouseenter( function(){showMenu(2,2);} );
	$("#menu23").mouseenter( function(){showMenu(2,3);} );
	$("#menu24").mouseenter( function(){showMenu(2,4);} );
}
function bindMenu3Events() {
	$("#menu31").mouseenter( function(){showSimpleMenu(3,1);} );
	$("#menu32").mouseenter( function(){showSimpleMenu(3,2);} );
}
function showMenu(n,j) {
	for(var i=1; i<=4; i++) {
		$('#box'+n+i).toggleClass("menu"+n+"box_show",i==j);
		$('#box'+n+i).toggleClass("menu"+n+"box_hide",i!=j);
		$('#menu'+n+i).toggleClass("typ"+i+"_select",i==j);
		$('#menu'+n+i).toggleClass("typ"+i,i!=j);
	}
	if (n == 1) $('#topsearchbox').css('backgroundImage','url(/styles/images/bg_box'+j+'.png)');
}
function showSimpleMenu(n,j) {
	for(var i=1; i<=2; i++) {
		$("#box"+n+i).toggleClass("menu"+n+"box_show",i==j);
		$("#box"+n+i).toggleClass("menu"+n+"box_hide",i!=j);
		$("#menu"+n+i).toggleClass("select",i==j);
		$("#menu"+n+i).toggleClass("typ"+i,i!=j);
	}
}

function bindKatalogFiltrEvents() {
	if (KatalogHidden) $('#detailsearch').hide();
	$("#KatalogFiltr").click( function(){ 
		$('#detailsearch').slideToggle(); 
	});
}
function bindObchodFiltrEvents() {
	if (ObchodHidden) $('#detailsearch').hide();
	$("#ObchodFiltr").click( function(){
		$('#detailsearch').slideToggle(); 
	});
}
 
function insertComment(id) {
	if (tinyMCE.activeEditor != null && tinyMCE.activeEditor.isHidden() == false)
		tinyMCE.execInstanceCommand('nucleus_cf_body', 'mceInsertContent', false, '['+id+'] ', true);
	else {
   		if (document.getElementById('nucleus_cf_body')) {
       		document.getElementById('nucleus_cf_body').focus();
           	document.getElementById('nucleus_cf_body').value+='['+id+'] ';
		}
	}
}

$(document).ready(function(){ $("a[rel='colorbox']").colorbox({
	onOpen: function(){
		$('object,iframe').each(function(){ 
			$(this).attr('rel', $(this).css('visibility'))
		}).css('visibility','hidden')
	},
  	onClosed: function(){
  		$('object,iframe').each(function(){ 
  			$(this).css('visibility', $(this).attr('rel'))
  		})
  	} 
}); });

