//core.js
//core functionality

//____popups__________________________________________________________________________________________________________________________________

//usage: <a href="mypage.htm" onClick="popUp('mypage.htm','small'); return false;" target="_blank" title="Popup HyperLink">Link Text</a>
//usage: <a href="mypage.htm" onClick="popUp('mypage.htm','none',400,550); return false;" target="_blank" title="Popup HyperLink">Link Text</a>
//usage: <a href="mypage.htm" onClick="popUp('mypage.htm'); return false;" target="_blank" title="Popup HyperLink">Link Text</a>

function popUp(newPage,popMode,popWidth,popHeight)  {
	if(popWidth && popHeight){
		var popProperties = "width=" + popWidth + ", height=" + popHeight + ", left=0, top=0, scrollbars=1,resizable=yes";
	}
	else if(popMode=="small"){ //if popMode is feedback
		var popProperties = "width=300, height=300, left=0, top=0, scrollbars=1,resizable=yes";
	}else{ //if popMode is large or other
		var popProperties = "width=720, height=520, left=0, top=0, scrollbars=1,resizable=yes";
	}

	activityWindow = window.open(newPage, 'thepopup', popProperties);
	activityWindow.focus();

}

//________handleEnter and print________________________________________________________________________________________________________________
var ACTION_PRINT='print';
var ACTION_CLOSE='close';
var ACTION_MC = 'multiple_choice';
var ACTION_TF = 'true_false';
var ACTION_MW = 'missing_word';
var ACTION_SA = 'short_answer';

function handleEnter(action,ev,file,identifier,truefalse) {
	var ENTER_KEY=13;
	var keyCode = ev.keyCode ? ev.keyCode : ev.which ? ev.which : ev.charCode;
	if (keyCode == ENTER_KEY) {
		switch(action){
			case ACTION_PRINT:
				printPage();
				return false;
			case ACTION_CLOSE:
				window.close();
				return false;
			case ACTION_MC:
				return checkMCAnswer(file, identifier);
				return false;
			case ACTION_TF:
				return checkTFAnswer(file, identifier, truefalse);
				return false;
			case ACTION_MW:
				return checkMWAnswer(file, identifier);
				return false;
			case ACTION_SA:
				return openFeedbackWindow(file, identifier);
				return false;
			default:
				return false;			
		}
	}
}

function printPage(){
	window.print?
		window.print()
		: alert('Sorry, your browser does not support this feature. Please choose print from the file menu.');
}


//_________showTranscript for audio options____________________________________________________________________________________________________


function showTranscript(){
	document.getElementById('transcript').style.visibility = 'visible';
	document.getElementById('audioShow').style.display = 'none';
	return false;
 }


//_________setting value for scroll attribute of body tag______________________________________________________________________________________

//sets scroll to no for IE/Windows and yes for everything else. This avoids double scroll bars (the style3000 CSS uses divs which have scrolling)

function setScrollValue(){
	if(navigator.userAgent.indexOf("MSIE") != -1 && navigator.platform.indexOf("Mac") == -1){
		document.getElementsByTagName("body")[0].setAttribute("scroll","no");
	}else{
		document.getElementsByTagName("body")[0].setAttribute("scroll","yes");
	}
}
//_________end setting value for scroll attribute of body tag__________________________________________________________________________________
