function httpGet(object, url) { object.open("GET", url, true); object.send(null); } function getXHTTPObject() { var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); return x; } function loadJsAsync(url) { var x = getXHTTPObject(); x.onreadystatechange = function() { if (x.readyState == 4 && x.status == 200) { var headTag = document.getElementsByTagName('head')[0]; setjs = document.createElement('script'); setjs.setAttribute('type', 'text/javascript'); headTag.appendChild(setjs); setjs.text = x.responseText; loadCount++; if (loadCount == 6) { onScriptsLoaded(); } } } httpGet(x, url); } function showContentPreload(){ var contentElement = document.getElementById('contentPreload'); contentElement.style.display = 'block'; } function hideContentPreload(){ var contentElement = document.getElementById('contentPreload'); contentElement.style.display = 'none'; } function loadContent(title, contentType, id) { var x = getXHTTPObject(); x.onreadystatechange = function() { if (x.readyState == 4 && x.status == 200) { hideContentPreload(); contentElement = document.getElementById('content_column'); contentElement.innerHTML = x.responseText; document.title = title + ' Ministry of Environment of the Republic of Lithuania'; if('' != contentType && '' != id){ window.location.href = appendHashToCurrentUrl("#" + contentType + "/" + id); } window.scroll(0,0); } } showContentPreload(); var url = ''; if (contentType == 'r') { url = 'http://www.am.lt/VI/en/VI/rubric-new.php3?rubric_id=' } else if (contentType == 'a') { url = 'http://www.am.lt/VI/en/VI/article-new.php3?article_id=' } else if (contentType == 'news') { url = 'http://www.am.lt/VI/en/VI/news.php'; id = ''; } else { hideContentPreload(); return; } url = url + id; httpGet(x, url); } function loadSearchResults(q, start){ var x = getXHTTPObject(); x.onreadystatechange = function() { if (x.readyState == 4 && x.status == 200) { hideContentPreload(); var contentElement = document.getElementById('content_column'); contentElement.innerHTML = x.responseText; document.title = 'PaieŇ°kos rezultatai - Aplinkos ministerija'; } } showContentPreload(); q = escape(q); httpGet(x, "http://www.am.lt/VI/en/VI/searchGoogleRes.php?q=" + q + "&start=" + start); } function loadNavigationLine(contentType, id) { var x = getXHTTPObject(); x.onreadystatechange = function() { if (x.readyState == 4 && x.status == 200) { var contentElement = document.getElementById('navigationPath'); contentElement.innerHTML = x.responseText; } } var url = "http://www.am.lt/VI/en/VI/navigationPath.php"; if ('a' == contentType) { url = url + "?aid="; } else { url = url + "?rid="; } url = url + id; httpGet(x, url); } function loadByUrl(title, newUrl) { var newUrlHash = ''; if (0 == arguments.length) { newUrl = window.location.href; newUrlHash = window.location.hash; title = ''; } else { if('#' == newUrl.charAt(0)){ newUrlHash = newUrl; newUrl = appendHashToCurrentUrl(newUrl); } else { newUrlHash = getHashFromUrl(newUrl); } } if (lastUrlLoaded == newUrl) { return; } lastUrlLoaded = newUrl; if (document.iframesfix) { document.getElementById('ajaxnav').setAttribute('src', 'http://www.am.lt/VI/en/VI/mock-page.php?currHash=' + newUrlHash.substr(1, newUrlHash.length-1)); } //alert('title: ' + title + ' newUrl: ' + newUrl + ' newUrlhash: ' + newUrlHash); if ('' != newUrlHash) { var ct = newUrlHash.substr(1, 1); var id = newUrlHash.substr(3, newUrlHash.length - 1); loadContent(title, ct, id); loadNavigationLine(ct, id); } else { if(window.location.href.indexOf('ka.php3') > 0 || window.location.href.indexOf('rubric.php3') > 0 || window.location.href.indexOf('article.php3') > 0 || window.location.href.indexOf('treeFull.php') > 0 || window.location.href.indexOf('favoriteRubrics.php') > 0 || window.location.href.indexOf('lrs_search_form.php3') > 0 || window.location.href.indexOf('lrs_search.php3') > 0 || window.location.href.indexOf('ta.php3') > 0 || window.location.href.indexOf('top10prj-nut.php3') > 0 || window.location.href.indexOf('top10prj-ist.php3') > 0 || window.location.href.indexOf('taproj.php3') > 0 || window.location.href.indexOf('rubric_archive.php3') > 0 || window.location.href.indexOf('searchGoo.php') > 0 || window.location.href.indexOf('registration/') > 0 ) { hideContentPreload(); } else { loadContent('Naujienos', 'news', ''); } var articleIdPos = window.location.href.indexOf('article_id'); var rubricIdPos = window.location.href.indexOf('rubric_id'); if(articleIdPos > 0) { var aid = window.location.href.substr(articleIdPos + 11, window.location.href.length - 1); loadNavigationLine('a', aid); } else if(rubricIdPos > 0) { var rid = window.location.href.substr(rubricIdPos + 10, window.location.href.length - 1); loadNavigationLine('r', rid); } else { loadNavigationLine('', ''); } } }