/* author: Martin Roclawski */
/* Creation date: 29/02/2004 */

var IsIE  = document.all ? 1 : 0
var IsNS4 = document.layers ? 1 : 0
var IsDOM = document.getElementById ? 1 : 0

var NewBrowser=null;

function CreatePopupSettings(w,h,scroll,pos) {
        if (pos=="random") {
                LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
                TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
        }
        if (pos=="center") {
                LeftPosition=(screen.width)?(screen.width-w)/2:100;
                TopPosition=(screen.height)?(screen.height-h)/2:100;
        }
        else if ((pos!="center" && pos!="random") || pos==null) {
                LeftPosition=0;
                TopPosition=20
        }
        return 'width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
};

function PagePopup(PopupPage,PopupTitle,w,h,scroll,pos){
        if (w != null) {
                lsettings=CreatePopupSettings(w,h,scroll,pos);
                var NewBrowser=window.open(PopupPage,'',lsettings);
        } else {
                NewBrowser=window.open(PopupPage,'','');
        };
        //alert (NewBrowser.document.title);
        if ((NewBrowser.document != null) && (PopupTitle != null)) {
        	try        	
        	{
                	NewBrowser.document.title=PopupTitle;
                }
                catch (e)
                {};
        };
};

function ResizeClient(cWidth, cHeight){
        if (IsIE){
                window.resizeTo(100,100);
                lwidth=100-(document.body.clientWidth-cWidth);
                lheight=100-(document.body.clientHeight-cHeight);
                window.resizeTo(lwidth,lheight);
        } else {
                window.innerWidth=cWidth;
                window.innerHeight=cHeight;
        };
};

function ResizeToImg() {
        ResizeClient(document.images[0].width, document.images[0].height);
};

function ImagePopup(PopupImage,PopupTitle,startw,starth,scroll,pos,pad){        
        if (pad == null) {
                pad = 5;
        };
        if (typeof startw != "number") {startw = parseInt(startw)};
        if (typeof starth != "number") {starth = parseInt(starth)};
        limage=new Image();
        limage.src = PopupImage;
        lsettings='';
        lsettings=CreatePopupSettings(startw+pad,starth+pad,scroll,pos);
        NewBrowser=window.open('','',lsettings);
        NewBrowser.document.writeln('<html><head><META HTTP-EQUIV="imagetoolbar" CONTENT="no">');
        //NewBrowser.document.writeln('<script language="JavaScript" src="../shared/java/pngFIX.js"></script>');
        NewBrowser.document.writeln('</head>');
        NewBrowser.document.writeln('<body style="margin:'+pad+'px;">');
        NewBrowser.document.writeln('<a><img src="'+PopupImage+'" oncontextmenu="return false;"></a>');
        NewBrowser.document.writeln('</body></html>');
        NewBrowser.document.close();
        NewBrowser.document.title=PopupTitle;
};