// PRELOADING IMAGESvar imgcount = directories.length;if (document.images) {    imageon = [];    imageoff = [];    for (var i=1; i<=imgcount; i++) {        front = "images/front/"+directories[i-1]+".jpg";        spine = "images/spine/"+directories[i-1]+".jpg";        imageon['img'+i] = new Image();        imageon['img'+i].src = front;        imageoff['img'+i] = new Image();        imageoff['img'+i].src = spine;    }}function handleOver() {    if (document.images)        document.imgName.src=img_on.src;}function handleOut() {    if (document.images)        document.imgName.src=img_off.src;}function hideAll() {    $('.directories img').each(function(){        var name = $(this).attr('name');        var source = imageoff[name].src;        if ($(this).attr('src') != source) {            $(this).attr('src', source);        }    });}function movr(k) {    hideAll();    $('img[name=img'+k+']').attr('src', imageon['img'+k].src);}function oc(a){    var o = {};    for(var i=0;i<a.length;i++)    {        o[a[i]]='';    }    return o;}function arrayconvert(a){    var o = {};    for(var i=0;i<a.length;i++)    {        o[a[i]]=i+1;    }    return o;}function intval (mixed_var, base) {    var type = typeof( mixed_var );     if (type === 'boolean') {        return (mixed_var) ? 1 : 0;    } else if (type === 'string') {        tmp = parseInt(mixed_var, base || 10);        return (isNaN(tmp) || !isFinite(tmp)) ? 0 : tmp;    } else if (type === 'number' && isFinite(mixed_var) ) {        return Math.floor(mixed_var);    } else {        return 0;    }}function qld() {    $('.bookshelf').each(function(){        if($(this).children().first().attr('alt') in oc(qlddirectories)){            $(this).css({                'display':'inline'            });        } else {            $(this).css({                'display':'none'            });        }    });    var dircount = qlddirectories.length;    var h = intval(dircount / 2);    var median;    if(dircount % 2 == 0) {        median = intval((h + (h-1)) / 2);    } else {        median = h;    }    hideAll();    var whichdir = qlddirectories[median];    var obj = arrayconvert(alldirectories);    var name = 'img'+obj[whichdir];    $('img[name='+name+']').attr('src', imageon[name].src);}function nsw() {    $('.bookshelf').each(function(){        if($(this).children().first().attr('alt') in oc(nswdirectories)){            $(this).css({                'display':'inline'            });        } else {            $(this).css({                'display':'none'            });        }    });    var dircount = nswdirectories.length;    var h = intval(dircount / 2);    var median;    if(dircount % 2 == 0) {        median = intval((h + (h-1)) / 2);    } else {        median = h;    }    hideAll();    var whichdir = nswdirectories[median];    var obj = arrayconvert(alldirectories);    var name = 'img'+obj[whichdir];    $('img[name='+name+']').attr('src', imageon[name].src);}function nt() {    $('.bookshelf').each(function(){        if($(this).children().first().attr('alt') in oc(ntdirectories)){            $(this).css({                'display':'inline'            });        } else {            $(this).css({                'display':'none'            });        }    });    var dircount = ntdirectories.length;    var h = intval(dircount / 2);    var median;    if(dircount % 2 == 0) {        median = intval((h + (h-1)) / 2);    } else {        median = h;    }    hideAll();    var whichdir = ntdirectories[median];    var obj = arrayconvert(alldirectories);    var name = 'img'+obj[whichdir];    $('img[name='+name+']').attr('src', imageon[name].src);}function showAll() {    $('.bookshelf').each(function(){        $(this).css({            'display':'inline'        });    });    var dircount = alldirectories.length;    var h = intval(dircount / 2);    var median;    if(dircount % 2 == 0) {        median = intval((h + (h-1)) / 2);    } else {        median = h;    }    hideAll();    var whichdir = alldirectories[median];    var obj = arrayconvert(alldirectories);    var name = 'img'+obj[whichdir];    $('img[name='+name+']').attr('src', imageon[name].src);}
