function addUrlParam(pUrl, pParamName, pParamValue) {
	pUrl = pUrl.replace(/&amp;/gi, '&');
	pUrl += (pUrl.indexOf('?') == -1 ? '?' : '&');
	pUrl += encodeURIComponent(pParamName) + '=' + encodeURIComponent(pParamValue);
	return pUrl;
}

function getAjaxObject() {
	try {
		var xmlhttp = new XMLHttpRequest();		
	} catch(err1) {
		var ieXmlHttpVersions = new Array();
		ieXmlHttpVersions[ieXmlHttpVersions.length] = 'MSXML2.XMLHttp.7.0';
		ieXmlHttpVersions[ieXmlHttpVersions.length] = 'MSXML2.XMLHttp.6.0';
		ieXmlHttpVersions[ieXmlHttpVersions.length] = 'MSXML2.XMLHttp.5.0';
		ieXmlHttpVersions[ieXmlHttpVersions.length] = 'MSXML2.XMLHttp.4.0';
		ieXmlHttpVersions[ieXmlHttpVersions.length] = 'MSXML2.XMLHttp.3.0';
		ieXmlHttpVersions[ieXmlHttpVersions.length] = 'MSXML2.XMLHttp';
		ieXmlHttpVersions[ieXmlHttpVersions.length] = 'Microsoft.XMLHttp';
		
		var i;
		for (i = 0; i < ieXmlHttpVersions.length; i++) {
			try {
				var xmlhttp = new ActiveXObject(ieXmlHttpVersions[i]);
				break;
			} catch (err2) {
				
			}
		}
	}
	return xmlhttp;
}

function AjaxLoad(link, elementid) {
	var element = document.getElementById(elementid);
	if (!element)
		return;
	var AjaxObject = getAjaxObject();
	if (typeof AjaxObject == 'undefined') {
		alert('In order to view this page your browser has to support AJAX.');
		return;
	}
	link = addUrlParam(link, 'nocache', Math.random());
	AjaxObject.open('GET', link, true);
	
	AjaxObject.send(null);
	AjaxObject.onreadystatechange = function() {
		if (AjaxObject.readyState == 4 && AjaxObject.status == 200) {
			element.innerHTML = AjaxObject.responseText;
		}
	}
	return;
}


function loadAjaxObjs() {
	if (document.getElementById('scrollContent')) { // Content for c-marquee.php
		var lParams = document.getElementById('quotes_params');
		AjaxLoad('/res/c-marquee.php?conly=1', 'scrollContent');
	}
	if (document.getElementById('quotes')) {
		var lParams = document.getElementById('quotes_params');
		AjaxLoad('/res/c-quotes.php?nodiv=1&' + lParams.value, 'quotes');
	}
	if (document.getElementById('indices')) {
		var lParams = document.getElementById('indices_params');
		AjaxLoad('/res/c-indices.php?nodiv=1&' + lParams.value, 'indices');
	}
	if (document.getElementById('bfbquotes')) {
		var lParams = document.getElementById('bfbquotes_params');
		AjaxLoad('/res/c-bfbquotes.php?nodiv=1&' + lParams.value, 'bfbquotes');
	}
	if (document.getElementById('mkquotes')) {
		var lParams = document.getElementById('mkquotes_params');
		AjaxLoad('/res/c-mkquotes.php?nodiv=1&' + lParams.value, 'mkquotes');
	}
}
