function setSize() {
	var footerSize = 55;
	var h = $('div#pgContainer').height();
	$('td#mainContainer').css('height', h - footerSize);
}

$(document).ready(function(){

	$("#formbutton").click(function() {
		$("#formbutton").css("color","gray");
		$("#formbutton").attr("disabled",true);	
		$("#addform").submit();
	});
	
	//$('table#centerContainerTab').css('height', $('table#pageContainer').css('height'));
	setSize();

	if($('#loginFormTab #login'))
		$('#loginFormTab #login').focus();
		
	if($('#remindPasswordFormTab #email'))
		$('#remindPasswordFormTab #email').focus();	
		
	$('#menu_' + menuItem).css({background:"#8a1913"});
	
	$("div.mmButton a").mouseover(function() {		
			var id = $(this).parent().attr('id');			
			//$('#menu_' + menuItem).css({background:"#8a1913"});			
			if($('#menu_' + menuItem).attr('id') != id)
			{
				$(this).parent().css({background:"#ac1f17"});
			}
		}).mouseout(function() {
			var id = $(this).parent().attr('id');			
			if($('#menu_' + menuItem).attr('id') != id)
			{
				$(this).parent().css({background:"#000000"});				
			}			
		});	
	
	if($('#favGroups')[0] && ($.cookie('favGroupsExp') == 1)) {
		$('#favGroups').css({display:'block'});
		$('#favGroupsIco').attr('src', $('#favGroupsIco').attr('src').replace('right', 'down'));
	}
	
	if($('#yourGroups')[0] && ($.cookie('yourGroupsExp') == 1)) {
		$('#yourGroups').css({display:'block'});
		$('#yourGroupsIco').attr('src', $('#yourGroupsIco').attr('src').replace('right', 'down'));
	}
	
	$('.resLinkTxt').mouseover(function() {$(this).css({textDecoration:'underline'})})
		.mouseout(function() {$(this).css({textDecoration:'none'})});
	
	/*$('.psearchform').submit(
		function() {
			
			if($(this).attr('id') == 'psearchform') {
				if($("#searchtype").attr("value") == 13)
					$("#psearchform").attr("action", zspath);
			} else {
				if($("#searchtype2").attr("value") == 13)
					$("#lpsearchform").attr("action", zspath); 
					// + '&gdzie=&promien=0'
			}	
		
		}
	);*/
	
	
	$(".psearchsubmit").click(function() {
		if($(this).attr('id') == 'psearchsubmit')		
			$("#psearchform").submit();
		else if($(this).attr('id') == 'lpsearchsubmit')		
			$("#lpsearchform").submit();
	});
});

function goto(link) {
	window.location.href = link;
}



function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var btop, btop2, btop3, tout;
function showFloatBanner() {
	btop2 = btop = parseInt(($(window).height() - $('#floatBanner').height()) / 2);
	var bleft = parseInt(($(window).width() - $('#floatBanner').width()) / 2);
	$('#floatBanner').css('left', bleft + 'px');
	$('#floatBanner').css('top', btop2 + 'px');
	$('#floatBanner').css('display', 'block'); 
	tout = setTimeout("moveFloatBanner()", 1); 
}

function showFloatBannerDelayed(delay) {
	if (!delay)
		delay = 2000;
	setTimeout("showFloatBanner()", delay);
}

function moveFloatBanner() {
	var btop3 = btop + $(window).scrollTop();
	
	if (btop3 > btop2) {
		btop2 += 5;
		if (btop2 > btop3)
			btop2 = btop3;
	}
	else if (btop3 < btop2) {
		btop2 -= 5;
		if (btop2 < btop3)
			btop2 = btop3;
	}
	
	$('#floatBanner').css('top', btop2 + 'px');
	clearTimeout(tout);
	tout = setTimeout("moveFloatBanner()", 1);
}

function closeFloat() {
	clearTimeout(tout);
	$('#floatBanner').css('display', 'none');
}

function menuSubmit(name){
	var fname = "itemMenuForm" + name;
	document.forms[fname].submit();
}

function dropDownClick(id) {
	if($.cookie(id+'Exp') == null) {
		$('#'+id).show();
		$('#'+id+'Ico').attr('src', $('#'+id+'Ico').attr('src').replace('right', 'down'));
		$.cookie(id+'Exp', 1);
	}
	else {
		$('#'+id).hide();
		$('#'+id+'Ico').attr('src', $('#'+id+'Ico').attr('src').replace('down', 'right'));
		$.cookie(id+'Exp', null);
	}

}

function printMail(text1, text2) {
	document.write('<a href="mailto:'+text1+'@'+text2+'">'+text1+'@'+text2+'</a>');
}
