
///////////////////////////////////////////////////////////////////////////
// CONFIG FOR ADICIO 'FEATURED EMPLOYERS' WIDGET

if(document.getElementById('featured-employers'))
    {
    var myFeaturedEmployers = new xmlScrollView();

    myFeaturedEmployers.setOutPutElement('featured-employers');
    myFeaturedEmployers.setItemRoot('Company');
    myFeaturedEmployers.declareVariable('ProfileUrl', '%homePageUrl%');
    myFeaturedEmployers.declareVariable('Name', '%companyName%');
    myFeaturedEmployers.declareConditionalVariable('LogoUrl', '%logoTag%', '<im' + 'g src="', '" border="0"/>');
    myFeaturedEmployers.declareConditionalVariable('ViewJobsUrl', '%jobsUrl%', '<'+'a href="', '">see all jobs for this company</a>');
    //myFeaturedEmployers.setTemplate('<table class="company-info"><tr><td>' + '<' + 'a href="%homePageUrl%">%logoTag%<' + '/a><' + 'a href="%homePageUrl%" class="company-name">%companyName%<' + '/a><' + 'br' + ' />'+ '<p class="jobslist">' + '%jobsUrl%' + '</p>' + '<' + '/td' + '><' + '/tr' + '><' + '/table' + '>');
    //myFeaturedEmployers.setTemplate('<center><a onmouseover="myFeaturedEmployers.scroller.stopScroll();" onmouseout="myFeaturedEmployers.scroller.startScroll();" href="%homePageUrl%">%logoTag%<' + '/a><' + 'a onmouseover="myFeaturedEmployers.scroller.stopScroll();" onmouseout="myFeaturedEmployers.scroller.startScroll();" href="%homePageUrl%" class="company-name">%companyName%<' + '/a><' + 'br' + ' />'+ '<p class="jobslist">' + '%jobsUrl%' + '</p>' + '</center><' + 'br' + '>');
    myFeaturedEmployers.setTemplate('<center><a onmouseover="myFeaturedEmployers.scroller.stopScroll();" onmouseout="myFeaturedEmployers.scroller.startScroll();" onclick=window.location=(\'%homePageUrl%\')>%logoTag%<span class="company-name">%companyName%</span><br /><p class="jobslist">%jobsUrl%</p></a></center></ br>' );
    myFeaturedEmployers.setScrollDelay(30);
    myFeaturedEmployers.outputFromString(xmlPrefCo1);
    }



///////////////////////////////////////////////////////////////////////////
// CONFIG FOR ADICIO 'FEATURED EMPLOYERS' WIDGET

if(document.getElementById('featured-employers-NoScroll'))
    {
    var myFeaturedEmployersNoScroll = new xmlScrollView();

    myFeaturedEmployersNoScroll.setOutPutElement('featured-employers-NoScroll');
    myFeaturedEmployersNoScroll.setItemRoot('Company');
    myFeaturedEmployersNoScroll.declareVariable('ProfileUrl', '%homePageUrl%');
    myFeaturedEmployersNoScroll.declareVariable('Name', '%companyName%');
    myFeaturedEmployersNoScroll.declareConditionalVariable('LogoUrl', '%logoTag%', '<im' + 'g src="', '" border="0"/>');
    myFeaturedEmployersNoScroll.declareConditionalVariable('ViewJobsUrl', '%jobsUrl%', '<'+'a href="', '">see all jobs for this company</a>');
    myFeaturedEmployersNoScroll.setTemplate('<table class="company-info"><tr><td>' + '<' + 'a href="%homePageUrl%">%logoTag%<' + '/a><' + 'a href="%homePageUrl%" class="company-name">%companyName%<' + '/a><' + 'br' + ' />'+ '<p class="jobslist">' + '%jobsUrl%' + '</p>' + '<' + '/td' + '><' + '/tr' + '><' + '/table' + '>');
    //myFeaturedEmployersNoScroll.setTemplate('<center><a onmouseover="myFeaturedEmployersNoScroll.scroller.stopScroll();" onmouseout="myFeaturedEmployersNoScroll.scroller.startScroll();" href="%homePageUrl%">%logoTag%<' + '/a><' + 'a onmouseover="myFeaturedEmployersNoScroll.scroller.stopScroll();" onmouseout="myFeaturedEmployersNoScroll.scroller.startScroll();" href="%homePageUrl%" class="company-name">%companyName%<' + '/a><' + 'br' + ' />'+ '<p class="jobslist">' + '%jobsUrl%' + '</p>' + '</center><' + 'br' + '>');
    //myFeaturedEmployersNoScroll.setTemplate('<center><a onmouseover="myFeaturedEmployersNoScroll.scroller.stopScroll();" onmouseout="myFeaturedEmployersNoScroll.scroller.startScroll();" onclick=window.location=(\'%homePageUrl%\')>%logoTag%<span class="company-name">%companyName%</span><br /><p class="jobslist">%jobsUrl%</p></a></center></ br>' );
    myFeaturedEmployersNoScroll.disableScroll();
    myFeaturedEmployersNoScroll.outputFromString(xmlPrefCo1);
    }


