// ############################################################
// <SCRIPT>
// Javascript Library for FlexWeb 2
// ID-3 Technologies inc. 2003
// ############################################################

// ============================================================
// PopupWindow
// ============================================================
function gf_PopUpWindow(URL, WindowName, WindowWidth, WindowHeight) {
	PosX = Math.round(screen.availWidth / 2) - (WindowWidth / 2) 
	PosY = Math.round(screen.availHeight / 2) - (WindowHeight / 2) - 20
	
	popupwin = window.open(URL,WindowName,"scrollbars=no,resizable=yes,directories=no,menubar=no,screenx=" + PosX + ",screeny=" + PosY + ",left=" + PosX + ",top=" + PosY + ",status=no,titlebar=yes,toolbar=no,height=" + WindowHeight + ",width=" + WindowWidth )
    popupwin.focus();
    //return(popupwin);
}
function gf_PopUpWindowScroll(URL, WindowName, WindowWidth, WindowHeight) {
	PosX = Math.round(screen.availWidth / 2) - (WindowWidth / 2) 
	PosY = Math.round(screen.availHeight / 2) - (WindowHeight / 2) - 20
	
	popupwin = window.open(URL,WindowName,"scrollbars=yes,resizable=yes,directories=no,menubar=no,screenx=" + PosX + ",screeny=" + PosY + ",left=" + PosX + ",top=" + PosY + ",status=no,titlebar=yes,toolbar=no,height=" + WindowHeight + ",width=" + WindowWidth )
    popupwin.focus();
    //return(popupwin);
}

function gf_PopUpModalWindow(URL,WindowWidth, WindowHeight) {	
	sReturnValue = window.showModalDialog(URL,'',"help:no;scroll:no;resizable:yes;center:yes;status:no;dialogHeight:" + WindowHeight + "px;dialogWidth:" + WindowWidth + "px")
    return(sReturnValue);
}

function gf_PopUpWindowExtra(URL, WindowName, WindowWidth, WindowHeight,sExtraAttributes) {
	PosX = Math.round(screen.availWidth / 2) - (WindowWidth / 2) 
	PosY = Math.round(screen.availHeight / 2) - (WindowHeight / 2) - 20
	
	popupwin = window.open(URL,WindowName,"directories=no,menubar=no,screenx=" + PosX + ",screeny=" + PosY + ",left=" + PosX + ",top=" + PosY + ",status=no,titlebar=yes,toolbar=no,height=" + WindowHeight + ",width=" + WindowWidth + "," + sExtraAttributes)
    popupwin.focus();
    return(popupwin);
}



// ############################################################
// Edition Forms
// ############################################################

function gf_OpenNouvellesForm(sID){
	gf_PopUpWindow("Nouvelles_e.asp?PK=" + sID,"NouvellesForm",550,400);
}
function gf_OpenPartenariatForm(sID){
	gf_PopUpWindow("Partenariat_e.asp?PK=" + sID,"PartenariatForm",550,400);
}
function gf_OpenUsersForm(sID){
	gf_PopUpWindow("Users_e.asp?PK=" + sID,"UsersForm",400,220);
}
function gf_OpenLienForm(sID){
	gf_PopUpWindow("Liens_e.asp?PK=" + sID,"LiensForm",500,350);
}
function gf_ShowStaticPageEditor(sFilePath,iTab){
	gf_PopUpWindow("static_e.asp?FilePath=" + sFilePath + "&FormTabButton=" + iTab,"StaticEditor",580,500);
}
function gf_OpenMembresForm(sID){
	gf_PopUpWindow("Membres_e.asp?PK=" + sID,"MembresForm",600,550);
}
function gf_AdminOpenDemandeSubventionForm(sID){
	gf_PopUpWindow("DemandeSubvention_e.asp?PK=" + sID,"DemandeSubventionsForm",720,400);
}
function gf_AdminOpenDemandeAdhesionForm(sID){
	gf_PopUpWindow("DemandeAdhesion_e.asp?PK=" + sID,"DemandeAdhesionsForm",740,470);
}
function gf_OpenDemandeAdhesion(){
	gf_PopUpWindowScroll("DemandeAdhesion.asp","DemandeAdhesion",720,400);
}
function gf_OpenDemandeSubvention(MemID, ID){
	gf_PopUpWindowScroll("../fr/500/InterfaceClient.asp?disable=true&FormName=FormDemandeSubvention&EncryptID=" + ID + "&MemEncryptID=" + MemID,"DemandeSubvention",720,400);
}
function gf_AdminOpenDemandeSubvention(MemID, ID){
	gf_PopUpWindowScroll("../fr/500/InterfaceClient.asp?Admin=True&FormName=FormDemandeSubvention&EncryptID=" + ID + "&MemEncryptID=" + MemID,"DemandeSubvention",720,400);
}
function gf_OpenRapportScientifique(MemID, ID){
	gf_PopUpWindowScroll("../fr/500/InterfaceClient.asp?Admin=True&FormName=FormRapportScientifique&EncryptID=" + ID + "&MemEncryptID=" + MemID,"RapportScientifique",720,400);
}
function gf_OpenRapportFinancier(MemID, ID){
	gf_PopUpWindowScroll("../fr/500/InterfaceClient.asp?Admin=True&FormName=FormRapportFinancier&EncryptID=" + ID + "&MemEncryptID=" + MemID,"RapportFinancier",720,400);
}
function gf_OpenEvaluationSubvention(MemID, ID, bDisable, iFormID){
	gf_PopUpWindowScroll("../500/InterfaceClient.asp?FormID=" + iFormID + "&FormName=FormEvaluationSubvention&EncryptID=" + ID + "&MemEncryptID=" + MemID + "&disable=" + bDisable,"RapportFinancier",720,400);
}
function gf_OpenEvaluationSubventionAdmin(MemID, ID, bDisable, iFormID){
	gf_PopUpWindowScroll("../fr/500/InterfaceClient.asp?Admin=true&FormID=" + iFormID + "&FormName=FormEvaluationSubvention&EncryptID=" + ID + "&MemEncryptID=" + MemID + "&disable=" + bDisable,"RapportFinancier",720,400);
}

