function loadInteracePannels() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	}
	if(myHeight > 400){	
		var contentHeight = myHeight - 125;
		document.getElementById('sidebar').style.height = contentHeight+'px';
		document.getElementById('content').style.height = contentHeight+'px';
		document.getElementById('listholder').style.height = contentHeight+'px';
	}
}


function showHideLoader(showStatus) {
	if(showStatus) {
		document.getElementById('activity').style.display = 'block';
	} else {
		document.getElementById('activity').style.display = 'none';
	}
}

function setListLinkHandler(){
	if(document.getElementsByTagName){
		var obj = document.getElementsByTagName('A');
		var linkcounter = 0;
		for(var i=0; i<obj.length; i++){
			if(obj[i].className =='list'){
				if(linkcounter==0){
					ajaxLoadFile(obj[i].href);
				}
				obj[i].onclick=function(){
					ajaxLoadFile(this.href);
					return false;
				}
				linkcounter++;
			}
		}
	}
}

function setContentLinkHandler(){
	if(document.getElementsByTagName){
		var obj = document.getElementsByTagName('A');
		for(var i=0; i<obj.length; i++){
			if((obj[i].className != 'list') && (obj[i].className != 'internal')){
				obj[i].onclick=function(){
					ajaxLoadFile(this.href);
					return false;
				}
			}
		}
	}
}

function ajaxLoadList(value){
	var sajax = new sack();
	sajax.requestFile = "/list.php";
	sajax.setVar("section", value);
	sajax.onLoading = function(){
		showHideLoader(true);
	};
	sajax.onCompletion = function(){ 
		showHideLoader(false);
		var searchReult = document.getElementById('listholder');
		searchReult.innerHTML = sajax.response;
		setListLinkHandler();
	};
	sajax.runAJAX();
}

function ajaxLoadFile(value){
	var sajax = new sack();
	sajax.requestFile = "/file.php";
	sajax.setVar("filename", value);
	sajax.onLoading = function(){
		showHideLoader(true);
	};
	sajax.onCompletion = function(){ 
		showHideLoader(false);
		var searchReult = document.getElementById('content');
		searchReult.innerHTML = '&nbsp;';
		searchReult.innerHTML = sajax.response;
		setContentLinkHandler();
	};
	sajax.runAJAX();
}


function onWindowLoadEvents(){
	loadInteracePannels();
	ajaxLoadList('General');
}


window.onresize=loadInteracePannels;
window.onload=onWindowLoadEvents;