$("document").ready(function(){
            /*$("#slider").scrollTo("li:eq(0)", 800 );
            
            $("#slider-control li").click(function() {
                pos = $(this).attr("id");
                $(this).parent().find("li").removeClass("current");
                $(this).addClass("current");
                $("#slider").scrollTo("li:eq(" + pos + ")", 800 );
            });*/
            
            
            
            $("#hide-support").click(function() {
                var rel = $(this).attr("rel");
                var h = 849;

                if(rel == 0) {
                    $("#support").hide();
                    $(this).text("развернуть");
                    $(this).attr("rel", "1");
                    $("#separator").height(h - $("#support").height() - 60);
                }
                else {
                    $("#support").show();
                    $(this).text("свернуть");
                    $(this).attr("rel", "0");
                    $("#separator").height(h);
                }
                return false;
            });
            
            $("#mb-menu > span").hover(
                function() {
                    $(this).prepend("<span class='mb-triangle png'></span>");
                },
                function() {
                    $(".mb-triangle").remove();
                }
            );
            $(".del-item").click(function() {
                $(this).parent().remove();
            });
            
            $("#loading").ajaxStart(function(){
                $(this).show();
            });
            $("#loading").ajaxComplete(function(event,request, settings){
                $(this).hide();
            });
            
            
});

function refreshCatalog()
{    
    $.post('/ajax-reponse/refresh-catalog.php',
                        {
                            'catList': $('#choosenCategories').val(), 
                            'country': $('#countryList').val(), 
                            'city': $('#cityList').val(), 
                            'product': $('#productList').val(), 
                            'participantYear': $('#participantYears').val(), 
                            'perPage': $('#perPageList').val(), 
                            'page': $('#page-nav').attr('rel')
                        }, 
                        function ( htmlContent ){
                                
                                $('#catalog-list').html( htmlContent );
                                var params = {
                                    changedEl: "#perPageList",
                                    visRows: 7
                                }
                                cuSel(params);
                        });
}

function setGalleryBlockWidth()
{	
    blockWidth = ( $('#fg-panel ul#blocks li:first').width() + parseInt( $('#fg-panel ul li:first').css('margin-right') ) ) * $('#fg-panel ul#blocks li').length;
    $('#fg-panel ul#blocks').css('width', blockWidth + 'px');
}
function array_search( needle, haystack, strict ) {    // Searches the array for a given value and returns the corresponding key if
    // successful
    // 
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)

    var strict = !!strict;

    for(var key in haystack){
        if( (strict && haystack[key] === needle) || (!strict && haystack[key] == needle) ){
            return key;
        }
    }

    return false;
}

