var _d = document;
var _w = window;
var d = document;
var w = window;
var siteurl = "/";
var disable_animations = false;
var window_loaded = false;
if( d.addEventListener ) {
d.addEventListener("load", window_onload, false);
w.addEventListener("load", window_onload, false);
}
else if( d.attachEvent ) {
d.attachEvent("onload", window_onload);
w.attachEvent("onload", window_onload);
}
function window_onload() {
if( window_loaded ) {
return;
}
window_loaded = true;
setInterval(keep_session, 300000);
if(posts_synchronize) {
setTimeout(posts_synchronize, 3000);
}
if(dbrd_check_tabs) {
if( w.location.pathname && w.location.pathname.match("/dashboard") ) {
setTimeout(dbrd_check_tabs, 10000);
}
}
}
function keep_session()
{
var req = ajax_init();
if( ! req ) { return; }
req.onreadystatechange = function() { };
req.open("POST", "http://skaiss.com/ajax/keepsession/r:"+Math.round(Math.random()*1000), true);
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
req.send(null);
}
function ajax_init(is_xml)
{
var req = false;
if (w.XMLHttpRequest) {
req = new XMLHttpRequest();
if (req.overrideMimeType) {
if( is_xml ) { req.overrideMimeType("application/xml"); }
else { req.overrideMimeType("text/plain"); }
}
} else if (w.ActiveXObject) {
try { req = new w.ActiveXObject("MSXML3.XMLHTTP"); } catch(exptn) {
try { req = new w.ActiveXObject("MSXML2.XMLHTTP.3.0"); } catch(exptn) {
try { req = new w.ActiveXObject("Msxml2.XMLHTTP"); } catch(exptn) {
try { req = new w.ActiveXObject("Microsoft.XMLHTTP"); } catch(exptn) {
}}}}
}
return req;
}
function posts_synchronize()
{
if( postcomments_open_state ) {
for(var i in postcomments_open_state) {
if( postcomments_open_state[i] != 0 ) {
return false;
}
}
}
if( dropcontrols_last_open || postuserbox_last_open ) {
return false;
}
var req = ajax_init(false);
if( ! req ) { return; }
var dv = d.getElementById("posts_html");
if( ! dv ) { return; }
var url = w.location.href.toString();
if( ! url ) { return; }
if( url.substr(0, siteurl.length) == siteurl ) {
url = url.substr(siteurl.length);
url = "http://skaiss.com/from:ajax/r:"+Math.round(Math.random()*1000);
}
else {
url = url.replace(/^http(s)?\:\/\//, "");
url = url.substr(url.indexOf("/"));
url = "http://skaiss.com/from:ajax/r:"+Math.round(Math.random()*1000);
}
var i, ch, lastpostdate = "", lastpostdates = [];
for(i=0; i<dv.childNodes.length; i++) {
ch = dv.childNodes[i];
if( !ch.id || !ch.id.match(/^post_/) || !ch.className.match(/^(m)?post/) || !ch.getAttribute("postdate") ) { continue; }
lastpostdates[lastpostdates.length] = parseInt(ch.getAttribute("postdate"), 10);
}
for(i=0; i<lastpostdates.length; i++) {
lastpostdate = Math.max(lastpostdate, lastpostdates[i]);
}
req.onreadystatechange = function() {
if( req.readyState != 4 ) { return; }
if( ! req.responseText ) { return; }
var txt = ltrim(req.responseText);
if( txt.substr(0,3) != "OK:" ) { return; }
txt = txt.substr(3);
dv.innerHTML = txt;
setTimeout(posts_synchronize_step2, 1);
setTimeout( function() {
var i, all = dv.getElementsByTagName("INPUT");
for(i=0; i<all.length; i++) {
postform_forbid_hotkeys_conflicts(all[i]);
}
all = dv.getElementsByTagName("TEXTAREA");
for(i=0; i<all.length; i++) {
postform_forbid_hotkeys_conflicts(all[i]);
input_set_autocomplete_toarea(all[i]);
}
}, 1 );
}
req.open("POST", url, true);
req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
req.send("lastpostdate="+encodeURIComponent(lastpostdate));
if(sync_tmout) {
clearTimeout(sync_tmout);
sync_tmout = false;
}
$(document).trigger("modifypost");
}