function showEditPortal(portalID)
{
      setSpanValue('editPortalID',portalID);
      engPortal.populatePortalObject(portalID,callback_PopulatePortal);
}

 

callback_PopulatePortal = function(res)
{
      if (res.error!=null){alert(res.error)};      

      checkResponse(res.value);
      var portal = res.value;
      setControlValue('txteditCommunityPortalTitle', portal.Title);
      setDropDownSelected('ddeditCategory', portal.Category);
	  geteditSubCategorylist();
      setDropDownSelected('ddeditSubCategory', portal.SubCategory)
      setControlValue('txteditTags', portal.Tags)
      setSelectedRadioValue('shareOptionsEdit', portal.SecurityID);
      setSelectedRadioValue('radeditinvitation', portal.Invitation);
      $('cbEditPortalShowSource').checked = portal.ViewSource;

      if (portal.FullViewMode == true) {
          setSelectedRadioValue('radFullScreenEdit', 1);
      }
      else {
          setSelectedRadioValue('radFullScreenEdit', 0);
      }
      
      if (portal.SecurityID == 2)
		document.getElementById('inviteOnlyDesc').style.display = 'block';
	  else 
		document.getElementById('inviteOnlyDesc').style.display = 'none';
	  openPortalModalWindow('editCommunityPortal');
}

function ChangeFullScreenModeOff() {
 if ($('radYesFullScreen') != null) { $('radYesFullScreen').checked = false;}
 if ($('radNoFullScreen') != null) { $('radNoFullScreen').checked = true;}    
}

function ChangeFullScreenModeOn() {

 if ($('radYesFullScreen') != null) { $('radYesFullScreen').checked = true;}
 if ($('radNoFullScreen') != null) { $('radNoFullScreen').checked = false;}
}

editPortal = function()
{
    showFeedback('EditPortalActionContainer');
    updateFeedbackMessage('Uploading_Image');
    saveimgFile('Edit');
    
//    var iframedocHeader = document.getElementById('uploadimgIFRAMEHeader').contentDocument;
//    if (iframedocHeader == null)
//    {
//        iframedocHeader = document.getElementById('uploadimgIFRAMEHeader').contentWindow.document;
//    }
//    
//    var imgNameHeader = iframedocHeader.getElementById('file').value;
//    var imgUploadGuidHeader = '';
//    
//    if (imgNameHeader != '')
//    {
//    	imgUploadGuidHeader = iframedocHeader.getElementById('guid').value;
//    	iframedocHeader.getElementById("fileErr").innerHTML = "";
//    	document.getElementById('uploadimgIFRAMEHeader').contentWindow.submitform();
//    }
}

function SetEditUploadImageToDone(filenames) {
   updateFeedbackMessage('Image_Uploaded');
   var fdata = filenames.split(":");
   var files = new Array();
      
     if (fdata.length == 1) {
         tmp = fdata[0].split("|");
         if (tmp[0] == 'badge') {
            files[0] = tmp[1]; 
            files[1] = '';        
         }
         else if (tmp[0] == 'header') {
            files[0]='';
            files[1] = tmp[1];
         }
         else if (tmp[0] == '') {
            files[0]='';
            files[1] = '';
         }         
     }
     else if (fdata.length == 2) {
         tmp1 = fdata[0].split("|");
         tmp2 = fdata[1].split("|");
            files[0] = tmp1[1]; 
            files[1] = tmp2[1];   
     }
     else {
        files[0] = '';
        files[1] = '';     
     } 

   
    var PortalID = getSpanValue('editPortalID');
    var Title = getControlValue('txteditCommunityPortalTitle');
    var Category = getDropDownSelected('ddeditCategory');
    var SubCategory = getDropDownSelected('ddeditSubCategory');
    var Tags = getControlValue('txteditTags');
    var Security = getSelectedRadioValue('shareOptionsEdit');
    var ViewSource = $('cbEditPortalShowSource').checked;

    var removePortalBadge = getSpanValue('removePortalBadge');
    var removePortalHeader = getSpanValue('removePortalHeader');

    var invitation = 0;
    var friendsIDs = new Array();

    if(friendsIDs[0] == void 0)
    {
        friendsIDs[0] = 0;
    }

    var groupsIDs = new Array();
    if(groupsIDs[0] == void 0)
    {
        groupsIDs[0] = 0;
    }
    
   
    
    debugstr = "PortalID:\t" + PortalID +
        "\nTitle\t:" + Title + 
        "\nCategory\t:" + Category + 
        "\nSubcategory\t:" + SubCategory + 
        "\nTags\t:" + Tags + 
        "\nSecurity\t:" + Security + 
        "\ngroupsIDs\t:" + groupsIDs + 
        "\nfriendsIDs\t:" + friendsIDs + 
        "\ninvitation\t:" + invitation + 
        "\nimgfname\t:" + imgfname + 
        "\nimguploadguid\t:" + imguploadguid + 
        "\nimgNameHeader\t:" + imgNameHeader;
        
    var fullViewMode = 1;
    if ($('radYesFullScreen') != null) {
     if ($('radYesFullScreen').checked) {
        fullViewMode = 1;
     }
     else {
        fullViewMode = 0;
     }
    }
    else if ($('radNoFullScreen') != null) {
     if ($('radNoFullScreen').checked) {
        fullViewMode = 0;
     }
     else {
        fullViewMode = 1;
     }    
    }
    else {
        fullViewMode = 1;
    }
        
    //alert(debugstr);

    engPortal.editPortal(PortalID, 'txteditCommunityPortalTitle', Title, Category, SubCategory, Tags, Security, groupsIDs, friendsIDs, invitation, files[0], imguploadguid, files[1], ViewSource, fullViewMode, removePortalHeader, removePortalBadge, callback_editPortal);
}


