// School Javascript

var psFolder = 'school';
var psModule = 'lessons/test';

function markTest() {
  myAction = 'markTest';
  setMessage( myAction, 'Calculating results...' );
  send( myAction );
}

function focusDiv(divId) {
	var div = document.getElementById(divId);
	div.scrollIntoView(true);
}

function resetEditDiv() {
	var editDiv = document.getElementById('editDiv');
	var editDivMsgs = document.getElementById('editDivMessages');
	editDiv.innerHTML = '';
	//editDivMsgs.innerHTML = '';
//	document.getElementById('editDiv').style.display = 'none';
}

function updateEditDiv(destNode, command, id, id2) {
	var editDiv = document.getElementById('editDiv');
	
	if (editDiv == null) {
		editDiv = document.createElement('div');
		editDiv.setAttribute ('id', 'editDiv');
		editDiv.setAttribute ('class', 'editBox');
	}

	destNode.parentNode.appendChild(editDiv);

	var form = document.getElementById('updateEditDivForm');
	
	form.elements[0].value = command;
	form.elements[1].value = id;
	form.elements[2].value = id2;
	send("updateEditDiv");
}


function showStartConfirmationDiv ( title, reqLink, text ) {
  $( 'div#startConfirmation_windowTopContent' ).text( title );
	$( 'div#startConfirmation_windowContent #text' ).text( text );
  $( 'button#startConfirmation_link' ).unbind("click");
	$( 'button#startConfirmation_link' ).bind( "click", function () { window.location = reqLink; } );
	$( 'div#startConfirmation_window' ).fadeIn( 500 );
}

function doTakeIqTest()
{
	if( document.selectBrand.brandId.selectedIndex == 0 )
	{
		alert( "Please select a poker room to get sponsored on!" );
		return;
	}
	
	var baseUrl = '/school/iq-test/?action=iqtest&b=';
	$( 'div#startConfirmation_windowContent div#iqExtra' ).html( $( 'div#terms' + document.selectBrand.brandId.value ).html() );
	$( 'button#startConfirmation_link' ).unbind("click");
	$( 'button#startConfirmation_link' ).bind( "click", function () { window.location = baseUrl + document.selectBrand.brandId.value; } );
	$( 'div#startConfirmation_window' ).fadeIn( 500 );
}

function showIQTestPayout( sel )
{
	if( sel.selectedIndex == 0 )
	{
		$( 'table#iq-test-payout tr:gt(0)' ).hide();
		$( 'table#iq-test-payout tr.payout-default' ).show();
		$( 'table#iq-test-payout tr:last' ).show();
		$( 'table#iq-test-payout tr.payout-default' ).highlightFade();
	}
	else
	{
		var app = sel.options[sel.selectedIndex].value;
		$( 'table#iq-test-payout tr:gt(0)' ).hide();
		$( 'table#iq-test-payout tr.payout' + app ).show();
		$( 'table#iq-test-payout tr:last' ).show();
		$( 'table#iq-test-payout tr.payout' + app ).highlightFade();
	}
}



