﻿ function windowFrame(windowName,frameWidth,frameHeight,url) {
  fw=window.open(url,windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=0,top=0,width=" + frameWidth + ",height=" + frameHeight);     
  fw.focus();
}

function windowReferenceCAWorksheets(windowName,frameWidth,frameHeight,url){
 var b_name="";
 
  b_name=browser_name();

  if(b_name=="msie" )
  {
   fw=window.open(url,windowName,"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,left=0,top=0,width=" + frameWidth + ",height=" + frameHeight);     
 
   fw.moveTo((screen.Width-780)/2,(screen.Height-500)/2 );
   }
   else
   {
    fw=window.open(url,windowName,"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,left=200,top=200,width=" + frameWidth + ",height=" + frameHeight); 
   }
   
   fw.focus();
}

function windowReferenceQW(windowName,frameWidth,frameHeight,url){
 var b_name="";
 
  b_name=browser_name();

  if(b_name=="msie" )
  {
   fw=window.open(url,windowName,"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,left=0,top=0,width=" + frameWidth + ",height=" + frameHeight);     
 
   fw.moveTo((screen.Width-780)/2,(screen.Height-500)/2 );
   }
   else
   {
    fw=window.open(url,windowName,"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,left=200,top=200,width=" + frameWidth + ",height=" + frameHeight); 
   }
   
   fw.focus();
}

function windowFrameWithBrowserControls(windowName,frameWidth,frameHeight,url) {
  fw=window.open(url,windowName,"status=0,toolbar=0,menubar=1,scrollbars=1,resizable=1,location=0,directories=0,left=0,top=0,width=" + frameWidth + ",height=" + frameHeight);     
  fw.focus();
}

function windowReference(windowName,url) {
 var b_name="";
 
  b_name=browser_name();

  if(b_name=="msie" )
  {
   fw=window.open(url,windowName,"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,left=0,top=0,width=780,height=500");     
 
   fw.moveTo((screen.Width-780)/2,(screen.Height-500)/2 );
   }
   else
   {
    fw=window.open(url,windowName,"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,left=200,top=200,width=780,height=500"); 
   }
   
   fw.focus();
}

function windowReferenceWithSize(windowName,w,h,url) {
 var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
   fw=window.open(url,windowName,"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,left=0,top=0,width=" + w + ",height=" + h);
 
   fw.moveTo((screen.Width-w)/2,(screen.Height-h)/2 );
   }
   else
   {
    fw=window.open(url,windowName,"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,left=200,top=200,width=" + w + ",height=" + h); 
   }
   
   fw.focus();
}

