var i1 = 0; var aphorismId = 1; var nextAphorism = 15000; check_brag(); function check_brag() { if($('.brag').length == 4) addHandlersToButtons(); else setTimeout('check_brag()', 500); } function addHandlersToButtons() { $("s").bind("mouseover", function(e) {if(this.className == "m")this.style.backgroundPosition = "0 -34px";else this.style.backgroundPosition = "0 -84px";}); $("s").bind("mouseout", function(e) {if(this.className == "m")this.style.backgroundPosition = "0 0";else this.style.backgroundPosition = "0 -50px";}); $("s").bind("mousedown", function(e) {if(this.className == "m")this.style.backgroundPosition = "0 -16px";else this.style.backgroundPosition = "0 -66px";}); $("s").bind("mouseup", function(e) {if(this.className=="m")this.style.backgroundPosition = "0 -84px";else this.style.backgroundPosition = "0 -34";}); $("s").bind("click", function(e) { var box = this.parentNode.parentNode; var div = box.getElementsByTagName("DIV"); if(div.length == 0) { var iTag = document.createElement('div') iTag.innerHTML = addContentIntoBox(this.parentNode.innerText);; iTag.style.fontStyle = "normal"; iTag.style.display = "none"; iTag.className = "wrapper"; box.appendChild(iTag); } if(this.className == "p") { $(div).css("display", "block"); this.className = "m"; } else { $(div).css("display", "none"); this.className = "p"; } } ); } function addContentIntoBox(boxCaption) { var oXmlHttp = createXMLHttp(); oXmlHttp.open('POST','contentForBoxOnFirstPage.php', false); oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); oXmlHttp.send('caption=' + boxCaption); if(oXmlHttp.status == 200) return oXmlHttp.responseText; } function createXMLHttp() //???????? ??????? XMLHttp { if(typeof XMLHttpRequest != "undefined") // ??? ????????? ??? Mozilla { return new XMLHttpRequest(); } else if(window.ActiveXObject) // ??? Internet Explorer (all versions) { var aVersions = ["MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp", "Microsoft.XMLHttp"]; for (var i = 0; i < aVersions.length; i++) { try { var oXmlHttp = new ActiveXObject(aVersions[i]); return oXmlHttp; } catch (oError) {} } throw new Error("?????????? ??????? ?????? XMLHttp."); } } var aphorisms; var aphorismI = 0; function setAphorism() //????????????? ??????? { var loElement = document.getElementById('Aphorism'); if(!loElement) { setTimeout('setAphorism()',100); return; } if(!aphorisms) { var oXmlHttp = createXMLHttp(); oXmlHttp.open('POST','http://www.cis2000.ru/cis/aphorisms.php', false); oXmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); oXmlHttp.send(); if(oXmlHttp.status == 200) aphorisms = oXmlHttp.responseText.split("\n"); } if(aphorisms) { if(!loElement.firstChild) loElement.appendChild(document.createTextNode(aphorisms[aphorismI])); else loElement.firstChild.data = aphorisms[aphorismI]; setTimeout('setAphorism()',5000); aphorismI = (aphorismI + 1)%aphorisms.length; } }