function ChangeFullScreenMode() {

    if ($('radYesFullScreen') != null) {
     if ($('radYesFullScreen').checked) {
        $('radYesFullScreen').checked = false;
     }
     else {
        $('radYesFullScreen').checked = true;
     }
    }
    
   if ($('radNoFullScreen') != null) {
     if ($('radNoFullScreen').checked) {
        $('radNoFullScreen').checked = false;
     }
     else {
        $('radNoFullScreen').checked = true;
     }    
    }
    
}
 

callback_editPortal = function(res)
{
    checkResponse(res.value);

    var results = res.value.Tables[0];

     if (results.Rows.length > 0)
         {
    
            if (results.Rows[0].result == "True")
            {
                var controls = res.value.Tables[1];
                for (var i=0; i<controls.Rows.length; i++)
                {
                    clearInputField('txteditCommunityPortalTitle');
                    setControlErrorMessage(controls.Rows[i].controlID,'');
                }
                switch (results.Rows[0].errMessage)
                {
                      case "valid":
                            var security = getSelectedRadioValue('shareOptionsEdit');
                            if (security == 5)
		                    {
			                    saveFile();
			                    feedbackValid('Saving','Saved');
			                    window.setTimeout('hideEditPortal();', 14000);	
		                    }
		                    else
		                    {
		                        feedbackValid('Saving','Saved');
		                        window.setTimeout('hideEditPortal();', 7000);
		                    }
                            break;
                }
            }
    }
    else
    {
        var controls = res.value.Tables[1];
        switch (controls.Rows[0].errMessage)
        {
              case "invalid":
                    feedbackInvalid('EditPortalActionContainer');
                    window.setTimeout(function(){processValidationResponse(controls)}, 2001);
              break;
				case "Please seperate your tags keywords with commas.":
				    feedbackInvalid('EditPortalActionContainer');
				    window.setTimeout(function(){processValidationResponse(controls)}, 2001);
				    break;	              
        }
    }
}

 

hideEditPortal = function()
{
    cleanupFeedback('EditPortalActionContainer');
    closePortalModalWindow('editCommunityPortal');
    window.location = "/myCommunityPortals/index.aspx?ddlMemberOption=ManagePortalSharing";
}

 

 

 

function showEditPrivateOptions(){

 

      setControlDisplay('editPortalGroups', 'none');

      setControlDisplay('editportalFriends', 'none');

      setControlDisplay('editportalCsv', 'none');

      //setControlDisplay('pubAddEmail', 'none');

}

 

function showEditPublicOptions(){

 

      setControlDisplay('editPortalGroups', 'none');

      setControlDisplay('editportalFriends', 'none');

      setControlDisplay('editportalCsv', 'none');

      //setControlDisplay('pubAddEmail', 'block');

}

 

function showEditGroupsOptions()
{
      Effect.SlideDown('editPortalGroups');

      setControlDisplay('editportalFriends', 'none');
      
      setControlDisplay('editportalCsv', 'none');
}

function showEditCsvOptions(){

 

      Effect.SlideDown('editportalCsv');

      setControlDisplay('editportalFriends', 'none');

      setControlDisplay('editPortalGroups', 'none');

      

}

function showEditFriendsOptions(){

                        

            //if (document.getElementById('uleditGroups').style.display != "none")

            //{

                  //setControlDisplay('editPortalGroups', 'none');

            //    Effect.SlideUp('addPortalGroups');

            //}

            //setControlDisplay('editportalCsv', 'none');

            //var ul = document.getElementById("uleditFriends"); 

            //Effect.toggle('editportalFriends','blind');

            

}

 

function callback_AutoCompleteeditFriends(res){

 

checkResponse(res.value);

 

      if (res.value != null)

            {

            var ds = res.value;

            var listControlID = "autoCompleteListtxtEditFriends";

            var listControlWrapper = "txtEditFriendsListWrapper";

            document.getElementById(listControlID).innerHTML = "";

            

            var ul = document.createElement("ul");

            ul.id = "autoList";

            

            if (ds != null && typeof(ds) == "object" && ds.Rows.length != 0)

                  {

                  

                  for (var i=0; i<ds.Rows.length; i++)

                        {

                        var li = document.createElement("li");

                        var a = document.createElement("a");



                        a.href = "javascript:completeEditUsername('" + ds.Rows[i].UserID + "','" + ds.Rows[i].Username + " (" + ds.Rows[i].firstname + " " + ds.Rows[i].lastname.replace("'", "") + ")" + "');void(0);";

                        a.innerHTML = ds.Rows[i].Username+ " ("+ds.Rows[i].firstname + " " + ds.Rows[i].lastname+")";

                        

                        li.appendChild(a);

                        ul.appendChild(li)

                        }

            

                        

                  document.getElementById(listControlID).appendChild(ul);

                  document.getElementById(listControlWrapper).style.display = "block";

                  document.getElementById(listControlID).style.display = "block";

            

                  }

            else

                  {

                  document.getElementById(listControlWrapper).style.display = "none";

                  document.getElementById(listControlID).style.display = "none";

                  }

            

            }

}

function completeEditUsername(accID, username)

