﻿//==== autosize  remplace $(... avec jQuery( ====
/*
* A faire Compatibilité entre LLGBO GMAPS
*           Infobulles spécifiques pour les EXIFS au survol du bouton :  Non  pour être ok
*147 llgbo2 main.php.	//	$template->Clear_assign('metadata');// hide original metadata
*[gmaps=id:1;width:800;height:640;]
*       Luciano rv_gmaps
*/
var d1 = 0;
var init_tb = 0;
var dom = {};
if (typeof jQuery == 'undefined') {
    alert(" jQuery n'est pas chargé");
} else {
    // jQuery est chargé
}

//===================================================

/*
  
*/
msie = jQuery.browser.msie || false;
opera= jQuery.browser.opera || false;
//========================================
/*function $defined(A) {
    $ = _$2; //   ;
    return A != undefined;
}
*/

var time_out = 0;
//===================================================

nbpa = 0;
var Fn;
function conflit(element, nc) {
    //--- cl_conflit    
    var retour = (getStackTrace());
    Fn = retour.fn;
    retour = retour.state;

    n = document;
    v = window;
    var ret_element = "";
    if (retour.match(RegExp("jQuery", "gi"))) {
        ret_element = jQuery(element);
    }
    else if (retour.match(RegExp("rv_gmaps", "gi"))) {
        ret_element = jQuery().$Prototype(element);
    } else if (retour.match(RegExp("GMaps", "gi"))) {
        ret_element = jQuery(element);
    } else if (retour.match(RegExp("pamooramics", "gi"))) {

    ret_element =   jQuery().$Pamoorama(element);

        if (retour.match(RegExp("init_", "gi"))) {

        }
        nbpa += 1;

    } else if (retour.match(RegExp("luciano", "gi"))) {
        $1 = $_;
        
        ret_element = jQuery().$Luciano(element,nc);

    } else if (retour.match(RegExp("jQuery", "gi"))) {
        ret_element = jQuery(element);
    }

    if (ret_element != "")
        return ret_element;

    if (typeof (element) == "string") {
        if (element.match("^#|.ui", "gi")) {
            ret_element = jQuery(element);
            return ret_element;
        }
    } else if (typeof (element) == "function") {
        fn = element.toString();
        if (fn.match("#pwg|open", "gi")) {
            ret_element = jQuery(element);
            return ret_element;
        }
    } else if (element == document) {

        ret_element = jQuery(element);
        return ret_element;


    }
    tp0 = typeof (element);

    ret_element = jQuery(element);
    if (DEBUG == "true") {
        retour = (getStackTrace());
        alert("element : " + element + " retour : " + retour);

    }
    return ret_element;
} // conflit(element,nc)





jQuery(document).ready(
    function (jQuery) {
        jQuery(window).load(function () {
            //============================================================
            jQuery("#icon_gmaps").bind('click', function () {

                jQuery('html,body').stop().scrollTop(0);
                jQuery('html,body').stop().scrollLeft(0);
                jQuery(".ui-widget-overlay").css("opacity", "0.75");

                l1 = (jQuery(window).width() - (jQuery(".gmapsPopup").width())) / 2;
                h1 = (jQuery(window).height() - (jQuery(".gmapsPopup").height())) / 2;

                jQuery(".gmapsPopup").css("left", l1 + "px");
                jQuery(".gmapsPopup").css("top", h1 + "px");
            })
            //=============================================================                
            p0 = jQuery("#theImage");
            if (p0.length) {

                //======================================================
                if (theme.match("gally", "gi"))
                    if (jQuery.isFunction(inittoolbar)) {
                        if (typeof (currentTab) == "undefined") inittoolbar();
                        else initializeImageMode("resize");
                    };

                p1 = jQuery("#theImage").css("position");
                if (p1 != "static") {
                    //==== compatibilité Gally/LLGBO ===
                    //--- passage relative ==> static ===/
                    jQuery("#theImage").css({ position: "static"
                    }

                    );
                    jQuery("#imageToolBar").css({ position: "relative", top: "0px" });
                }
            }
            //   jQuery(window).resize();

        });
        //=============================================================        

        //  $ = _$2; ;


    })
