/**
 * usage: $.preloadImages(images_url+'/ajaxloader.gif', images_url+'/image2.gif');
 **/
jQuery.preloadImages = function(){
    for(var i = 0; i<arguments.length; i++){
        jQuery("<img>").attr("src", arguments[i]);
    }
};
// preload images
$.preloadImages(images_url+'/ajaxloader.gif');

/**
 * Traslates the string, if the translation available and was set at the `translate` variable
 * @access public
 * @return string
 **/
function __t(string){
    if (typeof(translate[string]) != 'undefined') {
        // translation found
        return translate[string];
    }
    else {
        // translation not found - return the string itself
        return string;
    }
}

/* block UI interface initialization */
bui = {
	overlayCSS: {backgroundColor:'#000', opacity:'0.3'},
	// css: { color:'#777', backgroundColor:'#DDD', border:'2px solid #AAA', padding:0, margin:0},
	css: { color:'#555', backgroundColor:'#CCC', border:'2px solid #DDD',  padding:0, margin:0},
	baseZ:10000,
	fadeOut:10,
	message:'<img src="'+images_url+'/ajaxloader.gif" border=0/><br/>'+__t("Loading...")
};
$(document).ajaxStart(function(){
	$.blockUI(bui);
});
//$.ajaxSetup({dataFilter:preprocessHTML});
$(document).ajaxStop(function(){
	$.unblockUI();
});
/* END block UI interface initialization */

// this fills in the background of odd and even table.usual rows with proper row class
// (needed for the certain browsers which do not properly process :nth-child(odd) pseudoclasses)
$(document).ready(function(){
    $("table.usual tbody tr:visible:even").addClass("even");
    $("table.usual tbody tr:visible:odd").addClass("odd");
});

// bind click function to checkbox with class="select_all"
$('input:checkbox.select_all').live('click',function(){
	$(this).parents('table').find('input:checkbox').attr("checked",$(this).attr("checked"));
    //$(this).parents('table').find('tbody tr').toggleClass('select',$(this).attr("checked"));
});

// needed for the pages with multilingual content to make the tabs
$(document).ready(function(){
    $("#multilang_div").tabs();
});

// show all blocks with class="infoblock" with slide effect
$(".infoblock").hide();
$(document).ready(function(){
    $(".infoblock").effect('slide', {}, 1000);
});


// hover animation on main menu at header
$(document).ready(function() {
    $('div.menu_items li').hover(function(){
        $(this).find('a').animate({'color':'#105895'},{queue:false,duration:500});
    }, function(){
        $(this).find('a').animate({'color':'#ebebeb'},{queue:false,duration:500});
    });
});

// hover animation on menu at column
$(document).ready(function() {
    // initiates the timer used for the sliding animation
    var timer = 0;
    // show the animation
    $('#column div.menu li').each(function(){
        timer = (timer*0.8 + 100);
        $(this).animate({'padding-left':'15px'}, timer)
            .animate({'padding-left':'30px'}, timer)
            .animate({'padding-left':'15px'}, timer);
    });
    // make the hover event
    $('#column div.menu li.sliding').hover(function(){
        $(this).animate({'padding-left':'30px'},{queue:false,duration:150});
    }, function(){
        $(this).animate({'padding-left':'15px'},{queue:false,duration:150});
    });
});