{

      Effect.Fade('txtEditFriendsListWrapper');

      var ul = document.getElementById("ulEditFriendsList");      

      var chks = document.getElementById("ulEditFriendsList").getElementsByTagName("input");

      var counter = 0;

      if(chks.length != 0)

      {

            for(var i=0;i<chks.length;i++)

            {

                        if(accID == chks[i].value)

                        {

                              counter = 1;

                        }

            }                 

                  

            if(counter == 0)

            {

                  var chk = document.createElement("input");

                  chk.type = "checkbox";

                  chk.value = accID;

                  chk.id = "c_"+accID;

                  chk.style.display = "none"; 

                  var lbl = document.createElement("label");

                  lbl.innerHTML = username;

                  lbl.id = "l_"+accID;

                  var img = document.createElement("img");

                  img.id = "i_"+accID;

                  img.alt ="Remove";

                  img.src="/images/icons/delete.gif";

                  var aImg = document.createElement("a");

                  aImg.href ="javascript:deleteEditFriend(" + accID + ");";

                  aImg.id = "a_"+accID;

                  aImg.appendChild(img);

                  var li = document.createElement("li");

                  li.id="l_"+accID;

                  li.appendChild(chk);

                  li.appendChild(lbl);

                  li.appendChild(aImg);               

                  ul.appendChild(li);

            }

            else

            {

                  alert('You have already selected to share the event with this person.');

            }

            

      }

      else

      {

            var chk = document.createElement("input");

            chk.type = "checkbox";

            chk.value = accID;

            chk.id = "c_"+accID;

            chk.style.display = "none"; 

            var spn = document.createElement("span")

            spn.innerHTML = accID;

            

            var lbl = document.createElement("label");

            lbl.innerHTML = username;

            lbl.id = "l_"+accID;

            var img = document.createElement("img");

            img.id = "i_"+accID;

            img.alt ="Remove";

            img.src="/images/icons/delete.gif";

            var aImg = document.createElement("a");

            aImg.href ="javascript:deleteEditFriend(" + accID + ");";

            aImg.id = "a_"+ accID;

            aImg.appendChild(img);

            var li = document.createElement("li");

            li.id="l_"+accID;

            li.appendChild(chk);

            //li.appendChild(spn);

            li.appendChild(lbl);

            li.appendChild(aImg);               

            ul.appendChild(li);

      }

      document.getElementById("txtEditFriends").value = "";

}

 

 

function deleteEditFriend(accID)

{

      var ul = document.getElementById("ulEditFriendsList");

      var chks = document.getElementById("ulEditFriendsList").getElementsByTagName("input");

      var lis = document.getElementById("ulEditFriendsList").getElementsByTagName("li");

      for(var i=0;i<chks.length;i++)

            {

                        if(accID == chks[i].value)

                        {

                              var li = document.getElementById(lis[i].id);

                              ul.removeChild(li);

                        }

            }     

      

      

}

