var currentHash = '';
var firstContent = '';
function contentLoad(uri) {
    if (! uri) {
        return true;
    }
  
    var coords = getCoords(document.getElementById('content'));
    var progressbar = document.getElementById('progressbar');
    progressbar.style.left = coords['left'] + 'px';
    progressbar.style.top = coords['top'] + 'px';
    progressbar.style.display = '';
    var flag=false;
	flag=Prototype.Browser.IE;
	//alert(flagB);
	JsHttpRequest.query(
        '/' + uri,
        { },
        function(result, errors) {
			//alert(errors);
            if (result) {
				$('content').innerHTML = result['str'];
            }
            progressbar.style.display = 'none';
            return false;
        },
        flag
    );
    window.location.hash = '#ajax/' + uri;
    currentHash = window.location.hash;
    return false;
}
function bookmarkLoad() {
    if ('#ajax/' == window.location.hash.substring(0, 6)) {
        contentLoad(window.location.hash.substring(5));
    }
}
function historyLoad() {
    var hash = window.location.hash;
    if ('#ajax/' == hash.substring(0, 6) && currentHash != hash) {
        contentLoad(hash.substring(5));
    } else if ('#ajax/' != hash.substring(0, 6) && currentHash) {
        currentHash = '';
        document.getElementById('content').innerHTML = firstContent;
    }
    setTimeout('historyLoad()', 100);
}
function getCoords(element) {
    var left = element.offsetLeft;
    var top = element.offsetTop;
    for (var parent = element.offsetParent; parent; parent = parent.offsetParent) { 
        left += parent.offsetLeft - parent.scrollLeft;
        top += parent.offsetTop - parent.scrollTop
    }
    return {
    	left: left,
    	top: top,
    	width: element.offsetWidth,
    	height: element.offsetHeight
    };
}