;



//=========================================================

jQuery.fn.extend({

    //---------------- luciano -------------------------------
    $Luciano: function (el, nc) {
        return document.id(el, nc, this.document);
    },
    //=============== PaMOOramics ===========================

    $Pamoorama: function (B) {


        if (!B) {
            if (typeof (B) == "boolean") return null;

        }

        try {
            if (B.htmlElement) {
                return Garbage.collect(B);
            }
        } catch (e) {

        }

        if ([window, document].contains(B)) { return B; }
        var A = $type(B);
        if (A == "string") { B = document.getElementById(B); A = (B) ? "element" : false; }
        if (A != "element") {
            return null;
        }
        if (B.htmlElement) { return Garbage.collect(B); }
        if (["object", "embed"].contains(B.tagName.toLowerCase())) { return B; }
        $extend(B, Element.prototype);
        B.htmlElement = function () { };
        try { return Garbage.collect(B); } catch (e) {
            return;
        }

    },
    //===================================================
    $Prototype: function (element) {
        //======== prototype.js =====================
        if (arguments.length > 1) {
            for (var i = 0, elements = [], length = arguments.length; i < length; i++)
                elements.push($(arguments[i]));
            return elements;
        }
        if (typeof element == "string")
            element = document.getElementById(element);

        return Element.extend(element);

        try {
            new_element = Element.extend(element);
        } catch (e) {
            return new_element;
        }
        return new_element;
    }
    //=========================================================
});    // fin extend



/*
* mootools.js  version: "1.11"
* pamoorama0.3.js
*
* main.js (google maps)
* prototype.js(mootool version: "1.62")
* windows.js
*
*/
function getStackTrace() {
    var callstack = [];
    var isCallstackPopulated = false;
    try {
        i.dont.exist += 0; //doesn't exist- that's the point
    } catch (e) {
        var retcallstack = [];
        var e_message = e.message;
        var e_stack = e.stack;
        if (e_stack) { //Firefox Opera 3.6
            //=== test fichier source =============
            var lines = e.stack.split("\n");
            for (var i = 0, len = lines.length; i < len; i++) {
                var Src_Match = lines[i];
                if (Src_Match.match(/conflit.js/)) {
                    //
                } else {
                    if (Src_Match.match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
                        callstack.push(Src_Match); //php?
                    } else {
                        callstack.push(Src_Match);
                    }
                    if (Src_Match.match("GMaps|applyMap|markupMaps|applyMarkers")) {
                        callstack.push("GMaps");
                        isCallstackPopulated = true;
                        break;
                    }
                    if (Src_Match.match("rv_gmaps", "gi")) {
                        callstack.push("rv_gmaps");
                        isCallstackPopulated = true;
                        break;
                    }
                    if (Src_Match.match("paMOOramics")) {
                        isCallstackPopulated = true;
                        callstack.push("paMOOramics");
                        break;
                    }
                    if (Src_Match.match("Luciano", "gi")) {
                        callstack.push("Luciano");
                        isCallstackPopulated = true;
                        break;
                    }
                    if (Src_Match.match("main")) {
                      
                        callstack.push("main");
                        isCallstackPopulated = true;
                        break;
                    }
                    if (Src_Match.match("jQuery")) {
                        callstack.push("jQuery");
                        isCallstackPopulated = true;
                        break;
                    }
                }
            }
            //callstack.shift();
            isCallstackPopulated = false;
        }
        if (window.opera && e.message && isCallstackPopulated == false) {
            callstack = [];
            //Opera =================================
            var lines = e.message.split("\n");
            for (var i = 0, len = lines.length; i < len; i++) {
                if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
                    var entry = lines[i];
                    //Append next line also since it has the file info
                    if (lines[i + 1]) {
                        entry += " at " + lines[i + 1];
                        i++;
                    }
                    callstack.push(entry);
                    //isCallstackPopulated = true;
                }
            }

        }
        //===== fin Opera======================================
    }
    if (!isCallstackPopulated) { //IE and Safari
        var currentFunction = arguments.callee.caller;
        //next 
        callstack = [];
        all_functions = [];
        state = "";
        if (currentFunction == null) {
            return ("");
        }
        states = [];
        var fn1 = currentFunction.toString(); // fonction d'appel local (conflit)

        currentFunction = currentFunction.caller;
        currentFunction = currentFunction.caller;
        //$family

        while (currentFunction) {
            var fn = currentFunction.toString();
            all_functions.push(fn);
            var fname = fn.substring(fn.indexOf("function") + 8, fn.indexOf("(")) || " ";
            if (fname != " ") {

                jQuery.noop;
                if (states.length > 0) break;

                // if (fname != " $") callstack.push(fn);
            } if (fname != "") {
                jQuery.noop;
                // if (fname != " $") callstack.push(fn);
            }
            callstack.push(fn);

            if (fn.match(RegExp("jquery|switchmenu|switchTabs|switchInterface|gally|initializeImageMode", "gi"))) {
                states.push('jQuery');

            }
            if (fn.match(RegExp("dialog..open", "gi"))) {
                states.push('GMaps');

            }
            if (fn.match(RegExp("GMaps|applyMap|markupMaps|applyMarkers", "gi"))) {
                states.push('GMaps');

            }
            //======================
            if (fn.match(RegExp("_footer|ie_ready|makeDraggable|droppables", "gi"))) {

                states.push('paMOOramics');

            }
            if (fn.match(RegExp("observe|responder|stopobserving|fireContentLoadedEvent", "gi"))) {
                states.push('rv_gmaps');

            }
            //? bubble  
            Expression = new RegExp("\\$", "gi")
            if (fn.match(Expression)) {
                if (fn.match(RegExp("rateForm", "gi"))) {

                    states.push('Luciano');

                }
            }
            if (fn.match(RegExp("(splat|buildFrameWork|photoNext)", "gi"))) {  //luciano

                states.push('Luciano');

            }

            if (all_functions.length > 50) break;


            currentFunction = currentFunction.caller;
        }

    }
    state = states.join('\n');
    Fn = all_functions;
    return { state: state, fn: callstack.join('\n') };
}
//====================================