function geteditSubCategorylist(){
	
var Category = getDropDownSelected('ddeditCategory');

switch(Category)
{
	case "Schools":
			var subCategory = document.getElementById('ddeditSubCategory');
			subCategory.length = 0;
			var optn0 = document.createElement("OPTION");
			optn0.text = "";
			optn0.value = "";
			subCategory.options.add(optn0);
			var optn1 = document.createElement("OPTION");
			optn1.text = "Internal";
			optn1.value = "Internal";
			subCategory.options.add(optn1);
			var optn2 = document.createElement("OPTION");
			optn2.text = "External";
			optn2.value = "External";
			subCategory.options.add(optn2);
			var optn3 = document.createElement("OPTION");
			optn3.text = "Other";
			optn3.value = "Other";
			subCategory.options.add(optn3);
			break;
	case "Academics":
			var subCategory = document.getElementById('ddeditSubCategory');
			subCategory.length = 0;
			var optn0 = document.createElement("OPTION");
			optn0.text = "";
			optn0.value = "";
			subCategory.options.add(optn0);
			var optn1 = document.createElement("OPTION");
			optn1.text = "Accounting";
			optn1.value = "Accounting";
			subCategory.options.add(optn1);
			var optn2 = document.createElement("OPTION");
			optn2.text = "Additional Mathematics";
			optn2.value = "Additional Mathematics";
			subCategory.options.add(optn2);
			var optn3 = document.createElement("OPTION");
			optn3.text = "Afrikaans Eerste Taal";
			optn3.value = "Afrikaans Eerste Taal";
			subCategory.options.add(optn3);
			var optn4 = document.createElement("OPTION");
			optn4.text = "Afrikaans Tweede Taal";
			optn4.value = "Afrikaans Tweede Taal";
			subCategory.options.add(optn4);
			var optn5 = document.createElement("OPTION");
			optn5.text = "Art";
			optn5.value = "Art";
			subCategory.options.add(optn5);
			var optn60 = document.createElement("OPTION");
			optn60.text = "Arts and Culture";
			optn60.value = "Arts and Culture";
			subCategory.options.add(optn60);
			var optn61 = document.createElement("OPTION");
			optn61.text = "Advanced Mathematics";
			optn61.value = "Advanced Mathematics";						
			subCategory.options.add(optn61);
			var optn6 = document.createElement("OPTION");
			optn6.text = "Biblical Studies";
			optn6.value = "Biblical Studies";
			subCategory.options.add(optn6);
			var optn7 = document.createElement("OPTION");
			optn7.text = "Biology";
			optn7.value = "Biology";
			subCategory.options.add(optn7);
			var optn8 = document.createElement("OPTION");
			optn8.text = "Business Economics";
			optn8.value = "Business Economics";
			subCategory.options.add(optn8);
			var optn62 = document.createElement("OPTION");
			optn62.text = "Business Studies";
			optn62.value = "Business Studies";
			subCategory.options.add(optn62);
			var optn54 = document.createElement("OPTION");
			optn54.text = "Chapel";
			optn54.value = "Chapel";
			subCategory.options.add(optn54);				
			var optn86 = document.createElement("OPTION");
			optn86.text = "Cognitive Education";
			optn86.value = "Cognitive Education";
			subCategory.options.add(optn86);            						
			var optn63 = document.createElement("OPTION");
			optn63.text = "Computer Applications Technology";
			optn63.value = "Computer Applications Technology";
			subCategory.options.add(optn63);								
			var optn9 = document.createElement("OPTION");
			optn9.text = "Computer Studies";
			optn9.value = "Computer Studies";
			subCategory.options.add(optn9);
			var optn64 = document.createElement("OPTION");
			optn64.text = "Computers";
			optn64.value = "Computers";
			subCategory.options.add(optn64);			
			var optn10 = document.createElement("OPTION");
			optn10.text = "Computyping";
			optn10.value = "Computyping";
			subCategory.options.add(optn10);
			var optn87 = document.createElement("OPTION");
			optn87.text = "Consumer Studies";
			optn87.value = "Consumer Studies";
			subCategory.options.add(optn87);
			var optn85 = document.createElement("OPTION");
			optn85.text = "Creativity";
			optn85.value = "Creativity";
			subCategory.options.add(optn85);			
			var optn55 = document.createElement("OPTION");
			optn55.text = "Dance";
			optn55.value = "Dance";
			subCategory.options.add(optn55);
			var optn11 = document.createElement("OPTION");
			optn11.text = "Design";
			optn11.value = "Design";
			subCategory.options.add(optn11);
			var optn64 = document.createElement("OPTION");
			optn64.text = "Design and Technology";
			optn64.value = "Design and Technology";
			subCategory.options.add(optn64);				
			var optn66 = document.createElement("OPTION");
			optn66.text = "Economic Management Sciences";
			optn66.value = "Economic Management Sciences";
			subCategory.options.add(optn66);				
			var optn12 = document.createElement("OPTION");
			optn12.text = "Economics";
			optn12.value = "Economics";
			subCategory.options.add(optn12);
			var optn83 = document.createElement("OPTION");
			optn83.text = "Engineering, Graphics and Design";
			optn83.value = "Engineering, Graphics and Design";
			subCategory.options.add(optn83);			
			var optn13 = document.createElement("OPTION");
			optn13.text = "English First Language";
			optn13.value = "English First Language";
			subCategory.options.add(optn13);
			var optn14 = document.createElement("OPTION");
			optn14.text = "English Second Language";
			optn14.value = "English Second Language";
			subCategory.options.add(optn14);
			var optn15 = document.createElement("OPTION");
			optn15.text = "French";
			optn15.value = "French";
			subCategory.options.add(optn15);
			var optn16 = document.createElement("OPTION");
			optn16.text = "Geography";
			optn16.value = "Geography";
			subCategory.options.add(optn16);
			var optn17 = document.createElement("OPTION");
			optn17.text = "German First Language";
			optn17.value = "German First Language";
			subCategory.options.add(optn17);
			var optn18 = document.createElement("OPTION");
			optn18.text = "German Third Language";
			optn18.value = "German Third Language";
			subCategory.options.add(optn18);
			var optn19 = document.createElement("OPTION");
			optn19.text = "Graphic Art";
			optn19.value = "Graphic Art";
			subCategory.options.add(optn19);
			var optn20 = document.createElement("OPTION");
			optn20.text = "Hebrew";
			optn20.value = "Hebrew";
			subCategory.options.add(optn20);
			var optn21 = document.createElement("OPTION");
			optn21.text = "History";
			optn21.value = "History";
			subCategory.options.add(optn21);
			var optn22 = document.createElement("OPTION");
			optn22.text = "Home Economics";
			optn22.value = "Home Economics";
			subCategory.options.add(optn22);
			var optn23 = document.createElement("OPTION");
			optn23.text = "HotelKeeping & Catering";
			optn23.value = "HotelKeeping & Catering";
			subCategory.options.add(optn23);
			var optn67 = document.createElement("OPTION");
			optn67.text = "Human & Social Sciences";
			optn67.value = "Human & Social Sciences";
			subCategory.options.add(optn67);
			var optn68 = document.createElement("OPTION");
			optn68.text = "Information Technology";
			optn68.value = "Information Technology";
			subCategory.options.add(optn68);
			var optn69 = document.createElement("OPTION");
			optn69.text = "Information Skills";
			optn69.value = "Information Skills";
			subCategory.options.add(optn69);										
			var optn24 = document.createElement("OPTION");
			optn24.text = "IsiXhosa First Language";
			optn24.value = "IsiXhosa First Language";
			subCategory.options.add(optn24);
			var optn25 = document.createElement("OPTION");
			optn25.text = "IsiXhosa Second Language";
			optn25.value = "IsiXhosa Second Language";
			subCategory.options.add(optn25);
			var optn84 = document.createElement("OPTION");
			optn84.text = "IsiZulu First Additional Language";
			optn84.value = "IsiZulu First Additional Language";
			subCategory.options.add(optn84);				
			var optn26 = document.createElement("OPTION");
			optn26.text = "IsiZulu Second Language";
			optn26.value = "IsiZulu Second Language";
			subCategory.options.add(optn26);
			var optn27 = document.createElement("OPTION");
			optn27.text = "IsiZulu Third Language";
			optn27.value = "IsiZulu Third Language";
			subCategory.options.add(optn27);
			var optn28 = document.createElement("OPTION");
			optn28.text = "Italian";
			optn28.value = "Italian";
			subCategory.options.add(optn28);
			var optn29 = document.createElement("OPTION");
			optn29.text = "Jewish Studies";
			optn29.value = "Jewish Studies";
			subCategory.options.add(optn29);
			var optn31 = document.createElement("OPTION");
			optn31.text = "Latin";
			optn31.value = "Latin";
			subCategory.options.add(optn31);
			var optn70 = document.createElement("OPTION");
			optn70.text = "Library";
			optn70.value = "Library";
			subCategory.options.add(optn70);
			var optn71 = document.createElement("OPTION");
			optn71.text = "Life Orientation";
			optn71.value = "Life Orientation";
			subCategory.options.add(optn71);
			var optn72 = document.createElement("OPTION");
			optn72.text = "Life Sciences";
			optn72.value = "Life Sciences";
			subCategory.options.add(optn72);			
			var optn56 = document.createElement("OPTION");
			optn56.text = "Life Skills";
			optn56.value = "Life Skills";
			subCategory.options.add(optn56);
			var optn57 = document.createElement("OPTION");
			optn57.text = "Literacy";
			optn57.value = "Literacy";
			subCategory.options.add(optn57);			
			var optn73 = document.createElement("OPTION");
			optn73.text = "Mathematical Literacy";
			optn73.value = "Mathematical Literacy";
			subCategory.options.add(optn73);			
			var optn32 = document.createElement("OPTION");
			optn32.text = "Mathematics";
			optn32.value = "Mathematics";
			subCategory.options.add(optn32);
			var optn74 = document.createElement("OPTION");
			optn74.text = "Mathematics Paper 3";
			optn74.value = "Mathematics Paper 3";
			subCategory.options.add(optn74);	
			var optn82 = document.createElement("OPTION");
			optn82.text = "Media";
			optn82.value = "Media";
			subCategory.options.add(optn82);				
			var optn33 = document.createElement("OPTION");
			optn33.text = "Music";
			optn33.value = "Music";
			subCategory.options.add(optn33);
			var optn34 = document.createElement("OPTION");
			optn34.text = "Music Performance";
			optn34.value = "Music Performance";
			subCategory.options.add(optn34);
			var optn74 = document.createElement("OPTION");
			optn74.text = "Music (EEB)";
			optn74.value = "Music (EEB)";
			subCategory.options.add(optn74);
			var optn75 = document.createElement("OPTION");
			optn75.text = "Music (FET)";
			optn75.value = "Music (FET)";
			subCategory.options.add(optn75);
			var optn76 = document.createElement("OPTION");
			optn76.text = "Music (NSC)";
			optn76.value = "Music (NSC)";
			subCategory.options.add(optn76);			
			var optn58 = document.createElement("OPTION");
			optn58.text = "Natural Sciences";
			optn58.value = "Natural Sciences";
			subCategory.options.add(optn58);
			var optn59 = document.createElement("OPTION");
			optn59.text = "Numeracy";
			optn59.value = "Numeracy";
			subCategory.options.add(optn59);
			var optn35 = document.createElement("OPTION");
			optn35.text = "Painting";
			optn35.value = "Painting";
			subCategory.options.add(optn35);
			var optn36 = document.createElement("OPTION");
			optn36.text = "Physical Science";
			optn36.value = "Physical Science";
			subCategory.options.add(optn36);
			var optn77 = document.createElement("OPTION");
			optn77.text = "Physical Education";
			optn77.value = "Physical Education";
			subCategory.options.add(optn77);
			var optn37 = document.createElement("OPTION");
			optn37.text = "Portuguese";
			optn37.value = "Portuguese";
			subCategory.options.add(optn37);
			var optn78 = document.createElement("OPTION");
			optn78.text = "Science";
			optn78.value = "Science";
			subCategory.options.add(optn78);			
			var optn38 = document.createElement("OPTION");
			optn38.text = "Sculpture";
			optn38.value = "Sculpture";
			subCategory.options.add(optn38);
			var optn39 = document.createElement("OPTION");
			optn39.text = "Sepedi First Language";
			optn39.value = "Sepedi First Language";
			subCategory.options.add(optn39);
			var optn40 = document.createElement("OPTION");
			optn40.text = "Sepedi Second Language";
			optn40.value = "Sepedi Second Language";
			subCategory.options.add(optn40);
			var optn41 = document.createElement("OPTION");
			optn41.text = "Sesotho Second Language";
			optn41.value = "Sesotho Second Language";
			subCategory.options.add(optn41);
			var optn42 = document.createElement("OPTION");
			optn42.text = "Setswana First Language";
			optn42.value = "Setswana First Language";
			subCategory.options.add(optn42);
			var optn43 = document.createElement("OPTION");
			optn43.text = "Setswana Second Language";
			optn43.value = "Setswana Second Language";
			subCategory.options.add(optn43);
			var optn44 = document.createElement("OPTION");
			optn44.text = "Siswati First Language";
			optn44.value = "Siswati First Language";
			subCategory.options.add(optn44);
			var optn45 = document.createElement("OPTION");
			optn45.text = "Siswati Second Language";
			optn45.value = "Siswati Second Language";
			subCategory.options.add(optn45);
			var optn79 = document.createElement("OPTION");
			optn79.text = "Social Science";
			optn79.value = "Social Science";
			subCategory.options.add(optn79);			
			var optn46 = document.createElement("OPTION");
			optn46.text = "Spanish";
			optn46.value = "Spanish";
			subCategory.options.add(optn46);
			var optn47 = document.createElement("OPTION");
			optn47.text = "Speech & Drama";
			optn47.value = "Speech & Drama";
			subCategory.options.add(optn47);
			var optn48 = document.createElement("OPTION");
			optn48.text = "Technical & Drawing";
			optn48.value = "Technical & Drawing";
			subCategory.options.add(optn48);
			var optn49 = document.createElement("OPTION");
			optn49.text = "Technika Electronics";
			optn49.value = "Technika Electonics";
			subCategory.options.add(optn49);
			var optn80 = document.createElement("OPTION");
			optn80.text = "Technology";
			optn80.value = "Technology";
			subCategory.options.add(optn80);			
			var optn50 = document.createElement("OPTION");
			optn50.text = "Travel & Tourism";
			optn50.value = "Travel & Tourism";
			subCategory.options.add(optn50);
			var optn51 = document.createElement("OPTION");
			optn51.text = "Typing";
			optn51.value = "Typing";
			subCategory.options.add(optn51);
			var optn81 = document.createElement("OPTION");
			optn81.text = "Visual Arts";
			optn81.value = "Visual Arts";
			subCategory.options.add(optn81);			
			var optn52 = document.createElement("OPTION");
			optn52.text = "Woodwork";
			optn52.value = "Woodwork";
			subCategory.options.add(optn52);
			var optn53 = document.createElement("OPTION");
			optn53.text = "Other";
			optn53.value = "Other";
			subCategory.options.add(optn53);
			break;
	case "Cultural": 
			var subCategory = document.getElementById('ddeditSubCategory');
			subCategory.length = 0;
			var optn0 = document.createElement("OPTION");
			optn0.text = "";
			optn0.value = "";
			subCategory.options.add(optn0);
			var optn1 = document.createElement("OPTION");
			optn1.text = "Art";
			optn1.value = "Art";
			subCategory.options.add(optn1);
			var optn2 = document.createElement("OPTION");
			optn2.text = "Choir";
			optn2.value = "Choir";
			subCategory.options.add(optn2);
			var optn3 = document.createElement("OPTION");
			optn3.text = "Cultural Programme";
			optn3.value = "Cultural Programme";
			subCategory.options.add(optn3);
			var optn4 = document.createElement("OPTION");
			optn4.text = "Dance";
			optn4.value = "Dance";
			subCategory.options.add(optn4);
			var optn5 = document.createElement("OPTION");
			optn5.text = "Debating";
			optn5.value = "Debating";
			subCategory.options.add(optn5);
			var optn6 = document.createElement("OPTION");
			optn6.text = "Drama";
			optn6.value = "Drama";
			subCategory.options.add(optn6);
			var optn65 = document.createElement("OPTION");
			optn65.text = "Dramatic Arts";
			optn65.value = "Dramatic Arts";			
			subCategory.options.add(optn65);			
			var optn7 = document.createElement("OPTION");
			optn7.text = "First Aid";
			optn7.value = "First Aid";
			subCategory.options.add(optn7);
			var optn8 = document.createElement("OPTION");
			optn8.text = "Music";
			optn8.value = "Music";
			subCategory.options.add(optn8);
			var optn9 = document.createElement("OPTION");
			optn9.text = "Photography Club";
			optn9.value = "Photography Club";
			subCategory.options.add(optn9);
			var optn10 = document.createElement("OPTION");
			optn10.text = "Pottery";
			optn10.value = "Pottery";
			subCategory.options.add(optn10);
			var optn11 = document.createElement("OPTION");
			optn11.text = "Public Speaking";
			optn11.value = "Public Speaking";
			subCategory.options.add(optn11);
			var optn12 = document.createElement("OPTION");
			optn12.text = "Students' Christian Association";
			optn12.value = "Students' Christian Association";
			subCategory.options.add(optn12);
			var optn13 = document.createElement("OPTION");
			optn13.text = "Other";
			optn13.value = "Other";
			subCategory.options.add(optn13);
			break;
	case "Sport":
			var subCategory = document.getElementById('ddeditSubCategory');
			subCategory.length = 0;
			var optn0 = document.createElement("OPTION");
			optn0.text = "";
			optn0.value = "";
			subCategory.options.add(optn0);
			var optn1 = document.createElement("OPTION");
			optn1.text = "Athletics";
			optn1.value = "Athletics";
			subCategory.options.add(optn1);
			var optn2 = document.createElement("OPTION");
			optn2.text = "Badminton";
			optn2.value = "Badminton";
			subCategory.options.add(optn2);
			var optn3 = document.createElement("OPTION");
			optn3.text = "Baseball";
			optn3.value = "Baseball";
			subCategory.options.add(optn3);
			var optn4 = document.createElement("OPTION");
			optn4.text = "Basketball";
			optn4.value = "Basketball";
			subCategory.options.add(optn4);
			var optn5 = document.createElement("OPTION");
			optn5.text = "BMX";
			optn5.value = "BMX";
			subCategory.options.add(optn5);
			var optn6 = document.createElement("OPTION");
			optn6.text = "Canoeing";
			optn6.value = "Canoeing";
			subCategory.options.add(optn6);
			var optn7 = document.createElement("OPTION");
			optn7.text = "Climbing";
			optn7.value = "Climbing";
			subCategory.options.add(optn7);
			var optn8 = document.createElement("OPTION");
			optn8.text = "Cricket";
			optn8.value = "Cricket";
			subCategory.options.add(optn8);
			var optn9 = document.createElement("OPTION");
			optn9.text = "Cycling";
			optn9.value = "Cycling";
			subCategory.options.add(optn9);
			var optn10 = document.createElement("OPTION");
			optn10.text = "Dance";
			optn10.value = "Dance";
			subCategory.options.add(optn10);
			var optn11 = document.createElement("OPTION");
			optn11.text = "Diving";
			optn11.value = "Diving";
			subCategory.options.add(optn11);
			var optn12 = document.createElement("OPTION");
			optn12.text = "Equestrain";
			optn12.value = "Equestrain";
			subCategory.options.add(optn12);
			var optn13 = document.createElement("OPTION");
			optn13.text = "Fishing";
			optn13.value = "Fishing";
			subCategory.options.add(optn13);
			var optn14 = document.createElement("OPTION");
			optn14.text = "Golf";
			optn14.value = "Golf";
			subCategory.options.add(optn14);
			var optn15 = document.createElement("OPTION");
			optn15.text = "Gymnastics";
			optn15.value = "Gymanstics";
			subCategory.options.add(optn15);
			var optn16 = document.createElement("OPTION");
			optn16.text = "Hiking";
			optn16.value = "Hiking";
			subCategory.options.add(optn16);
			var optn17 = document.createElement("OPTION");
			optn17.text = "Hockey";
			optn17.value = "Hockey";
			subCategory.options.add(optn17);
			var optn18 = document.createElement("OPTION");
			optn18.text = "Judo";
			optn18.value = "Judo";
			subCategory.options.add(optn18);
			var optn19 = document.createElement("OPTION");
			optn19.text = "Karate";
			optn19.value = "Karate";
			subCategory.options.add(optn19);
			var optn20 = document.createElement("OPTION");
			optn20.text = "Kayaking";
			optn20.value = "Kayaking";
			subCategory.options.add(optn20);
			var optn21 = document.createElement("OPTION");
			optn21.text = "Kite Surfing";
			optn21.value = "Kite Surfing";
			subCategory.options.add(optn21);
			var optn22 = document.createElement("OPTION");
			optn22.text = "Mixed Discipline";
			optn22.value = "Mixed Discipline";
			subCategory.options.add(optn22);
			var optn23 = document.createElement("OPTION");
			optn23.text = "Motorcycling";
			optn23.value = "Motorcycling";
			subCategory.options.add(optn23);
			var optn24 = document.createElement("OPTION");
			optn24.text = "Mountain Biking";
			optn24.value = "Mountain Biking";
			subCategory.options.add(optn24);
			var optn25 = document.createElement("OPTION");
			optn25.text = "Mountaineering";
			optn25.value = "Mountaineering";
			subCategory.options.add(optn25);
			var optn26 = document.createElement("OPTION");
			optn26.text = "Netball";
			optn26.value = "Netball";
			subCategory.options.add(optn26);
			var optn27 = document.createElement("OPTION");
			optn27.text = "Parachuting";
			optn27.value = "Parachuting";
			subCategory.options.add(optn27);
			var optn28 = document.createElement("OPTION");
			optn28.text = "Pilates";
			optn28.value = "Pilates";
			subCategory.options.add(optn28);
			var optn29 = document.createElement("OPTION");
			optn29.text = "Rollerblading";
			optn29.value = "Rollerblading";
			subCategory.options.add(optn29);
			var optn30 = document.createElement("OPTION");
			optn30.text = "Rowing";
			optn30.value = "Rowing";
			subCategory.options.add(optn30);
			var optn31 = document.createElement("OPTION");
			optn31.text = "Rugby";
			optn31.value = "Rugby";
			subCategory.options.add(optn31);
			var optn32 = document.createElement("OPTION");
			optn32.text = "Sailing";
			optn32.value = "Sailing";
			subCategory.options.add(optn32);
			var optn33 = document.createElement("OPTION");
			optn33.text = "Shooting";
			optn33.value = "Shooting";
			subCategory.options.add(optn33);
			var optn34 = document.createElement("OPTION");
			optn34.text = "Skateboarding";
			optn34.value = "Skateboarding";
			subCategory.options.add(optn34);
			var optn35 = document.createElement("OPTION");
			optn35.text = "Skiing";
			optn35.value = "Skiing";
			subCategory.options.add(optn35);
			var optn36 = document.createElement("OPTION");
			optn36.text = "Snooker";
			optn36.value = "Snooker";
			subCategory.options.add(optn36);
			var optn37 = document.createElement("OPTION");
			optn37.text = "Snowboarding";
			optn37.value = "Snowboarding";
			subCategory.options.add(optn37);
			var optn38 = document.createElement("OPTION");
			optn38.text = "Soccer";
			optn38.value = "Soccer";
			subCategory.options.add(optn38);
			var optn39 = document.createElement("OPTION");
			optn39.text = "Squash";
			optn39.value = "Squash";
			subCategory.options.add(optn39);
			var optn40 = document.createElement("OPTION");
			optn40.text = "Surfing";
			optn40.value = "Surfing";
			subCategory.options.add(optn40);
			var optn41 = document.createElement("OPTION");
			optn41.text = "Swimming";
			optn41.value = "Swimming";
			subCategory.options.add(optn41);
			var optn42 = document.createElement("OPTION");
			optn42.text = "Synchronised Swimming";
			optn42.value = "Synchronised Swimming";
			subCategory.options.add(optn42);
			var optn43 = document.createElement("OPTION");
			optn43.text = "Tennis";
			optn43.value = "Tennis";
			subCategory.options.add(optn43);
			var optn44 = document.createElement("OPTION");
			optn44.text = "Wake boarding";
			optn44.value = "Wake boarding";
			subCategory.options.add(optn44);
			var optn45 = document.createElement("OPTION");
			optn45.text = "Waterpolo";
			optn45.value = "Waterpolo";
			subCategory.options.add(optn45);
			var optn46 = document.createElement("OPTION");
			optn46.text = "Water Skiing";
			optn46.value = "Water Skiing";
			subCategory.options.add(optn46);
			var optn47 = document.createElement("OPTION");
			optn47.text = "Widsurfing";
			optn47.value = "Widsurfing";
			subCategory.options.add(optn47);
			var optn48 = document.createElement("OPTION");
			optn48.text = "Yoga";
			optn48.value = "Yoga";
			subCategory.options.add(optn48);
			var optn49 = document.createElement("OPTION");
			optn49.text = "Other";
			optn49.value = "Other";
			subCategory.options.add(optn49);
			break;
	case "Groups":
			var subCategory = document.getElementById('ddeditSubCategory');
			subCategory.length = 0;
			var optn0 = document.createElement("OPTION");
			optn0.text = "";
			optn0.value = "";
			subCategory.options.add(optn0);
			var optn1 = document.createElement("OPTION");
			optn1.text = "Year";
			optn1.value = "Year";
			subCategory.options.add(optn1);
			var optn2 = document.createElement("OPTION");
			optn2.text = "Class";
			optn2.value = "Class";
			subCategory.options.add(optn2);
			var optn3 = document.createElement("OPTION");
			optn3.text = "House";
			optn3.value = "House";
			subCategory.options.add(optn3);
			var optn4 = document.createElement("OPTION");
			optn4.text = "Parents";
			optn4.value = "Parents";
			subCategory.options.add(optn4);
			var optn5 = document.createElement("OPTION");
			optn5.text = "Teachers";
			optn5.value = "Teachers";
			subCategory.options.add(optn5);
			var optn6 = document.createElement("OPTION");
			optn6.text = "Pupils";
			optn6.value = "Pupils";
			subCategory.options.add(optn6);
			var optn7 = document.createElement("OPTION");
			optn7.text = "Other";
			optn7.value = "Other";
			subCategory.options.add(optn7);
			break;
	case "Other":
			var subCategory = document.getElementById('ddeditSubCategory');
			subCategory.length = 0;
			var optn0 = document.createElement("OPTION");
			optn0.text = "";
			optn0.value = "";
			subCategory.options.add(optn0);
			var optn1 = document.createElement("OPTION");
			optn1.text = "Animals";
			optn1.value = "Animals";
			subCategory.options.add(optn1);
			var optn2 = document.createElement("OPTION");
			optn2.text = "Beauty & Fashion";
			optn2.value = "Beauty & Fashion";
			subCategory.options.add(optn2);
			var optn3 = document.createElement("OPTION");
			optn3.text = "Business";
			optn3.value = "Business";
			subCategory.options.add(optn3);
			var optn4 = document.createElement("OPTION");
			optn4.text = "Entertainment";
			optn4.value = "Entertainment";
			subCategory.options.add(optn4);
			var optn5 = document.createElement("OPTION");
			optn5.text = "Family";
			optn5.value = "Family";
			subCategory.options.add(optn5);
			var optn6 = document.createElement("OPTION");
			optn6.text = "Food & Drink";
			optn6.value = "Food & Drink";
			subCategory.options.add(optn6);
			var optn7 = document.createElement("OPTION");
			optn7.text = "Health & Fitness";
			optn7.value = "Heatlh & Fitness";
			subCategory.options.add(optn7);
			var optn8 = document.createElement("OPTION");
			optn8.text = "Home & Garden";
			optn8.value = "Home & Garden";
			subCategory.options.add(optn8);
			var optn9 = document.createElement("OPTION");
			optn9.text = "Just for Fun";
			optn9.value = "Jusr for Fun";
			subCategory.options.add(optn9);
			var optn10 = document.createElement("OPTION");
			optn10.text = "Medical";
			optn10.value = "Medical";
			subCategory.options.add(optn10);
			var optn11 = document.createElement("OPTION");
			optn11.text = "Money";
			optn11.value = "Money";
			subCategory.options.add(optn11);
			var optn12 = document.createElement("OPTION");
			optn12.text = "News & Politics";
			optn12.value = "News & Politics";
			subCategory.options.add(optn12);
			var optn13 = document.createElement("OPTION");
			optn13.text = "Relationships";
			optn13.value = "Relationships";
			subCategory.options.add(optn13);
			var optn14 = document.createElement("OPTION");
			optn14.text = "Religion";
			optn14.value = "Religion";
			subCategory.options.add(optn14);
			var optn15 = document.createElement("OPTION");
			optn15.text = "Technology";
			optn15.value = "Technology";
			subCategory.options.add(optn15);
			var optn16 = document.createElement("OPTION");
			optn16.text = "Travel";
			optn16.value = "Travel";
			subCategory.options.add(optn16);
			var optn17 = document.createElement("OPTION");
			optn17.text = "Other";
			optn17.value = "Other";
			subCategory.options.add(optn17);
			break;		
}		

}