function gf_AdminOpenEvaluationSubvention(MemID, ID, bDisable){
	gf_PopUpWindowScroll("../fr/500/InterfaceClient.asp?FormName=FormEvaluationSubvention&EncryptID=" + ID + "&MemEncryptID=" + MemID + "&disable=" + bDisable,"RapportFinancier",720,400);
}

function gf_OpenRapportScientifiqueRapRecu(MemID, ID, bDisable){
	gf_PopUpWindowScroll("../fr/500/InterfaceClient.asp?Admin=true&FormName=FormRapportScientifique&EncryptID=" + ID + "&MemEncryptID=" + MemID + "&disable=" + bDisable,"RapportScientifiqueRapRecu",720,400);
}
function gf_OpenRapportFinancierRapRecu(MemID, ID, bDisable){
	gf_PopUpWindowScroll("../fr/500/InterfaceClient.asp?Admin=true&FormName=FormRapportFinancier&EncryptID=" + ID + "&MemEncryptID=" + MemID + "&disable=" + bDisable,"RapportFinancierRapRecu",720,400);
}

function gf_ShowPreviewStatic(sFilePath){
	gf_PopUpWindowExtra(sFilePath,"PreviewWindow",800,600,"scrollbars=yes,resize=no");
}

function gf_RechercheEvaluateurForm(sID){
	gf_PopUpWindow("RechercheEvaluateur.asp?PK=" + sID,"RechEvalForm",600,400);
}

function gf_EvaluationAddFileForm(sID, SubId){
	gf_PopUpWindow("FormEvaluationAddFile.asp?MemEncryptID=" + sID + "&EncryptId=" + SubId,"RechEvalForm",400,75);
}
function gf_OpenEvenementForm(sID){
	gf_PopUpWindow("evenements_e.asp?PK=" + sID,"EvenementsForm",760,550);
}
function gf_OpenFormulaireForm(sID){
	gf_PopUpWindow("formulaires_e.asp?PK=" + sID,"FormulairesForm",760,550);
}
function gf_OpenQuestion(sID){
	gf_PopUpWindow("questions_e.asp?PK=" + sID,"QuestionsForm",560,370);
}
function gf_OpenReponse(sID){
	gf_PopUpWindow("reponses_l.asp?PK=" + sID,"ReponsesForm",560,370);
}
function gf_EditReponse(sID){
	gf_PopUpWindow("reponses_e.asp?PK=" + sID,"ReponsesEditForm",560,370);
}
// ############################################################
// Autre fonctions
// ############################################################
function ID3_FormatAsURL(oField) {
	var sString;

	sString = oField.value;
	sString = sString.replace(/ /gi,'');
	if (sString.length > 0) {
		if (sString.length > 5 && sString.indexOf('.') > 0) {
			if (sString.substr(0,7) != 'http://' && sString.substr(0,8) != 'https://') {
				sString = 'http://' + sString
				}
			}
		else {
			sString = '';
			alert("Ce champ doit contenir une adresse URL valide");
			}
		}
	oField.value = sString;
	}