
//Ajax functions
function requestCurriculum(formsel,sid,default_id,default_photo_width){
	var params = "";
	
	params += formsel	? 'ac_select='+formsel.value : '';
	params += sid 	? '&sid=' + sid : '';
	params += default_id ? '&defaultid=' + default_id : '';
	
	var selectID = formsel.id;
	
	if(selectID == "ac-ddlb-dept"){
		otherSelObj = $("ac-ddlb-grade");
	}else if(selectID == "ac-ddlb-grade"){
		otherSelObj = $("ac-ddlb-dept");
	}
	if(otherSelObj != undefined) otherSelObj.selectedIndex = 0;
	
	if(onCourse){
		closeCourse(onCourse);
		onCourse = NaN;
	}
	
	if(onCourse){
		closeCourse(onCourse);
		onCourse = NaN;
	}
	//target container, parameters to the page
	ajax_req_course_box_list('curriculum_content',params);
	
	//target container, parameters to the page
	ajax_req_fac_staff_sidebar('curriculum_facstaff',params);
	
	//target container, gallery id, photo width, parameters to the page
	ajax_req_department_photos('curriculum_dphotos', 0, default_photo_width, params);

}
function ajax_req_department_photos(target, galid, width, params){
	images = $('galimages' + galid);
	
	for(i = images.childNodes.length; i > 0; i--){
		images.removeChild(images.childNodes[0]);
	}
	
	var ajaxDPhotos = new Ajax.Updater(
		{
			success: 'galimages' + galid
		},
		"/academics/inc/request_dphotos.asp",
		{
			method: 'get',
			parameters: params,
			asynchronous: true,
			onFailure: function() {
				$(target).innerHTML = "There was an error processing your request."
			},
			onComplete: function(){
				//debug("photo success");

				eval("myGallery"+galid+".resetGallery("+galid+")");
				eval("myGallery"+galid+".setWidth("+width+")");
					
				ReSizeIFRAME();
			}
		}
	);
}
function ajax_req_course_box_list(target, params){
	$(target).innerHTML = "<div style='text-align: center;'><img src='/academics/inc/spinner.gif' /></div>";

	var ajaxCurriculum = new Ajax.Updater(
		{
			success: target
		},
		"/academics/inc/request_courses.asp",
		{	
			method: 'get', 
			parameters:	params,
			asynchronous: true,
			onFailure:	function() {
				$(target).innerHTML = "There was an error processing your request."
			},
			onComplete: function(){
				//debug("courses success");	
				ReSizeIFRAME();
			
			//	greetingHeight = Element.getHeight('curriculum_dept_greeting');
			//	if(greetingHeight > 285){
			//		Element.setHeight('curriculum_dept_greeting',285);
			//		$('curriculum_dept_greeting').style.overflow = "auto";
			//	}
				
			}
		}
	);
}
function ajax_req_fac_staff_sidebar(target, params){
	$(target).innerHTML = "<div style='text-align: center;'><img src='/academics/inc/spinner.gif' /></div>";

	var ajaxCurriculum = new Ajax.Updater(
		{
			success: target
		},
		"/academics/inc/request_fac_staff.asp",
		{	
			method: 'get', 
			parameters:	params,
			asynchronous: true,
			onFailure:	function() {
				$(target).innerHTML = "There was an error processing your request."
			},
			onComplete: function(){
				//debug("courses success");	
				ReSizeIFRAME();
			}
		}
	);
}
//End Ajax functions

var onCourse = NaN;
function rollONcourse(cNum){
	if(onCourse != cNum){
		fe_css('swap','titleBack_'+cNum,'titleBack_on','titleBack_off'); 
		fe_css('swap','titleText_'+cNum,'titleText_on','titleText_off'); 
		fe_css('swap','arrow_'+cNum,'courseArrow_on','courseArrow_off'); 
	}
}
function rollOFFcourse(cNum){
	if(fe_css('check','titleBack_'+cNum,'titleBack_on') && onCourse != cNum){
		fe_css('swap','titleBack_'+cNum,'titleBack_off','titleBack_on'); 
		fe_css('swap','titleText_'+cNum,'titleText_off','titleText_on'); 
		fe_css('swap','arrow_'+cNum,'courseArrow_off','courseArrow_on');
		
	}
}
function openCourse(cNum){
	if(onCourse == cNum){
		closeCourse(cNum); 
	}else{    
		if(onCourse){
			closeCourse(onCourse);
		}
		if(!fe_css('check','titleBack_'+cNum,'titleBack_on')){
			fe_css('swap','titleBack_'+cNum,'titleBack_on','titleBack_off');
			fe_css('swap','titleText_'+cNum,'titleText_on','titleText_off');
			fe_css('swap','arrow_'+cNum,'courseArrow_on','courseArrow_off'); 
		}
		fe_css('remove','course_'+cNum,'hide');
		onCourse = cNum; 
	}
}
function closeCourse(cNum){
	fe_css('swap','titleBack_'+cNum,'titleBack_off','titleBack_on');
	fe_css('swap','titleText_'+cNum,'titleText_off','titleText_on'); 
	fe_css('swap','arrow_'+cNum,'courseArrow_off','courseArrow_on');
	fe_css('add','course_'+cNum,'hide');
	onCourse = NaN;
}
var btnopenid = NaN;
function btnover(btnid)	{//MouseOver here
	}
function btnout(btnid)	{
	if (btnopenid != btnid)
		{//Mouseout here
		}
	}
function btnopen(btnid) {
	if (btnopenid) btnclose(btnopenid);
	if(btnopenid == btnid) {
		 //Close if one is open
		 btnclose(btnid);
		 btnopenid = NaN;
	}
	else{
		$("bio_off_" + btnid).style.display = "none";
		$("bio_" + btnid).style.display = "";

		btnopenid = btnid;

		ReSizeIFRAME();
	}
}

function btnclose(btnid) {
	$("bio_off_" + btnid).style.display = "";
	$("bio_" + btnid).style.display = "none";
	ReSizeIFRAME();
}
