var categories = '';

$(document).ready(function() {

	function fixbg() {
		var docHeight = $(document).height();
		var scroll    = $(window).height();
		 
		if(docHeight > scroll) {	  		
			$('body').css('background-color', '#ffffff');  
		} else {
			$('body').css('background-color', '#a4a2a3');  
		}
	}

	$("input[name='keywords']").blur(function() {
		if(this.value == '') this.value = 'quick search';
	}).focus(function() {
		if(this.value == 'quick search') this.value = '';
	});

	categories = $("select[name='categories']").html();

	$("select[name='categories']").change(function() {
        if($(this).attr('value') != 'all') {
            // $(this).html(categories);
            $("select[name='show-with'] option[title!='" + $(this).attr('value') + "'][title!='any']").each(function() {
                $(this).remove();
            });
        }
        else {
            $(this).html(categories);
        }
	});

	// find all pdf links in tables and add class to them	
	$('table a').each(function() {	
		$link = $(this).attr('href');
		if($link.indexOf('.pdf', 0) > 1) {
			$(this).addClass('pdf-link');			
		}		
	});
	
	fixbg();
	
	$(window).bind('resize', function() {
		fixbg();	
	});
	
	
});
