var ajax, previd, nextid; function init() { initAjax(); if (!document.importNode) { document.importNode = function(node, allChildren) { switch (node.nodeType) { case 1: var newNode = document.createElement(node.nodeName); if (allChildren && node.childNodes && node.childNodes.length > 0) { il=node.childNodes.length; for (var i = 0; i < il; i++) newNode.appendChild(document.importNode(node.childNodes[i], allChildren)); } return newNode; break; default: return document.createTextNode(node.nodeValue); break; } }; } nextid=(document.getElementById("next_image")!=null)?document.getElementById("next_image").alt:-1; previd=(document.getElementById("prev_image")!=null)?document.getElementById("prev_image").alt:-1; } function initAjax() { try { ajax = new XMLHttpRequest(); // nowoczesne przegladarki ajax.overrideMimeType('text/xml'); } catch(e) // IE <= 6 { var XmlHttpVersions = [ 'MSXML2.XMLHTTP.6.0', 'MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP' ]; for (var i=0; i < XmlHttpVersions.length && null === ajax; i++) { try { ajax = new ActiveXObject(XmlHttpVersions[i]); } catch (e) {} } if (null === ajax) { throw new Error('AJAX Error'); } } return true; } function response() { if (ajax.readyState != 4 || ajax.status != 200) return; var xml = ajax.responseXML; document.getElementById("curr_image").parentNode.href=document.getElementById("curr_image").src='images/upload/'+xml.getElementsByTagName("current")[0].getAttribute("src"); document.title = 'Podgląd zdjęcia nr ' + xml.getElementsByTagName("current")[0].getAttribute("id"); document.getElementById("author").firstChild.nodeValue=xml.getElementsByTagName("author")[0].firstChild.nodeValue; desc=document.getElementById("description"); while(desc.hasChildNodes()) desc.removeChild(desc.firstChild); children=document.importNode(xml.getElementsByTagName("desc")[0], true).childNodes; for(i=0; i0) { document.getElementById("next_image").src='images/upload/'+xml.getElementsByTagName("next")[0].getAttribute("thumb"); nextid=xml.getElementsByTagName("next")[0].getAttribute("id"); document.getElementById("next_image").alt=nextid; document.getElementById("next").style.display="block"; } else { document.getElementById("next").style.display="none"; nextid=-1; } if(xml.getElementsByTagName("prev").length>0) { document.getElementById("prev_image").src='images/upload/'+xml.getElementsByTagName("prev")[0].getAttribute("thumb"); previd=xml.getElementsByTagName("prev")[0].getAttribute("id"); document.getElementById("prev_image").alt=previd; document.getElementById("prev").style.display="block"; } else { document.getElementById("prev").style.display="none"; previd=-1; } } function previewImage(el) { if(el==-1) return 0; ajax.onreadystatechange = response; ajax.open('GET', path+ '/ask.php?id=' + el, true); ajax.send(null); } function prev() { previewImage(previd); } function next() { previewImage(nextid); }