function externalLinks() {
    if (!document.getElementsByTagName) return;
    var anchors = document.getElementsByTagName("a");
    for (var i=0; i<anchors.length; i++) {
        var anchor = anchors[i];
        if (anchor.getAttribute("href") &&
            anchor.getAttribute("rel") == "external")
            anchor.target = "_blank";
    }
}

window.onload = externalLinks;


(function(){
    var jQ=typeof jQuery=='function';
    function isDomReady(){
        if(domReady.done){
            return false
        }
        var d=document;
        if(d&&d.getElementsByTagName&&d.getElementById&&d.body){
            clearInterval(domReady.timer);
            domReady.timer=null;
            for(var i=0;i<domReady.ready.length;i++){
                domReady.ready[i].call()
            }
            domReady.ready=null;
            domReady.done=true
        }
    }
    var domReady=jQ?jQuery:function(f){
        if(domReady.done){
            return f()
        }
        if(domReady.timer){
            domReady.ready.push(f)
        }else{
            domReady.ready=[f];
            domReady.timer=setInterval(isDomReady,13)
        }
    };

    function extend(to,from){
        if(from){
            for(key in from){
                if(from.hasOwnProperty(key)){
                    to[key]=from[key]
                }
            }
        }
        return to
    }
    function asString(obj){
        switch(typeOf(obj)){
            case'string':
                obj=obj.replace(new RegExp('(["\\\\])','g'),'\\$1');
                obj=obj.replace(/^\s?(\d+)%/,"$1pct");
                return'"'+obj+'"';
            case'array':
                return'['+map(obj,function(el){
                    return asString(el)
                }).join(',')+']';
            case'function':
                return'"function()"';
            case'object':
                var str=[];
                for(var prop in obj){
                    if(obj.hasOwnProperty(prop)){
                        str.push('"'+prop+'":'+asString(obj[prop]))
                    }
                }
                return'{'+str.join(',')+'}'
        }
        return String(obj).replace(/\s/g," ").replace(/\'/g,"\"")
    }
    function typeOf(obj){
        if(obj===null||obj===undefined){
            return false
        }
        var type=typeof obj;
        return(type=='object'&&obj.push)?'array':type
    }
    if(window.attachEvent){
        window.attachEvent("onbeforeunload",function(){
            __flash_unloadHandler=function(){};

            __flash_savedUnloadHandler=function(){}
        })
    }
    function map(arr,func){
        var newArr=[];
        for(var i in arr){
            if(arr.hasOwnProperty(i)){
                newArr[i]=func(arr[i])
            }
        }
        return newArr
    }
    function getHTML(p,c){
        var e=extend({},p);
        var ie=document.all;
        var html='<object width="'+e.width+'" height="'+e.height+'"';
        if(ie&&!e.id){
            e.id="_"+(""+Math.random()).substring(9)
        }
        if(e.id){
            html+=' id="'+e.id+'"'
        }
        e.src+=((e.src.indexOf("?")!=-1?"&":"?")+Math.random());
        if(e.w3c||!ie){
            html+=' data="'+e.src+'" type="application/x-shockwave-flash"'
        }else{
            html+=' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
        }
        html+='>';
        if(e.w3c||ie){
            html+='<param name="movie" value="'+e.src+'" />'
        }
        e.width=e.height=e.id=e.w3c=e.src=null;
        for(var k in e){
            if(e[k]!==null){
                html+='<param name="'+k+'" value="'+e[k]+'" />'
            }
        }
        var vars="";
        if(c){
            for(var key in c){
                if(c[key]!==null){
                    vars+=key+'='+(typeof c[key]=='object'?asString(c[key]):c[key])+'&'
                }
            }
            vars=vars.substring(0,vars.length-1);
            html+='<param name="flashvars" value=\''+vars+'\' />'
        }
        html+="</object>";
        return html
    }
    function Flash(root,opts,flashvars){
        var version=flashembed.getVersion();
        extend(this,{
            getContainer:function(){
                return root
            },
            getConf:function(){
                return opts
            },
            getVersion:function(){
                return version
            },
            getFlashvars:function(){
                return flashvars
            },
            getApi:function(){
                return root.firstChild
            },
            getHTML:function(){
                return getHTML(opts,flashvars)
            }
        });
        var required=opts.version;
        var express=opts.expressInstall;
        var ok=!required||flashembed.isSupported(required);
        if(ok){
            opts.onFail=opts.version=opts.expressInstall=null;
            root.innerHTML=getHTML(opts,flashvars)
        }else if(required&&express&&flashembed.isSupported([6,65])){
            extend(opts,{
                src:express
            });
            flashvars={
                MMredirectURL:location.href,
                MMplayerType:'PlugIn',
                MMdoctitle:document.title
            };

            root.innerHTML=getHTML(opts,flashvars)
        }else{
            if(root.innerHTML.replace(/\s/g,'')!==''){}else{
                root.innerHTML="<h2>Flash version "+required+" or greater is required</h2>"+"<h3>"+(version[0]>0?"Your version is "+version:"You have no flash plugin installed")+"</h3>"+(root.tagName=='A'?"<p>Click here to download latest version</p>":"<p>Download latest version from <a href='http://www.adobe.com/go/getflashplayer'>here</a></p>");
                if(root.tagName=='A'){
                    root.onclick=function(){
                        location.href='http://www.adobe.com/go/getflashplayer'
                    }
                }
            }
        }
        if(!ok&&opts.onFail){
            var ret=opts.onFail.call(this);
            if(typeof ret=='string'){
                root.innerHTML=ret
            }
        }
        if(document.all){
            window[opts.id]=document.getElementById(opts.id)
        }
    }
    window.flashembed=function(root,conf,flashvars){
        if(typeof root=='string'){
            var el=document.getElementById(root);
            if(el){
                root=el
            }else{
                domReady(function(){
                    flashembed(root,conf,flashvars)
                });
                return
            }
        }
        if(!root){
            return
        }
        var opts={
            width:'100%',
            height:'100%',
            allowfullscreen:true,
            allowscriptaccess:'always',
            quality:'high',
            version:null,
            onFail:null,
            expressInstall:null,
            w3c:false
        };

        if(typeof conf=='string'){
            conf={
                src:conf
            }
        }
        extend(opts,conf);
        return new Flash(root,opts,flashvars)
    };

    extend(window.flashembed,{
        getVersion:function(){
            var version=[0,0];
            if(navigator.plugins&&typeof navigator.plugins["Shockwave Flash"]=="object"){
                var _d=navigator.plugins["Shockwave Flash"].description;
                if(typeof _d!="undefined"){
                    _d=_d.replace(/^.*\s+(\S+\s+\S+$)/,"$1");
                    var _m=parseInt(_d.replace(/^(.*)\..*$/,"$1"),10);
                    var _r=/r/.test(_d)?parseInt(_d.replace(/^.*r(.*)$/,"$1"),10):0;
                    version=[_m,_r]
                }
            }else if(window.ActiveXObject){
                try{
                    var _a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")
                }catch(e){
                    try{
                        _a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
                        version=[6,0];
                        _a.AllowScriptAccess="always"
                    }catch(ee){
                        if(version[0]==6){
                            return version
                        }
                    }
                    try{
                        _a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")
                    }catch(eee){}
                }
                if(typeof _a=="object"){
                    _d=_a.GetVariable("$version");
                    if(typeof _d!="undefined"){
                        _d=_d.replace(/^\S+\s+(.*)$/,"$1").split(",");
                        version=[parseInt(_d[0],10),parseInt(_d[2],10)]
                    }
                }
            }
            return version
        },
        isSupported:function(version){
            var now=flashembed.getVersion();
            var ret=(now[0]>version[0])||(now[0]==version[0]&&now[1]>=version[1]);
            return ret
        },
        domReady:domReady,
        asString:asString,
        getHTML:getHTML
    });
    if(jQ){
        jQuery.tools=jQuery.tools||{
            version:{}
        };

        jQuery.tools.version.flashembed='1.0.3';
        jQuery.fn.flashembed=function(conf,flashvars){
            var el=null;
            this.each(function(){
                el=flashembed(this,conf,flashvars)
            });
            return conf.api===false?this:el
        }
    }
})();




/**
 * jQuery Lightbox
 * Version 0.5 - 11/29/2007
 * @author Warren Krewenki
 *
 * Changes by:
 * @author Krzysztof Kotowicz <koto at webworkers dot pl>:
 *  - bugfix: multiple instances of Lightbox galleries allowed
 *    (using opts variable instead of $.fn.lightbox.defaults)
 *  - bugfix: use var for local variables in a few functions
 *  - added support for navbarOnTop setting
 *  - added support for displayTitle setting
 *  - added support for slideNavBar setting (with slideNavBarSpeed)
 *  - added support for displayHelp setting
 *  - added support for fitToScreen setting (ported Lightbox VinDSL hack)
 *    (see http://www.huddletogether.com/forum/comments.php?DiscussionID=307)
 *  - plugin now uses jQuery.width() and jQuery.height()
 *  - removed eval() calls
 *  - removed destroyElement - uses jQuery.remove()
 *  - use of prevLinkText, nextLinkText and help
 *  - all strings are now placed in opts.strings to allow for customization/translation
 *
 * Based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
 * Originally written to make use of the Prototype framework, and Script.acalo.us, now altered to use jQuery.
 *
 **/

(function($){
    var opts;

    $.fn.lightbox = function(options){
        // build main options
        opts = $.extend({}, $.fn.lightbox.defaults, options);

        // initalize the lightbox
        $.fn.lightbox.initialize();
        return this.each(function(){
            $(this).click(function(){
                $(this).lightbox.start(this);
                return false;
            });
        });
    };

    // lightbox functions
    $.fn.lightbox.initialize = function(){
        $('#overlay').remove();
        $('#lightbox').remove();
        opts.inprogress = false;
        var outerImage = '<div id="outerImageContainer"><div id="imageContainer"><img id="lightboxImage"><div id="hoverNav"><a href="javascript://" title="' + opts.strings.prevLinkTitle + '" id="prevLink"></a><a href="javascript://" id="nextLink" title="' + opts.strings.nextLinkTitle + '"></a></div><div id="loading"><a href="javascript://" id="loadingLink"><img src="'+opts.fileLoadingImage+'"></a></div></div></div>';
        var imageData = '<div id="imageDataContainer" class="clearfix"><div id="imageData"><div id="imageDetails"><span id="caption"></span><span id="numberDisplay"></span></div><div id="bottomNav">'

        if (opts.displayHelp)
            imageData += '<span id="helpDisplay">' + opts.strings.help + '</span>';

        imageData += '<a href="javascript://" id="bottomNavClose" title="' + opts.strings.closeTitle + '"><img src="'+opts.fileBottomNavCloseImage+'"></a></div></div></div>';

        var string;

        if (opts.navbarOnTop) {
            string = '<div id="overlay"></div><div id="lightbox">' + imageData + outerImage + '</div>';
            $("body").append(string);
            $("#imageDataContainer").addClass('ontop');
        } else {
            string = '<div id="overlay"></div><div id="lightbox">' + outerImage + imageData + '</div>';
            $("body").append(string);
        }

        $("#overlay").click(function(){
            $.fn.lightbox.end();
        }).hide();
        $("#lightbox").click(function(){
            $.fn.lightbox.end();
        }).hide();
        $("#loadingLink").click(function(){
            $.fn.lightbox.end();
            return false;
        });
        $("#bottomNavClose").click(function(){
            $.fn.lightbox.end();
            return false;
        });
        $('#outerImageContainer').width(opts.widthCurrent).height(opts.heightCurrent);
        $('#imageDataContainer').width(opts.widthCurrent);
    };

    $.fn.lightbox.getPageSize = function(){
        var xScroll, yScroll;

        if (window.innerHeight && window.scrollMaxY) {
            xScroll = window.innerWidth + window.scrollMaxX;
            yScroll = window.innerHeight + window.scrollMaxY;
        } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
            xScroll = document.body.scrollWidth;
            yScroll = document.body.scrollHeight;
        } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
            xScroll = document.body.offsetWidth;
            yScroll = document.body.offsetHeight;
        }

        var windowWidth, windowHeight;

        if (self.innerHeight) { // all except Explorer
            if(document.documentElement.clientWidth){
                windowWidth = document.documentElement.clientWidth;
            } else {
                windowWidth = self.innerWidth;
            }
            windowHeight = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
            windowWidth = document.documentElement.clientWidth;
            windowHeight = document.documentElement.clientHeight;
        } else if (document.body) { // other Explorers
            windowWidth = document.body.clientWidth;
            windowHeight = document.body.clientHeight;
        }

        // for small pages with total height less then height of the viewport
        if(yScroll < windowHeight){
            pageHeight = windowHeight;
        } else {
            pageHeight = yScroll;
        }


        // for small pages with total width less then width of the viewport
        if(xScroll < windowWidth){
            pageWidth = xScroll;
        } else {
            pageWidth = windowWidth;
        }

        var arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
        return arrayPageSize;
    };


    $.fn.lightbox.getPageScroll = function(){
        var xScroll, yScroll;

        if (self.pageYOffset) {
            yScroll = self.pageYOffset;
            xScroll = self.pageXOffset;
        } else if (document.documentElement && document.documentElement.scrollTop){  // Explorer 6 Strict
            yScroll = document.documentElement.scrollTop;
            xScroll = document.documentElement.scrollLeft;
        } else if (document.body) {// all other Explorers
            yScroll = document.body.scrollTop;
            xScroll = document.body.scrollLeft;
        }

        var arrayPageScroll = new Array(xScroll,yScroll);
        return arrayPageScroll;
    };

    $.fn.lightbox.pause = function(ms){
        var date = new Date();
        var curDate = null;
        do{
            curDate = new Date();
        }
        while( curDate - date < ms);
    };

    $.fn.lightbox.start = function(imageLink){

        $("select, embed, object").hide();
        var arrayPageSize = $.fn.lightbox.getPageSize();
        $("#overlay").hide().css({
            width: '100%',
            height: arrayPageSize[1]+'px',
            opacity : opts.overlayOpacity,
            backgroundColor:	opts.overlayBgColor
        }).fadeIn();
        opts.imageArray = [];
        imageNum = 0;

        var anchors = document.getElementsByTagName( imageLink.tagName);

        // if image is NOT part of a set..
        if(!imageLink.rel || (imageLink.rel == '')){
            // add single image to Lightbox.imageArray
            opts.imageArray.push(new Array(imageLink.href, opts.displayTitle ? imageLink.title : ''));
        } else {
            // if image is part of a set..
            $("a").each(function(){
                if(this.href && (this.rel == imageLink.rel)){
                    opts.imageArray.push(new Array(this.href, opts.displayTitle ? this.title : ''));
                }
            })


            for(i = 0; i < opts.imageArray.length; i++){
                for(j = opts.imageArray.length-1; j>i; j--){
                    if(opts.imageArray[i][0] == opts.imageArray[j][0]){
                        opts.imageArray.splice(j,1);
                    }
                }
            }
            while(opts.imageArray[imageNum][0] != imageLink.href) {
                imageNum++;
            }
        }

        // calculate top and left offset for the lightbox
        var arrayPageScroll = $.fn.lightbox.getPageScroll();
        var lightboxTop = arrayPageScroll[1] + (arrayPageSize[3] / 10);
        var lightboxLeft = arrayPageScroll[0];
        $('#lightbox').css({
            top: lightboxTop+'px',
            left: lightboxLeft+'px'
        }).show();


        if (!opts.slideNavBar)
            $('#imageData').hide();

        $.fn.lightbox.changeImage(imageNum);

    };

    $.fn.lightbox.changeImage = function(imageNum){
        if(opts.inprogress == false){
            opts.inprogress = true;
            opts.activeImage = imageNum;	// update global var

            // hide elements during transition
            $('#loading').show();
            $('#lightboxImage').hide();
            $('#hoverNav').hide();
            $('#prevLink').hide();
            $('#nextLink').hide();

            if (opts.slideNavBar) { // delay preloading image until navbar will slide up
                // $('#imageDataContainer').slideUp(opts.navBarSlideSpeed, $.fn.doChangeImage);
                $('#imageDataContainer').hide();
                $('#imageData').hide();
                $.fn.doChangeImage();
            } else {
                $.fn.doChangeImage();
            }
        }
    };

    $.fn.doChangeImage = function(){

        imgPreloader = new Image();

        // once image is preloaded, resize image container
        imgPreloader.onload=function(){
            var newWidth = imgPreloader.width;
            var newHeight = imgPreloader.height;


            if (opts.fitToScreen) {
                var arrayPageSize = $.fn.lightbox.getPageSize();
                var ratio;
                var initialPageWidth = arrayPageSize[2] - 2 * opts.borderSize;
                var initialPageHeight = arrayPageSize[3] - 200;

                if (imgPreloader.height > initialPageHeight)
                {
                    newWidth = parseInt((initialPageHeight/imgPreloader.height) * imgPreloader.width);
                    newHeight = initialPageHeight;
                }
                else if (imgPreloader.width > initialPageWidth)
                {
                    newHeight = parseInt((initialPageWidth/imgPreloader.width) * imgPreloader.height);
                    newWidth = initialPageWidth;
                }
            }

            $('#lightboxImage').attr('src', opts.imageArray[opts.activeImage][0])
            .width(newWidth).height(newHeight);
            $.fn.lightbox.resizeImageContainer(newWidth, newHeight);
        }

        imgPreloader.src = opts.imageArray[opts.activeImage][0];
    }

    $.fn.lightbox.end = function(){
        $.fn.lightbox.disableKeyboardNav();
        $('#lightbox').hide();
        $('#overlay').fadeOut();
        $('select, object, embed').show();
    };

    $.fn.lightbox.preloadNeighborImages = function(){
        if((opts.imageArray.length - 1) > opts.activeImage){
            preloadNextImage = new Image();
            preloadNextImage.src = opts.imageArray[opts.activeImage + 1][0];
        }
        if(opts.activeImage > 0){
            preloadPrevImage = new Image();
            preloadPrevImage.src = opts.imageArray[opts.activeImage - 1][0];
        }
    };

    $.fn.lightbox.keyboardAction = function(e){
        if (e == null) { // ie
            var keycode = event.keyCode;
            var escapeKey = 27;
        } else { // mozilla
            var keycode = e.keyCode;
            var escapeKey = e.DOM_VK_ESCAPE;
        }

        var key = String.fromCharCode(keycode).toLowerCase();

        if((key == 'x') || (key == 'o') || (key == 'c') || (keycode == escapeKey)){ // close lightbox
            $.fn.lightbox.end();
        } else if((key == 'p') || (keycode == 37)){ // display previous image
            if(opts.activeImage != 0){
                $.fn.lightbox.disableKeyboardNav();
                $.fn.lightbox.changeImage(opts.activeImage - 1);
            }
        } else if((key == 'n') || (keycode == 39)){ // display next image
            if(opts.activeImage != (opts.imageArray.length - 1)){
                $.fn.lightbox.disableKeyboardNav();
                $.fn.lightbox.changeImage(opts.activeImage + 1);
            }
        }
    };

    $.fn.lightbox.resizeImageContainer = function(imgWidth, imgHeight){
        // get current width and height
        opts.widthCurrent = document.getElementById('outerImageContainer').offsetWidth;
        opts.heightCurrent = document.getElementById('outerImageContainer').offsetHeight;

        // get new width and height
        var widthNew = (imgWidth  + (opts.borderSize * 2));
        var heightNew = (imgHeight  + (opts.borderSize * 2));

        // scalars based on change from old to new
        opts.xScale = ( widthNew / opts.widthCurrent) * 100;
        opts.yScale = ( heightNew / opts.heightCurrent) * 100;

        // calculate size difference between new and old image, and resize if necessary
        wDiff = opts.widthCurrent - widthNew;
        hDiff = opts.heightCurrent - heightNew;

        $('#imageDataContainer').animate({
            width: widthNew
        },opts.resizeSpeed,'linear');
        $('#outerImageContainer').animate({
            width: widthNew
        },opts.resizeSpeed,'linear',function(){
            $('#outerImageContainer').animate({
                height: heightNew
            },opts.resizeSpeed,'linear',function(){
                $.fn.lightbox.showImage();
            });
        });


        // if new and old image are same size and no scaling transition is necessary,
        // do a quick pause to prevent image flicker.
        if((hDiff == 0) && (wDiff == 0)){
            if (jQuery.browser.msie){
                $.fn.lightbox.pause(250);
            } else {
                $.fn.lightbox.pause(100);
            }
        }

        $('#prevLink').height(imgHeight);
        $('#nextLink').height(imgHeight);
    };

    $.fn.lightbox.showImage = function(){
        $('#loading').hide();
        $('#lightboxImage').fadeIn("slow");
        $.fn.lightbox.updateDetails();
        $.fn.lightbox.preloadNeighborImages();

        opts.inprogress = false;
    };

    $.fn.lightbox.updateDetails = function(){

        if(opts.imageArray[opts.activeImage][1]){
            $('#caption').html(opts.imageArray[opts.activeImage][1]).show();
        }

        // if image is part of set display 'Image x of x'
        if(opts.imageArray.length > 1){
            var nav_html;

            nav_html = opts.strings.image + (opts.activeImage + 1) + opts.strings.of + opts.imageArray.length;

            // display previous / next text links
            if ((opts.activeImage) > 0) {
                nav_html = '<a title="' + opts.strings.prevLinkTitle + '" href="#" id="prevLinkText">' + opts.strings.prevLinkText + "</a>" + nav_html;
            }

            if ((opts.activeImage + 1) < opts.imageArray.length) {
                nav_html += '<a title="' + opts.strings.nextLinkTitle + '" href="#" id="nextLinkText">' + opts.strings.nextLinkText + "</a>";
            }

            $('#numberDisplay').html(nav_html).show();
        }

        if (opts.slideNavBar) {
            $("#imageData").slideDown(opts.navBarSlideSpeed);
        } else {
            $("#imageData").show();
        }

        var arrayPageSize = $.fn.lightbox.getPageSize();
        $('#overlay').height(arrayPageSize[1]);
        $.fn.lightbox.updateNav();
    };

    $.fn.lightbox.updateNav = function(){
        $('#hoverNav').show();

        // if not first image in set, display prev image button
        if(opts.activeImage != 0){
            $('#prevLink,#prevLinkText').show().click(function(){
                $.fn.lightbox.changeImage(opts.activeImage - 1);
                return false;
            });
        }

        // if not last image in set, display next image button
        if(opts.activeImage != (opts.imageArray.length - 1)){
            $('#nextLink,#nextLinkText').show().click(function(){

                $.fn.lightbox.changeImage(opts.activeImage +1);
                return false;
            });
        }

        $.fn.lightbox.enableKeyboardNav();
    };


    $.fn.lightbox.enableKeyboardNav = function(){
        document.onkeydown = $.fn.lightbox.keyboardAction;
    };

    $.fn.lightbox.disableKeyboardNav = function(){
        document.onkeydown = '';
    };

    $.fn.lightbox.defaults = {
        fileLoadingImage : '/pics_must/lightbox/lightbox-ico-loading.gif',
        fileBottomNavCloseImage : '/pics_must/lightbox/lightbox-btn-close.gif',
        overlayBgColor: '#45542f',
        overlayOpacity : 0.95,
        borderSize : 10,
        imageArray : new Array,
        activeImage : null,
        inprogress : false,
        resizeSpeed : 350,
        widthCurrent: 250,
        heightCurrent: 250,
        xScale : 1,
        yScale : 1,
        displayTitle: true,
        navbarOnTop: false,
        slideNavBar: true, // slide nav bar up/down between image resizing transitions
        navBarSlideSpeed: 350,
        displayHelp: false,
        strings : {
            help: ' \u2190 / P - previous image\u00a0\u00a0\u00a0\u00a0\u2192 / N - next image\u00a0\u00a0\u00a0\u00a0ESC / X - close image gallery',
            prevLinkTitle: 'voriges Bild',
            nextLinkTitle: 'n&auml;chstes Bild',
            prevLinkText:  '&laquo; Voriges',
            nextLinkText:  'N&auml;chstes &raquo;',
            closeTitle: 'schliessen',
            image: 'Bild ',
            of: ' of '
        },
        fitToScreen: true		// resize images if they are bigger than window
    };
})(jQuery);




