/* IE6 Image flicker fix */
try {
    document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}
/* End */
function openNewWindow() {
    window.open(this.href);
    return false;
}
function openNewSizedWindow() {
    var eImage = new Image();
    eImage.src = this.href;
    iWidth = (eImage.width?eImage.width:(getElementWidth(eImage)?getElementWidth(eImage):false));
    iHeight = (eImage.height?eImage.height:(getElementHeight(eImage)?getElementHeight(eImage):false));
    //alert('Test: '+iWidth+' | '+iHeight);
    if (!iWidth || !iHeight) {
        mywindow = window.open(this.href);
    } else {
        mywindow = window.open('viewImage.php?src='+this.href+'&title='+this.getElementsBySelector('img')[0].alt, null, 'menubar=0,resizable=0,width='+(iWidth + 20)+',height='+(iHeight + 80)+',left=50,top=100');    }
    if (mywindow) { return false; }
}
function returnFalse() { return false; }

Event.observe(window, 'load', function(){
    $$('a[href$=".jpg"]').each(function(e){
        var eImage = new Image();
        eImage.src = e.href;
        e.onclick = openNewSizedWindow;
    });
});