
function moveToCentre(p){
    newLeftX = (parseInt(screen.width)-parseInt(PAGE_WIDTH))/2;
    newLeftY = (parseInt(screen.height)-parseInt(PAGE_HEIGHT))/2;
    p.setPagePosition(newLeftX, 120);

    p.syncSize();
    if (p.layout) {
        p.doLayout();
    }
//alert("moving : "+newLeftX+newLeftY);
};
	
function getCurrentUser() {
    return formatAdherent(user["nom"], user["prenom"]);
}

function formatRecordAdherent(record) {
    return record.data.ADH_PRENOM.toLowerCase() + " " + record.data.ADH_NOM.toUpperCase();
}


function formatAdherent(nom, prenom) {
    return prenom.toLowerCase() + " " + nom.toUpperCase();
}
	
/**
 *Methode de deconnexion de l'intranet 
 * -effacement du cookies 
 * -redirection � la page principale
 */ 
function logoutIntranet(){
    window.location = s_context+"lib/php/Authentification/dao_login_post.php?action=2";
};






// <summary>
// Fonction de conversion de chaîne accentué en chaîne sans accent
// </summary>
// <param name="chaine">La chaine à convertir</param>
// <returns>string</returns>
function convertirChaineSansAccent(chaine){
    // Déclaration de variables
    var accent = "ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÌÍÎÏìíîïÙÚÛÜùúûüÿÑñÇç";
    var sansAccent = "AAAAAAaaaaaaOOOOOOooooooEEEEeeeeIIIIiiiiUUUUuuuuyNnCc";

    // Pour chaque accent
    for(var i=0; i<accent.length; i++) {
        // Remplacement de l'accent par son équivalent sans accent dans la chaîne de caractères
        chaine = chaine.replace(accent.charAt(i), sansAccent.charAt(i));
    }
    // Retour du résultat
    return chaine;
};


function Capitalize(value) {
    var valueSsAccent = convertirChaineSansAccent(value) ;//
    return valueSsAccent.toUpperCase();
};


//style="text-transform: uppercase;" will make the input all caps too without the onkeyup c

/**
 * Methode permettat de passer en capital la 1er lettre du Text et en minuscule les suivantes.
 */
function firstCapital(value) {
    var valueSsAccent = convertirChaineSansAccent(value) ;//
    var cap=valueSsAccent.charAt(0).toUpperCase() + valueSsAccent.substring(1,valueSsAccent.length).toLowerCase();
    return cap;
};

function widthWin(size, rate) {
    var winWidth = Ext.getDoc().getViewSize(false).width;
    var minWidth = size;
    var widthWin = winWidth < minWidth ? winWidth* rate : minWidth;
    return widthWin;
}

function heightWin(size, rate) {
    var winHeight = Ext.getDoc().getViewSize(false).height;
    var minHeight = size;
    var heightWin = winHeight < minHeight ? winHeight * rate : minHeight;
    return heightWin;
}

function heightWinDefaut(size) {
    return heightWin(size, 0.9);
}



function widthWinDefaut(size) {
    return widthWin(size, 0.9);
}

function getHttpProxy (ServiceName) {
    return new Ext.data.HttpProxy({
        api: {
            read: {
                url: urlRest + ServiceName,
                method: 'GET'
            },
            create: {
                url: urlRest + ServiceName,
                method: 'POST'
            },
            destroy: {
                url: urlRest + ServiceName + '-DELETE',
                method: 'PUT'
            },
            update: {
                url: urlRest + ServiceName,
                method: 'PUT'
            }
        }
    });
}
