// Copyright Sergey Krushinsky , 2006
// mailto: mail@s2dio.info

var win = null;

function openWindow(url, name, width, height) {
        var w = width
        var h = height

        var wh = 'width=' + w + ',height=' + h
           + ',menubar=0'
           + ',toolbar=0'
           + ',status=0'
           + ',scrollbars=1'
           + ',resizeable=1'
           + ',top=20,left=20';
        //var btn_x = width - 70;
        //var btn_y = height - 40;
        var tit_y = height - 20;
        if (name == null)
                name = '';
        win = window.open('', '', wh);
        with(win.document) {
                writeln('<html>');
                writeln('<head>');
                writeln('<meta content="text/html; charset=windows-1251" http-equiv="content-type">');
                writeln('<title>' + name + '</title>');
                writeln('<style type="text/css">');
                //writeln('div.button {background:#ccccff; z-index:2; position:absolute;top=' + btn_y + 'px; left=' + btn_x + 'px; }');
                writeln('div.title {background:brown; z-index:2; position:absolute; top:' + tit_y + 'px;left:3px;padding-left:2px;padding-right:2px;padding-top:1px;padding-bottom:2px;}');
                writeln('span.title {color:white; font-family:"Courier New",Courier,monospaced; font-size:12px}');
                //writeln('a.button {color:#ff9933; font-family:Arial,Helvetica,sans-serif; font-size:12px;font-weight: bold;text-decoration: none;}');
                //writeln('a.button:hover {color:white;text-decoration: underline;}');
                writeln('</style>');
                writeln('</head>');
                writeln('<body style="margin: 0 0 0 0; background:black;">');
                writeln('<div align="center">');
                writeln('<img src="' + url + '">');
                writeln('</div>');
                //writeln('<div class="button">');
                //writeln('<a href="javascript:window.close();" class="button">ÇÀÊÐÛÒÜ</a>');
                //writeln('</div>');

                //if (name != '' && name != null) {
                //        writeln('<div class="title">');
                //        writeln('<span class="title">' + name + '</span>');
                //        writeln('</div>');
                //}
                writeln('</body>');
                writeln('</html>');
                close();
        }
        win.focus();
}

function openURL(url, w, h) {
    var style = 'width=' + w + ', height=' + h
       + ',menubar=0'
       + ',toolbar=0'
       + ',status=0'
       + ',scrollbars=1'
       + ',resizable=1'
       + ',top=20,left=20'

    win = window.open(url, '', style);
    win.focus();
}

function openModal(url, name, w, h) {
    if (document.dialog.state.value == '0' || win.closed) {
        var style = 'width=' + w + ', height=' + h
           + ',menubar=no'
           + ',toolbar=no'
           + ',directories=no'
           + ',status=no'
           + ',scrollbars=no'
           + ',resizable=no'
           + ',top=20,left=20'
           + ',copyhistory=no'
		   + ',modal=yes'

		win = window.open(url, '', style)
		document.dialog.state.value = '1'
    }
    win.focus();
}


function closeThisModal() {
	with(window) {
		if (opener && !opener.closed) {
          opener.document.dialog.state.value = '0'
          opener.window.location.reload()
          close();
		}
	}
}

function submitThisModal() {
    with (document.forms[0]) {
        seenform.value='1';
        submit();
    }
    opener.document.dialog.state.value = '0'
}

function closeWindow() {
        if (win != null) {
                win.close();
                win = null;
        }
}

function toggleWindow(url, width, height) {
        if (win == null) {
                openWindow(url, width, height);
        } else {
                closeWindow();
        }
}

function showImage(url, w, h, title) {
        if (win != null)
                closeWindow();
        if (title == null)
                title = '';
    openWindow(url, title, w, h);
}



