/**
 *  i18n
 */
function __(message) {
    return __i18n[message] ? __i18n[message] : message;
}

/**
 *  init main events and triggers
 */
jQuery(function($){
    $(document).ready(function(){
	
        /**
         *  Insured accident modal dialog
         */
		$('#insured_accident_notify').click(function(e){
		    e.preventDefault();
			var insuredAccidentLink = $(this);
			
			var btns = {};
			btns[__('Close')] = function() {
			    $(this).dialog('close'); 
			};
			btns[__('Notify about insured accident')] = function() {
			    document.location = $(insuredAccidentLink).attr('href'); 
			};
			
		    $("#"+$(insuredAccidentLink).attr('rel')).dialog({
	            resizable:     false,
	            height:        400,
				width:         650,
				title:         $(insuredAccidentLink).attr('title'),
	            modal:         true,
	            buttons:       btns
	        });
		});
		
		/**
		 *  Top panel
		 */
        $('#top-panel').hide();
        $('#top-panel').removeClass('hidden');
        $('.ac-toggler').click(function(e){
            e.preventDefault();
            $('#top-panel').slideToggle();
        });
        $('.lang').mouseover(function(e){
            $(this).addClass('hover');
        });
        $('.lang').mouseleave(function(e){
            $(this).removeClass('hover');
        });
        $('.not-available').click(function(e){
            return false;
        });
        
        /**
         *  Toggle on checkbox
         */
        $('input[act_as=switch]').click(function(){
		    //if ($.browser.msie ? $(this).attr('checked') : ($(this).attr('checked') && $(this).attr('checked')=='checked')) {
		    if ($(this).attr('checked')) {
		        $('#'+$(this).attr('act_for')).fadeOut();
		    } else {
		        $('#'+$(this).attr('act_for')).fadeIn();
		    }
		});
		
    });
});
