// CSS IE SWAP IMAGE FIX //

try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}


/* 
   openPopupPos creates a popup at (winnX, winnY)
*/
function openPopupPos (linkOb, thewidth, theheight, winnX, winnY, params) {
    var aname = 'popup';
    var url   = linkOb.href;

    if ( ! url ) {
        return true; // failed because no link to open!
    }
    
    if ( params ) {
        params = ',' + params;
    }

    str_WinParams = 'top=' + winnY+',left=' + winnX + params + ',width='+thewidth+',height='+theheight;

    thewindowobject = window.open(url,aname, str_WinParams);

    if (window.focus) thewindowobject.focus()

    if ( thewindowobject )
        return false; // success!!
    else
        return true; // failed
}

/* a slightly strange function because it returns 'true' when it fails
   and 'false' when it succeeds. This means that it can be used in an onclick event

   onclick="return openPopup(this, '')"

   openPopup creates a centered popup
*/
function openPopup (linkOb, thewidth, theheight, params) {
    var url  = linkOb.href;
    var winX = 0;
    var winY = 0;
    var winnX = 0;
    var winnY = 0;

    if ( ! url ) {
        return true; // failed because no link to open!
    }

    if ( screen ) {
        if ( thewidth != 0 ) {
            var diffX = (screen.width-thewidth); /* don't want to do a division by 0 */
            if ( diffX > 0 ) winnX = diffX / 2;
        } else {
            thewidth  = screen.width - 10;
        }

        if ( theheight ) {
            var diffY = (screen.height-theheight);
            if ( diffY > 0 ) winnY = diffY / 2;
        } else {
            theheight = screen.height - 10;
        }
    } else {
        if ( ! thewidth ) thewidth   = 795;
        if ( ! theheight ) theheight = 595;
    }

    return openPopupPos(linkOb, thewidth, theheight, winnX, winnY, params);
}