(function($) {
    $(document).ready(function(){
         jQuery(window).load(function () {
               a = jQuery(':Description');
        });
    });
    //==============================================
    jQuery.extend(jQuery.expr[':'], {
    // Nom du sélecteur personnalisé
        Description: function (a) {
        n = jQuery(a).infos();
        if (n.id != "") {
            //alert("<" + n.nodeName  +" id= " + n.id    + " >") ;
        }
        if (n.nodeName == "SCRIPT")
            if (a.src == "") {
                Match = jQuery(a).html();
                /*
                if ( Match.match(new RegExp("jQuery", "gi") )) {
                alert(n.id + n.nodeName + a.outerHTML ) ;
                }
                if ( Match.match(new RegExp("ajax", "gi") )) {
                alert(n.id + n.nodeName + a.outerHTML ) ;
                }
                */
                if (Match.match(new RegExp("\\$", "gi"))) {

                    if (Match.match(new RegExp("ajax", "gi"))) {
                        //     alert(n.id + n.nodeName + a.outerHTML);

                    }
                }
                if (Match.match(new RegExp("pamoorama", "ig"))) {

                    //     alert(n.id + n.nodeName + a.innerHTML);

                }
            }else{ 
          
            if (a.src.match(RegExp("mootools|pamooramic|luciano", "gi"))) {   
              jQuery.noop;            

                     }
 
                }

        return a;

    }
  }); //fin extend
  /*
  *
  */






})(jQuery); 


 function $(element, nc0) {
        a = conflit(element, nc0);
        return a;
    }
if (typeof ($.ajax)!="function") 
    {    
    $.ajax=        function  (origSettings) {
             jQuery.ajax(origSettings) ;
        } 
     

     $.parseJSON=  function (msg){
            return jQuery.parseJSON(msg) ;
        }


    }
if (typeof ($.get)!="function") 
    {
        $.get = function (options) {
            return jQuery.get(options);
        }


    }
    $_ = $;
    function save_framework(page) {
        $_ = $;
      return  
  
}


