currentSelectedDiv = 'keywordsTitle';
onMouseOverBackgroundColor = '#F1EDF9';
onMouseOutBackgroundColor = '#FFFFFF';
onClickBackgroundColor = '#E9EBEC';

function appendChoices(obj,$divName) {
	
	selectedEntities=''; 
		for(i=0; i<obj.length; i++) { 
			if(obj.options[i].selected) 
				selectedEntities+=obj.options[i].text+', '; 
		} 
		document.getElementById($divName).innerHTML = selectedEntities.slice(0,-2);
}
function getArticle(selObj,restore){ //v3.0
	var url = selObj.options[selObj.selectedIndex].value;
	if (url) {
			remote = window.open(url, 'newWindow');
			if (remote != null) {
			if (remote.opener == null)
			remote.opener = self;
		}
	}
	if (restore) selObj.selectedIndex=0;
} 

function changeDiv($divName,$contentName) {
	var obj = document.getElementById($divName);
	
	if($contentName == 'keywords') {
		//change the content of the div
		obj.innerHTML = formsArray[0];
		
		//change the global variable to remind the application which div is selected
		currentSelectedDiv = 'keywordsTitle';
		
		//change the color of the div to the on state
		changeColor('keywordsTitle','on');
		
		//set the other two divs to off state
		changeColor('subjectsTitle','out');
		changeColor('journalsTitle','out');
	}
	if($contentName == 'subjects')  {
		//change the content of the div
		obj.innerHTML = formsArray[1];
		
		//change the global variable to remind the application which div is selected
		currentSelectedDiv = 'subjectsTitle';
		
		//change the color of the div to the on state
		changeColor('subjectsTitle','on');
		
		//set the other two divs to off state
		changeColor('keywordsTitle','out');
		changeColor('journalsTitle','out');
	}
	if($contentName == 'journals')  {
		//change the content of the div
		obj.innerHTML = formsArray[2];
		
		//change the global variable to remind the application which div is selected
		currentSelectedDiv = 'journalsTitle';
		
		//change the color of the div to the on state
		changeColor('journalsTitle','on');
		
		//set the other two divs to off state
		changeColor('keywordsTitle','out');
		changeColor('subjectsTitle','out');
	}
}

function changeColor($divInfo,$state) {
	
	/*alert($divInfo);*/
	
	var obj = document.getElementById($divInfo);
	
	//if this div is not already selected, change it's color
	if(currentSelectedDiv != $divInfo) {
		
		//change the color based on whether the current state is mouse over or mouse out
		if($state == 'over'){
			obj.style.backgroundColor = onMouseOverBackgroundColor;
		} else if($state == 'out'){
			obj.style.backgroundColor = onMouseOutBackgroundColor;
		}
	}
	
	//if you are trying to switch the on color, it doesn't need to not be the currently selected one
	if($state == 'on') {
		obj.style.backgroundColor = onClickBackgroundColor;
	}
}
function showDiv($divName) {
	var obj = document.getElementById($divName);
	obj.style.visibility = "visible";
}
function hideDiv($divName) {
	var obj = document.getElementById($divName);
	obj.style.visibility = "hidden";
}

function changeResults($results,$orderBy,$orderDirection) {
	
	//Change the value of the 3 variables allowed: Number of results, orderby and orderDirection
	document.forms.changeResultsNumber.results.value = $results;
	document.forms.changeResultsNumber.orderBy.value = $orderBy;
	document.forms.changeResultsNumber.orderDirection.value = $orderDirection;
	
	document.forms.changeResultsNumber.submit();
}
//use this function to choose a subject
function chooseSubject($subject) {
	
	//Change the value of the 3 variables allowed: Number of results, orderby and orderDirection
	document.forms.changeResultsNumber.keywords.value = '';
	document.forms.changeResultsNumber.journals.value = '';
	
	document.forms.changeResultsNumber.subjects.value = $subject;
	
	document.forms.changeResultsNumber.submit();
}