// JavaScript Document

///////////////////////////////////////////////////////////////////////////////////
// load menus
// if frameSize not set, set frame size
// load content item
///////////////////////////////////////////////////////////////////////////////////
function initPageTop(doResize) {
	
	load_tech_menu(1);
	load_science_menu(1);
	load_courses_menu(1);
	load_math_menu(1);
	load_citsci_menu(1);
	load_ed_menu(1);

	if (doResize) {
		setSize();
	}
}


///////////////////////////////////////////////////////////////////////////////////
// load menus
// this version is used to drive the menu creation for sub-level pages
// the distinction comes into play for pages that load into the frameset
// load content item
///////////////////////////////////////////////////////////////////////////////////
function initPage(doResize) {
	
	load_tech_menu(0);
	load_science_menu(0);
	load_courses_menu(0);
	load_math_menu(0);
	load_ed_menu(0);
	load_citsci_menu(0);
	
	if (doResize) {
		setSize();
	}

}

///////////////////////////////////////////////////////////////////////////////////
// return the params from the HTML query string
///////////////////////////////////////////////////////////////////////////////////
function getArgs( ) {
	var args = new Object( );
	var query = location.search.substring(1);
	var pairs = query.split("&");
	if (pairs.length == 0 ) {
		return 0;
	}
	for(var i = 0; i < pairs.length; i++) {
		var pos = pairs[i].indexOf('=');
		if (pos == -1) continue;
		var argname = pairs[i].substring(0,pos);
		var value = pairs[i].substring(pos+1);
		value = decodeURIComponent(value);
		args[argname] = value;
		
	}
	return args;
}


//////////////////////////////////////////////////////////
////////////////////////////////////////////////////////// 
function setSize() {

	return;

	var contentMainVar = document.getElementById('content_main')
	var footerVar = document.getElementById('footer')

	if (contentMainVar == null) {
		return;
	};
	
	var header_height = 150;
	var footer_height = 55;

	var height = windowHeight() - (header_height+footer_height);
	var footer_top = header_height + height;

	var ContentSidebarVar = document.getElementById('content_sidebar')
	if (ContentSidebarVar != null) {
		var width = windowWidth() - document.getElementById('content_sidebar').offsetWidth - 22;
	} else {
		var width = windowWidth()  - 22;
	}


	document.getElementById('content_main').style.height = height-20 + 'px';
	document.getElementById('content_main').style.width = width + 'px';

	if (footerVar == null) {
		return;
	};
	document.getElementById('footer').style.top = footer_top + 'px';

	if (ContentSidebarVar != null) {
		document.getElementById('content_sidebar').style.height = height-20 + 'px';
	}
	
	document.getElementById('content_wrapper').style.top = header_height + 10 + 'px';
	//document.getElementById('content_wrapper').style.height = height + 'px';

	var contentFrameVar = document.getElementById('contentFrame')
	if (contentFrameVar != null) {
		contentFrameVar.style.height = height-20 + 'px';
		contentFrameVar.style.width = width + 'px';
	}
	
}

/////////////////////////////////////////////////////////////////////////////////////
// used by the window resizing code
/////////////////////////////////////////////////////////////////////////////////////
function windowWidth() {
	if (self.innerWidth) {
		return self.innerWidth;
	}
		
	if (document.documentElement && document.documentElement.clientWidth) {
		return y = document.documentElement.clientWidth;
	}
	
	if (document.body) {
		return document.body.clientWidth;
	}
	
	// just in case
	return 0;
	
}



/////////////////////////////////////////////////////////////////////////////////////
// used by the window resizing code
/////////////////////////////////////////////////////////////////////////////////////
function windowHeight() {
	if (self.innerHeight) {
		return self.innerHeight;
	}
		
	if (document.documentElement && document.documentElement.clientHeight) {
		return y = document.documentElement.clientHeight;
	}
	
	if (document.body) {
		return document.body.clientHeight;
	}
	
	// just in case
	return 0;
	
}

window.onresize = setSize;