		var myArrayOfKeysSelected = new Array();
		var myArrayOfValuesSelected = new Array();

		function GetSelection(myTabName){
			for(cpt = 0; cpt < myArrayOfKeysSelected.length; cpt++){
				if (myArrayOfKeysSelected[cpt] == myTabName ) return(myArrayOfValuesSelected[myPos]); 
			}
			return("");
		}
		
		function UnFixSelection(myTabName){
			//clear the old selection
			var myTRs = document.getElementById(myTabName).getElementsByTagName("tr"); 
			for (var cptTR = 0; cptTR < myTRs.length; cptTR++) { 
				myTRs[cptTR].className = 'normal';
			}
			
			//fix the value
			myPos = 0; 
			for(cpt = 0; cpt < myArrayOfKeysSelected.length; cpt++){
				if (myArrayOfKeysSelected[cpt] == myTabName ) myPos = cpt; 
			}
			myArrayOfKeysSelected[myPos] = myTabName;
			myArrayOfValuesSelected[myPos] = "";
		}

		function FixSelection(myTR, myTabName, myValue){
			//clear the old selection
			var myTRs = document.getElementById(myTabName).getElementsByTagName("tr"); 
			for (var cptTR = 0; cptTR < myTRs.length; cptTR++) { 
				myTRs[cptTR].className = 'normal';
			}

			//select the new
			myTR.className = 'selected';
		
			//fix the value
			myPos = 0; 
			for(cpt = 0; cpt < myArrayOfKeysSelected.length; cpt++){
				if (myArrayOfKeysSelected[cpt] == myTabName ) myPos = cpt; 
			}
			myArrayOfKeysSelected[myPos] = myTabName;
			myArrayOfValuesSelected[myPos] = myValue;
		}
		
		function isFixedSelection(myTabName){
/*
			for(cpt = 0; cpt < myArrayOfKeysSelected.length; cpt++){
				if (myArrayOfKeysSelected[cpt] == myTabName ) return(true);
			}
			return(false)
*/
			for(cpt = 0; cpt < myArrayOfKeysSelected.length; cpt++){
				if (myArrayOfKeysSelected[cpt] == myTabName )
					if (myArrayOfValuesSelected[cpt] != "" ) return(true);
			}
			return(false)
		}
		
		function FromSelectedToNormal(myTR, myTabName, myValue){
			if(GetSelection(myTabName) == myValue) {
				//must be selected
				myTR.className = 'selected';
			} else {
				//must be "normal"
				myTR.className = 'normal';
			}
		}

		function ViewItem(myItemID, mustPopup){
			myItem = (myItemID).split(":");
			if (myItemID == ""){
				alert('Merci de sélectionner un média à afficher');
			} else {
				myForm = document.forms['ActionForm'];
				myForm.ghost_id.value = myItem[1];
				myForm.action = myBookmarkLink + 'multimedia/dsp_details_media.php';
				if (myItem.length > 2)
					if (myItem[2] == "AVL"){
						myForm.action = myBookmarkLink + 'online_medical_help/dsp_help_details.php';
					}
				if (mustPopup)
					myForm.target = '_blank';
				myForm.submit()
				if (mustPopup)
					myForm.target = '';
			}
		}
		function PopDiapo (myURL){
			myDiapoWindow = window.open(myURL , 'Diaporama', 'resizable=yes, location=no, menubar=no, status=no, scrollbars=no, menubar=no');
		}

		function EditMedia(myMediaID, myFormName){
			if (myMediaID == ""){
				alert('Merci de sélectionner un média à éditer');
			} else {
				myItem = (myMediaID).split(":");
				myForm = document.forms[myFormName];
				myForm.ghost_id.value = myItem[1];
				myForm.submit()
			}
		}

		function EditVideo(myVideoID, myFormName){
			if (myVideoID == ""){
				alert('Merci de sélectionner une vidéo à éditer');
			} else {
				myForm = document.forms[myFormName];
				myForm.ghost_id.value = myVideoID;
				myForm.submit()
			}
		}

		function CheckFillMedia(){
			myForm = document.forms['SubmitForm'];
			if (document.getElementById('rd_dvd_yes').checked) {
				if (!CheckMandatory(myForm, 'txt_adress_shop', 'text', 'Indiquez un email ou une addresse où se procurer cette vidéo')) return(false);
			}

			if (!CheckMandatory(myForm, 'txt_name', 'text', 'Indiquez un titre')) return(false);
			if (!CheckMandatory(myForm, 'txt_keywords', 'text', 'Indiquez au moins un mot clé')) return(false);
			
			if (myForm.ghost_institutionnal_partner.value == "Y") {
				// check for an institutionnal partner
				if (!CheckMandatory(myForm, 'select_rubric', 'select', '')){
					if (!CheckMandatory(myForm, 'select_institution', 'select', 'Indiquez une rubrique ou une insitution')) return(false);
				} else {
					if (!CheckMandatory(myForm, 'select_spec1', 'select', 'Indiquez au moins une spécialité')) return(false);
				}
			} else {
				// check for a normal user
				if (!CheckMandatory(myForm, 'select_rubric', 'select', 'Indiquez une rubrique')) return(false);
				if (!CheckMandatory(myForm, 'select_spec1', 'select', 'Indiquez une spécialité')) return(false);
			}

			if (!CheckMandatory(myForm, 'txt_speakers', 'text', 'Indiquez au moins un intervenant')) return(false);

			if (!CheckMandatory(myForm, 'txt_date', 'text', 'Indiquez une date de tournage')) return(false);
			if (!ValideInputDate(myForm.txt_date)) return (false)
			if (!CheckMandatory(myForm, 'txt_city', 'text', 'Indiquez une ville de tournage')) return(false);
			if (!CheckMandatory(myForm, 'select_department', 'select', 'Indiquez un département de tournage')) return(false);
			if (!CheckMandatory(myForm, 'select_country', 'select', 'Indiquez un pays')) return(false);
			
			return (true);
		}

		function CheckMediaValidation(){
			//CheckFillVideo() + other checks
			if (confirm('Etes-vous sur de vouloir valider ce média?')){
				myForm = document.forms['SubmitForm'];
				myForm.ghost_validated.value = "Y";
				if (CheckFillMedia()){
					if (CheckMandatory(myForm, 'select_level', 'select', 'Indiquez un niveau'))
						if (CheckMandatory(myForm, 'txt_length', 'text', 'Indiquez une durée/un nombre de diapos'))
							return(true);
				}
			}
		}

		function SelectSpe(myObj){
			myForm = document.forms['SubmitForm'];
			switch(myObj.name){
				case 'select_spec1':
					if (myObj.selectedIndex == 0) {
						myForm.select_spec2.selectedIndex = 0;
						myForm.select_spec3.selectedIndex = 0;
						myForm.select_spec2.disabled = true;
						myForm.select_spec3.disabled = true;
					} else {
						myForm.select_spec2.disabled = false;
					}
					break;
				case 'select_spec2':
					if (myObj.selectedIndex == 0) {
						myForm.select_spec3.selectedIndex = 0;
						myForm.select_spec3.disabled = true;
					} else {
						myForm.select_spec3.disabled = false;
					}
					break;
			}
		}

		function SelectRubricOrInstit(myObj){
			document.getElementById('DHTML_media_specs').style.display = '';
			if (myObj.selectedIndex > 0) {
				myForm = document.forms['SubmitForm'];
				
				if (myObj.name == "select_rubric"){
					//selected a Rubric
					myForm.select_institution.selectedIndex = 0;
				} else {
					//selected an Institution
					myForm.select_rubric.selectedIndex = 0;
					document.getElementById('DHTML_media_specs').style.display = 'none';
				}
			}
		
		}
