	function refreshParent() {
	  window.opener.location.reload();
	  //window.opener.location.href = window.opener.location.href;
	  window.close();
	  return true;
	}
	
	function fileUploadElement(id,mediatype,uploadmode)	{
		window.open('fileUpload.php?id='+id+'&type='+mediatype+'&uploadmode='+uploadmode,'popup','height=50,width=320,location=no,status=no');
	}
	
	function writePopup(strPopupType,strQuerystring)	{

		switch(strPopupType)	{
		 case 'thumbnails':
		 	iWidth = 300;
			iHeight = 500;
			strURL = 'default.php?'+strQuerystring;
		break;
		 case 'permissions':
		 	iWidth = 550;
			iHeight = 320;
			strURL = 'default.php?'+strQuerystring;
		break;
		 case 'presentations':
		 	iWidth = 600;
			iHeight = 500;
			strURL = 'default.php?'+strQuerystring;
		break;
		case 'htmlcode':
		 	iWidth = 415;
			iHeight = 240;
			strURL = '../default.php?'+strQuerystring;
		break;
		 default:
		 	iWidth = 50;
			iHeight = 320;
		}
		window.open(strURL,strPopupType,'width='+iWidth+',height='+iHeight+',location=no,status=no,scrollbars=1');
	}

	function setMedialist (arrMedialist) {
		for (i = 0; i < document.forms.length; i++) {
			fForm = document.forms[i];
			strFormname = fForm.name;
			if(strFormname.substr(0,4)=='form')	{
				theSel = fForm.medialist;		
				var oOption = new Option('Select mediafile',-1,true,false);
				theSel.options[0]=oOption;
				iSelectedMedia = theSel.attributes['cpselected'].value;
				bSelectedFound = (! iSelectedMedia >0);

				for (j=0;j<arrMedialist.length;j++)	{
					//Not sure we need this line, but it was added at some point and doesn't hurt
					strMedianame = ''+arrMedialist[j][1];
					iMediaID = arrMedialist[j][0];
					//If this is a header, this will be false as well

					bSelected = (! bSelectedFound && (iMediaID == iSelectedMedia));
					bSelectedFound = (bSelectedFound || bSelected);
					var oOption = new Option(strMedianame ,iMediaID,bSelected,false);
					if (iMediaID==-1) {
						oOption.style.color = '#ff0000';
					}
					theSel.options[j+1] = (oOption);
					//Needed for IE 6
					if (bSelected) theSel.selectedIndex = j+1;
				}
			}
		}
	}
	
	function toggle(targetId)	{
		target = document.getElementById(targetId);
		if (target.style.display == 'none')	{
			target.style.display = '';
		} else {
			target.style.display = 'none';
		}
	}
	

	function moveToActive()	{
		for (i = possible.options.length - 1; i>= 0; i--){
			element = possible.options[i];
			if (element.selected != false){
				active.options[active.length] = new Option(element.text, element.value, false, false);
				possible.options[i] = null;
			}
		}
	}

	function moveToPossible()	{
		for (i = active.options.length - 1; i >= 0; i--){
			element = active.options[i];
			if (element.selected != false){
				possible.options[possible.length] = new Option(element.text, element.value, false, false);
				active.options[i] = null;
			}
		}
	}
	
	function setPermission()	{
		selectbox = document.getElementById('active');
		var permissionList = '';
		for(i=0;i<selectbox.options.length;i++)	{
			if (permissionList!='')	{
				permissionList += ';';
			}
			permissionList += selectbox.options[i].value;
		}
		document.forms[0].elements['permissions'].value=permissionList;
	}

	function popUploadThumb(id){
   		window.open("uploadThumb.php?id="+id,"_blank", "width=400,height=200");
	}

