// Teacher Zone - March 2009

function tzSHAdmin(option)	{
	var theOption = option
	
	if (theOption=='open'){
		document.getElementById('adminOpen').style.display = 'block';
		document.getElementById('adminClosed').style.display = 'none';
		document.getElementById('adminTitle').style.display = 'block';
	}else{
		document.getElementById('adminOpen').style.display = 'none';
		document.getElementById('adminClosed').style.display = 'block';
		document.getElementById('adminTitle').style.display = 'none';
	}
}

function tzSHResources(option)	{
	var theOption = option
	
	if (theOption=='open'){
		document.getElementById('resourceOpen').style.display = 'block';
		document.getElementById('resourceClosed').style.display = 'none';
		document.getElementById('resourceTitle').style.display = 'block';
	}else{
		document.getElementById('resourceOpen').style.display = 'none';
		document.getElementById('resourceClosed').style.display = 'block';
		document.getElementById('resourceTitle').style.display = 'none';
	}
}


function tzSHpContact(option)	{
	var theOption = option
	
	if (theOption=='open'){
		document.getElementById('tzContactOpen').style.display = 'block';
		document.getElementById('tzContactClosed').style.display = 'none';
		document.getElementById('tzContactTitle').style.display = 'block';
	}else{
		document.getElementById('tzContactOpen').style.display = 'none';
		document.getElementById('tzContactClosed').style.display = 'block';
		document.getElementById('tzContactTitle').style.display = 'none';
	}
}

function tzSHpLinks(option)	{
	var theOption = option
	
	if (theOption=='open'){
		document.getElementById('pLinksOpen').style.display = 'block';
		document.getElementById('pLinksClosed').style.display = 'none';
		document.getElementById('pLinksTitle').style.display = 'block';
	}else{
		document.getElementById('pLinksOpen').style.display = 'none';
		document.getElementById('pLinksClosed').style.display = 'block';
		document.getElementById('pLinksTitle').style.display = 'none';
	}
}


function tzSHPress(option)	{
	var theOption = option
	
	if (theOption=='open'){
		document.getElementById('pressOpen').style.display = 'block';
		document.getElementById('pressClosed').style.display = 'none';
		document.getElementById('pressTitle').style.display = 'block';
	}else{
		document.getElementById('pressOpen').style.display = 'none';
		document.getElementById('pressClosed').style.display = 'block';
		document.getElementById('pressTitle').style.display = 'none';
	}
}


function clearBoxes(boxToClear){
	var theBox = boxToClear
	alert(theBox)
}

function tzLogin(theType){
	var theAction = theType
	if (theAction=='login'){
		document.frmTZ.action = 'schools_login_process.asp'
		document.frmTZ.submit()
	}else{
		if(document.getElementById('acNo').value.length >0){
			document.frmTZ.action = 'teacher-signup.asp'
			document.frmTZ.submit()
		}else{
			alert('Please enter a valid Account Code')	
		}
		
	}
}

function showCodeSearch(action){
	var theAction = action
	if (theAction=='show'){
		document.getElementById('theSearchResult').style.display = 'block';
	}else{
		document.getElementById('theSearchResult').style.display = 'none';
	}
	
}	

function populateCode(code)	{
	var theCode = code
	document.getElementById('theSearchResult').style.display = 'none';
	document.getElementById('acNo').value= theCode;
	document.getElementById('txtPassword2').value= '';
}


function deleteLink(id){
	var theId = id

		http = createRequestObject();
		http.open('get', 'deleteLink.asp?id=' + theId); 
		http.send(null);
		alert('This product has been deleted from your list!  You must refresh the page to view changes!')

}
function updatePoints(noPoints){
	document.getElemntById('noPoints').value = noPoints	
}




//------------------------Function to send TZ to a friend

	function createRequestObject() {
		var ro;		
		if (window.XMLHttpRequest) { 				// Mozilla, Safari,...
			ro = new XMLHttpRequest();
			//if (ro.overrideMimeType) {
			//	ro.overrideMimeType('text/xml');
			//}
		}else if (window.ActiveXObject) { 			// IE
			try {
				ro = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
				ro = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
	
		return ro;
			
	}
	
function tzSendFriend(){
		
		if(document.sendFriend.yourName.value==''){
			alert('Please enter your name')
		}else if(document.sendFriend.theirName.value==''){
			alert('Please enter your friend\'s name')	
		}else if(document.sendFriend.theirEmail.value==''){
			alert('Please enter your friend\'s email address')
		}else{
			var theName = document.getElementById('yourName').value
			var theirName = document.getElementById('theirName').value
			var theEmail = document.getElementById('theirEmail').value
			
			http = createRequestObject();
			http.open('get', 'tzSendFriend.asp?name=' + theName +'&email='+ theEmail+'&theirName='+ theirName); 
			http.onreadystatechange = handleSendResponse;
			http.send(null);
		}

}

function handleSendResponse() {
	if(http.readyState == 4){
		var response = http.responseText;
		document.getElementById("sendFriendResult").innerHTML = response;
	}
}
//------------------------End of Function to send TZ to a friend