/*
 * JTip
 * By Cody Lindley (http://www.codylindley.com)
 * Under an Attribution, Share Alike License
 * JTip is built on top of the very light weight jquery library.
 */

//on page load (as soon as its ready) call JT_init
$(document).ready(JT_init);

function JT_init(){
    $("a.jTip")
    .hover(function(){
        JT_show(this.href,this.id,this.name)
        },function(){
        $('#JT').remove()
        })
    .click(function(){
        return false
        });
}

function JT_show(url,linkId,title){
    if(title == false)title="&nbsp;";
    var de = document.documentElement;
    var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
    var hasArea = w - getAbsoluteLeft(linkId);
    var clickElementy = getAbsoluteTop(linkId) - 3; //set y position

    var queryString = url.replace(/^[^\?]+\??/,'');
    var params = parseQuery( queryString );
    if(params['width'] === undefined){
        params['width'] = 290
        };
    if(params['link'] !== undefined){
        $('#' + linkId).bind('click',function(){
            window.location = params['link']
            });
        $('#' + linkId).css('cursor','pointer');
    }

    if(hasArea>((params['width']*1)+75)){
        $("body").append("<div id='JT' style='width:"+params['width']*1+"px'><div id='JT_close_left'>"+title+"</div><div id='JT_copy'><div class='JT_loader'><div></div></div>");//right side
        var arrowOffset = getElementWidth(linkId) + 11;
        var clickElementx = getAbsoluteLeft(linkId) + arrowOffset; //set x position
    }else{
        $("body").append("<div id='JT' style='width:"+params['width']*1+"px'><div id='JT_close_right'>"+title+"</div><div id='JT_copy'><div class='JT_loader'><div></div></div>");//left side
        var clickElementx = getAbsoluteLeft(linkId) - ((params['width']*1) + 15); //set x position
    }

    $('#JT').css({
        left: clickElementx+"px",
        top: clickElementy+"px"
        });
    $('#JT').show();
    $('#JT_copy').load(url);

}