function windowNonResizable(windowName,frameWidth,frameHeight,url, centered){
var b_name="";
  b_name=browser_name();
   if(b_name=="msie" )
  {
  fw=window.open(url,windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,left=0,top=0,width=" + frameWidth + ",height=" + frameHeight);     
  if(centered==true){
    fw.moveTo((screen.Width-frameWidth)/2,(screen.Height-frameHeight)/2 );
  }
  }
   else
   {
  fw=window.open(url,windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,left=200,top=200,width=" + frameWidth + ",height=" + frameHeight); 
   }
  fw.focus();
}

function windowReferenceEdGuide(windowName,frameWidth,frameHeight,url, centered){
var b_name="";
  b_name=browser_name();
   if(b_name=="msie" )
  {
  fw=window.open(url,windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=yes,left=0,top=0,width=" + frameWidth + ",height=" + frameHeight);     
  if(centered==true){
    fw.moveTo((screen.Width-frameWidth)/2,(screen.Height-frameHeight)/2 );
  }
  }
   else
   {
  fw=window.open(url,windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=no,left=200,top=200,width=" + frameWidth + ",height=" + frameHeight); 
   }
  fw.focus();
}

function setcookie(args)
{
	var aryArgs = args.split("|");
	var Audio = aryArgs[0];
	var Volume = aryArgs[1];
	document.cookie='audio=' + Audio;
	document.cookie='volume=' + Volume;
}

function getCookie(name) {
  var result = null;
  var myCookie = " " + document.cookie + ";";
  var searchName = "courseStatus=";
  var startOfCookie = myCookie.indexOf(searchName);
  var endOfCookie;
  if (startOfCookie != -1) {
    startOfCookie += searchName.length;
    endOfCookie = myCookie.indexOf(";",startOfCookie);
    result = unescape(myCookie.substring(startOfCookie,endOfCookie));
  }
  return result;
}

function browser_name() { 
    var browserName = ""; 

    var ua = navigator.userAgent.toLowerCase(); 
    if ( ua.indexOf( "safari" ) != -1 ) { 
        browserName = "safari"; 
    } 
    if ( ua.indexOf( "msie" ) != -1 ) { 
        browserName = "msie"; 
    }
    return browserName; 
};

function toggleBlock(blockID) {
	if (document.getElementById) {
		var subNodes = document.getElementById(blockID);
		subNodes.style.display = (subNodes.style.display == 'block') ? 'none' : 'block';
	}
}

function toggleResourceTocBlock(parentNode, blockID) {
	if (document.getElementById) {
		var subNodes = document.getElementById(blockID);
		if (subNodes.style.display == 'block') { //it is by default none but set in css class
		    subNodes.style.display = "none";
		  
		    parentNode.style.color = "#003399";
		} else {
		    subNodes.style.display = "block";
		    parentNode.style.color = "#003399";
		}
	}
}

function toggleTableContentBlock(aID) {
	if (document.getElementById) {
		var tableNode = document.getElementById('tableContentBlock' + aID);
		if (tableNode.style.display=="none") {
		    tableNode.style.display = "block";
		    document.getElementById('showTableContentBlock' + aID).style.display = "none";
		    document.getElementById('hideTableContentBlock' + aID).style.display = "block";
		 } else {
		    tableNode.style.display = "none";
		    document.getElementById('showTableContentBlock' + aID).style.display = "block";
		    document.getElementById('hideTableContentBlock' + aID).style.display = "none";
		 }
	}
}

function toggleTopic(blockID) {
	if (document.getElementById) {
		var plusminus = document.getElementById("plusminus" + blockID);
		var topic = document.getElementById("topic" + blockID);
		if (topic.style.display == 'block') {
		    plusminus.src = '/images/b_plus.gif';
		    topic.style.display = "none";
		} else {
		    plusminus.src = '/images/b_minus.gif';
		    topic.style.display = "block";
		}
	}
}

function PopupGlossaryTerm(glossaryID) {
var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
  fw=window.open("../glossaryPopup/" + glossaryID, 'Glossary',"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=0,top=0,width=550,height=485");     
  fw.moveTo((screen.Width-550)/2,(screen.Height-485)/2 );
  }
  else
  {
  fw=window.open("../glossaryPopup/" + glossaryID, 'Glossary',"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=200,top=200,width=550,height=485");
  }
  fw.focus();
}

function PopupGlossarySource() {
var b_name="";
  b_name=browser_name();

  if(b_name=="msie" )
  {
  fw=window.open("../glossarySourcePopup", 'Glossary',"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=0,top=0,width=650,height=550");     
  fw.moveTo((screen.Width-650)/2,(screen.Height-550)/2 );
   }
  else
  { fw=window.open("../glossarySourcePopup", 'Glossary',"toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,left=200,top=200,width=650,height=550"); 
  }    
  fw.focus();
  
}

function showBoxes(divName){
   var i=1;
   var nodeId, tocNode;
   
   if (divName=='tocnodesime')
   {
    for (i=2;i<=99;i++)
     {
        tocNode  = document.getElementById('tocnodesime_c0' + i);
        if (tocNode!=null) tocNode.style.display='block';
     }
   } else if (divName=='partBlock100'){
    for (i=0;i<9;i++)
     {
      document.getElementById(divName+i).style.display='block';
     }
   }  else if (divName=='partBlock200'){
    for (i=0;i<9;i++)
     {
      document.getElementById(divName+i).style.display='block';
     }
   } 
document.getElementById('expandall').style.color='gray';
document.getElementById('hideall').style.color='#003399';
}
function hideBoxes(divName){
   var i=1;
   var nodeId, tocNode;
   
   if (divName=='tocnodesime')
   {
    for (i=2;i<=99;i++)
     {
        tocNode  = document.getElementById('tocnodesime_c0' + i);
        if (tocNode!=null) tocNode.style.display='none';
     }
   } else if (divName=='partBlock100'){
   for (i=0;i<9;i++)
{
document.getElementById(divName+i).style.display='none';
}
   }else if (divName=='partBlock200'){
   for (i=0;i<9;i++)
{
document.getElementById(divName+i).style.display='none';
}
   }
document.getElementById('hideall').style.color='gray';
document.getElementById('expandall').style.color='#003399';
}

function preloadImage(){
    var myimages = new Array();
    for (var x=0; x<preloadImage.arguments.length; x++){
    myimages[x] = new Image();
    myimages[x].src = preloadImage.arguments[x];
    }
}

function reloadParentWindow() {
 var parentURL = top.opener.location.href;
 if (parentURL.indexOf("&refresh=1") > 0) {
    parentURL = parentURL.replace("&refresh=1", "&refresh=2");
 }else if (parentURL.indexOf("&refresh=2") > 0) {
   parentURL = parentURL.replace("&refresh=2", "&refresh=2");
 }else if (parentURL.indexOf("?") > 0) {
    parentURL = parentURL + "&refresh=1"; 
 }else {
    parentURL = parentURL + "?&refresh=1"; 
 }
 top.opener.location.href = parentURL;
}

function selectMyJamaItems(idPrefix, check) {
     var items = document.getElementsByTagName("input");
     for (var i=0; i<items.length; i++) {
         if (items[i].type == "checkbox" && items[i].id.indexOf(idPrefix)==0) {
             items[i].checked = check;
         }
     }
}

function EnterKeyPressed(e) {
        var keycode;
        if (window.event) keycode = window.event.keyCode;
        else if (e) keycode = e.which;
        
        return (keycode==13)?true:false;
}



/********  CUSTOM SYLLABUS JAVASCRIPT *********/
function reloadParent()
{
    window.top.location = window.top.location;
}

function launchClipContent(windowName,url, centered){
    var frameWidth = 500;
    var frameHeight = 300;
   
    var b_name="";
  b_name=browser_name();
   if(b_name=="msie" )
  {
    fw=window.open(url,windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,left=0,top=0,width=" + frameWidth + ",height=" + frameHeight);     
        if(centered==true)
        {
            fw.moveTo((screen.Width-frameWidth)/2,(screen.Height-frameHeight)/2 );
        }
   }
   else
    {
        fw=window.open(url,windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,left=200,top=200,width=" + frameWidth + ",height=" + frameHeight);     
    }
    fw.focus();
}

function GetRadWindow()
{
	var oWindow = null;
	if (window.radWindow) { oWindow = window.radWindow;}
	else if (window.frameElement.radWindow) { oWindow = window.frameElement.radWindow;}
	return oWindow;
}   

function CloseWindow()
{
 	var oWindow = GetRadWindow();
	oWindow.Close();
}

function CloseWindowNoReload()
{
 	var oWindow = GetRadWindow();
 	//oWindow.remove_close(reloadParent);
	oWindow.Close();
}

function popupDrillDownView(userID)
{
    // var oWnd = window.radopen("/customSyllabus/csAdminStudentView.aspx?studentID=" + userID ,"ReportDrillDown");
    var oWnd = window.radopen(" /customsyllabus/instructor/reportView/" + userID ,"ReportDrillDown");
    oWnd.SetSize (875,550); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
}

function popupSubmitActivity(ID,typeID)
{
    var oWnd = window.radopen("/customSyllabus/popupSubmitActivity.aspx?id=" + ID + "&typeID=" + typeID,"SubmitActivity");
    oWnd.SetSize (600,500); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
    oWnd.add_close(reloadParent);
}


function popupCustomWorksheet(ID,typeID)
{
    if (typeID==1){
        // Pass the specific userworksheetID
        var oWnd = window.radopen("/customSyllabus/csCustomWorksheet.aspx?uwkID=" + ID,"CustomWorksheet");
    } else {
        // Default to pass the activityID
        var oWnd = window.radopen("/customSyllabus/csCustomWorksheet.aspx?activityID=" + ID,"CustomWorksheet");
    }    
       
    oWnd.SetSize (685,600); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
    oWnd.add_close(reloadParent);
}

function popupCustomWorksheetCreation(typeID, ID)
{   
    
    // -1 is not a valid ID, therefor we go get the ID from dropdown box
    if (ID == -1){
        ID = document.getElementById('ctl00_mainContent_DropDownFilteredOptions').value;
    }
    
    if (typeID==1){
        // Pass the specific worksheetAID
        var oWnd = window.radopen("/customSyllabus/popupCustomWorksheetCreation.aspx?wkAID=" + ID,"CustomWorksheet");
            oWnd.SetSize (685,600); // Width, Height
            oWnd.set_modal(true);
            oWnd.set_visibleStatusbar(false);
            oWnd.set_visibleTitlebar(false);
            oWnd.center();
            oWnd.add_close(reloadParent);
    } else if (typeID == 0) {
        // Pass the specific worksheetID
        if(document.getElementById('ctl00_mainContent_DropDownCustomTypes').value == 3){
            popupCustomQuestionWizardCreation(1,ID);
        }
        else{
            var oWnd = window.radopen("/customSyllabus/popupCustomWorksheetCreation.aspx?wkID=" + ID,"CustomWorksheet");
                oWnd.SetSize (685,600); // Width, Height
                oWnd.set_modal(true);
                oWnd.set_visibleStatusbar(false);
                oWnd.set_visibleTitlebar(false);
                oWnd.center();
                oWnd.add_close(reloadParent);
        }
    } else if(typeID=-3){
        popupCustomQuestionWizardCreation(2,ID);
    }
    else{//Error, Error
    }    
       

}
function popupCustomQuestionWizardCreation(typeID, ID)
{
    if(typeID==1){
    //Opens a new Question Wizard Form
    var oWnd = window.radopen("/customSyllabus/popupCustomQuestionWizardCreation.aspx?qId=" + ID,"CustomQuestionWizard");
    oWnd.SetSize (685,600); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
    oWnd.add_close(reloadParent);
   }
   else if (typeID==2){
   //Opens a Existing Question Wizard Form
   var oWnd = window.radopen("/customSyllabus/popupCustomQuestionWizardCreation.aspx?qwAID=" + ID,"CustomQuestionWizard");
    oWnd.SetSize (685,600); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
    oWnd.add_close(reloadParent);
   }
   else
   {
     //Error, Error
   }
}

function popupCustomWorksheetClip(aID, typeID)
{   
    if(typeID==1){
        var oWnd = window.radopen("/customSyllabus/popupClipCustomContent.aspx?aID=" + aID,"CustomWorksheet");
    }
        else {
        var oWnd = window.radopen("/customSyllabus/popupClipCustomContent.aspx?qwAID=" + aID,"CustomWorksheet");
    }
    
    oWnd.SetSize (500,300); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
}

function popupCustomQuestionWizard(ID,typeID)
{
    if (typeID==1){
        // Pass the specific userworksheetID
        var oWnd = window.radopen("/customSyllabus/csCustomQuestionWizard.aspx?userQWID=" + ID,"CustomWizard");
    } else {
        // Default to pass the activityID
        var oWnd = window.radopen("/customSyllabus/csCustomQuestionWizard.aspx?activityID=" + ID,"CustomWizard");
    }    
    //var oWnd = window.radopen("/customSyllabus/csCustomQuestionWizard.aspx?activityID=" + activityID,"QuestionWizard");
    oWnd.SetSize (685,600); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
    oWnd.add_close(reloadParent);
}

function popupUplodAFile(activityID,topicID)
{
    var oWnd = window.radopen("/customSyllabus/popupUploadFile.aspx?topicID=" + topicID + "&activityID=" + activityID,"UploadFile");
    oWnd.SetSize (500,400); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
    oWnd.add_close(reloadParent);
}


function popupPublishTopic(topicID,isPublic,isEmpty)
{
    var oWnd = window.radopen("/customSyllabus/popupPublishTopic.aspx?topicID=" + topicID + "&ispublic=" + isPublic + "&isEmpty=" + isEmpty,"PublishTopic");
    oWnd.SetSize (500,400); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
}

function popupSaveTopicAs(topicID)
{
    var oWnd = window.radopen("/customSyllabus/popupSaveTopicAs.aspx?topicID=" + topicID,"SaveAsTopic");
    oWnd.SetSize (500,400); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
}

function popupDeleteTopic(topicID)
{
    var oWnd = window.radopen("/customSyllabus/popupDeleteTopic.aspx?topicID=" + topicID,"DeleteTopic");
    oWnd.SetSize (500,400); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
}

function popupDeleteCourse(courseID)
{
    var oWnd = window.radopen("/customSyllabus/popupDeleteCourse.aspx?courseID=" + courseID,"DeleteCourse");
    oWnd.SetSize (500,400); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
}

function popupTeamStart(topicID)
{
    var oWnd = window.radopen("/customSyllabus/popupStartTeam.aspx?topicID=" + topicID,"StartTeam");
    oWnd.SetSize (550,600); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
    //oWnd.add_close(reloadParent);
}

function popupTeamJoin(topicID)
{
    var oWnd = window.radopen("/customSyllabus/popupJoinTeam.aspx?topicID=" + topicID,"JoinTeam");
    oWnd.SetSize (550,600); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
    oWnd.add_close(reloadParent);
}

function popupTeamAssign(teamID)
{
    var oWnd = window.radopen("/customSyllabus/popupAssignTeam.aspx?teamID=" + teamID,"EditTeam");
    oWnd.SetSize (550,600); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
    //oWnd.add_close(reloadParent);
}


function popupTeamInvite(topicID,teamID)
{
    var oWnd = window.radopen("/customSyllabus/popupStartTeam.aspx?topicID=" + topicID + "&teamID=" + teamID,"TeamInvite");
    oWnd.SetSize (550,600); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
}

function popupLeaveTeam(teamID)
{
    var oWnd = window.radopen("/customSyllabus/popupLeaveTeam.aspx?teamID=" + teamID,"LeaveTeam");
    oWnd.SetSize (550,600); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
    oWnd.add_close(reloadParent);
}

function popupDeleteTeam(teamID)
{
    var oWnd = window.radopen("/customSyllabus/popupDeleteTeam.aspx?teamID=" + teamID,"DeleteTeam");
    oWnd.SetSize (550,600); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
    oWnd.add_close(reloadParent);
}

function popupTeamLocked(topicID,teamID)
{
    var oWnd = window.radopen("/customSyllabus/popupWhatsThis.aspx?mode=locked","TeamLocked");
    oWnd.SetSize (500,300); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
}

function popupCourseDescr(courseID)
{
    var oWnd = window.radopen("/customSyllabus/popupDescription.aspx?courseID=" + courseID,"CourseDescription");
    oWnd.SetSize (500,600); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
}

function popupInstructorComments(commentID, typeID)
{
    var oWnd = window.radopen("/customSyllabus/popupComments.aspx?comID=" + commentID + "&typeID=" + typeID,"Comments");
    oWnd.SetSize (500,600); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
}

function popupEditTopic(topicID)
{
    var oWnd = window.radopen("/customSyllabus/popupEditTopicInfo.aspx?topicID=" + topicID,"EditTopic");
    oWnd.SetSize (760,700); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
}


function LaunchAssignmentPopup(topicID)
{
    var sel = document.getElementById("selAssignmentTypes");
    var i = sel.selectedIndex;
    var strType;
    if (i==0){
        alert("You must choose an assignment type.");
        return;
    }
    strType = sel.options[i].value;
    var oWnd = window.radopen("/customSyllabus/popupAddAssignment.aspx?topicID=" + topicID + "&typeName=" + strType,"AssignmentPopup");
    oWnd.SetSize (760,720); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
}

function popupHelpSharedTopic()
{
    var oWnd = window.radopen("/customSyllabus/popupWhatsThis.aspx?mode=shared","HelpSharedTopic");
    oWnd.SetSize (500,400); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
}

function popupRemoveTeam(teamID)
{
    var oWnd = window.radopen("/customSyllabus/popupRemoveTeam.aspx?teamID=" + teamID,"RemoveTeam");
    oWnd.SetSize (550,600); // Width, Height
    oWnd.set_modal(true);
    oWnd.set_visibleStatusbar(false);
    oWnd.set_visibleTitlebar(false);
    oWnd.center();
    oWnd.add_close(reloadParent);
 
}

/********  CUSTOM SYLLABUS JAVASCRIPT - James' oldskool animations (no JQuery - for popup windows)*********/
function animate(elementID, newLeft, newTop, newWidth, newHeight, time, callback)
{
  var el = document.getElementById(elementID);
  if(el == null)
    return;
 
  var cLeft = parseInt(el.style.left);
  var cTop = parseInt(el.style.top);
  var cWidth = parseInt(el.style.width);
  var cHeight = parseInt(el.style.height);
 
  var totalFrames = 1;
  if(time > 0)
    totalFrames = time/40;

  var fLeft = newLeft - cLeft;
  if(fLeft != 0)
    fLeft /= totalFrames;
 
  var fTop = newTop - cTop;
  if(fTop != 0)
    fTop /= totalFrames;
 
  var fWidth = newWidth - cWidth;
  if(fWidth != 0)
    fWidth /= totalFrames;
 
  var fHeight = newHeight - cHeight;
  if(fHeight != 0)
    fHeight /= totalFrames;
   
  doFrame(elementID, cLeft, newLeft, fLeft, cTop, newTop, fTop,
      cWidth, newWidth, fWidth, cHeight, newHeight, fHeight, callback);
}

function doFrame(eID, cLeft, nLeft, fLeft, cTop, nTop, fTop,
    cWidth, nWidth, fWidth, cHeight, nHeight, fHeight, callback)
{
  var el = document.getElementById(eID);
  if(el == null)
    return;

  cLeft = moveSingleVal(cLeft, nLeft, fLeft);
  cTop = moveSingleVal(cTop, nTop, fTop);
  cWidth = moveSingleVal(cWidth, nWidth, fWidth);
  cHeight = moveSingleVal(cHeight, nHeight, fHeight);

  el.style.left = Math.round(cLeft) + 'px';
  el.style.top = Math.round(cTop) + 'px';
  el.style.width = Math.round(cWidth) + 'px';
  el.style.height = Math.round(cHeight) + 'px';
 
  if(cLeft == nLeft && cTop == nTop && cHeight == nHeight
    && cWidth == nWidth)
  {
    if(callback != null)
      callback();
    return;
  }
   
  setTimeout( 'doFrame("'+eID+'",'+cLeft+','+nLeft+','+fLeft+','+cTop+','
      +nTop+','+fTop+','+cWidth+','+nWidth+','+fWidth+','+cHeight+','
      +nHeight+','+fHeight+','+callback+')', 40);
}

function moveSingleVal(currentVal, finalVal, frameAmt)
{
  if(frameAmt == 0 || currentVal == finalVal)
    return finalVal;
 
  currentVal += frameAmt;
  if((frameAmt > 0 && currentVal >= finalVal)
      || (frameAmt < 0 && currentVal <= finalVal))
  {
    return finalVal;
  }
  return currentVal;
}

//The following animations based on function Animate
//signature: animate(elementID, newLeft, newTop, newWidth, newHeight, time, callback)

function slideExample1(elementId, headerElement)
{
   var element = document.getElementById(elementId);
   var elementparent = document.getElementById('panCustomQuestions');
   //Animate to display all 12 Questions - Popup window does not like to be resized.. hold for now
    //animate(elementId, parseInt(element.style.left), parseInt(element.style.top), parseInt(element.style.width), newHeight, 250, null);
   element.style.height = parseInt(element.style.height) + 168 + 'px';
   elementparent.style.height = parseInt(elementparent.style.height) + 168 + 'px';
   if(parseInt(element.style.height) > 700){
        //hide "add more Questions link"
        document.getElementById('add3button').style.visibility = "hidden";
   }
}
