// USERS ONLINE FUNCTIONS
function loadOnlineUsers(timeOut,requestUri) {
	new Ajax.Updater('online_users', 'jax/online_users.jax.php', {evalScripts:true, method:'post', postBody:'timeout='+timeOut+'&request_uri='+requestUri});
	setTimeout('loadOnlineUsers(\''+timeOut+'\',\''+requestUri+'\')', (timeOut*1000));
}

// GALLERY FUNCTIONS
function centerDiv(divID) {
	var theDiv = document.getElementById(divID);
	//var newTop = (document.body.clientHeight - theDiv.offsetHeight) / 2;
	//var newLeft = (document.body.clientWidth - theDiv.offsetWidth) / 2;
	
	var newTop = (screen.height - theDiv.offsetHeight) / 2;
	var newLeft = (document.body.clientWidth - theDiv.offsetWidth) / 2;
	
	theDiv.style.top = (newTop - 100);
	theDiv.style.left = (newLeft + document.documentElement.scrollLeft);
	var output = '';
		output += 'screen: '+screen.width+'x'+screen.height+'\n';
		output += 'client: '+document.body.clientWidth+'x'+document.body.clientHeight+'\n';
		output += 'scroll: '+document.documentElement.scrollTop+'x'+document.documentElement.scrollLeft+'\n';
		output += 'offset: '+theDiv.offsetWidth+'x'+theDiv.offsetHeight+'\n';
	//alert (output);
}

function imageLoaded(img) {
    if (!img.complete) {
        return false;
    }
	if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
        return false;
    }
	 return true;
}

function clearDiv(divID) {
	document.getElementById(divID).innerHTML = '';
}

function showDiv(divID) {
	document.getElementById(divID).style.display = 'block';
}

function hideDiv(divID) {
	document.getElementById(divID).style.display = 'none';
	clearDiv(divID);
}

function loadGalleryImagePreview(divID,imgID) {
	new Ajax.Updater(divID, 'jax/galleryImagePreview.jax.php', {onComplete:function(t) { centerDiv(divID);},evalScripts:true, method:'post', postBody:'id='+imgID});
	centerDiv(divID);
}
