var lsajaxpageloadcontent_a_id = "sectionaoutput";
var lsajaxpageloadcontent_b_id = "sectionboutput";
var lsajaxpageloadcontent_menu_id = "sectionmenu_output";
var lastpagehistory = "";

function GetRequeryVal()
{
var d = new Date();
return d.getTime();
}

function lsAjaxPageLoadAjaxProccesReturn(requestname, http_request, waitingtext) {
var elementid = '';

windivid = requestname;
if (http_request.readyState == 4) {
    irequest = GetRunningRequest(requestname);
    RemoveRunningRequest(irequest);
    if (http_request.status == 200) {
        xmlresponse = http_request.responseXML.documentElement;
        if (xmlresponse.getElementsByTagName('htmlcode_a').length > 0) {
        htmlcode_a = xmlresponse.getElementsByTagName('htmlcode_a')[0].firstChild.nodeValue;
        jscode_a = xmlresponse.getElementsByTagName('jscode_a')[0].firstChild.data;
		document.getElementById(lsajaxpageloadcontent_a_id).innerHTML = htmlcode_a;
        if (jscode_a != '') {
		if (window.execScript) {
		window.execScript(jscode_a);
		} else {
		var script = document.createElement('script');
        script.type = 'text/javascript';
        script.innerHTML = jscode_a;
        document.getElementById(lsajaxpageloadcontent_a_id).appendChild(script);
		window.eval(jscode_a);
        }
		}
		}
		if (lsajaxpageloadcontent_b_id != '') {
		if (xmlresponse.getElementsByTagName('htmlcode_b').length > 0) {
        htmlcode_b = xmlresponse.getElementsByTagName('htmlcode_b')[0].firstChild.nodeValue;
        jscode_b = xmlresponse.getElementsByTagName('jscode_b')[0].firstChild.data;
		document.getElementById(lsajaxpageloadcontent_b_id).innerHTML = htmlcode_b;
        if (jscode_b != '') {
        if (window.execScript) {
		window.execScript(jscode_b);
		} else {
		var script = document.createElement('script');
        script.type = 'text/javascript';
        script.innerHTML = jscode_b;
        document.getElementById(lsajaxpageloadcontent_b_id).appendChild(script);
		window.eval(jscode_b);
		}
        }
		}
		}
		if (xmlresponse.getElementsByTagName('htmlcode_menu').length > 0) {
        htmlcode_menu = xmlresponse.getElementsByTagName('htmlcode_menu')[0].firstChild.nodeValue;
        document.getElementById(lsajaxpageloadcontent_menu_id).innerHTML = htmlcode_menu;
        }
		if (xmlresponse.getElementsByTagName('title').length > 0) {
        title = xmlresponse.getElementsByTagName('title')[0].firstChild.nodeValue;
        document.title = title;
        }
		if (xmlresponse.getElementsByTagName('keywords').length > 0) {
        keywords = xmlresponse.getElementsByTagName('keywords')[0].firstChild.nodeValue;
		setkeywords(keywords);
        }
		if (document.getElementById('subpageditpagesettingslink') != null) {
		if (xmlresponse.getElementsByTagName('titleid').length > 0) {
        titleid = xmlresponse.getElementsByTagName('titleid')[0].firstChild.nodeValue;
		document.getElementById('subpageditpagesettingslink').setAttribute('titleid',titleid);
        } else {
		titleid = 0;
		document.getElementById('subpageditpagesettingslink').setAttribute('titleid',titleid);
		}
		}
		if (document.getElementById('thumbsdisplay') != null) {InitGallery();}
    } else {
        document.getElementById(windivid).innerHTML = alert('Napaka...' + http_request.statusText);        
    }
    if (document.getElementById('loadingdiv') != null) {
       document.getElementById('loadingdiv').parentNode.removeChild(document.getElementById('loadingdiv'));
    }
} else {
   /*if (document.getElementById('loadingdiv') == null) {
      var loadingdiv = document.createElement('div');
      loadingdiv.setAttribute('id', 'loadingdiv');
      loadingdiv.innerHTML = '<img src="design/indicator_waitanim.gif" />';
	  document.body.appendChild(loadingdiv);
   } */
}
}

function parseURLQueryString(url) {
var urlstr = String(url);
var paramvalue = '';
querystring = '';
indexofquery = urlstr.indexOf('?',0);
if (indexofquery >= 0) {
   indexofquery = indexofquery + 1;
   querystring = urlstr.slice(indexofquery);
   indexofendquery = querystring.indexOf('#');
   if (indexofendquery > 0) {
   querystring = querystring.slice(0, indexofendquery);
   }
}
return querystring;
}

function lsAjaxPageLoad(urlhref, dontclosesearchresult) {
if ((navigator.userAgent.indexOf("MSIE") > 1) && (parseFloat(navigator.appVersion.split("MSIE")[1]) < 7)) {
window.location = urlhref;
} else {
if (dontclosesearchresult != true) {
if (window.closesearchresult) {
closesearchresult();
}
}
if (document.getElementById(lsajaxpageloadcontent_b_id) != null) {
document.getElementById(lsajaxpageloadcontent_b_id).innerHTML = '&#160;';
}
document.getElementById(lsajaxpageloadcontent_a_id).innerHTML = '<div style="text-align: center; padding: 20px;"><img border="0" src="design/ajax-loader.gif" /></div>';
makeRequest('ajaxload', 'subpages/csvsubpagesajaxload.php', '?action=getpages&' + parseURLQueryString(urlhref) + '&requeryval=' + GetRequeryVal(), lsAjaxPageLoadAjaxProccesReturn, '', -1);
}
}