var is_test = /is_test/.test(window.location.href);
(function($){$(document).ready(function(){
        if ( $.browser.msie ){
            if (parseInt($.browser.version, 10) < 8){
                $('body').css('overflow','visible');
                $('#contact_form').find('.left').find('.contact_form_field').css({
                    'margin-left':'0px'
                });
                $('#contact_form').find('.left').find('.contact_form_field').find('span').css({
                    'margin-left':'0px'
                });
                $('#contact_form').find('.left').find('.contact_form_field').find('input').css({
                    'margin-left':'50px'
                });
            }
        }
        
        if($("#pildi_album").length){
            $('img:last').load(function() {
                setTimeout(load_height,1000);
            });
        }else{
            load_height();
        }  
        
        if($("#pildi_album").find(".gallery-link").length){
            $("#pildi_album").find(".gallery-link").each(function(){
                $(this).hide();
            });
        }

        if($("#pildi_album").find(".load_next_image").length){
            $(window).bind("scroll", function(){
                if($("#pildi_album").find(".load_next_image").length){
                    var top = getPageScroll()[1];
                    var page_height = getPageHeight();
                    var last_offset = $(".load_next_image").first().offset().top;
                    var last_height = $(".loaded_image").last().height();

                    var vp = page_height+top;
                    var nl = Math.abs(last_offset-last_height);

                    if(vp > nl){
                        var load = $(".load_next_image").first();
                        load.removeClass('load_next_image').addClass("loaded_image");
                        load.attr('src',function(){
                            return str_replace('large/','',$(this).parent().attr('href'));
                        });
                    }
                }
            });
        }

        
        $("#switch_view").click(function(){
            $("#gallery_view_form").submit();
            return false;
        });

});})(jQuery);

function load_height(){
    var left_height = $('.content_table').find('.left_bar').children('.level_up').height();
    var right_height = $('.content_table').find('.right_bar').children('.level_up').height();
    if(left_height > right_height){
        $('.content_table').find('.right_bar').children('.level_up').height(left_height);
    }else if(left_height < right_height){
        $('.content_table').find('.left_bar').children('.level_up').height(right_height);
    } 
}
