var bHide = true; var oFlash; var bFlashWorks = true; var bNaslovnica = true; var infoShown = false; function testRegExp(sRegExp, sInput){ var oRegExp = new RegExp(sRegExp); if (oRegExp.test(sInput)) { return true; } else { return false; } } function check(){ // CS validacija forme var oName = document.getElementById("name"); var oEmail = document.getElementById("email"); var oText = document.getElementById("text"); var oSubject = document.getElementById("subject"); oName.setAttribute("class", ""); oEmail.setAttribute("class", ""); oText.setAttribute("class", ""); oSubject.setAttribute("class", ""); if (!testRegExp("[a-zA-Z0-9]{2}", oName.value)){ oName.setAttribute("class", "error"); oName.focus(); return false; } else if (!testRegExp("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]{2,}(\.[a-z0-9-]+)*\.[a-z]{2,4}$", oEmail.value)){ oEmail.setAttribute("class", "error"); oEmail.focus(); return false; } else if (!testRegExp("[a-zA-Z0-9]{3}", oSubject.value)){ oSubject.setAttribute("class", "error"); oSubject.focus(); return false; } else if (!testRegExp("[a-zA-Z0-9]{3}", oText.value)){ oText.setAttribute("class", "error"); oText.focus(); return false; } else return true; } function setHeight(){ // postavljamo height na visinu najveceg za sve druge divove var iMax=0; var oMain = document.getElementById("main"); var oDivovi = oMain.getElementsByTagName("div"); for (var x=0; x< oDivovi.length; x++){ if ((oDivovi[x].parentNode == oMain) && (oDivovi[x].clientHeight > iMax)){ iMax = oDivovi[x].clientHeight; } } for (x=0; x < oDivovi.length; x++){ if ((oDivovi[x].parentNode == oMain) && (oDivovi[x].getAttribute("id") != "kalendar")) oDivovi[x].style.height = iMax + "px"; } } function displayFlags(what){ var oObject = document.getElementById("zastave"); if (what){ bHide = false; oObject.style.top = "0px"; } else { // ovdje napravimo timeout 3 sec i kasnije sakrijemo... window.setTimeout("hideFlags()", 3000); bHide = true; } } function hideFlags(){ // sakrij zastave (s animacijom)... var iHeight = document.getElementById("zastave").clientHeight; var iTop = document.getElementById("zastave").style.top.match(/^(.*)px$/)[1]; if (bHide && ((iTop * -1) < iHeight)){ document.getElementById("zastave").style.top = --iTop + "px"; window.setTimeout("hideFlags()", 10); } } function flagShow(){ displayFlags(true); } function flagHide(){ displayFlags(false); } function windowOpen(link, width, height, name, features){ var x = (window.screen.width/2)-(width/2); var y = (window.screen.height/2)-(height/2); if (y < 0) y=0; // mala rezolucija (npr. 1024x768), a slika je portrait (600x800) if (features==undefined) features = "resizable=no,titlebar=no,status=no,scrollbars=no,toolbar=no"; var prozor=window.open(link, name, "height=" + height + ", width=" + width + ", left=" + x + ", top="+ y + features); if (prozor==null){ alert ('Greska kod otvaranja prozora'); } else { prozor.focus(); } return false; } function setCookie( name, value, path) { document.cookie = name+"="+escape( value ) + ( ( path ) ? ";path=" + path : "" ); } function getCookie(name) { var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else { begin += 2; } var end = document.cookie.indexOf(";", begin); if (end == -1) { end = dc.length; } return unescape(dc.substring(begin + prefix.length, end)); } function setFlashSayIt(sGDoba){ var oIzgovori = document.getElementsByTagName("cite"); for (var x=0; x < oIzgovori.length; x++){ if (oIzgovori[x].childNodes.length <= 1){ // postavi img unutra var oSlika = document.createElement("img"); oSlika.alt = "Izgovori '"+ oIzgovori[x].innerHTML +"'"; oSlika.src = "/layout/"+ sGDoba +"/tell.png"; var iTabIndex = 38; if (bNaslovnica){ // ovdje dohvacamo tabindex preko slike koja je na vrhu var oParentDiv = oIzgovori[x].parentNode.parentNode; var aImageLink = oParentDiv.getElementsByTagName("a"); for (var y=0; y< aImageLink.length; y++){ if (!testRegExp("/$", aImageLink[y])){ // nema / na kraju pa je to ono sto trebamo iTabIndex = aImageLink[y].tabIndex; break; } } } var oLink = document.createElement("a"); oLink.title = "Izgovori '"+ oIzgovori[x].innerHTML +"'"; oLink.href = "javascript:tell('"+ oIzgovori[x].getAttribute("title") +"')"; oLink.tabIndex = iTabIndex; oLink.appendChild(oSlika); oIzgovori[x].appendChild(oLink); } } } function unsetFlashSayIt(){ var oIzgovori = document.getElementsByTagName("cite"); for (var x=0; x < oIzgovori.length; x++){ var aLink = oIzgovori[x].getElementsByTagName("a")[0]; oIzgovori[x].removeChild(aLink); } } function getFlashLoaded (oMovie){ if (typeof(oMovie) != "undefined") { return oMovie.PercentLoaded() == 100; } else { return false; } } function tell(sWhat) { // ne smije nis vratiti jer nece radit kako treba if (!bFlashWorks){ // ovdje izderi za usrane browsere (Opera, Konqueror, Safari) var oDiv = document.getElementById("proxy"); if (oDiv == null){ var oCreateDiv = document.createElement("div"); oCreateDiv.setAttribute("id", "proxy"); document.getElementById("header").appendChild(oCreateDiv); oDiv = document.getElementById("proxy"); } else { for (var x = 0; x < oDiv.childNodes.length; x++) oDiv.removeChild(oDiv.childNodes[x]); } var oObject = document.createElement("object"); oObject.setAttribute("data", "/gateway.swf"); oObject.setAttribute("width", "0"); oObject.setAttribute("height", "0"); oObject.setAttribute("type", "application/x-shockwave-flash"); oObject.setAttribute("id", "proxy"); aNames = new Array("movie", "FlashVars", "allowScriptAccess", "swLiveConnect"); aValues = new Array("/gateway.swf", "sWhat="+ sWhat, "always", "true"); for (var z=0; z< aNames.length; z++){ oParam = document.createElement("param"); oParam.setAttribute("name", aNames[z]); oParam.setAttribute("value", aValues[z]); oObject.appendChild(oParam); } oDiv.appendChild(oObject); } else if (getFlashLoaded(oFlash)){ // Flash nije sjeban oFlash.SetVariable("/mc/izgovaratelj:sTalk", sWhat); oFlash.TGotoFrame("/mc/izgovaratelj", 1); } } function reformat(){ var sTitle = new String(this.getAttribute("title")); alert(sTitle.replace(/,\s*(\d{4})./, "\n$1.")); } function init(sGoDoba, bNaslov){ var W3CDOM = (document.getElementById && document.createElement && document.getElementsByTagName); if (!W3CDOM) return; else { bNaslovnica = bNaslov; setHeight(); // postavi mouse evente na elemente, XHTML style var oZastave = document.getElementById("zastave"); oZastave.onmouseover = flagShow; oZastave.onfocus = flagShow; oZastave.onmouseout = flagHide; oZastave.onblur = flagHide; var oHeader = document.getElementById("headerImg"); oHeader.onmouseover = flagShow; oHeader.onfocus = flagShow; oHeader.onmouseout = flagHide; oHeader.onblur = flagHide; var oZastavice = document.getElementsByTagName("img"); var sBrowser = navigator.userAgent.toLowerCase(); if ((sBrowser.indexOf('konqueror') != -1) || (sBrowser.indexOf('safari') != -1) || (sBrowser.indexOf('opera') != -1)){ bFlashWorks = false; } // click event za kalendar var oKalendar = document.getElementById("kalendar"); var oDatumi = oKalendar.getElementsByTagName("acronym"); for (x=0; x < oDatumi.length; x++){ oDatumi[x].onclick = reformat; } var oSelect = oKalendar.getElementsByTagName("select")[0]; oSelect.onchange = function(){ var oKalendar = document.getElementById("kalendar"); oKalendar.getElementsByTagName("form")[0].submit(); } // slozi slikice u O nama i Reference var oSlike = document.getElementsByTagName("img"); for (x=0; x < oSlike.length; x++){ if (oSlike[x].height == 30 && oSlike[x].width == 40){ oSlike[x].style.paddingTop = "5px"; } } // nas flash oFlash = document.getElementById("container"); for (var x=0; x < oZastavice.length; x++){ if (oZastavice[x].getAttribute("class") == "zastavice"){ // ovo su moje zastavice oZastavice[x].onmouseover = flagShow; oZastavice[x].onfocus = flagShow; oZastavice[x].onmouseout = flagHide; oZastavice[x].onblur = flagHide; } } } }