function showPublishPortalChanges()
{
    
}

var isMouseDown = false;

function startLeftScroll()
{
    if ($('divScrollRight').style.backgroundImage != 'url(../../images/scrollRightDown.png)')
        $('divScrollRight').style.backgroundImage = 'url(../../images/scrollRightDown.png)';
        
    isMouseDown = true;
    scrollFeatPortalsLeft();
}

function scrollFeatPortalsLeft()
{
    if (isMouseDown)
    {
        var scrollerRight = $('featPortalsScroller').cumulativeOffset()[0] + $('featPortalsScroller').getWidth();
        var containerRight = $('featuredPortals').cumulativeOffset()[0] + $('featuredPortals').getWidth();
        
        //alert("scroller:\t" + scrollerRight + "\n" + "container:\t" + containerRight);
        
        if (containerRight < (scrollerRight + 100))
        {
            new Effect.Move('featPortalsScroller', {x: containerRight - scrollerRight, mode: 'relative', duration: 0.5});
            isMouseDown = false;
        }
        else if (containerRight < scrollerRight)
        {
            new Effect.Move('featPortalsScroller', {x: -100, mode: 'relative', duration: 0.5});
            window.setTimeout('scrollFeatPortalsLeft()', 500);
        }
        else
        {
            isMouseDown = false;
        }
    }
}

