var childWindow = false;
var player;

function displayAlert()
	{			
		var x1= document.getElementById("cId");
		
		if(x1==null){
		
		alert('Please, Select a Course');
		}else{

         var valueURL='loadResourceTOC.action?courseId=0&from=teacherHome';
		 document.location.href= valueURL;
	  }
	}

function displayAlert(value)
{
	if(value=='0'){		
		alert('First, Select a Class');

	}else if(value=='resTree'){		 
		  document.location.href='loadResourceTOC.action?courseId=0&from=teacherHome';
    }else if(value=='assmtTree'){		
		 document.location.href='loadTeacherTOC.action';
	  }

}
function closeChildWindow()
{
	if(childWindow)
	player.close();
}
function displayAsmtTree(classId,courseId,className,courseName)
{	
	
	if(!childWindow){
		document.location.href='loadTeacherTOC.action?classId='+classId+'&courseId='+courseId+'&className='+className+'&courseName='+courseName;
	}else{
		//player.focus();
	}
	

}

function getNodeData (nodeId,childrenCount,name) {
			//form = document.forms['tocForm'];
			//form.id.value = nodeId;  			
			
			var x='http:';
			
			if(childrenCount=='0')
			{
				if(name.indexOf(x)!=-1){					
					window.open(name);
				}
				else  {
					
					document.location.href='retrieveLinkedAssets.action?nodeId='+nodeId;
				}
					
			}
		}

function displayResTree(classId,courseId,className,courseName)
{
	if(!childWindow){
			document.location.href='loadResourceTOC.action?classId='+classId+'&courseId='+courseId+'&className='+className+'&courseName='+courseName;
		}else{
			if(null!=player)
			player.focus();
		}
	
}


 var winConfirm = null; 
 var buttonNum = 0; 
 var doDelete = "No"; 
 var actionValue=null;
 function confirm() 
 { 
		 var windowWidth = 500; 
		 var windowHeight = 200; 
		 var locX = ( screen.width - windowWidth ) / 2; 
		 var locY = ( screen.height - windowHeight ) / 2; 
		 var windowFeatures = "width=" + windowWidth 
		 + ",height=" + windowHeight 
		 + ",screenX=" + locX 
		 + ",screenY=" + locY 
		 + ",titlebar=no" 
		 + ",left=" + locX 
		 + ",top=" + locY; 
 
		if ( ( winConfirm != null ) && !winConfirm.closed ) { 
			 winConfirm.close(); 
 } 
 
 winConfirm = window.open( "", "winConfirm", windowFeatures ); 
 
 var theHTML = '<head><title>Confirm Deletion</title>' 
 + '<body bgcolor="#cccccc">' 
 + '<center><font="Verdana, Arial" font-size="12px"><b>' 
 + 'You have requested to delete this class, which will unassign currently assigned students and remove this class from your class list. All student data, including personal information and assessment scores, will be preserved and saved with the students record, even after the class is deleted. Please confirm that you would like to delete this class.' 
 + '</b><form name="buttonForm">' 
 + '<input type="button" value=" Yes "' 
 + ' onclick="opener.buttonClicked(0);self.close();">' 
 + '&nbsp;' 
 + '<input type="button" value=" No "' 
 + ' onclick="opener.buttonClicked(1);self.close();">' 
 + '</form></center></font></body>'; 
 
 winConfirm.document.writeln( theHTML ); 
 //alert("Flow shouldn't get here until after the user has selected Yes   or No. How to make it wait for Yes/No ?"); 
 } 
 
 function buttonClicked( buttonChoice ) 
 { 
 switch( buttonChoice ) 
 { 
 case 0: 
	 {	
		document.location.href= actionValue;
	 }
	break; 
	default: 
		doDelete = "No"; 
	 } 
 } 

	function deleteClass(action)
	{	

		if(!childWindow)
		{
			buttonNum=2;
			actionValue=action;
			doDelete=confirm('You have requested to delete this class, which will unassign currently assigned students and remove this class from your class list. All student data, including personal information and assessment scores, will be preserved and saved with the students record, even after the class is deleted. Please confirm that you would like to delete this class.');
		}else{
			if(null!=player)
			player.focus();
		}
		

	}

	function resetStudentPwd(action)
	{	
		if(!childWindow){
			document.location.href= action;
		}else{
			if(null!=player)
			player.focus();
		}
		
		
	}

	function loadTeacherTOC(action)
	{	
		if(!childWindow){
			document.location.href= action;
		}else{
			if(null!=player)
			player.focus();
		}
	}

	function openEBookWindow(url) 
	{
		
		if(!childWindow)
		{				
			var scrx = 0;//(screen.availWidth - pwidth) * .5;
			var scry = 0;//(screen.availHeight - pheight) * .5;
			var pwidth=1000;	
			var pheight=700;
			var features = "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=" + pwidth + ",height=" + pheight + ",left =" + scrx + ",top =" + scry;
			player=window.open(url,'AdvanceLP',features);

		}else{
			if(null!=player)
			player.focus();
		}
       
	}

	function openAsmtWindowPlayer (url)
		{	
				
				var scrx = 0;//(screen.availWidth - pwidth) * .5;
				var scry = 0;//(screen.availHeight - pheight) * .5;
				var pwidth=1000;	
				var pheight=700;
				var features = "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=" + pwidth + ",height=" + pheight + ",left =" + scrx + ",top =" + scry;
				player=window.open(url,'AdvanceLP',features);

			
		}
		
	function openResource(url)
		{	
				
				var scrx = 0;//(screen.availWidth - pwidth) * .5;
				var scry = 0;//(screen.availHeight - pheight) * .5;
				var pwidth=1000;	
				var pheight=700;
				var features = "toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=" + pwidth + ",height=" + pheight + ",left =" + scrx + ",top =" + scry;
				player=window.open(url,'AdvanceLP',features);

			
		}	

	function loadURL(value)
	{
		if(!childWindow){
			document.location.href=value;
		}else{
			if(null!=player)
			player.focus();
		}
		
		
	}
	
	function teacherHome(action,selCourseId,selClassId,selClassName)
	{
		if(!childWindow){
			
		
			if(selClassId == 'null' || selCourseId == 'null' || selClassName == 'null')
			{	
				document.location.href='TeacherHome.action';
			}
			else
			{				
				document.location.href= 'TeacherHome.action?courseId='+selCourseId+'&classId='+selClassId+'&className='+selClassName;	
			}
	}else{
			if(null!=player)
			player.focus();
		}
				
	}
	
	function loadAction(value1,value2)
	{

		if(!childWindow){
			document.location.href=value2;
			document.location.href=value1;
		}else{
			if(null!=player)
			player.focus();
		}
		
		//document.loadTeacherHome.classId.value=value2;
		//document.loadTeacherHome.submit();
	}
	
	