function viewPic(url, title) {
    if (url == '') return false;
    width = 300;
    height = 100;
    window_top = (screen.height - height) / 2;
    window_left = (screen.width - width) / 2;
    win = window.open(url, 'image', 'width='+width+', height='+height+', top='+window_top+', left='+window_left+', toolbar=0, statusbar=0, location=0, scrollbars=no, resizable=0');
    win.document.open();
    win.document.write('<html><head><title>'+title+'</title>');
    win.document.write('<' + 'script language="Javascript"> ');
    win.document.write('function body_on_load() {window.document.getElementById("text").innerHTML = ""; document.getElementById("photo").style.display = "block"; window.resizeTo((document.images.photo.width+10),(document.images.photo.height+29)); window.moveTo((screen.width-document.images.photo.width)/2, (screen.height-document.images.photo.height)/2); window.focus(); }</'+'script>');
    win.document.write('</head><body leftmargin=0 topmargin=0 rightmargin=0 bottommargin=0 marginwidth=0 marginheight=0 onload="body_on_load()">');
    win.document.write('<span id="text"><br><center>Идет загрузка изображения...</center></span><a href="javascript:window.close();"><img id="photo" src="'+url+'" style="display:none" border="0"></a>');
    win.document.write('</body></html>');
    win.document.close();    
}

function viewURL(url, width, height, scroll) {
    if (url == '')   return false;
    if (width == null) width = 640;
    if (height == null) height = 480;

    if (scroll == null) scroll = 0;
    win = window.open(url, '', 'width='+width+', height='+height+', toolbar=0, statusbar=0, location=0, scrollbars='+scroll+', resizable=0');
    win.moveTo((screen.width-width)/2, (screen.height-height)/2);
}


function viewURLfull(url, width, height, scroll) {
    if (url == '')   return false;
    if (width == null) width = screen.width;
    if (height == null) height = screen.height;

    if (scroll == null) scroll = 1;
    win = window.open(url, '', 'width='+width+', height='+height+', toolbar=1, statusbar=1, location=1, scrollbars=yes, resizable=0, menubar=1, title=1');
    win.moveTo((screen.width-width)/2, (screen.height-height)/2);
}

function set_per_page () {
	if (oElement = document.getElementById('per_page')) {
		SetCookie('per_page', oElement.value);
		window.location.reload();
	}
}

function SetCookie(name, value) {
	var expiry = new Date();
        expiry.setTime(expiry.getTime() + 24 * 60 * 60 * 1000 * 10000);
        document.cookie = name + '=' + value + '; path=/; expires=' + expiry.toGMTString();
}
