//Ready function

$(function() {

    $('ul.questions li h4 a').click(function(event) {
        $(this).toggleClass('expanded');
        $('.content', $(this).parents('li')).toggleClass('hidden');
        return false;
    });

    $('a.modal').each(function() {
        var $dialog = $('<div></div>');
        var $link = $(this).one('click', function() {
	    $dialog
                .load($link.attr('href') + ' #content')
                .dialog({
                    bgiframe: true,
                    title: $link.attr('title'),
                    width: 500,
                    /*height: 300,*/
                    modal: true,
                    buttons: {
                        Ok: function() {
                            $(this).dialog('close');
                        }
                    }
                });
            $link.click(function() {
                $dialog.dialog('open');
                return false;
            });
            return false;
        });
    });
});
// columnize cities on homepage
$(function(){
    $('.specialisten dl').columnize({columns: 5, height: 110, width: 80});
});	

// columnize submenu-items
$(function(){
    $('#nav ul li ul').columnize({height: 275, dontsplit: "li.parent,a"});
});	

// style form tables
$(function(){

		
	// create and style a green button
	if(jQuery.browser.msie && (parseInt(jQuery.browser.version) == 6  || 
	                           parseInt(jQuery.browser.version) == 7  || 
							   parseInt(jQuery.browser.version) == 8 )) {
		$("a.button").wrapInner('<div class="button_m" />');
		$("a.button div.button_m").before('<div class="button_l" />');
		$("a.button div.button_m").after('<div class="button_r" />');
		
		$('input[type="submit"].button').addClass('button_m');
		$('input[type="submit"].button').css('margin-left','0px');
		
		$('input[type="submit"].button').after('<div class="button_r" />');
		$('input[type="submit"].button').before('<div class="button_l" />');
	} else {
		$("a.button").button();
		$('input[type="submit"].button').button();
	}
	
	if(jQuery.browser.msie && (parseInt(jQuery.browser.version) == 6  || 
	                           parseInt(jQuery.browser.version) == 7 )) {
		//width for table header cells with label
		$('table.form tr th label').parent('th').css("width","120px");
		//width for table normal cells with label
		$('table.form tr td label').parent('td').css("width","200px");
		
		$('table.form tr td input[type=text]').parent('td').css("width","100px");
		$('table.form tr td[colspan=2]').css("width","240px");
		
	} 
	
	// fixed width for table cells with only radio or checkbox inputs
    $('table.form tr td input[type=radio]:only-child, table.form tr td input[type=checkbox]:only-child').parent('td').css("width","10px");
		
});	

// Truncate text in home_articles
$(function(){
    $('div.home_articles p span').expander({
        slicePoint: 40, 
        widow: 5,
        expandEffect: 'show', 
        userCollapseText: '',
        expandText: ''
    });

});
