// JavaScript Document
// JavaScript Document
function addPopUpLinks() {
	if(document.getElementById) {
		var pl = document.getElementById('main').getElementsByTagName('ul');
		var divs = document.getElementById('main').getElementsByTagName('div');
/*		var title = document.getElementById('main').getElementsByTagName('h1');
		var pageTtitle = title[0].firstChild.alt;
		pageTtitle += ', РџСЂРѕРґСѓРєС‚Рё | Р¤РѕСЂРµСЃС‚ РўСЂРµР№Рґ РћРћР”';*/
		var i, j, k, m;
		for(j=0; j < pl.length; j++) {
			if(/gallery/.test(pl[j].className)) {
				for(i = 0; i < pl[j].childNodes.length; i++) {
					if(pl[j].childNodes[i].tagName == 'LI') { //&& pl[j].childNodes[i].firstChild.tagName == 'A'
						var inlinks = pl[j].childNodes[i].getElementsByTagName('a');
						for(n = 0; n < inlinks.length; n++) {
							inlinks[n].onclick = function () {popw(this); return false; }
						}
						/*
						pl[j].childNodes[i].firstChild.onclick = function () {popw(this); return false; }
						var oTitle = pl[j].childNodes[i].firstChild.getAttribute('title');
						pl[j].childNodes[i].firstChild.setAttribute('title', 'Отваря се в нов прозорец');*/
					}
				}
			}
			else if(/illustration/.test(divs[j].className)) {
				for(i = 0; i < divs[j].childNodes.length; i++) {
					if(divs[j].childNodes[i].tagName == 'P' && divs[j].childNodes[i].firstChild.tagName == 'A') {
						divs[j].childNodes[i].firstChild.onclick = function () {popw(this); return false; }
						var oTitle = divs[j].childNodes[i].firstChild.getAttribute('title');
						divs[j].childNodes[i].firstChild.setAttribute('title', 'Отваря се в нов прозорец');
					}
				}
			}
		}
		//for div.illustration
		/*for(l=0; l < divs.length; l++) {
			if(/illustration/.test(divs[l].className)) {
				for(k = 0; k < divs[l].childNodes.length; k++) {
					if(divs[j].childNodes[k].tagName == 'P' && divs[l].childNodes[k].firstChild.tagName == 'A') {
						divs[j].childNodes[k].firstChild.onclick = function () {popw(this); return false; }
						var oTitle = divs[l].childNodes[k].firstChild.getAttribute('title');
						divs[l].childNodes[k].firstChild.setAttribute('title', ' (РѕС‚РІР°СЂСЏ СЃРµ РІ РЅРѕРІ РїСЂРѕР·РѕСЂРµС†)');
					}
				}
			}
		}*/
	}
}
function popw(o) {
	var newWindow;
	var src = o.href;
	//var features = "menubar=no, resizable=no, scrollbars=no, toolbar=no, status=no, screenX=100, screenY=100";
	// generate and fill the new window
	function makeNewWindow( ) {
		// make sure it isn't already opened
		var features = "menubar=no, resizable=no, scrollbars=no, toolbar=no, status=no, screenX=10, screenY=10, left=10, top=10, width=300, height=300";
		if (!newWindow || newWindow.closed) {
			newWindow = window.open("","sub",features);
			var newContent = "<html><head><title>Image</title>";
			newContent += "<style type='text/css' media='all'>body { margin: 0; padding: 0; text-align: center; background-color: #000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 70%; color: #000; } p { margin: 5px 0 0 0; padding: 0; } img { margin: 0; padding: 0; border: 1px solid #D7D8DB; } a:link, a:visited, a:hover, a:active { color: #FF6D00; background-color: transparent; text-decoration: none; } a:hover { text-decoration: underline; }</style>";
			newContent += "</head>";
			newContent += "<body><p><a href='#' onclick='window.close();'><img src=" + src + " alt='Image' /></a></p>";
			newContent += "<p><a href='#' onclick='window.close();'>Затвори</a></p>";
			newContent += "<script type='text/javascript'>";
			newContent += "setTimeout('window.resizeTo(document.images[0].width+50, document.images[0].height+80)',500);";
			newContent += "</script>";
			newContent += "</body></html>";
			newWindow.document.write(newContent);
			
			newWindow.document.close( ); // close layout stream
						
		} else if (newWindow.focus) {
			// window is already open and focusable, so bring it to the front
			newWindow.focus( );
		}
	}
	makeNewWindow();
	newWindow.focus( );
	return false;
		
}