function getElementWidth(objectId) {
    x = document.getElementById(objectId);
    return x.offsetWidth;
}

function getAbsoluteLeft(objectId) {
    // Get an object left position from the upper left viewport corner
    o = document.getElementById(objectId)
    oLeft = o.offsetLeft            // Get left position from the parent object
    while(o.offsetParent!=null) {   // Parse the parent hierarchy up to the document element
        oParent = o.offsetParent    // Get parent object reference
        oLeft += oParent.offsetLeft // Add parent left position
        o = oParent
    }
    return oLeft
}

function getAbsoluteTop(objectId) {
    // Get an object top position from the upper left viewport corner
    o = document.getElementById(objectId)
    oTop = o.offsetTop            // Get top position from the parent object
    while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
        oParent = o.offsetParent  // Get parent object reference
        oTop += oParent.offsetTop // Add parent top position
        o = oParent
    }
    return oTop
}

function parseQuery ( query ) {
    var Params = new Object ();
    if ( ! query ) return Params; // return empty object
    var Pairs = query.split(/[;&]/);
    for ( var i = 0; i < Pairs.length; i++ ) {
        var KeyVal = Pairs[i].split('=');
        if ( ! KeyVal || KeyVal.length != 2 ) continue;
        var key = unescape( KeyVal[0] );
        var val = unescape( KeyVal[1] );
        val = val.replace(/\+/g, ' ');
        Params[key] = val;
    }
    return Params;
}

function blockEvents(evt) {
    if(evt.target){
        evt.preventDefault();
    }else{
        evt.returnValue = false;
    }
}