/*
if (screen.width != 1024 || screen.height != 768) {
	window.alert("Your computers screen resolution is set to " + screen.width + " x " + screen.height + ". It is recommended that a resolution of 1024 x 768 be used to best simulate the testing experience.");
//	window.location = "http://www.beyondgmat.cn/";
}
*/
if (navigator.appName != "Microsoft Internet Explorer") {
	window.alert("Your Explorer is " + navigator.appName + ". It is recommended that Microsoft Internet Explorer 6.0 or later be used to best simulate the testing experience.");
	window.location = "http://www.beyondgmat.cn/";
}
// document.body.onselectstart = new Function("return false;");
// document.body.oncontextmenu = new Function("return false;");


function selectItem(li, count) {
	if (location.href.indexOf("r_") > -1) return;
	var char = String.fromCharCode(li+65);
	if (questionForm.response.value == char) {
		questionForm.response.value = "";
		document.all["opt"+li].src = "images/optionButtonUnSelected.gif";
	}
	else {
	  questionForm.response.value = char;
		for (var i = 0; i < count; i++) {
	    var char = String.fromCharCode(i+65);
			if (i != li) 
          document.all["opt"+i].src = "images/optionButtonUnSelected.gif";
			else 
          document.all["opt"+i].src = "images/optionButtonSelected.gif";
		}
	}
}

function changeTime(obj) {

    questionForm.time_end.value = questionForm.time_end.value - 1 ;

	var time = obj.innerText;
	if (time == "" || time == "00:00") {
		main.style.visible = "hidden";
		ExpiredLayer.style.visibility = "visible";
		return;
	}
	var times = time.split(":");
	var hour = Math.floor(times[0] / 60);
	var minute = times[0] % 60;
	var second = times[1];
	var now = new Date();
	now.setHours(hour);
	now.setMinutes(minute);
	now.setSeconds(second);
	var timestamp = now.getTime();
	timestamp -= interval;
	var moment = new Date(timestamp);
	var hours = moment.getHours();
	var minutes = hours * 60 + moment.getMinutes();
	var seconds = moment.getSeconds();
	var strMinutes = String(minutes);
	var strSeconds = String(seconds);
	if (strMinutes.length == 1) strMinutes = "0" + strMinutes;
	if (strSeconds.length == 1) strSeconds = "0" + strSeconds;
	obj.innerHTML = strMinutes + ":" + strSeconds;
	if (obj.innerText == "04:59") {
		clockSpan.className = "yellow";
		imgClock.src = "images/clockRollOver.gif";
	}
}

function switchTime() {
	if (clock.style.display == "none") {
		clock.style.display = "inline";
		questionForm.timestat.value = 0;
	}
	else {
		clock.style.display = "none";
		questionForm.timestat.value = 1;
	}
}

function switchStep() {
	if (percent.style.display == "none") {
		percent.style.display = "inline";
		questionForm.stepstat.value = 0;
	}
	else {
		percent.style.display = "none";
		questionForm.stepstat.value = 1;
	}
}

function switchFlag() {
	if (questionForm.flag.value == 1) {
		questionForm.flag.value = 0;
		flag.src = "images/flagForReviewUnSelected.gif";
	}
	else {
		questionForm.flag.value = 1;
		flag.src = "images/flagForReviewSelected.gif";
	}
}

function doExplainAnswer(link) {
	if (link == null) return;
	document.all["ExplainFrame"].src = link;
	document.all["ExplainLayer"].style.visibility = "visible";
}
function doHelp(id) {
	if (id == null) return;
	document.all["HelpFrame"].src = "help/index.asp?id=" + id;
//	document.all["HelpFrame"].document.body.onload = new Function("parent.all['HelpLayer'].style.visibility='visible';");
	document.all["HelpLayer"].style.visibility = "visible";
}
function doExit() {
	document.all["ExitLayer"].style.visibility = "visible";
}
function doEnd() {
	document.all["EndLayer"].style.visibility = "visible";
}
function doSubmit(obj) {
	if (obj != null) obj.style.visibility = "hidden";
	questionForm.submit();
}

function doCheckAnswer(correct) {
	if (correct == 1)
		CorrectLayer.style.visibility = "visible";
	else IncorrectLayer.style.visibility = "visible";
}
function doShowAnswer() {
	if (questionForm.correct.value == "") return;
	document.all["opt" + (questionForm.correct.value.charCodeAt(0)-65)].style.backgroundImage = "url(images/optionButtonCorrect.gif)";
}
function doPostQuestion(gmatid, author) {
	document.all["PostFrame"].src = "http://www.passion.org.cn/classroom/PostQuestion.php?gmatid=" + gmatid + "&author=" + author;
	document.all["PostLayer"].style.visibility = "visible";
}

function doExec(action) {
	var obj = questionForm.response;
	obj.focus();
	var range = document.selection.createRange();
	range.execCommand(action);
}

function doUndo() {
	if (imgUndo.src.indexOf("Pressed") > -1) return;
	questionForm.redo.value = questionForm.response.value;
	questionForm.response.value = questionForm.undo.value;
	imgUndo.src = "images/undoPressed.gif";
	imgRedo.src = "images/redo.gif";
}
function doRedo() {
	if (imgRedo.src.indexOf("Pressed") > -1) return;
	questionForm.undo.value = questionForm.response.value;
	questionForm.response.value = questionForm.redo.value;
	imgUndo.src = "images/undo.gif";
	imgRedo.src = "images/redoPressed.gif";
}