///////////////////////////////////////////////////////////////////////////
// CONFIG FOR ADICIO 'FEATURED JOBS' WIDGET

if(document.getElementById('featured-jobs'))
    {
    var myFeaturedJobs = new xmlScrollView();
    myFeaturedJobs.setOutPutElement('featured-jobs');
    myFeaturedJobs.setItemRoot('Job');
    myFeaturedJobs.declareVariable('Title', '%jobTitle%');
    myFeaturedJobs.declareVariable('Employer', '%jobEmployer%');
    myFeaturedJobs.declareVariable('Location', '%jobLocation%');
    myFeaturedJobs.declareVariable('Url', '%jobLink%');
    myFeaturedJobs.setTemplate('<a onmouseover="myFeaturedJobs.scroller.stopScroll();" onmouseout="myFeaturedJobs.scroller.startScroll();" onclick=window.location=(\'%jobLink%\')><' + 'span class="job-title">%jobTitle%<' + '/' + 'span><' + 'br /><' + 'span class="employer">%jobEmployer%<' + '/' + 'span> <' + 'span class="location"> - %jobLocation%<' + '/' + 'span><' + '/a>');
    myFeaturedJobs.setScrollDelay(30);
        myFeaturedJobs.outputFromString(xmlString);
    }


// WHEN THE DOCUMENT HAS LOADED
$(document).ready(function() {

    ///////////////////////////////////////////////////////////////////////////
    // SHARED BY ALL PAGES

    // add class to enable special css when javascript is available
    $('body').addClass('js');

    // remove link titles generated by WordPress
    $('#sidebar a').attr('title', '');
    $('#primary-nav a').attr('title', '');
    $('#footer-links a').attr('title', '');

    // remove link titles generated by WP Page Navi plugin
    $('.wp-pagenavi a').attr('title', '');

    // open PDFs in a new common window
    $('#content a[href*="pdf"]').attr('target', 'blank');


    ///////////////////////////////////////////////////////////////////////////
    //  HOME PAGE

    if (document.getElementById('slides'))
        {
        $('#slides img').removeClass('hide');
        $('#slides').innerfade({ 'speed':3000, 'timeout':10000 });
        }


    ///////////////////////////////////////////////////////////////////////////
    //  LIBRARY PAGE

    if (document.getElementById('promos'))
        {
        // make columns equal height
        var tallestPromo = Math.max($('#promo-1').height(), $('#promo-2').height());
        $('#promos li').height(tallestPromo);
        }


    ///////////////////////////////////////////////////////////////////////////
    // WRAP LATEST BLOG POST IN A LINK

    if (document.getElementById('to-blog'))
        {
        var blogLinkText = $('#to-blog a').text();
        $('#to-blog a').remove();
        $('#to-blog h5').text(blogLinkText);
        $('#to-blog').wrapInner('<a href="/blog/"></a>')
        }


    ///////////////////////////////////////////////////////////////////////////
    //  'ABOUT' WORDPRESS TEMPLATE

    if (document.getElementById('team-bios'))
        {
        var teamPhotosImg = $('#team-photos img');
        var teamBiosDiv = $('#team-bios div');
        alert('1');
        teamPhotosImg.tooltip({
            showURL: false,
            delay: 0,
            track: true,
            top: -10,
            left: 10,
            opacity: 0.90
            });

        // initially hide all bios
        teamBiosDiv.hide();

        // make the photo block tall enough to accomodate the longest bio
        $('#team-photos').css('height', '52em');

        $('body').click(function() {
            // fade out the current bio, if any
            teamBiosDiv.hide();
            // reset borders and opacity to defaults
            teamPhotosImg.removeClass('fade selected');
        });

        teamPhotosImg.click(function(){
                // reset borders to default, fade all images
                teamPhotosImg.addClass('fade').removeClass('selected');

                // change the border for the image that was clicked and make it fully opaque
                $(this).removeClass('fade').addClass('selected');

                // hide the current bio
                teamBiosDiv.hide();

                // get the index of the image that was clicked
                var imgIndex = teamPhotosImg.index(this);
                // show the corresponding bio
                teamBiosDiv.eq(imgIndex).show();
                });

        $('a, #team-photos img, #team-bios div').click(function(event){
            // prevent link clicks from triggering the body click function, see: http://j.mp/C6NBF
            event.stopPropagation();
            });
        }
});


