/* Pihlajalinna specific javascript, (c) Smart Files Oy / Tomi Kulmala, 2009 */

$(document).ready(function() {
	$("a.name").click(function() {
		if($(this).next('div').attr('class') == 'opencard') {
			$("div.opencard").each(function() {
				$(this).remove();
			});
		}
		else {
			$("div.opencard").each(function() {
				$(this).remove();
			});
			if($(this).parent().attr('class') == 'personHallinto'){
                $(this).parent().append('<div class="opencard" id="'+$(this).attr('rel')+'"></div>');
                var ID = $(this).attr('rel');
                $.post('ajax.php', {act: 'getHallinto', id: $(this).attr('rel')},
                    function(returned_data) {
                        $('div#'+ID+'"').html(returned_data);
                    }
                );
            }
            else{
                $(this).parent().append('<div class="opencard" id="'+$(this).attr('rel')+'"></div>');
                var ID = $(this).attr('rel');
                $.post('ajax.php', {act: 'getPerson', id: $(this).attr('rel')},
                    function(returned_data) {
                        $('div#'+ID+'"').html(returned_data);
                    }
                );
            }
		}
	});
	
	$("input#freesearch").focus(function() {
		$(this).val('');
	});
	
	$("input#freesearch").blur(function() {
		if($(this).val() == '') {
			$(this).val('Vapaahaku...');
		}		
	});
})(jQuery);






