$(document).ready(function() {
    setTxtDiv();
    $('#info p:gt(1)').hide();
    $('span.more').click(function() {
        $('#info p:gt(1)').animate({height: "show", width: "show", opacity:"show"}, 'slow');
        $(this).hide();
    });
});

function setTxtDiv() {
    var ww = $('#outer').width();
    
    if(ww > 993 && ww < 1100) {
        $('#txt').width(480);
    }
    if(ww == 1100) {
        $('#txt').width(530);
    }
}

function initMenu(section) {
    
    $('#acc ul').hide();
    if(section.length > 0) {
        $('#acc ul#'+section).show();
        var div = '';
        switch(section) {
            case 'represented':
              div = 'ra';
              break;
            case 'featured':
              div = 'fa';
              break;
            case 'ole':
              div = 'ol';
              break;
        }
        $('#'+div).css('color', '#CD7F32');
    }
    $('#acc li a').click(
        function() {
            var title = $(this).attr('title');
            var targetUrl = '';
            switch(title) {
                case 'represented':
                  targetUrl = '/represented-artists/';
                  break;
                case 'featured':
                  targetUrl = '/featured-artists/';
                  break;
                case 'ole':
                  targetUrl = '/exhibition/on-line/';
                  break;
            }
            window.location.href = targetUrl;
            var checkElement = $(this).next();
            if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
                return false;
            }
            if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
                $('#acc ul:visible').slideUp('normal');
                checkElement.slideDown('normal');
                return false;
            }
        }
    );
}

$(function(){
    $('a.new-window').click(function(){
        window.open(this.href);
        return false;
    });
});


$(function(){
    $('.vad').mouseover(function() {
        var artid = this.id;
        bits = artid.split("_");
        $.post("/incs/ajax.php", {aid: bits[1], artexh: bits[0], loc:bits[2]},
            function(html){
                showArtData(html);
        });
    });
});


function showArtData(xhtml) {
    //alert(xhtml);
    var img_html = xhtml.split("~");
    
    $(".pop").attr("href", img_html[1]);
    $("#cimg").attr("src", img_html[0]);
    $("#pdata").html(img_html[2]);
}
