/*$(document).ready( function() {
	var fix = $(document).height() - ($('#foot').offset().top + $('#foot').height() + $('#foot').height());

	if( fix > 0 ) {
		$('#foot').css('margin-top', fix-10);
	}
}); */

function searchInit() {
	$(document).ready( function() {
		$('#search')
			.submit(function () {
				window.location = $(this).attr('action')+'/'+encodeURIComponent($('#query').val());
				return false;
			});
	});
}

function advSearchInit() {
	$(document).ready( function() {
		$('#advsearch')
			.submit(function () {
				var f = $(this);
				var cats = [];
				
				if( $('#allcats').attr('checked') ) {
					cats.push('');
				}
				else {
					$(':checkbox[@name="categories[]"][checked]').each(function() {
						var v = $(this).val();
						if( v != '' ) {
							cats.push( v );
						}
					});
				}
				
				var s=$('#section').val();
				
				window.location =
					f.attr('action')
						+'/'+encodeURIComponent($('#query').val())
						+';'+(s?s:'')
						+';'+cats.join('|')
						+';'+$('#in').val();
						
				return false;
			})
			.find(':checkbox[@name="categories[]"]').change(function(){
				var chs = $(':checkbox[@name="categories[]"]');
				
				if( $(this).val() == 'all' ) {
					if( $(this).attr('checked') ) {
						chs.attr('checked', true);
					}
				}
				else {
					$('#allcats').attr('checked', false);
					if( $(':checkbox[@name="categories[]"][checked]').length==0 ) {
						chs.attr('checked', true);
					}
				}
			});
			
		$(':checkbox[@name="categories[]"]').attr('checked', true);
	});
}

function PrivacyPL() {
    window.open("http://www.codetwo.pl/regulations/privacy.php", "", "height=500,width=450,location=0,menubar=0,status=1,toolbar=0,resizeable=1,scrollbars=1");
}
function TrademarksPL() {
    window.open("http://www.codetwo.pl/regulations/trademarks.php", "", "height=275,width=450,location=0,menubar=0,status=1,toolbar=0,resizeable=1,scrollbars=1");
}

function PrivacyEN() {
    window.open("http://www.codetwo.com/regulations/privacy.php", "", "height=500,width=450,location=0,menubar=0,status=1,toolbar=0,resizeable=1,scrollbars=1");
}
function TrademarksEN() {
    window.open("http://www.codetwo.com/regulations/trademarks.php", "", "height=275,width=450,location=0,menubar=0,status=1,toolbar=0,resizeable=1,scrollbars=1");
}
