 function setMetaTag(metaName, name, value, id) {
    $('meta[name='+metaName+']').remove();
    var t = 'meta['+metaName+'='+name+']';
    var mt = $(t);
    if (mt.length === 0) {
        t = '<meta '+metaName+'="'+name+'" />';
        mt = $(t).appendTo('head');
    }
        mt.attr('content', value);
 }


 function GoTo(section){
//     var section = 'section-'+section;
//     var menu_id = section.replace("section-", "")   
//   
//    // alert("S: "+section+" Menu id: "+menu_id);
//     $("#vertical_menu li a").removeClass("menuBtn_active");
//     $("#vertical_menu li a").addClass("menuBtn");
//     $("#m"+menu_id).removeClass("menuBtn");
//     $("#m"+menu_id).addClass("menuBtn_active");
//     alert("Hash: "+document.location.hash);

 }
 
 
 function getCharAt(str,index) {
   // if(index > str.length-1) return str;
    var mystring =  str.substring(index,str.length);
    alert("Index: "+index+" String: "+str+"  Mystring"+mystring);
    return mystring;
}

function change_hash(nlocation){
//    if (window.location.href.indexOf('#!')==-1) 
//        alert('New location:: '+nlocation); 
//   if(nlocation == '#!/section-'){
//       if(current_language == 'ro'){
//           nlocation += 'despre-noi'
//       }else{
//           nlocation += 'about-us'
//       }
//   }
//        window.location.href = basew+nlocation;
}

 
 function ReloadPage(){
    //return false;
//     var h=window.location.hash;
//     var lhr = window.location.href
//     alert("Hash: "+h+"- window location: "+lhr);
//     var lang_position = lhr.indexOf('/'+current_language+'/');
//     var section_char = getCharAt(lhr,lang_position+4);
//     var nlocation = '#!/'+section_char;
//     alert("New location: "+nlocation);
//     
//        if(h.indexOf('#!') == -1){
//            alert("Nu Avem hash"+h.length+window.location.hash+" Lh: "+lhr+" Position of #!: "+h.indexOf('#!')+"Position of ro"+lang_position);
//            window.location.hash == '';
//          }else{
//             alert("Avem hash"+h.length+window.location.hash);
//        }
//       
//       if (h.length == 0) 
//       {
//           alert("NL: "+nlocation);
//           setTimeout("change_hash('"+nlocation+"')",1700);   
//       }   
   }
        

 