function stopLeftScroll()
{
    if ($('divScrollRight').style.backgroundImage != 'url(../../images/scrollRightOver.png)')
        $('divScrollRight').style.backgroundImage = 'url(../../images/scrollRightOver.png)';
    isMouseDown = false;
}

function exitLeftScroll()
{
    if ($('divScrollRight').style.backgroundImage != 'url(../../images/scrollRight.png)')
        $('divScrollRight').style.backgroundImage = 'url(../../images/scrollRight.png)';
    isMouseDown = false;
}

function enterLeftScroll()
{
    if ($('divScrollRight').style.backgroundImage != 'url(../../images/scrollRightOver.png)')
        $('divScrollRight').style.backgroundImage = 'url(../../images/scrollRightOver.png)';
}

function startRightScroll()
{
    if ($('divScrollLeft').style.backgroundImage != 'url(../../images/scrollLeftDown.png)')
        $('divScrollLeft').style.backgroundImage = 'url(../../images/scrollLeftDown.png)';
        
    isMouseDown = true;
    scrollFeatPortalsRight();
}

function scrollFeatPortalsRight()
{
    if (isMouseDown)
    {
        var scrollerLeft = $('featPortalsScroller').cumulativeOffset()[0];
        var containerLeft = $('featuredPortals').cumulativeOffset()[0];
        
        if (scrollerLeft < (containerLeft - 100))
        {
            new Effect.Move('featPortalsScroller', {x: scrollerLeft - containerLeft, mode: 'relative', duration: 0.5});
            isMouseDown = false;
        }
        else if (scrollerLeft < containerLeft)
        {
            new Effect.Move('featPortalsScroller', {x: 100, mode: 'relative', duration: 0.5});
            window.setTimeout('scrollFeatPortalsRight()', 500);
        }
        else
        {
            isMouseDown = false;
        }
    }
}

function stopRightScroll()
{
    if ($('divScrollLeft').style.backgroundImage != 'url(../../images/scrollLeftOver.png)')
        $('divScrollLeft').style.backgroundImage = 'url(../../images/scrollLeftOver.png)';
    isMouseDown = false;
}

function exitRightScroll()
{
    if ($('divScrollLeft').style.backgroundImage != 'url(../../images/scrollLeft.png)')
        $('divScrollLeft').style.backgroundImage = 'url(../../images/scrollLeft.png)';
    isMouseDown = false;
}

function enterRightScroll()
{
    if ($('divScrollLeft').style.backgroundImage != 'url(../../images/scrollLeftOver.png)')
        $('divScrollLeft').style.backgroundImage = 'url(../../images/scrollLeftOver.png)';
}
