﻿/* VARIABLES GLOBALES */
// URL du site, URL de la page courante

var cap_siteURL = document.location.protocol + '//' + document.location.hostname;
var cap_pageURL = document.location;
if (typeof cap_CMS_SiteName == "undefined") cap_CMS_SiteName = "";
if (typeof cap_CMS_DocumentName == "undefined") cap_CMS_DocumentName = "";
if (typeof cap_CMS_Environment == "undefined") cap_CMS_Environment = "";
if (typeof cap_SiteRootUrl == "undefined") cap_SiteRootUrl = "";
if (typeof cap_CMS_AliasPath == "undefined") {
    cap_CMS_AliasPath = "";
} else {
    if (cap_CMS_AliasPath.slice(0, 1) == "/") {
        cap_CMS_AliasPath = cap_CMS_AliasPath.slice(1);
    }
    cap_CMS_AliasPath = cap_CMS_AliasPath.toLowerCase()
}

var cap_globalVarAlert = {
    view: function() {
        alert(
                'hostname = ' + document.location.hostname + '\n' +
                'cap_siteURL = ' + cap_siteURL + '\n' +
                'cap_pageURL = ' + cap_pageURL + '\n' +
                'cap_CMS_SiteName = ' + cap_CMS_SiteName + '\n' +
                'cap_CMS_DocumentName = ' + cap_CMS_DocumentName + '\n' +
                'cap_CMS_Environment = ' + cap_CMS_Environment + '\n' +
                'cap_SiteRootUrl = ' + cap_SiteRootUrl + '\n' +
                'cap_CMS_AliasPath = ' + cap_CMS_AliasPath
            );
    }
}
//cap_globalVarAlert.view();


/*  MOVE CONTENT  */
// Pour déplacer du contenu HTML

function cap_moveHtmlContent(before, after) {
    //alert('before = ' + before + '\n' + 'after = ' + after);
    if (before && after) {
        var htmlToMove = before.get('html');
        before.dispose();
        after.set('html', htmlToMove);
        return true;
    } else {
        return false;
    }
}


/* OldIEDetect **/
// Detection des vielles versions d'IE

function cap_OldIEDetect(version) {
    var nAgt = navigator.userAgent;
    if ((verOffset = nAgt.indexOf("MSIE")) != -1) {
        fullVersion = nAgt.substring(verOffset + 5);
        if ((ix = fullVersion.indexOf(";")) != -1) fullVersion = fullVersion.substring(0, ix);
        majorVersion = parseInt('' + fullVersion, 10);
        if (majorVersion <= version) {
            return true;
        } else {
            return false;
        }
    } else {
        return false;
    }
}