// JavaScript Document
function addPopUpLinks() {
	if(document.getElementById) {
		var pl = document.getElementsByTagName('td');
		var rows = document.getElementsByTagName('tr');
		var pics;
/*		var title = document.getElementById('main').getElementsByTagName('h1');
		var pageTtitle = title[0].firstChild.alt;
		pageTtitle += ', Продукти | Форест Трейд ООД';*/
		var i, j;
		for(j=0; j < pl.length; j++) {
//			if(/characteristics/.test(pl[j].className)) {
				for(i = 0; i < pl[j].childNodes.length; i++) {
					if(pl[j].childNodes[i].tagName == 'A' && pl[j].childNodes[i].firstChild.tagName == 'IMG') {
						pl[j].childNodes[i].onclick = function () {popw(this); return false; }
						var oTitle = pl[j].childNodes[i].firstChild.getAttribute('title');
						pl[j].childNodes[i].firstChild.setAttribute('title', '(opens in new window)');
					}
					else if (pl[j].childNodes[i].tagName == 'A') {
						pl[j].childNodes[i].onmouseover = function () {changeSrc(this); return false; }
					}
				}
			}
//		}
	}
}
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=100, screenY=100, 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: #fff; 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: #0473A8; 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();'>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;
		
}
function changeSrc(o) {
	var localtds = o.parentNode.parentNode.getElementsByTagName('td');
	var img = o.parentNode.parentNode.parentNode.getElementsByTagName('img');
	var pl = o.parentNode.parentNode.parentNode.getElementsByTagName('td');
	var allpl = document.getElementsByTagName('td');
	for(var i=0; i < allpl.length; i++) {
			allpl[i].style.backgroundColor = 'white';
				allpl[i].style.borderBottom = '1px solid #fff';
		}
	for(var i=0; i < pl.length; i++) {
			if((/illustration/.test(pl[i].className))) {
				pl[i].style.backgroundColor = '#f2ecee';
			}
			else {
				pl[i].style.backgroundColor = 'white';
			}
			
		}
	for(var i=0; i < localtds.length; i++) {
//			if(localtds[i].id != 'illustration_1') {
			if(!localtds[i].getAttribute('id')) {
				localtds[i].style.backgroundColor = '#f2ecee';
				//localtds[i].style.borderTop = '1px solid #606060';
				var picinfo = localtds[i].className;
				img[0].src = '../../i/products/shpric/small/EXP' + picinfo + '.jpg';
				img[0].parentNode.href = '../../i/products/shpric/big/EXP' + picinfo + '.jpg'; 
				//document.getElementById('illustration')
//				img[0].parentNode.parentNode.nodeName.style.backgroundColor = '#ccc';
			}
	}
	o.onclick = function () {return false};
}