// dragging script
 
  jQuery(function($){
     
    var M = {
        isLog: false,
        currentHash: "",
        currentTitle: " | MPG",
        sections: [],
        sectionsCentre: 0,
        sectionWidth: 0,
        scrollXStart: 0,
        scrollXEaseInterval: 0,
        scrollXSpeed:0,
        sectionSnapMargin:200,
        scrollYSiectionsMax:0,
        scrollY:0,
        scrollYSectionsMax:0,
        totalLoaded:0,
        siteWidth:400,
        currentSection: false,
        
        ready: function() {
                if (document) {
                document.onselectstart = function (c) {                    
                    c.preventDefault();
                    return false
                }
                }
                $(window).unbind("resize", M.initStateResizes).resize(M.initStateResizes);
                $(window).resize();
                M.centerScrollerX()
                if(!M.isLog)
                {
                    $("#log").css('display','none')
                }
                // M.checkLoaded();
                M.startMPG();
            },
        log: function(param) {
            if(M.isLog) {                
                $("#log").prepend(param + '<br/>')
            }
        },
        initStateResizes: function () {
            if ($("body").hasClass("ie")) {
                $("#footer").css("top", $(window).height() - $("#footer").height() + "px")
            }
            $("#content").height($(window).height() - $("#content").offset().top + "px");            
            $("#content").width($(window).width() - $("#content").offset().left + "px");
            $("#container").height($("#content").height() + "px");
            $(".section").height($("#content").height() + "px")
            $("#scrollerx").width($(window).width() - $("#content").offset().left + "px");
            //$("#scrollerx").css('left',$("#content").offset().left + "px");
        },
        startMPG: function(){
            // M.log('Add to log');
            // 
            //S.siteWidth = $(".site:first").outerWidth();
            if (!$.cookie("dragnotifier")) {
                M.messageTimeout = setTimeout(function () {
                    $(document).mousemove(function (c) {
                        $("#dragnotifier").css({
                            top: c.pageY + 20,
                            left: c.pageX + 20
                        });
                        if (c.pageX > $("#content").position().left && c.pageY > $(".section_header:first").offset().top + $(".section_header:first").outerHeight()) {
                            $("#dragnotifier").show()  
                            $("#dragnotifier").addClass("showing");
                        } else {
                            $("#dragnotifier").hide()
                        }
                    })
                }, 1000)
            }
            M.detectBrowser();
            M.sections = $.makeArray($(".section"));
            M.alignSections();            
           // M.applyScrollingX();
            
           // M.applyScrollingY();
            $(window).hashchange(M.checkForDeepLink);
                        
            //S.applyImageBlocking($("#left"));
            M.sectionsIdsGet() 
            M.selectMenu(window.location.hash.replace('#!/',''))			
        },
        detectBrowser: function () {
            if ($.browser.msie) {
                $("body").addClass("ie");
                if ($.browser.version == "9.0") {
                    $("body").addClass("ie9")
                } else {
                    if ($.browser.version == "8.0") {
                        $("body").addClass("ie8")
                    } else {
                        if ($.browser.version == "7.0") {
                            $("body").addClass("ie7")
                        } else {
                            $("body").addClass("ie6")
                        }
                    }
                }
            }
            if ($.browser.webkit) {
                $("body").addClass("webkit");
                if (navigator.userAgent.indexOf("Chrome") === -1) {
                    $("body").addClass("safari")
                } else {
                    $("body").addClass("chrome")
                }
            }
            if ($.browser.mozilla) {
                $("body").addClass("ff");
                if ($.browser.version.substr(0, 3) == "1.9") {
                    $("body").addClass("ff3")
                } else {
                    $("body").addClass("ff2")
                }
            }
            if ($.browser.opera) {
                $("body").addClass("opera")
            }
            if (navigator.userAgent.indexOf("Windows") != -1) {
                $("body").addClass("windows")
            } else {
                if (navigator.userAgent.indexOf("Mac") != -1) {
                    $("body").addClass("mac")
                }
            }
            if (navigator.userAgent.indexOf("iPhone") != -1) {
                $("body").addClass("iphone")
            } else {
                if (navigator.userAgent.indexOf("iPad") != -1) {
                    $("body").addClass("ipad")
                } else {
                    if (navigator.userAgent.indexOf("Android") != -1) {
                        $("body").addClass("android");
                        if (navigator.userAgent.indexOf("GT-I9000") != -1) {
                            $("body").addClass("samsung_galaxy_s")
                        }
                    }
                }
            }
        
        
        },
        hideDragMessage: function () {
            
        
        clearTimeout(M.messageTimeout);
        $.cookie("dragnotifier", 1, {
            expires: 1000
        });
        if ($("#dragnotifier").hasClass("showing")) {
            $(document).unbind("mousemove");
            $("#dragnotifier").removeClass("showing").hide()
        }
        },
        sectionsIdsGet: function () {
                
        $.getJSON(basew+'ajax/ajax_sections', function(data) {
          M.sectionsData = $.makeArray($.parseJSON(data));            
          M.sectionIdsReady(data);
        

        });
        },
        sectionIdsReady: function (a){
            M.sectionsData = a;    
            M.totalLoaded = 0;                 
            $.each(M.sectionsData, function () {
                if (this == null || this == undefined) {
                    return
                }
                var b = this.html
				//	alert(" B: "+b);
			
                
                $(b).appendTo("#container")
            });
            M.sectionWidth = $(".section:first").outerWidth();
            M.sections = $.makeArray($(".section"));
           
            M.alignSections();
            M.applyScrollingX();
            M.applyScrollingY();
            
            $(window).hashchange(M.checkForDeepLink);
            M.sectionsGet(M.sections);
            $("#loading_page").hide();

        },        
        sectionsGet: function (b) {           
            if (b == null || b == undefined) {
                return
            }
            
            // move to section on click on section title
            $(".section_header h1 span").click(function () {
                    M.hideDragMessage();
                    var id = $(this).attr('rel').replace('section-','');                  
                    M.panToSection(id)
                    
            })
            
            // move to section on click on left menu
            $("#menu li a").unbind("click").click(function (event) {
                event.preventDefault();
                if ($(this).attr('href') == "") {
                    return
                }
                M.ignoreHashChange = true;
                var i = $(this).attr('href').toLowerCase().split("/");
                i=i[i.length-1].replace('section-','')
                M.panToSection(i)
            });
                
            M.checkForDeepLink();
            
        },
        alignSections: function () {          
            var length =0;
            $(M.sections).each(function (a) {            
                $(this).css("left", a * $(this).outerWidth() + "px")
                length+= $(this).outerWidth();
            })
            $("#container").css('width',length+ "px");
            M.sectionsCentre = ($("#container").width() / -2) + $("#content").offset().left            
            M.sectionWidth = length / M.sections.length;
            
        },
        applyScrollingX: function() {
            $("#scrollerx").fadeIn();
            $("#scrollerxhandle").draggable("destroy").draggable({
                axis: "x",
                containment: [134, 9, 356, 9],
                start: function () {                    
                    $(document).unbind("mouseup", M.resetScrollerX).mouseup(M.resetScrollerX)
                },
                drag: function (a) {
                    M.scrollX()
                }
            });
            $(document).unbind("keyup").keyup(M.handleKeyboard);
            //$(window).unbind("resize", M.applyScrollingXResize).resize(M.applyScrollingXResize);
            //$(window).resize();
            M.applyScrollXForSections()
        },
        handleKeyboard: function(a) {
            switch (a.keyCode) {
                case 27:
                    a.preventDefault();
                    break;
                case 37:
                case 39:
                    M.scrollXEaseDo();
                    $(document).unbind("keyup");
                    $("#container").stop(true).animate({
                        left: "+=" + (a.keyCode === 37 ? 1 : -1) * M.sectionWidth
                    }, "slow", "easeOutQuint", function () {
                        M.scrollXSnap(true);
                        $(document).unbind("keyup").keyup(M.handleKeyboard)
                    });
                    a.preventDefault();
                    break
                
                case 38:
                case 40:
                   // $(M.currentSection).css('top','500px');
                break;
            }
        },
        applyScrollingXResize: function () {
            var length = 0;
            
            $(M.sections).each(function (a) {            
                length+= $(this).outerWidth();
            })
            $("#container").width(length+"px");
            M.sectionsCentre = ($("#container").width() / -2) + $("#content").offset().left            
            M.sectionWidth = length / M.sections.length();
            
        },
        applyScrollXForSections: function () {        
            $("#container").unbind("mousedown").mousedown(M.scrollXDown)        
            $(window).resize()
        },
        scrollXGetCoords: function (b) {
            var a;
            b.preventDefault();
            a = b.clientX        
            return a
        },
        scrollXDown: function (c) {
            var a = M.scrollXGetCoords(c);
            M.scrollXStart = a;
            $("#container").stop(true);
            if (M.scrollXEaseInterval) {
                clearInterval(M.scrollXEaseInterval)
            }        
            $("#container").unbind("mousemove", M.scrollXDrag).mousemove(M.scrollXDrag).unbind("mouseleave", M.stopScrollX).mouseleave(M.stopScrollX).unbind("mouseup", M.stopScrollX).mouseup(M.stopScrollX)        

        },
        scrollXDrag: function (b) {
            var a = M.scrollXGetCoords(b, true);             
            M.scrollXSpeed = a - M.scrollXStart;            
            M.scrollXDo(M.scrollXSpeed);
            M.scrollXStart = a
        },
        scrollXDo: function (a) {
            $("#container").stop(true).css({
                left: function (c, b) {
                    var d = Number(b.replace("px", "")) + a;  
                    return d
                }
            })
        },
        stopScrollX: function() {
            
            $("#container").unbind("mousemove").unbind("mouseup").unbind("mouseleave")
        
            if (arguments[0] !== true) {
                M.scrollXRound()
            }
        },
        scrollXRound: function () {
            
            if ($("body").hasClass("ie7") || $("body").hasClass("ie8")) {
                M.scrollXSpeed = 0;
                M.scrollXEaseDo()
            } else {
                if (M.scrollXSpeed > 5 || M.scrollXSpeed < -5) {
                    M.scrollXSnap()
                } else {
                    M.scrollXSpeed = 0;
                    M.scrollXEaseDo()
                }
            }
        },
        scrollXEaseDo: function () {
           
            var b = $("#container").position().left;
            var c = Math.floor((b - M.sectionsCentre) / M.sectionWidth);
            var a;
            if (c > 0 || c < 0) {
                while (c < 0) {
                    a = $(M.sections.shift());
                    M.sections.push(a);
                    b += M.sectionWidth;
                    c++
                }
                while (c > 0) {
                    a = $(M.sections.pop());
                    M.sections.unshift(a);
                    b -= M.sectionWidth;
                    c--
                }
            }
            if (arguments[0] !== false) {
                b += M.scrollXSpeed
            }
            $("#container").css("left", b + "px");
            M.alignSections();
            M.setTitleToFirstChild()
        },
        scrollXSnap: function () {
            M.scrollXEaseDo();
            var b = $("#container").position().left;
            var c = b + M.scrollXSpeed;
            var a = (Math.round(c / M.sectionWidth) * M.sectionWidth);
            var d = a - c;            
            if (d < M.sectionSnapMargin && d > -M.sectionSnapMargin) {
                c = a
            }
            if (arguments[0] === true) {
                c = a
            }
            $("#container").animate({
                left: c
            }, "slow", "easeOutQuint", M.scrollXEaseDo);
            M.scrollXSpeed = 0
        },
        scrollX: function () {
            clearInterval(M.scrollXTick);
            M.scrollXSpeed = -$("#scrollerxhandle").position().left;
            M.scrollXInterval();
            M.scrollXTick = setInterval(M.scrollXInterval, 13)
        },
        scrollXInterval: function () {
            var a = M.scrollXSpeed / 5;
            M.scrollXDo(a);
            M.scrollXEaseDo(false)
        },
        resetScrollerX: function (a) {
            clearInterval(M.scrollXTick);
            M.scrollXSpeed = (M.scrollXSpeed > 0 ? 10 : M.scrollXSpeed < 0 ? -10 : 0);
            M.scrollXRound();
            M.centerScrollerX()
        },
        centerScrollerX: function () {
            var a = $(window).width() - $("#content").offset().left;
            $("#scrollerxhandle").css({
                "margin-left": (a - $("#scrollerxhandle").width()) / 2,
                left: ""
            });
            $("#scrollerxhover").css({
                "margin-left": (a - $("#scrollerxhover").width()) / 2
            })
        },
        applyScrollingY: function () {
            $(".scroller_handle").draggable("destroy").draggable({
                axis: "y",
                containment: "parent",
                start: function () {
                    M.scrollYSectionsMax = 0
                },
                drag: M.scrollY  ,
                
                stop: function () {
                    M.scrollYSectionsMax = 0
                }
            });
            $(window).unbind("resize", M.applyScrollingYResize).resize(M.applyScrollingYResize);
            $(window).resize()
        },
        applyScrollingYResize: function () {
            var a = $(window).height() - $(".section_header:first").outerHeight() - $("#container").offset().top;
            $(".section_container").height(a + "px");
            $(".scroller").height(a + ($(".scroller:first").position().top * -1) + "px");
            M.scrollYHandleMax = a - $(".scroller_handle:first").outerHeight() + ($(".scroller:first").position().top * -1);
            M.applyScrollYForSections()
        },
        
        applyScrollYForSections: function () {            
            
       
            $(arguments[0] || ".section").each(function () {
             
            if ($(".section_content", this).outerHeight() > $(window).height() - $(this).offset().top) {
                
                    $(".scroller", this).show().unbind("click").click(function (a) {   
                        M.hideDragMessage();
                        M.scrollYSectionsMax = 0;
                        M.scrollYTarget = $(this).parent().find(".section_content");                        
                        M.scrollYTargetParent = M.scrollYTarget.parent();
                        M.scrollYTargetHeight = M.scrollYTarget.outerHeight();
                        M.scrollYSectionsStart = M.scrollYTarget.position().top * -1;
                        M.scrollYSectionsMax = M.scrollYTargetHeight - M.scrollYTargetParent.height();                        
                        M.scrollYHandleTo(((a.clientY - $(this).offset().top) / $(this).height()) * M.scrollYSectionsMax)
                        
                    });
                    
                    
                    
                    
                    $(".section_content", this).unbind("mousedown").mousedown(function (a) {
                        M.hideDragMessage();
                        M.scrollYSectionsMax = 0;                        
                        M.applyScrollYForSection(this, a)
                    }).unbind("mouseup").mouseup(M.stopScrollY).unbind("mouseleave").unbind("mousewheel").mousewheel(function (b, c) { 
                        M.hideDragMessage();
                        M.scrollYSectionsMax = 0;
                        M.scrollYTarget = $(this);
                        M.scrollYTargetParent = M.scrollYTarget.parent();
                        M.scrollYTargetHeight = M.scrollYTarget.outerHeight();
                        M.scrollYSectionsStart = M.scrollYTarget.position().top * -1;
                        M.scrollYSectionsMax = M.scrollYTargetHeight - M.scrollYTargetParent.height();
                        var f = 40;
                        f = ($("body").hasClass("chrome") ? 80 : f);
                        f = ($("body").hasClass("chrome") && $("body").hasClass("windows") ? 200 : f);
                        f = ($("body").hasClass("safari") ? 1 : f);
                        f = ($("body").hasClass("opera") ? 100 : f);
                        f = ($("body").hasClass("opera") && $("body").hasClass("windows") ? 135 : f);
                        f = ($("body").hasClass("ie") || ($("body").hasClass("ff") && $("body").hasClass("windows")) ? 200 : f);
                        var a = M.scrollYSectionsStart + (c * -f);                        
                        M.scrollYHandleTo(a)
                        
                    })
                
            } else {
                $(".scroller", this).stop(true).hide();                
                $(".section", this).unbind("mousedown").unbind("mouseup").unbind("mouseleave").unbind("mousewheel")
                
            }
            
           
            
            $(".up_arrow", this).unbind("click").click(function (a) {
                a.preventDefault();          
                // $(this).parents(".section_content").css('top',0)
                M.scrollSectionToTopByObj($(this).parents(".section_content"));
                
                return false
            });
            
            
                    
        })
       // alert($(arguments[2]));
        if ($(arguments[2]) !== true) {
                
            
            M.scrollDownToTarget( /*isNaN( scrollT ) ? site : null, scrollT*/ )
            }
            
        },
        scrollSectionToTopByObj: function (obj) {
            $(obj).stop().animate({
                top: "0px"
            }, "slow", "easeOutQuint");
            
            var scroller = $(obj).parents(".section_container").find(".scroller_handle")
            
            $(scroller).stop().animate({
                top: "0px"
            }, "slow", "easeOutQuint")
            
        },
        scrollSectionToTop: function (a) {
        
        $(".section_content", a).stop().animate({
            top: "0px"
        }, "slow", "easeOutQuint");
        $(".scroller_handle", a).stop().animate({
            top: "0px"
        }, "slow", "easeOutQuint")
        },
        scrollYHandleTo: function (b) {       
       
            var a = b / M.scrollYSectionsMax;            
            a = (a < 0 ? 0 : a);
            a = (a > 1 ? 1 : a);
            $(".scroller_handle", M.scrollYTargetParent).css({
                top: M.scrollYHandleMax * a + "px"
            });
            if (a == 0 || a == 1) {
                b = a * M.scrollYSectionsMax
            }
            
            M.scrollYDo(b, M.scrollYTarget)
        },
        applyScrollYForSection: function (a, b) {
            
            var c = M.scrollYGetCoords(b);            
            M.scrollYStart = c;
            M.scrollYStartReal = c;
            M.scrollYTarget = $(a);            
            M.scrollYTargetParent = M.scrollYTarget.parent();
            M.scrollYTargetHeight = M.scrollYTarget.outerHeight();
            M.scrollYSectionsStart = M.scrollYTarget.position().top * -1;            
            M.scrollYSectionsMax = M.scrollYTargetHeight - M.scrollYTargetParent.height();            
            M.scrollYTarget.unbind("mouseleave").mouseleave(M.stopScrollY);
            if ($("body").hasClass("webkit") || $("body").hasClass("opera")) {
                $("#content").mousedown()
            }
            M.scrollYXStart = M.scrollXGetCoords(b);
            
            clearInterval(M.scrollYEaseInterval);
            $(document).unbind("mousemove", M.scrollYDrag).mousemove(M.scrollYDrag)        
        },
        scrollYGetCoords: function (b) {
            var a;
            b.preventDefault();
            a = b.clientY        
            return a
        },
        scrollYDrag: function (d) {
            var g = M.scrollYGetCoords(d, true);             
            var c = (M.scrollYStart - g);            
            var f = (M.scrollYSectionsStart + c);
            
            f = (f < 0 ? 0 : f);            
            f = (f > M.scrollYSectionsMax ? M.scrollYSectionsMax : f);
            
            var a = M.scrollXGetCoords(d);
            var b = M.scrollYXStart - a;
            if ((c > 100 || c < -100) && (b < 100 && b > -100)) {
                M.stopScrollX(true)
            }
            M.scrollYSpeed = M.scrollYStartReal - g;
            M.scrollYStartReal = g;
            M.scrollYHandleTo(f)
           
        },
        scrollYDragEase: function () {
            M.scrollYSpeed = 0
        },
        scrollY: function (d, b) {
           
            b = b.helper;
            if(b.hasClass('ui-draggable'))
                {
                    M.stopScrollX(true)
                }
             
            if (b.hasClass("cancel")) {
                return false
            }
            var c = b.position().top / M.scrollYHandleMax;
            var c = (c < 0 ? 0 : c);
            var c = (c > 1 ? 1 : c);
            M.scrollYTarget = $(b).parents(".section").eq(0).find(".section_content");
            
            var a = (M.scrollYSectionsMax > 0 ? M.scrollYSectionsMax : M.scrollYTarget.outerHeight() - M.scrollYTarget.parent().height());            
            if (M.scrollYSectionsMax == 0) {
                M.scrollYSectionsMax = a
            }
            var f = c * a;
            
            // M.loadMoreContent(c, f);
            M.scrollYDo(f, M.scrollYTarget);
            $("#content").unbind("mousemove").unbind("mouseup").unbind("mouseleave")
        },
        loadMoreContent: function (d, f) {
            return true;
        },        
        scrollYDo: function (b, a) {
            M.hideDragMessage();
            b = b * -1;
            b = (b > 0 ? 0 : b);            
            a.css({
                top: b + "px"
            })
        },
        stopScrollY: function (a) {
            $(document).unbind("mousemove", M.scrollYDrag);
            M.scrollYDragEase()
        },
        
        checkLoaded: function (b, a) {        
            $(window).resize();            
            if (M.sectionMatchesHash(b)) {
                M.currentHash = "";
                $(window).hashchange()
            }        
            if (window.location.hash == "") {
                M.currentHash = "";
                M.setTitleToFirstChild()
            } else {
                M.currentHash = "";
                //$(window).hashchange()
            }            
        },
        checkForDeepLink: function () {     
            
            if (window.location.hash == "") {
                M.setTitleToFirstChild();                
                return
            }
           // alert("ch: "+M.currentHash);
            if (window.location.hash.replace(/\//gim, "") == M.currentHash.replace(/\//gim, "")) {                
                return
            }
            
            var b = window.location.hash.replace("#!", "").split("/"); /*$.ga.trackPageview(window.location.hash.replace("#!",""));*/
            
            b = b.filter(function (d) {
                return !!d
            });
            
            if (b.length > 0) {
               
                var a = $("#section-" + b[0]);
                
                if (a.length > 0) {
                    if (window.location.hash.replace(/\//gim, "").indexOf(M.currentHash.replace(/\//gim, "")) == -1 || !M.currentHash) {                           
                        M.panToSection(b[0])                        
                    }                    
                    if(b.length=== 2)
                        {
                            M.scrollDownToTarget(b);
                        }
                    M.currentHash = window.location.hash;                  
                } else {
                    if (b.length === 1) {
                        M.currentHash = window.location.hash;
                        if (M.ignoreHashChange) {
                            M.ignoreHashChange = false;
                            return
                        }                        
                        $('a[href*="#!/' + b[0] + '"]').click();
                        return
                    }
                }
            } else {
                M.setTitleToFirstChild()
            }
            M.ignoreHashChange = false
        },
        sectionMatchesHash: function (b) {        
            var a = window.location.hash.replace("#!", "").split("/");            
            a = a.filter(function (c) {
                return !!c
            });                        
            return $(b).attr("id").replace("section-", "") == a[0]
        },
        scrollDownToTarget: function () {
            
            if (arguments[0] != null || arguments[0] != undefined) {
                M.scrollToTarget = arguments[0]
            }
            if (!M.scrollToTarget) {
                return
            }
            
            if (isNaN(arguments[1])) {
                var c = $(M.scrollToTarget);   
                 
                if (c.length < 1) {
                    
                    if (M.sectionsData.length == 0) {
                        M.scrollToTarget = null
                    }
                    return
                }                
                
                var d = $("#"+c[1]).position().top;                
                var b = $("#"+c[1]).parents(".article");   
                
                if (b.length > 0) {
                    b.each(function () {
                        
                        d += $(this).position().top
                    })
                }
                
                M.scrollYTarget = $("#"+c[1]).parents(".section_content").eq(0)
                
            } else {
                M.scrollYTarget = $(".section_container", arguments[0]);
                d = arguments[1];
                return
            }
            
            M.scrollYTargetParent = M.scrollYTarget.parent();
            M.scrollYTargetHeight = M.scrollYTarget.outerHeight();
            M.scrollYSectionsStart = M.scrollYTarget.position().top * -1;            
            M.scrollYSectionsMax = M.scrollYTargetHeight - M.scrollYTargetParent.height();             
            M.scrollYHandleTo(d);
            M.scrollToTarget = null
        },
        panToSection: function (b) {
            var c = 0;            
            var a = $("#section-" + b);            
            if (a.offset().left == $("#content").offset().left) {
                return
            }
            
            var start_count=0;
            $(M.sections).each(function (d) {
                if ("section-" + b == $(this).attr("id")) {
                    c = start_count;
                }       
                start_count+=$(this).outerWidth();                
            });            
            M.currentHash = window.location.hash;
            
            if (arguments[1] === true) {
                $("#container").stop(true).css({
                    left: -c + "px"
                });
                M.scrollXEaseDo()
            } else {                    
                $("#container").stop(true).animate({
                    left: -c + "px"
                }, "slow", "easeOutQuint", M.scrollXEaseDo)
            }
            
            
        },
        setTitleToFirstChild: function () {
        var b = $("#content").outerWidth();        
        var a = $("#content").outerWidth() + M.sectionWidth;        
        var d;
        $(".section").each(function () {
            var e = $(this).offset().left;           
            // if (e >= b && e <= a) {
            if (e >= 100 && e <= M.sectionWidth) {
                d = $(this)
            }
        });        
        if (!d) {
            return
        }
        
        M.currentSection = d;
        
        M.updateTitle($(".section_header h1 span", d).text());
        var c = "#!/" + $(".section_header h1 span", d).attr("rel").replace('section-','');
        if (window.location.hash.indexOf(c) === -1 && !M.scrollToTarget) {
            M.currentHash = c;
            window.location.hash = c
            M.selectMenu(window.location.hash.replace('#!/',''))
        }
        },
        updateTitle: function (a) {
            document.title =  a + M.currentTitle
            
        },
        selectMenu:function(rels)
        {
            $("a.menuBtn").removeClass("menuBtn_active");
            $("[rel='"+rels+"']").addClass('menuBtn_active');
        }
        
        
        
        
    }
    
    M.ready();
    
    $(window).hashchange( function(){
    _gaq.push(['_trackPageview',location.pathname + location.search  + location.hash]);
    })
 });
    
    



