// JavaScript Document

function checkPoll (resultscheck){
	//var resultscheck;

	for(var i=0; i<resultscheck.length; i++) {
		if(resultscheck[i].checked == true){
		 	var radioResults = 'yes';
		}
		}
		if(radioResults != 'yes'){
			alert('Please select a MyLibrary button from the list and vote again!');
			return false;
		}

	//resultscheck = document.frmPoll.result.value;
	//if (resultscheck != null){
	//	return true;
	//}else{
	//alert('in false');
	//		alert ('Please select a Mylibrary button from the list and vote again!');

	//	return false;
	//}
}


function clearCheckboxes(chkboxindex){
	//clear other checkboxes in search form
	for (var i=0; i<document.frmUnitSearch.chkUnit.length; i++) {
		if (chkboxindex != i ) {
			document.frmUnitSearch.chkUnit[i].checked = false;
		}
		if(chkboxindex != null){
			document.frmBookSearch.journals.checked = false;	
		}	
	} //end for
}

// function to open new window when a article database is selected from drop down list
function changeArticleDatabase(){
	var URL = document.getElementById('articleDatabases').value;
	if(URL != '') {
		window.open(URL, 'newWindow');
	}
}

// function to ensure a search term is entered before form submitted
function checkSearch(form){
        var text='';
        if(form.name == 'frmBookSearch') {
           text = form.search.value;
        } else {
           text = form.searchunit.value;
        }
       
	if(text == ''){
		alert('Please enter a search term.');
		return false;
	} else {
		return true;
	}
}

//function to clear other search box if a search term is entered in one
function clearSearch(form){
	if(form.name == 'frmBookSearch'){
		document.frmUnitSearch.searchunit.value = '';
		//clear all checkboxes in unit search form only
		clearCheckboxes(null);
	} else {
		document.frmBookSearch.search.value = '';
		document.frmBookSearch.journals.checked = false;
	}
}



function dropdown(mySel)
{
var myWin, myVal;
myVal = mySel.options[mySel.selectedIndex].value;
if(myVal)
   {
   if(mySel.form.target)myWin = parent[mySel.form.target];
   else myWin = window;
   if (! myWin) return true;
   myWin.location = myVal;
   }
return false;
}

function poponload()
{
testwindow= window.open ("http://www.deakin.edu.au/", "mywindow", "location=1,status=0, toolbar=0, menubar=0, directories=0, scrollbars=0,width=400,height=400");
testwindow.moveTo(0,0);
}

function submitSubject() {
window.location= document.subjectSearch.bySubject.options[document .subjectSearch.bySubject.selectedIndex].value;
return true;
}