/* =========================================================

// jquery.innerfade.js

// Datum: 2008-02-14
// Firma: Medienfreunde Hofmann & Baldes GbR
// Author: Torsten Baldes
// Mail: t.baldes@medienfreunde.com
// Web: http://medienfreunde.com

// based on the work of Matt Oakes http://portfolio.gizone.co.uk/applications/slideshow/
// and Ralf S. Engelschall http://trainofthoughts.org/

 *
 *  <ul id="news">
 *      <li>content 1</li>
 *      <li>content 2</li>
 *      <li>content 3</li>
 *  </ul>
 *
 *  $('#news').innerfade({
 *    animationtype: Type of animation 'fade' or 'slide' (Default: 'fade'),
 *    speed: Fading-/Sliding-Speed in milliseconds or keywords (slow, normal or fast) (Default: 'normal'),
 *    timeout: Time between the fades in milliseconds (Default: '2000'),
 *    type: Type of slideshow: 'sequence', 'random' or 'random_start' (Default: 'sequence'),
 *      containerheight: Height of the containing element in any css-height-value (Default: 'auto'),
 *    runningclass: CSS-Class which the container getŐs applied (Default: 'innerfade'),
 *    children: optional children selector (Default: null)
 *  });
 *

// ========================================================= */


(function($) {

    $.fn.innerfade = function(options) {
        return this.each(function() {
            $.innerfade(this, options);
        });
    };

    $.innerfade = function(container, options) {
        var settings = {
            'animationtype':    'fade',
            'speed':            'normal',
            'type':             'sequence',
            'timeout':          2000,
            'containerheight':  'auto',
            'runningclass':     'innerfade',
            'children':         null
        };
        if (options)
            $.extend(settings, options);
        if (settings.children === null)
            var elements = $(container).children();
        else
            var elements = $(container).children(settings.children);
        if (elements.length > 1) {
            $(container).css('height', settings.containerheight).addClass(settings.runningclass);
            for (var i = 0; i < elements.length; i++) {
                $(elements[i]).css('z-index', String(elements.length-i)).css('position', 'absolute').hide();
            };
            if (settings.type == "sequence") {
                setTimeout(function() {
                    $.innerfade.next(elements, settings, 1, 0);
                }, settings.timeout);
                $(elements[0]).show();
            } else if (settings.type == "random") {
                    var last = Math.floor ( Math.random () * ( elements.length ) );
                setTimeout(function() {
                    do {
                                                current = Math.floor ( Math.random ( ) * ( elements.length ) );
                                        } while (last == current );
                                        $.innerfade.next(elements, settings, current, last);
                }, settings.timeout);
                $(elements[last]).show();
                        } else if ( settings.type == 'random_start' ) {
                                settings.type = 'sequence';
                                var current = Math.floor ( Math.random () * ( elements.length ) );
                                setTimeout(function(){
                                    $.innerfade.next(elements, settings, (current + 1) %  elements.length, current);
                                }, settings.timeout);
                                $(elements[current]).show();
                        }   else {
                            alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
                        }
                }
    };

    $.innerfade.next = function(elements, settings, current, last) {
        if (settings.animationtype == 'slide') {
            $(elements[last]).slideUp(settings.speed);
            $(elements[current]).slideDown(settings.speed);
        } else if (settings.animationtype == 'fade') {
            $(elements[last]).fadeOut(settings.speed);
            $(elements[current]).fadeIn(settings.speed, function() {
                            removeFilter($(this)[0]);
                        });
        } else
            alert('Innerfade-animationtype must either be \'slide\' or \'fade\'');
        if (settings.type == "sequence") {
            if ((current + 1) < elements.length) {
                current = current + 1;
                last = current - 1;
            } else {
                current = 0;
                last = elements.length - 1;
            }
        } else if (settings.type == "random") {
            last = current;
            while (current == last)
                current = Math.floor(Math.random() * elements.length);
        } else
            alert('Innerfade-Type must either be \'sequence\', \'random\' or \'random_start\'');
        setTimeout((function() {
            $.innerfade.next(elements, settings, current, last);
        }), settings.timeout);
    };

})(jQuery);

// **** remove Opacity-Filter in ie ****
function removeFilter(element) {
    if(element.style.removeAttribute){
        element.style.removeAttribute('filter');
    }
}





