﻿$(document).ready(function () {

    loadJS();
    setGA();

    $("#personSelector").fancybox({
        'scrolling': 'no',
        'titleShow': false
    });

    $('div.FilialenBlock h3 a').click(function () {
        var fidID = $(this).attr('id');
        $('div#' + fidID).toggle();
    });

    $('img.popup').click(function () {
        var large = $(this).attr('src').replace('/thumbs', '/large');

        $.fancybox({
            'padding': 0,
            'href': large,
            'title': $(this).attr('alt'),
            'transitionIn': 'elastic',
            'transitionOut': 'elastic'
        });
    });

    $("div.commonSearch input").val('').focus();
    $("div.commonSearch input").blur(function () {
        if ($("div.commonSearch input").val() == '') {
            $("div.commonSearch input").val('Bestemming of naam accommodatie');
        }
    });
})

var buildChart = function (w, dataObject) {

    var holder = $(w);
    var holderId = $(holder).attr('id');

    var data = new google.visualization.DataTable();
    data.addColumn('string', 'maand');
    data.addColumn('number', 'Maximale temp.');
    data.addColumn('number', 'Minimale temp.');


    var formatter = new google.visualization.NumberFormat({ suffix: '&degree;' });
    formatter.format(data, 1);
    formatter.format(data, 2);

    if (dataObject[0].length > 3) {
        data.addColumn('number', 'Water temp.');
        formatter.format(data, 2);
    }

    data.addRows(dataObject);

    var options = {
        width: 740, height: 240,
        title: 'minimale en maximale temperatuur',
        chartArea: { left: 40, top: 10, width: "70%", height: "70%" },
        legendTextStyle: { color: '#666666' },
        colors: ['#ED145B', '#FFAE21', '#21BDFF']
    };

    var chart = new google.visualization.LineChart(document.getElementById(holderId));
    chart.draw(data, options);
}

var setupScripts = function () {

    setupHighLights();
    setSubmenuItems();
    hideShowLocationLinks();
    hideWeatherBlocks();
    showGallery();
    setupLinksForAction();
    setupFavos();
    setupInformationTabs();
    breadCrumbs();
    setupCarousel();
    setupMijnVX();


}

var getHighLights = function (id, name, type, location) {

	$('#' + location).hide();
	return;

    $('#' + location).html('<p style="text-align:center;"><img border="0" alt="laden" src="http://cdn.vx.nl/_resources/images/indicator.gif"/><br/><br/>Bezig met laden</p>');

    $.ajax({
        url: currentHostName() + 'InformationControl/Remote/Highlights.aspx?itemId=' + id + '&itemType=' + type + '&locationName=' + name,
        cache: true,
        success: function (data) {
            $('#' + location).html(data);
            //Cufon.refresh();
        },
        error: function (err) {
            $('#' + location).html('De aanbiedingen konden niet worden opgehaald');
        }
    });

}

var getFavos = function (id, location) {

    $('#' + location).html('<p style="text-align:center;"><img border="0" alt="laden" src="http://cdn.vx.nl/_resources/images/indicator.gif"/><br/><br/>Bezig met laden</p>');

    $.ajax({
        url: currentHostName() + 'InformationControl/Remote/Favos.aspx?itemId=' + id,
        cache: true,
        success: function (data) {
            
			if(data.length<100){$('#' + location).hide();}else{$('#' + location).html(data);}
        },
        error: function (err) {
            $('#' + location).html('De aanbiedingen konden niet worden opgehaald');
        }
    });

}

var getRecommendations = function (id) {

    $('#' + location).html('<p style="text-align:center;"><img border="0" alt="laden" src="http://cdn.vx.nl/_resources/images/indicator.gif"/><br/><br/>Bezig met laden</p>');

    $.ajax({
        url: currentHostName() + 'InformationControl/Remote/recommendations.aspx?itemId=' + id,
        cache: true,
        success: function (data) {
            $('#recommendationsLoader').html(data);
            //Cufon.refresh();
        },
        error: function (err) {
            $('#recommendationsLoader').html('De aanbiedingen konden niet worden opgehaald');
        }
    });

}

var showTabManual = function () {

    $('div.tabElement').hide();
    $('li a.locTabMenu').removeClass('active');
    $('#infoTab').addClass('active').show();

}

var setupCarousel = function () {

    if ($('#CarouselBanners').length > 0) {
        $('#CarouselBanners').cycle({
            fx: 'fade',
            pause: 1,
            speed: 1000,
            timeout: 5000
        });
    }
}

var OpenAccoGallery = function () {
    $('a.AccoGallery:first').trigger('click');
}

/** USER ACTIONS ********************************************************************************/

var saveAcco = function (sid) {
    $.ajax({
        url: currentHostName() + 'com/User.ashx?act=accosave&sid=' + sid,
        cache: false,
        success: function (data) {
            showBox("Bewaren", "Deze accommodatie is succesvol opgeslagen", true);
            setNumberMijnVX('a#savedAccos', data);
        }
    });
}

var setupMijnVX = function () {
    if ($('a#viewedAccos').length > 0) getViewedAccos();
    if ($('a#savedAccos').length > 0) getSavedAccos();
}

var getSavedAccos = function () {
    $.ajax({
        url: currentHostName() + 'com/User.ashx?act=savedcount',
        cache: false,
        success: function (data) {
            setNumberMijnVX('a#savedAccos', data);
        }
    });
}

var getViewedAccos = function () {
    $.ajax({
        url: currentHostName() + 'com/User.ashx?act=viewedcount',
        cache: false,
        success: function (data) {
            setNumberMijnVX('a#viewedAccos', data);
        }
    });
}

var setNumberMijnVX = function (id, value) {
    var counter = parseInt(value);
    if (counter > 0) {
        $(id + ' span').html('(' + counter.toString() + ')');
    } else {
        $(id + ' span').html('(0)');
    }

    $(id + ' span').fadeIn();
}

/************************************************************************************************/

function showMessage(title, msg) {

    $.fancybox(
		'<h2>' + title + '</h2><p>' + msg + '</p>',
		{
		    'autoDimensions': false,
		    'width': 350,
		    'height': 'auto',
		    'transitionIn': 'none',
		    'transitionOut': 'none'
		}
	);

}

function changeMap(w) { var url = currentHostName(); var imgmap = document.getElementById("VxMapImage"); imgmap.src = url + "/_resources/Images/Maps/" + w + ".gif"; }
function SetPersons(a, c, b, u) { var ran = Math.random(10000000000000); var adults = $("#" + a).val(); var children = $("#" + c).val(); var babies = $("#" + b).val(); if ((parseFloat(adults) + parseFloat(children) + parseFloat(babies)) > 8) { alert("U kunt met maximaal 8 personen reizen."); } else { var url = $("#" + u).val(); url += "&adults=" + adults; url += "&children=" + children; url += "&babies=" + babies; document.location = url; } }

var _gaq = _gaq || [];
function setGA() {
    _gaq.push(['_setAccount', 'UA-12090061-1']);
    _gaq.push(['_setDomainName', 'none']);
    _gaq.push(['_setAllowLinker', true]);
    _gaq.push(['_trackPageview']);
    (function () { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();
}

function loadJS() {
    var baseUrl = currentHostName();
    var listJS = new Array('fastsearch.js', 'cycle.js', 'qtip.js', 'modj.js');
    $(listJS).each(function () { loadScriptTag(baseUrl + '_resources/scripts/' + this); });

    //external resources
    loadScriptTag(('https:' == document.location.protocol ? 'https://www' : 'http://www') + '.googleadservices.com/pagead/conversion.js');
}

function loadScriptTag(url) {
    (function () { var sl = document.createElement('script'); sl.type = 'text/javascript'; sl.async = true; sl.src = url; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(sl, s); })();
}

/** doSendContactForm ************************************************/

var sendContactForm = function () {

    var canSend = true;

    var cfn = $('#name').val();
    var fea = $('#email').val();
    var fqt = $('#question').val();
    var fpn = $('#phonenumber').val();
    var cea = $('#filiaalEmailAdres').val();
    var sbj = $('#subjectLine').val();

    if (cfn == '') {
        canSend = false
        $('#name').addClass('inputError');
    } else $('#name').removeClass('inputError');

    if (!validEmail(fea)) {
        canSend = false
        $('#email').addClass('inputError');
    } else $('#email').removeClass('inputError');

    if (fqt == '') {
        canSend = false
        $('#question').addClass('inputError');
    } else $('#question').removeClass('inputError');

    if (fpn == '') {
        canSend = false
        $('#phonenumber').addClass('inputError');
    } else $('#phonenumber').removeClass('inputError');


    if (!canSend) {
        showBox('Niet alles is ingevuld', 'Niet alle velden zijn ingevuld, kijk het formulier na en probeer het nogmaals.', true);
    }
    else {
        showBox('Een momen geduld...', 'We zijn uw aanvraag aan het versturen...', false);

        var dataObject = "a=sc&cea=" + cea + "&cfn=" + cfn + "&fea=" + fea + "&fqt=" + fqt + "&fpn=" + fpn + "&sbj=" + sbj;
        $.ajax({
            type: "POST",
            url: currentHostName() + 'com/post.ashx',
            data: dataObject,
            cache: false,
            success: function (msg) {
                if (msg == "true") {
                    $.fancybox.close();
                    $('div.contactForm').html('Uw bericht is succesvol verstuurd, wij nemen spoedig contact met u op.');
                } else {
                    $.fancybox.close();
                    showBox('Er is een fout opgetreden', 'Helaas is er een fout opgetreden tijdens het versturen, probeer het nogmaals a.u.b.', true);
                }
            }
        });
    }
}
var showLoader = function () {

    $.fancybox({
        'scrolling': 'no',
        'href': '#loadingMessage',
        'titleShow': false,
        'transitionIn': 'elastic'
    });
}

var showBox = function (title, message, autoHide) {

    $.fancybox(
		    '<h1>' + title + '</h1><p></p><p>' + message + '</p>',
		    {
		        'autoDimensions': false,
		        'width': 420,
		        'height': 100,
		        'transitionIn': 'none',
		        'transitionOut': 'none',
		        'modal': true,
		        'scrolling': 'no'
		    }
	    );

    Cufon.refresh();
    if (autoHide) {
        setTimeout("$.fancybox.close()", 1500);
    }

}

/** doQuickSearchCountries *******************************************/
var currentLocation = '';

var searchCountries = function () {
    if ($('#vakantieBestemming').length > 0) {
        url = 'Data/Fuzzy.ashx?type=lsp';
        $('#vakantieBestemming').autocomplete(url, {
            parse: prep_data,
            formatItem: function (item) {
                return item.SearchText;
            }
        }).result(function (event, item) {
            currentLocation = item.Url;
        });
    }
}

var submitSearch = function () {

    var resultUrl = '';
    if ($("#vakantieBestemming").val() != '' && $("#vakantieBestemming").val() != 'bijv. Spanje of Griekenland' && currentLocation == '') {
        var actmp_url = "Data/Fuzzy.ashx?type=lsp&q=" + $("#vakantieBestemming").val();
        $.getJSON(actmp_url, function (data) {
            var items = [];
            if (data != null) {
                resultURL = data[0].Url;
            } else {
                showMessage('Mededeling', 'Deze bestemming hebben wij niet gevonden');
                $('#lspValue').focus();
                return;
            }
        });
    }
    else if ((currentLocation == '' || $("#vakantieBestemming").val() == 'bijv. Spanje of Griekenland')) {
        resultUrl = "alle_landen/zoeken/"
    }
    else if (currentLocation != '') {
        resultUrl = currentLocation;
    }
    else {
        resultUrl = "alle_landen/zoeken/"
    }

    var pl = $("#vakantieType").val();
    var dd = $('#vertrekWeek').val();
    var dr = $('#vakantieDuur').val();
    var fi = $('#fidValue').val();

    var locationURL = currentHostName() + pl + "/" + resultUrl + "?s=1&dd=" + dd + "&dur=" + dr + "&filiaalid=" + fi;
    document.location = locationURL;
}

var breadCrumbs = function () {
    $("#breadcrumbs ul li:last-child").addClass("last");
}

/** setNavigationItemsFavos ***********************************/
var favoWidth = 291;
var maxOffset = 0;
var setupFavos = function () {

    var totalItems = $('div#searchBookBanners div.searchBookBannerTipItem').length;
    maxOffset = ((totalItems - 2) * favoWidth) * -1;
    var holder = $('#searchBookBanners').width(291 * totalItems);

    if (totalItems == 2) $('#searchBookBanner a#previous').hide();
    $('#searchBookBanner a#next').hide();
}

var isScrolling = false;
var scrollFavos = function (direction) {
    var offset = favoWidth * direction;

    if (isScrolling) return;
    isScrolling = true;
    $.fx.off = false;
    var element = $('div#searchBookBanners');
    $(element).animate({ left: '+=' + offset }, 300, function () {

        if ($(element).position().left >= 0) {
            $('#searchBookBanner a#next').hide();

        }
        else if ($(element).position().left < 0) {
            $('#searchBookBanner a#next').show();
        }

        if ($(element).position().left <= maxOffset) {
            $('#searchBookBanner a#previous').hide();
        } else {
            $('#searchBookBanner a#previous').show();
        }

        isScrolling = false;
        $.fx.off = true;
    });
}


/** setPopupSearch *******************************************/
var setupLinksForAction = function () {

    $('a.travelInfoPop').fancybox({ 'width': 780, 'height': 660, 'type': 'iframe', 'centerOnScroll': true, 'scrolling': 'no', 'showCloseButton': true, 'enableEscapeButton': true, 'showNavArrows' : false });
    $('a.vacatureLink').fancybox({ 'width': 780, 'height': 550, 'type': 'iframe', 'centerOnScroll': true, 'scrolling': 'auto', 'showCloseButton': true, 'enableEscapeButton': true, 'showNavArrows': false });
    $('a.filiaalFoto').fancybox({ 'type': 'image', 'centerOnScroll': true, 'scrolling': 'auto', 'showCloseButton': true, 'enableEscapeButton': true, 'showNavArrows': false });
    $('a.inlineLinker').fancybox({ 'type': 'inline', 'centerOnScroll': true, 'titleShow': false, 'scrolling': 'auto', 'showCloseButton': true, 'enableEscapeButton': true, 'showNavArrows' : false });
    $('a.myaccos').fancybox({ 'width': 780, 'height': 660, 'type': 'iframe', 'centerOnScroll': true, 'titleShow': false, 'scrolling': 'no', 'showCloseButton': true, 'enableEscapeButton': true, 'showNavArrows': false });
    $('a.iframeLinker').fancybox({ 'width': 400, 'height': 180, 'type': 'iframe', 'centerOnScroll': true, 'titleShow': false, 'scrolling': 'auto', 'showCloseButton': true, 'enableEscapeButton': true, 'showNavArrows': false });
    $('a.iframeMedium').fancybox({ 'width': 640, 'height': 600, 'type': 'iframe', 'centerOnScroll': true, 'titleShow': false, 'scrolling': 'auto', 'showCloseButton': true, 'enableEscapeButton': true, 'showNavArrows': false });
    $('a.iframeLarge').fancybox({ 'width': 1020, 'height': 600, 'type': 'iframe', 'centerOnScroll': true, 'titleShow': false, 'scrolling': 'auto', 'showCloseButton': true, 'enableEscapeButton': true, 'showNavArrows': false });
    $('a.iframeNormal').fancybox({ 'width': 920, 'height': 600, 'type': 'iframe', 'centerOnScroll': true, 'titleShow': false, 'scrolling': 'no', 'showCloseButton': true, 'enableEscapeButton': true, 'showNavArrows': false });
    $('a[rel="zinfogal"]').fancybox({ 'width': 1020, 'height': 600, 'type': 'image', 'centerOnScroll': true, 'titleShow': false, 'scrolling': 'auto', 'showCloseButton': true, 'enableEscapeButton': true });

    $("#loadingMessage").fancybox();

    $('#ctl00_FilterHolder_FilterControlObject_ddSelector').change(function () {
        showLoader();
    });

    $('a[href*="&bki="]').click(function () {
        $('#bookingMsg').html('De beschikbaarheid wordt gecontroleerd<br/>bij alle reisorganisaties');
        showLoader();
    });

    $('a[href*="/boeken.aspx"]').click(function () {
        showLoader();
    });

    $('a[href*="/boeken/"]').click(function () {
        showLoader();
    });

    $('a[href*="/zoeken/"]').click(function () {
        showLoader();
    });

    $('div.ttip').each(function () {
        $("#tt" + this.id).hide();
        $(this).qtip({
            content: $("#tt" + this.id).html(),
            position: {
                my: 'middle right',
                at: 'left middle',
                target: $(this),
                adjust: { y: 30 }
            },
            style: { classes: 'ui-tooltip-blue ui-tooltip-shadow' }
        }
        );
    });
}

var blockPrice = function () {
    $('#bookingMsg').html('De goedkoopste vanaf prijzen worden opgezocht');
    showLoader();
}

var submitFiliaalSearch = function () {
    document.location = 'filialen/?pc=' + $('#postcodePlaats').val();
}

prep_data = function (data) {
    if (data != null && data != "") {
        tmp = $.parseJSON(data);
        parsed_data = [];
        for (i = 0; i < tmp.length; i++) {
            obj = tmp[i];
            parsed_data[i] = {
                data: obj,
                value: obj.Url,
                result: obj.MainText
            };
        }
        return parsed_data;
    } else { return []; }

}

/** setHighLights ****************************************************/
var currentItemsCaroussel = 0;
var totalItemsCaroussel = 0;
var offsetItems = 5;
var setupHighLights = function () {
    if ($('div.highlightCarousel ul li').length > 0) {
        var total = $('div.highlightCarousel ul li').length;
        totalItemsCaroussel = Math.ceil(total / offsetItems);
        if (totalItemsCaroussel > 1) {
            $('span.hlTitleCarousel').html("Highlights 1/" + totalItemsCaroussel);
            $('div.HighlightsHolder')._scrollable();
        } else {
            $("div.highlightCarousel a.previous").hide();
            $("div.highlightCarousel a.next").hide();
        }
    }
}

var moveHighLights = function (w) {
    currentItemsCaroussel += w;
    if (currentItemsCaroussel < 0) { currentItemsCaroussel = 0; } else if (currentItemsCaroussel >= totalItemsCaroussel) { currentItemsCaroussel = 0; }
    $('span.hlTitleCarousel').html("Highlights " + (currentItemsCaroussel + 1) + "/" + totalItemsCaroussel);
    $('div.HighlightsHolder').scrollTo($('div.HighlightsHolder ul li:eq(' + (currentItemsCaroussel * offsetItems) + ')'), 800);

    if ((currentItemsCaroussel + 1) >= totalItemsCaroussel) {
        $("div.highlightCarousel a.next").addClass('deActive')
    } else {
        $("div.highlightCarousel a.next").removeClass('deActive');
    }

    if ((currentItemsCaroussel - 1) < 0) { $("div.highlightCarousel a.previous").addClass('deActive'); } else { $("div.highlightCarousel a.previous").removeClass('deActive'); }
    Cufon.refresh();
}

function submitEnterSearch(e) {
    var keycode;
    if (window.event) {
        keycode = window.event.keyCode;
    }
    else if (e) {
        keycode = e.which;
    }
    else {
        return true;
    }

    if (keycode == 13) {
        submitSearch();
        return false;
    }
    else {
        return true;
    }
}

function submitEnterZip(e) {
    var keycode;
    if (window.event) {
        keycode = window.event.keyCode;
    }
    else if (e) {
        keycode = e.which;
    }
    else {
        return true;
    }

    if (keycode == 13) {
        eZipCode();
        return false;
    }
    else {
        return true;
    }
}

function submitEnterRoute(e) {
    var keycode;
    if (window.event) {
        keycode = window.event.keyCode;
    }
    else if (e) {
        keycode = e.which;
    }
    else {
        return true;
    }

    if (keycode == 13) {
        DirectRoute();
        return false;
    }
    else {
        return true;
    }
}

function eZipCode() { var loc = $('#input_filiaal').val(); if (loc != '') document.location = "../filialen/?pc=" + loc; else return false; }

var geocoder;

function DirectRoute() {
    geocoder = new google.maps.Geocoder();

    var address = $('#userAdresField').val();
    var location = $('#FiliaalLocation').val();

    var arr = location.split(';');
    var dest = new google.maps.LatLng(arr[0], arr[1]);
    if (geocoder) {

        $.fancybox.showActivity();

        geocoder.geocode({ 'address': address + ' NL' }, function (results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                var position = results[0].geometry.location
                var directionsService = new google.maps.DirectionsService();
                var directionsDisplay = new google.maps.DirectionsRenderer();
                directionsDisplay.setPanel(document.getElementById("routePlanner"));

                var request = {
                    destination: dest,
                    origin: position,
                    travelMode: google.maps.DirectionsTravelMode.DRIVING,
                    unitSystem: google.maps.DirectionsUnitSystem.METRIC
                };
                directionsService.route(request, function (response, status) {
                    if (status == google.maps.DirectionsStatus.OK) {

                        $('.option_directions').remove();

                        document.getElementById("routePlanner").style.display = 'block';
                        directionsDisplay.setDirections(response);
                        document.getElementById("routePlanner").innerHTML += "<div class='option_directions'><a href='javascript:PrintDirections();'>Print uw routebeschrijving</a></div><p class='clear'>&nbsp;</p>";
                        $('html, body').animate({ scrollTop: 0 }, 'slow', function () { $.fancybox.center(); });
                        $.fancybox.hideActivity();
                    }
                    else {
                        alert(status);
                    }
                });

            } else {
                alert("Uw postcode wordt niet herkend");
            }
        });
    }
}

function CloseDirections() { document.getElementById("routePlanner").innerHTML = ""; document.getElementById("routePlanner").style.display = 'none'; }
//linkelm.href = "http://www.vx.nl/adore_assets/css/vx2010.css";
function PrintDirections() { var prtContent = document.getElementById("routePlanner"); var WinPrint = window.open('', '', 'left=0,top=0,width=1,height=1,t oolbar=0,scrollbars=0,status=0'); var linkelm = document.createElement("link"); linkelm.rel = "stylesheet"; linkelm.type = "text/css"; WinPrint.document.getElementsByTagName("head")[0].appendChild(linkelm); WinPrint.document.write(prtContent.innerHTML); WinPrint.document.close(); WinPrint.focus(); WinPrint.print(); WinPrint.close(); }
String.prototype.stripSpaces = function () { return this.replace(/\s/g, ""); };

/** setLocationInformationLinks **************************************/

hideShowLocationLinks = function () {

    actShowLocationLinks('div.filterBlock', 3, 3);
    actShowLocationLinks('div.themaCountries', 8, 4);
}

var actShowLocationLinks = function (who, count, show) {
    $(who).each(function () {
        var itemCount = $('li', this).length;
        if (itemCount > count) {
            $('li:gt(' + show + ')', this).hide();
            $('a.moreLess', this).click(function () {
                var collection = $('li:gt(' + show + ')', $(this).prev())
                if ($(collection[0]).is(":visible")) $(this).html('meer'); else $(this).html('minder');
                $(this).toggleClass('collapsed');
                $(collection).toggle();
            });
        } else {
            $('a.moreLess', this).hide();
        }
    });
}

var menuClick = function () { }

var setupInformationTabs = function () {

    $('li a.locTabMenu').click(function () {

        $('div.tabElement').hide();
        $('li a.locTabMenu').removeClass('active');
        $(this).addClass('active');
        var activeTab = $(this).attr('rel');
        $('#' + activeTab).show();

        if (activeTab == 'weatherTab') {
            hideWeatherBlocks();
        }

    });

}


/** setFilters *******************************************************/

var showHideFilters = function (q) {

    var selector = $('#' + q);
    var collection = $('li:gt(2)', selector)
    if ($(collection[0]).is(":visible")) $('#tr' + q).html('meer filters tonen');
    else $('#tr' + q).html('minder filters tonen');
    $(collection).toggle()

}

var showHideCurrentFilters = function () {

    var collection = $('a.searchBookSelecetionDeleteBt:gt(2)');
    if ($(collection[0]).is(":visible")) $('#aCurrentFilters').html('bekijk alle geselecteerde filters');
    else $('#aCurrentFilters').html('verberg geselecteerde filters');

    $(collection).toggle()
}

/** setMenuItems ************************************************/

var setSubmenuItems = function () {

    $.fx.off = true;

    $("div.closeButton").click(function () {
        $('div.mainMenuDropDown').hide('0');
    });

    $("div#mainMenu ul li.mmi").each(function () {
        var loc = window.location.href.toString().toLowerCase();
        if (loc.indexOf($(this).attr("id")) > -1) {
            $('a span', this).addClass("isActive");
        }
    });

    $("div#mainMenu ul li.nro").click(
        function () {
            $('div.mainMenuDropDown').hide('0');
            $('div#mainMenu ul li a').removeClass("active");
            $('div#mainMenu ul li a span').removeClass("active");
        }
    );

    var position = $("div#mainMenu").offset();
    var currentItem = null;

    $("div#mainMenu ul li.mmi").click(function () {

        $('div.mainMenuDropDown').hide();
        $('a', currentItem).removeClass("active");
        $('a span', currentItem).removeClass("active");

        currentItem = this;

        if ($(this).hasClass("special")) {
            position = $(this).offset();
        } else {
            position = $("div#mainMenu").offset();
        }

        var timeout = $(this).data("timeout");
        if (timeout) clearTimeout(timeout);

        $('div#mainMenu ul li a').removeClass("active");
        $('div#mainMenu ul li a span').removeClass("active");

        $('a', currentItem).addClass("active");
        $('a span', currentItem).addClass("active");

        $('#' + $(this).attr('rel')).css({ "left": (position.left) + "px", "top": (position.top + 39) + "px" });
        $('#' + $(this).attr('rel')).show(0);

    });


    $("div#mainMenu ul li.mmi").hover(
        function () {
        },

        function () {

            var timeout = $(this).data("timeout");

            $('#' + $(this).attr('rel')).hover(
                function () {
                    if (timeout) clearTimeout(timeout);
                    $(this).data("timeout", setTimeout($.proxy(function () {
                        $(this).show();
                    }, this), 500));
                },

                function () {
                    $(this).data("timeout", setTimeout($.proxy(function () {
                        $(this).hide('0');
                        $('a', currentItem).removeClass("active");
                        $('a span', currentItem).removeClass("active");
                    }, this), 500));
                }
            );

            $(this).data("timeout", setTimeout($.proxy(function () {
            }, this), 500))
        });
}

/** SetLeaveScript *********************************************************/
var setLeaveScript = function () {
    //setLeaveScript();
    var siteURL = "http://" + top.location.host.toString();
    var internalLinks = $("a[href^='" + siteURL + "'], a[href^='/'], a[href^='./'], a[href^='../'], a[href^='#']");
    $('#modalLoader').jqm({ trigger: 'a.jq' });
}


var hideWeatherBlocks = function () {
    w = $('div.weatherItem')[0];
    var location = $('div.smallMaps', $(w).parent()).attr("id");
    var country = $('div.smallMaps', $(w).parent()).attr("rel");

    codeAddress(location, country);
    $('h3', w).addClass('open');
    $('div.weatherContainer div.weatherData:gt(0)').hide();
}


var toggleWeather = function (w) {

    $('div.weatherData:visible').slideToggle('slow', function () {
        $('h3.open').removeClass('open');
        $('div.weatherData', $(w).parent()).slideToggle();
        $(w).addClass('open');

        var location = $('div.smallMaps', $(w).parent()).attr("id");
        var country = $('div.smallMaps', $(w).parent()).attr("rel");

        codeAddress(location, country);
    })
}

/** MAPS *******************************************************************/

function codeMaps(latlonzoom) {

    if (latlonzoom != '') {
        var arr = latlonzoom.split(';');

        var latlng = new google.maps.LatLng(arr[0], arr[1]);
        var myOptions = {
            zoom: 15,
            center: latlng,
            mapTypeId: google.maps.MapTypeId.SATELLITE
        };

        var image = new google.maps.MarkerImage(currentHostName() + '_resources/images/marker.png', new google.maps.Size(32, 32), new google.maps.Point(0, 0), new google.maps.Point(0, 32));

        var map = new google.maps.Map(document.getElementById("branchInfoMap"), myOptions);
        var marker = new google.maps.Marker({
            position: latlng,
            map: map,
            animation: google.maps.Animation.DROP,
            icon: image
        });
    }
}

function codeAddress(location, country) {

    var address = location + ' ' + country;
    var geocoder = new google.maps.Geocoder();
    var myOptions = { zoom: 3, mapTypeId: google.maps.MapTypeId.SATELLITE }
    geocoder.geocode({ 'address': address }, function (results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            var map = new google.maps.Map(document.getElementById(location), myOptions);
            map.setCenter(results[0].geometry.location);
            var marker = new google.maps.Marker({
                map: map,
                position: results[0].geometry.location
            });

            google.maps.event.addListener(marker, 'click', function (event) { openLargeMap(results[0].geometry.location); });
        }
    });
}

var openLargeMap = function (latLng) {
    var myOptions = { zoom: 10, mapTypeId: google.maps.MapTypeId.TERRAIN }
    $('#googleMapsLarge').remove();
    var gml = $('<div id="googleMapsLarge"></div>');
    $('body').prepend(gml);
    $(gml).jqm({ modal: false });
    $(gml).jqmShow();
    var map = new google.maps.Map(document.getElementById("googleMapsLarge"), myOptions);
    map.setCenter(latLng);
}

var showGallery = function () {

    if (typeof fancybox == 'function') {

        $("a[rel=zinfogal]").fancybox({
            'transitionIn': 'none',
            'transitionOut': 'none',
            'titlePosition': 'over',
            'titleFormat': function (title, currentArray, currentIndex, currentOpts) {
                return '<span id="fancybox-title-over">Afbeelding ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
            }
        });
    }
}

var validEmail = function (address) {
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    if (reg.test(address) == false) {
        return false;
    }
    else { return true; }
}

var currentHostName = function () {

    if (!window.location.origin) {
        window.location.origin = window.location.protocol + "//" + window.location.host + "/";
    }

    if (window.location.origin.substr(window.location.origin.length - 1, 1) != '/') {
        return window.location.origin + '/';
    } else {
        return window.location.origin;
    }

}

var mapSwitch = function (hide, show) { $('img#' + hide).fadeOut(); $('img#' + show).fadeIn(); }


//E-heroes : Scrolll Library --------------------------------------
; (function (d) { var k = d.scrollTo = function (a, i, e) { d(window).scrollTo(a, i, e) }; k.defaults = { axis: 'xy', duration: parseFloat(d.fn.jquery) >= 1.3 ? 0 : 1 }; k.window = function (a) { return d(window)._scrollable() }; d.fn._scrollable = function () { return this.map(function () { var a = this, i = !a.nodeName || d.inArray(a.nodeName.toLowerCase(), ['iframe', '#document', 'html', 'body']) != -1; if (!i) return a; var e = (a.contentWindow || a).document || a.ownerDocument || a; return d.browser.safari || e.compatMode == 'BackCompat' ? e.body : e.documentElement }) }; d.fn.scrollTo = function (n, j, b) { if (typeof j == 'object') { b = j; j = 0 } if (typeof b == 'function') b = { onAfter: b }; if (n == 'max') n = 9e9; b = d.extend({}, k.defaults, b); j = j || b.speed || b.duration; b.queue = b.queue && b.axis.length > 1; if (b.queue) j /= 2; b.offset = p(b.offset); b.over = p(b.over); return this._scrollable().each(function () { var q = this, r = d(q), f = n, s, g = {}, u = r.is('html,body'); switch (typeof f) { case 'number': case 'string': if (/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)) { f = p(f); break } f = d(f, this); case 'object': if (f.is || f.style) s = (f = d(f)).offset() } d.each(b.axis.split(''), function (a, i) { var e = i == 'x' ? 'Left' : 'Top', h = e.toLowerCase(), c = 'scroll' + e, l = q[c], m = k.max(q, i); if (s) { g[c] = s[h] + (u ? 0 : l - r.offset()[h]); if (b.margin) { g[c] -= parseInt(f.css('margin' + e)) || 0; g[c] -= parseInt(f.css('border' + e + 'Width')) || 0 } g[c] += b.offset[h] || 0; if (b.over[h]) g[c] += f[i == 'x' ? 'width' : 'height']() * b.over[h] } else { var o = f[h]; g[c] = o.slice && o.slice(-1) == '%' ? parseFloat(o) / 100 * m : o } if (/^\d+$/.test(g[c])) g[c] = g[c] <= 0 ? 0 : Math.min(g[c], m); if (!a && b.queue) { if (l != g[c]) t(b.onAfterFirst); delete g[c] } }); t(b.onAfter); function t(a) { r.animate(g, j, b.easing, a && function () { a.call(this, n, b) }) } }).end() }; k.max = function (a, i) { var e = i == 'x' ? 'Width' : 'Height', h = 'scroll' + e; if (!d(a).is('html,body')) return a[h] - d(a)[e.toLowerCase()](); var c = 'client' + e, l = a.ownerDocument.documentElement, m = a.ownerDocument.body; return Math.max(l[h], m[h]) - Math.min(l[c], m[c]) }; function p(a) { return typeof a == 'object' ? a : { top: a, left: a} } })(jQuery);

; (function ($) {

    $.fn.extend({
        autocomplete: function (urlOrData, options) {
            var isUrl = typeof urlOrData == "string";
            options = $.extend({}, $.Autocompleter.defaults, {
                url: isUrl ? urlOrData : null,
                data: isUrl ? null : urlOrData,
                delay: isUrl ? $.Autocompleter.defaults.delay : 10,
                max: options && !options.scroll ? 10 : 150
            }, options);

            // if highlight is set to false, replace it with a do-nothing function
            options.highlight = options.highlight || function (value) { return value; };

            // if the formatMatch option is not specified, then use formatItem for backwards compatibility
            options.formatMatch = options.formatMatch || options.formatItem;

            return this.each(function () {
                new $.Autocompleter(this, options);
            });
        },
        result: function (handler) {
            return this.bind("result", handler);
        },
        search: function (handler) {
            return this.trigger("search", [handler]);
        },
        flushCache: function () {
            return this.trigger("flushCache");
        },
        setOptions: function (options) {
            return this.trigger("setOptions", [options]);
        },
        unautocomplete: function () {
            return this.trigger("unautocomplete");
        }
    });

    $.Autocompleter = function (input, options) {

        var KEY = {
            UP: 38,
            DOWN: 40,
            DEL: 46,
            TAB: 9,
            RETURN: 13,
            ESC: 27,
            COMMA: 188,
            PAGEUP: 33,
            PAGEDOWN: 34,
            BACKSPACE: 8
        };

        // Create $ object for input element
        var $input = $(input).attr("autocomplete", "off").addClass(options.inputClass);

        var timeout;
        var previousValue = "";
        var cache = $.Autocompleter.Cache(options);
        var hasFocus = 0;
        var lastKeyPressCode;
        var config = {
            mouseDownOnSelect: false
        };
        var select = $.Autocompleter.Select(options, input, selectCurrent, config);

        var blockSubmit;

        // prevent form submit in opera when selecting with return key
        $.browser.opera && $(input.form).bind("submit.autocomplete", function () {
            if (blockSubmit) {
                blockSubmit = false;
                return false;
            }
        });

        // only opera doesn't trigger keydown multiple times while pressed, others don't work with keypress at all
        $input.bind(($.browser.opera ? "keypress" : "keydown") + ".autocomplete", function (event) {
            // track last key pressed
            lastKeyPressCode = event.keyCode;
            switch (event.keyCode) {

                case KEY.UP:
                    event.preventDefault();
                    if (select.visible()) {
                        select.prev();
                    } else {
                        onChange(0, true);
                    }
                    break;

                case KEY.DOWN:
                    event.preventDefault();
                    if (select.visible()) {
                        select.next();
                    } else {
                        onChange(0, true);
                    }
                    break;

                case KEY.PAGEUP:
                    event.preventDefault();
                    if (select.visible()) {
                        select.pageUp();
                    } else {
                        onChange(0, true);
                    }
                    break;

                case KEY.PAGEDOWN:
                    event.preventDefault();
                    if (select.visible()) {
                        select.pageDown();
                    } else {
                        onChange(0, true);
                    }
                    break;

                // matches also semicolon     
                case options.multiple && $.trim(options.multipleSeparator) == "," && KEY.COMMA:
                case KEY.TAB:
                case KEY.RETURN:
                    if (selectCurrent()) {
                        // stop default to prevent a form submit, Opera needs special handling
                        event.preventDefault();
                        blockSubmit = true;
                        return false;
                    }
                    break;

                case KEY.ESC:
                    select.hide();
                    break;

                default:
                    clearTimeout(timeout);
                    timeout = setTimeout(onChange, options.delay);
                    break;
            }
        }).focus(function () {
            // track whether the field has focus, we shouldn't process any
            // results if the field no longer has focus
            hasFocus++;
        }).blur(function () {
            hasFocus = 0;
            if (!config.mouseDownOnSelect) {
                hideResults();
            }
        }).click(function () {
            // show select when clicking in a focused field
            if (hasFocus++ > 1 && !select.visible()) {
                onChange(0, true);
            }
        }).bind("search", function () {
            // TODO why not just specifying both arguments?
            var fn = (arguments.length > 1) ? arguments[1] : null;
            function findValueCallback(q, data) {
                var result;
                if (data && data.length) {
                    for (var i = 0; i < data.length; i++) {
                        if (data[i].result.toLowerCase() == q.toLowerCase()) {
                            result = data[i];
                            break;
                        }
                    }
                }
                if (typeof fn == "function") fn(result);
                else $input.trigger("result", result && [result.data, result.value]);
            }
            $.each(trimWords($input.val()), function (i, value) {
                request(value, findValueCallback, findValueCallback);
            });
        }).bind("flushCache", function () {
            cache.flush();
        }).bind("setOptions", function () {
            $.extend(options, arguments[1]);
            // if we've updated the data, repopulate
            if ("data" in arguments[1])
                cache.populate();
        }).bind("unautocomplete", function () {
            select.unbind();
            $input.unbind();
            $(input.form).unbind(".autocomplete");
        });


        function selectCurrent() {
            var selected = select.selected();
            if (!selected)
                return false;

            var v = selected.result;
            previousValue = v;

            if (options.multiple) {
                var words = trimWords($input.val());
                if (words.length > 1) {
                    v = words.slice(0, words.length - 1).join(options.multipleSeparator) + options.multipleSeparator + v;
                }
                v += options.multipleSeparator;
            }

            $input.val(v);
            hideResultsNow();
            $input.trigger("result", [selected.data, selected.value]);
            return true;
        }

        function onChange(crap, skipPrevCheck) {
            if (lastKeyPressCode == KEY.DEL) {
                select.hide();
                return;
            }

            var currentValue = $input.val();

            if (!skipPrevCheck && currentValue == previousValue)
                return;

            previousValue = currentValue;

            currentValue = lastWord(currentValue);
            if (currentValue.length >= options.minChars) {
                $input.addClass(options.loadingClass);
                if (!options.matchCase)
                    currentValue = currentValue.toLowerCase();
                request(currentValue, receiveData, hideResultsNow);
            } else {
                stopLoading();
                select.hide();
            }
        };

        function trimWords(value) {
            if (!value) {
                return [""];
            }
            var words = value.split(options.multipleSeparator);
            var result = [];
            $.each(words, function (i, value) {
                if ($.trim(value))
                    result[i] = $.trim(value);
            });
            return result;
        }

        function lastWord(value) {
            if (!options.multiple)
                return value;
            var words = trimWords(value);
            return words[words.length - 1];
        }

        // fills in the input box w/the first match (assumed to be the best match)
        // q: the term entered
        // sValue: the first matching result
        function autoFill(q, sValue) {
            // autofill in the complete box w/the first match as long as the user hasn't entered in more data
            // if the last user key pressed was backspace, don't autofill
            if (options.autoFill && (lastWord($input.val()).toLowerCase() == q.toLowerCase()) && lastKeyPressCode != KEY.BACKSPACE) {
                // fill in the value (keep the case the user has typed)
                $input.val($input.val() + sValue.substring(lastWord(previousValue).length));
                // select the portion of the value not typed by the user (so the next character will erase)
                $.Autocompleter.Selection(input, previousValue.length, previousValue.length + sValue.length);
            }
        };

        function hideResults() {
            clearTimeout(timeout);
            timeout = setTimeout(hideResultsNow, 200);
        };

        function hideResultsNow() {
            var wasVisible = select.visible();
            select.hide();
            clearTimeout(timeout);
            stopLoading();
            if (options.mustMatch) {
                // call search and run callback
                $input.search(
				function (result) {
				    // if no value found, clear the input box
				    if (!result) {
				        if (options.multiple) {
				            var words = trimWords($input.val()).slice(0, -1);
				            $input.val(words.join(options.multipleSeparator) + (words.length ? options.multipleSeparator : ""));
				        }
				        else
				            $input.val("");
				    }
				}
			);
            }
            if (wasVisible)
            // position cursor at end of input field
                $.Autocompleter.Selection(input, input.value.length, input.value.length);
        };

        function receiveData(q, data) {
            if (data && data.length && hasFocus) {
                stopLoading();
                select.display(data, q);
                autoFill(q, data[0].value);
                select.show();
            } else {
                hideResultsNow();
            }
        };

        function request(term, success, failure) {
            if (!options.matchCase)
                term = term.toLowerCase();
            var data = cache.load(term);
            // recieve the cached data
            if (data && data.length) {
                success(term, data);
                // if an AJAX url has been supplied, try loading the data now
            } else if ((typeof options.url == "string") && (options.url.length > 0)) {

                var extraParams = {
                    timestamp: +new Date()
                };
                $.each(options.extraParams, function (key, param) {
                    extraParams[key] = typeof param == "function" ? param() : param;
                });

                $.ajax({
                    // try to leverage ajaxQueue plugin to abort previous requests
                    mode: "abort",
                    // limit abortion to this input
                    port: "autocomplete" + input.name,
                    dataType: options.dataType,
                    url: options.url,
                    data: $.extend({
                        q: lastWord(term),
                        limit: options.max
                    }, extraParams),
                    success: function (data) {
                        var parsed = options.parse && options.parse(data) || parse(data);
                        cache.add(term, parsed);
                        success(term, parsed);
                    }
                });
            } else {
                // if we have a failure, we need to empty the list -- this prevents the the [TAB] key from selecting the last successful match
                select.emptyList();
                failure(term);
            }
        };

        function parse(data) {
            var parsed = [];
            var rows = data.split("\n");
            for (var i = 0; i < rows.length; i++) {
                var row = $.trim(rows[i]);
                if (row) {
                    row = row.split("|");
                    parsed[parsed.length] = {
                        data: row,
                        value: row[0],
                        result: options.formatResult && options.formatResult(row, row[0]) || row[0]
                    };
                }
            }
            return parsed;
        };

        function stopLoading() {
            $input.removeClass(options.loadingClass);
        };

    };

    $.Autocompleter.defaults = {
        inputClass: "ac_input",
        resultsClass: "ac_results",
        loadingClass: "ac_loading",
        minChars: 1,
        delay: 400,
        matchCase: false,
        matchSubset: true,
        matchContains: false,
        cacheLength: 10,
        max: 100,
        mustMatch: false,
        extraParams: {},
        selectFirst: true,
        formatItem: function (row) { return row[0]; },
        formatMatch: null,
        autoFill: false,
        width: 0,
        multiple: false,
        multipleSeparator: ", ",
        highlight: function (value, term) {
            return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
        },
        scroll: true,
        scrollHeight: 180
    };

    $.Autocompleter.Cache = function (options) {

        var data = {};
        var length = 0;

        function matchSubset(s, sub) {
            if (!options.matchCase)
                s = s.toLowerCase();
            var i = s.indexOf(sub);
            if (options.matchContains == "word") {
                i = s.toLowerCase().search("\\b" + sub.toLowerCase());
            }
            if (i == -1) return false;
            return i == 0 || options.matchContains;
        };

        function add(q, value) {
            if (length > options.cacheLength) {
                flush();
            }
            if (!data[q]) {
                length++;
            }
            data[q] = value;
        }

        function populate() {
            if (!options.data) return false;
            // track the matches
            var stMatchSets = {},
			nullData = 0;

            // no url was specified, we need to adjust the cache length to make sure it fits the local data store
            if (!options.url) options.cacheLength = 1;

            // track all options for minChars = 0
            stMatchSets[""] = [];

            // loop through the array and create a lookup structure
            for (var i = 0, ol = options.data.length; i < ol; i++) {
                var rawValue = options.data[i];
                // if rawValue is a string, make an array otherwise just reference the array
                rawValue = (typeof rawValue == "string") ? [rawValue] : rawValue;

                var value = options.formatMatch(rawValue, i + 1, options.data.length);
                if (value === false)
                    continue;

                var firstChar = value.charAt(0).toLowerCase();
                // if no lookup array for this character exists, look it up now
                if (!stMatchSets[firstChar])
                    stMatchSets[firstChar] = [];

                // if the match is a string
                var row = {
                    value: value,
                    data: rawValue,
                    result: options.formatResult && options.formatResult(rawValue) || value
                };

                // push the current match into the set list
                stMatchSets[firstChar].push(row);

                // keep track of minChars zero items
                if (nullData++ < options.max) {
                    stMatchSets[""].push(row);
                }
            };

            // add the data items to the cache
            $.each(stMatchSets, function (i, value) {
                // increase the cache size
                options.cacheLength++;
                // add to the cache
                add(i, value);
            });
        }

        // populate any existing data
        setTimeout(populate, 25);

        function flush() {
            data = {};
            length = 0;
        }

        return {
            flush: flush,
            add: add,
            populate: populate,
            load: function (q) {
                if (!options.cacheLength || !length)
                    return null;
                /* 
                * if dealing w/local data and matchContains than we must make sure
                * to loop through all the data collections looking for matches
                */
                if (!options.url && options.matchContains) {
                    // track all matches
                    var csub = [];
                    // loop through all the data grids for matches
                    for (var k in data) {
                        // don't search through the stMatchSets[""] (minChars: 0) cache
                        // this prevents duplicates
                        if (k.length > 0) {
                            var c = data[k];
                            $.each(c, function (i, x) {
                                // if we've got a match, add it to the array
                                if (matchSubset(x.value, q)) {
                                    csub.push(x);
                                }
                            });
                        }
                    }
                    return csub;
                } else
                // if the exact item exists, use it
                    if (data[q]) {
                        return data[q];
                    } else
                        if (options.matchSubset) {
                            for (var i = q.length - 1; i >= options.minChars; i--) {
                                var c = data[q.substr(0, i)];
                                if (c) {
                                    var csub = [];
                                    $.each(c, function (i, x) {
                                        if (matchSubset(x.value, q)) {
                                            csub[csub.length] = x;
                                        }
                                    });
                                    return csub;
                                }
                            }
                        }
                return null;
            }
        };
    };

    $.Autocompleter.Select = function (options, input, select, config) {
        var CLASSES = {
            ACTIVE: "ac_over"
        };

        var listItems,
		active = -1,
		data,
		term = "",
		needsInit = true,
		element,
		list;

        // Create results
        function init() {
            if (!needsInit)
                return;
            element = $("<div/>")
		.hide()
		.addClass(options.resultsClass)
		.css("position", "absolute")
		.appendTo(document.body);

            list = $("<ul/>").appendTo(element).mouseover(function (event) {
                if (target(event).nodeName && target(event).nodeName.toUpperCase() == 'LI') {
                    active = $("li", list).removeClass(CLASSES.ACTIVE).index(target(event));
                    $(target(event)).addClass(CLASSES.ACTIVE);
                }
            }).click(function (event) {
                $(target(event)).addClass(CLASSES.ACTIVE);
                select();
                // TODO provide option to avoid setting focus again after selection? useful for cleanup-on-focus
                input.focus();
                return false;
            }).mousedown(function () {
                config.mouseDownOnSelect = true;
            }).mouseup(function () {
                config.mouseDownOnSelect = false;
            });

            if (options.width > 0)
                element.css("width", options.width);

            needsInit = false;
        }

        function target(event) {
            var element = event.target;
            while (element && element.tagName != "LI")
                element = element.parentNode;
            // more fun with IE, sometimes event.target is empty, just ignore it then
            if (!element)
                return [];
            return element;
        }

        function moveSelect(step) {
            listItems.slice(active, active + 1).removeClass(CLASSES.ACTIVE);
            movePosition(step);
            var activeItem = listItems.slice(active, active + 1).addClass(CLASSES.ACTIVE);
            if (options.scroll) {
                var offset = 0;
                listItems.slice(0, active).each(function () {
                    offset += this.offsetHeight;
                });
                if ((offset + activeItem[0].offsetHeight - list.scrollTop()) > list[0].clientHeight) {
                    list.scrollTop(offset + activeItem[0].offsetHeight - list.innerHeight());
                } else if (offset < list.scrollTop()) {
                    list.scrollTop(offset);
                }
            }
        };

        function movePosition(step) {
            active += step;
            if (active < 0) {
                active = listItems.size() - 1;
            } else if (active >= listItems.size()) {
                active = 0;
            }
        }

        function limitNumberOfItems(available) {
            return options.max && options.max < available
			? options.max
			: available;
        }

        function fillList() {
            list.empty();
            var max = limitNumberOfItems(data.length);
            for (var i = 0; i < max; i++) {
                if (!data[i])
                    continue;
                var formatted = options.formatItem(data[i].data, i + 1, max, data[i].value, term);
                if (formatted === false)
                    continue;
                var li = $("<li/>").html(options.highlight(formatted, term)).addClass(i % 2 == 0 ? "ac_even" : "ac_odd").appendTo(list)[0];
                $.data(li, "ac_data", data[i]);
            }
            listItems = list.find("li");
            if (options.selectFirst) {
                listItems.slice(0, 1).addClass(CLASSES.ACTIVE);
                active = 0;
            }
            // apply bgiframe if available
            if ($.fn.bgiframe)
                list.bgiframe();
        }

        return {
            display: function (d, q) {
                init();
                data = d;
                term = q;
                fillList();
            },
            next: function () {
                moveSelect(1);
            },
            prev: function () {
                moveSelect(-1);
            },
            pageUp: function () {
                if (active != 0 && active - 8 < 0) {
                    moveSelect(-active);
                } else {
                    moveSelect(-8);
                }
            },
            pageDown: function () {
                if (active != listItems.size() - 1 && active + 8 > listItems.size()) {
                    moveSelect(listItems.size() - 1 - active);
                } else {
                    moveSelect(8);
                }
            },
            hide: function () {
                element && element.hide();
                listItems && listItems.removeClass(CLASSES.ACTIVE);
                active = -1;
            },
            visible: function () {
                return element && element.is(":visible");
            },
            current: function () {
                return this.visible() && (listItems.filter("." + CLASSES.ACTIVE)[0] || options.selectFirst && listItems[0]);
            },
            show: function () {
                var offset = $(input).offset();
                element.css({
                    width: typeof options.width == "string" || options.width > 0 ? options.width : $(input).width(),
                    top: offset.top + input.offsetHeight,
                    left: offset.left
                }).show();
                if (options.scroll) {
                    list.scrollTop(0);
                    list.css({
                        maxHeight: options.scrollHeight,
                        overflow: 'auto'
                    });

                    if ($.browser.msie && typeof document.body.style.maxHeight === "undefined") {
                        var listHeight = 0;
                        listItems.each(function () {
                            listHeight += this.offsetHeight;
                        });
                        var scrollbarsVisible = listHeight > options.scrollHeight;
                        list.css('height', scrollbarsVisible ? options.scrollHeight : listHeight);
                        if (!scrollbarsVisible) {
                            // IE doesn't recalculate width when scrollbar disappears
                            listItems.width(list.width() - parseInt(listItems.css("padding-left")) - parseInt(listItems.css("padding-right")));
                        }
                    }

                }
            },
            selected: function () {
                var selected = listItems && listItems.filter("." + CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);
                return selected && selected.length && $.data(selected[0], "ac_data");
            },
            emptyList: function () {
                list && list.empty();
            },
            unbind: function () {
                element && element.remove();
            }
        };
    };

    $.Autocompleter.Selection = function (field, start, end) {
        if (field.createTextRange) {
            var selRange = field.createTextRange();
            selRange.collapse(true);
            selRange.moveStart("character", start);
            selRange.moveEnd("character", end);
            selRange.select();
        } else if (field.setSelectionRange) {
            field.setSelectionRange(start, end);
        } else {
            if (field.selectionStart) {
                field.selectionStart = start;
                field.selectionEnd = end;
            }
        }
        field.focus();
    };

})(jQuery);

; (function (b) {
    var m, t, u, f, D, j, E, n, z, A, q = 0, e = {}, o = [], p = 0, d = {}, l = [], G = null, v = new Image, J = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i, W = /[^\.]\.(swf)\s*$/i, K, L = 1, y = 0, s = "", r, i, h = false, B = b.extend(b("<div/>")[0], { prop: 0 }), M = b.browser.msie && b.browser.version < 7 && !window.XMLHttpRequest, N = function () { t.hide(); v.onerror = v.onload = null; G && G.abort(); m.empty() }, O = function () {
        if (false === e.onError(o, q, e)) { t.hide(); h = false } else {
            e.titleShow = false; e.width = "auto"; e.height = "auto"; m.html('<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>');
            F()
        } 
    }, I = function () {
        var a = o[q], c, g, k, C, P, w; N(); e = b.extend({}, b.fn.fancybox.defaults, typeof b(a).data("fancybox") == "undefined" ? e : b(a).data("fancybox")); w = e.onStart(o, q, e); if (w === false) h = false; else {
            if (typeof w == "object") e = b.extend(e, w); k = e.title || (a.nodeName ? b(a).attr("title") : a.title) || ""; if (a.nodeName && !e.orig) e.orig = b(a).children("img:first").length ? b(a).children("img:first") : b(a); if (k === "" && e.orig && e.titleFromAlt) k = e.orig.attr("alt"); c = e.href || (a.nodeName ? b(a).attr("href") : a.href) || null; if (/^(?:javascript)/i.test(c) ||
c == "#") c = null; if (e.type) { g = e.type; if (!c) c = e.content } else if (e.content) g = "html"; else if (c) g = c.match(J) ? "image" : c.match(W) ? "swf" : b(a).hasClass("iframe") ? "iframe" : c.indexOf("#") === 0 ? "inline" : "ajax"; if (g) {
                if (g == "inline") { a = c.substr(c.indexOf("#")); g = b(a).length > 0 ? "inline" : "ajax" } e.type = g; e.href = c; e.title = k; if (e.autoDimensions) if (e.type == "html" || e.type == "inline" || e.type == "ajax") { e.width = "auto"; e.height = "auto" } else e.autoDimensions = false; if (e.modal) {
                    e.overlayShow = true; e.hideOnOverlayClick = false; e.hideOnContentClick =
false; e.enableEscapeButton = false; e.showCloseButton = false
                } e.padding = parseInt(e.padding, 10); e.margin = parseInt(e.margin, 10); m.css("padding", e.padding + e.margin); b(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change", function () { b(this).replaceWith(j.children()) }); switch (g) {
                    case "html": m.html(e.content); F(); break; case "inline": if (b(a).parent().is("#fancybox-content") === true) { h = false; break } b('<div class="fancybox-inline-tmp" />').hide().insertBefore(b(a)).bind("fancybox-cleanup", function () { b(this).replaceWith(j.children()) }).bind("fancybox-cancel",
function () { b(this).replaceWith(m.children()) }); b(a).appendTo(m); F(); break; case "image": h = false; b.fancybox.showActivity(); v = new Image; v.onerror = function () { O() }; v.onload = function () { h = true; v.onerror = v.onload = null; e.width = v.width; e.height = v.height; b("<img />").attr({ id: "fancybox-img", src: v.src, alt: e.title }).appendTo(m); Q() }; v.src = c; break; case "swf": e.scrolling = "no"; C = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + e.width + '" height="' + e.height + '"><param name="movie" value="' + c +
'"></param>'; P = ""; b.each(e.swf, function (x, H) { C += '<param name="' + x + '" value="' + H + '"></param>'; P += " " + x + '="' + H + '"' }); C += '<embed src="' + c + '" type="application/x-shockwave-flash" width="' + e.width + '" height="' + e.height + '"' + P + "></embed></object>"; m.html(C); F(); break; case "ajax": h = false; b.fancybox.showActivity(); e.ajax.win = e.ajax.success; G = b.ajax(b.extend({}, e.ajax, { url: c, data: e.ajax.data || {}, error: function (x) { x.status > 0 && O() }, success: function (x, H, R) {
    if ((typeof R == "object" ? R : G).status == 200) {
        if (typeof e.ajax.win ==
"function") { w = e.ajax.win(c, x, H, R); if (w === false) { t.hide(); return } else if (typeof w == "string" || typeof w == "object") x = w } m.html(x); F()
    } 
} 
})); break; case "iframe": Q()
                } 
            } else O()
        } 
    }, F = function () {
        var a = e.width, c = e.height; a = a.toString().indexOf("%") > -1 ? parseInt((b(window).width() - e.margin * 2) * parseFloat(a) / 100, 10) + "px" : a == "auto" ? "auto" : a + "px"; c = c.toString().indexOf("%") > -1 ? parseInt((b(window).height() - e.margin * 2) * parseFloat(c) / 100, 10) + "px" : c == "auto" ? "auto" : c + "px"; m.wrapInner('<div style="width:' + a + ";height:" + c +
";overflow: " + (e.scrolling == "auto" ? "auto" : e.scrolling == "yes" ? "scroll" : "hidden") + ';position:relative;"></div>'); e.width = m.width(); e.height = m.height(); Q()
    }, Q = function () {
        var a, c; t.hide(); if (f.is(":visible") && false === d.onCleanup(l, p, d)) { b.event.trigger("fancybox-cancel"); h = false } else {
            h = true; b(j.add(u)).unbind(); b(window).unbind("resize.fb scroll.fb"); b(document).unbind("keydown.fb"); f.is(":visible") && d.titlePosition !== "outside" && f.css("height", f.height()); l = o; p = q; d = e; if (d.overlayShow) {
                u.css({ "background-color": d.overlayColor,
                    opacity: d.overlayOpacity, cursor: d.hideOnOverlayClick ? "pointer" : "auto", height: b(document).height()
                }); if (!u.is(":visible")) { M && b("select:not(#fancybox-tmp select)").filter(function () { return this.style.visibility !== "hidden" }).css({ visibility: "hidden" }).one("fancybox-cleanup", function () { this.style.visibility = "inherit" }); u.show() } 
            } else u.hide(); i = X(); s = d.title || ""; y = 0; n.empty().removeAttr("style").removeClass(); if (d.titleShow !== false) {
                if (b.isFunction(d.titleFormat)) a = d.titleFormat(s, l, p, d); else a = s && s.length ?
d.titlePosition == "float" ? '<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">' + s + '</td><td id="fancybox-title-float-right"></td></tr></table>' : '<div id="fancybox-title-' + d.titlePosition + '">' + s + "</div>" : false; s = a; if (!(!s || s === "")) {
                    n.addClass("fancybox-title-" + d.titlePosition).html(s).appendTo("body").show(); switch (d.titlePosition) {
                        case "inside": n.css({ width: i.width - d.padding * 2, marginLeft: d.padding, marginRight: d.padding });
                            y = n.outerHeight(true); n.appendTo(D); i.height += y; break; case "over": n.css({ marginLeft: d.padding, width: i.width - d.padding * 2, bottom: d.padding }).appendTo(D); break; case "float": n.css("left", parseInt((n.width() - i.width - 40) / 2, 10) * -1).appendTo(f); break; default: n.css({ width: i.width - d.padding * 2, paddingLeft: d.padding, paddingRight: d.padding }).appendTo(f)
                    } 
                } 
            } n.hide(); if (f.is(":visible")) {
                b(E.add(z).add(A)).hide(); a = f.position(); r = { top: a.top, left: a.left, width: f.width(), height: f.height() }; c = r.width == i.width && r.height ==
i.height; j.fadeTo(d.changeFade, 0.3, function () { var g = function () { j.html(m.contents()).fadeTo(d.changeFade, 1, S) }; b.event.trigger("fancybox-change"); j.empty().removeAttr("filter").css({ "border-width": d.padding, width: i.width - d.padding * 2, height: e.autoDimensions ? "auto" : i.height - y - d.padding * 2 }); if (c) g(); else { B.prop = 0; b(B).animate({ prop: 1 }, { duration: d.changeSpeed, easing: d.easingChange, step: T, complete: g }) } })
            } else {
                f.removeAttr("style"); j.css("border-width", d.padding); if (d.transitionIn == "elastic") {
                    r = V(); j.html(m.contents());
                    f.show(); if (d.opacity) i.opacity = 0; B.prop = 0; b(B).animate({ prop: 1 }, { duration: d.speedIn, easing: d.easingIn, step: T, complete: S })
                } else { d.titlePosition == "inside" && y > 0 && n.show(); j.css({ width: i.width - d.padding * 2, height: e.autoDimensions ? "auto" : i.height - y - d.padding * 2 }).html(m.contents()); f.css(i).fadeIn(d.transitionIn == "none" ? 0 : d.speedIn, S) } 
            } 
        } 
    }, Y = function () {
        if (d.enableEscapeButton || d.enableKeyboardNav) b(document).bind("keydown.fb", function (a) {
            if (a.keyCode == 27 && d.enableEscapeButton) { a.preventDefault(); b.fancybox.close() } else if ((a.keyCode ==
37 || a.keyCode == 39) && d.enableKeyboardNav && a.target.tagName !== "INPUT" && a.target.tagName !== "TEXTAREA" && a.target.tagName !== "SELECT") { a.preventDefault(); b.fancybox[a.keyCode == 37 ? "prev" : "next"]() } 
        }); if (d.showNavArrows) { if (d.cyclic && l.length > 1 || p !== 0) z.show(); if (d.cyclic && l.length > 1 || p != l.length - 1) A.show() } else { z.hide(); A.hide() } 
    }, S = function () {
        if (!b.support.opacity) { j.get(0).style.removeAttribute("filter"); f.get(0).style.removeAttribute("filter") } e.autoDimensions && j.css("height", "auto"); f.css("height", "auto");
        s && s.length && n.show(); d.showCloseButton && E.show(); Y(); d.hideOnContentClick && j.bind("click", b.fancybox.close); d.hideOnOverlayClick && u.bind("click", b.fancybox.close); b(window).bind("resize.fb", b.fancybox.resize); d.centerOnScroll && b(window).bind("scroll.fb", b.fancybox.center); if (d.type == "iframe") b('<iframe id="fancybox-frame" name="fancybox-frame' + (new Date).getTime() + '" frameborder="0" hspace="0" ' + (b.browser.msie ? 'allowtransparency="true""' : "") + ' scrolling="' + e.scrolling + '" src="' + d.href + '"></iframe>').appendTo(j);
        f.show(); h = false; b.fancybox.center(); d.onComplete(l, p, d); var a, c; if (l.length - 1 > p) { a = l[p + 1].href; if (typeof a !== "undefined" && a.match(J)) { c = new Image; c.src = a } } if (p > 0) { a = l[p - 1].href; if (typeof a !== "undefined" && a.match(J)) { c = new Image; c.src = a } } 
    }, T = function (a) {
        var c = { width: parseInt(r.width + (i.width - r.width) * a, 10), height: parseInt(r.height + (i.height - r.height) * a, 10), top: parseInt(r.top + (i.top - r.top) * a, 10), left: parseInt(r.left + (i.left - r.left) * a, 10) }; if (typeof i.opacity !== "undefined") c.opacity = a < 0.5 ? 0.5 : a; f.css(c);
        j.css({ width: c.width - d.padding * 2, height: c.height - y * a - d.padding * 2 })
    }, U = function () { return [b(window).width() - d.margin * 2, b(window).height() - d.margin * 2, b(document).scrollLeft() + d.margin, b(document).scrollTop() + d.margin] }, X = function () {
        var a = U(), c = {}, g = d.autoScale, k = d.padding * 2; c.width = d.width.toString().indexOf("%") > -1 ? parseInt(a[0] * parseFloat(d.width) / 100, 10) : d.width + k; c.height = d.height.toString().indexOf("%") > -1 ? parseInt(a[1] * parseFloat(d.height) / 100, 10) : d.height + k; if (g && (c.width > a[0] || c.height > a[1])) if (e.type ==
"image" || e.type == "swf") { g = d.width / d.height; if (c.width > a[0]) { c.width = a[0]; c.height = parseInt((c.width - k) / g + k, 10) } if (c.height > a[1]) { c.height = a[1]; c.width = parseInt((c.height - k) * g + k, 10) } } else { c.width = Math.min(c.width, a[0]); c.height = Math.min(c.height, a[1]) } c.top = parseInt(Math.max(a[3] - 20, a[3] + (a[1] - c.height - 40) * 0.5), 10); c.left = parseInt(Math.max(a[2] - 20, a[2] + (a[0] - c.width - 40) * 0.5), 10); return c
    }, V = function () {
        var a = e.orig ? b(e.orig) : false, c = {}; if (a && a.length) {
            c = a.offset(); c.top += parseInt(a.css("paddingTop"),
10) || 0; c.left += parseInt(a.css("paddingLeft"), 10) || 0; c.top += parseInt(a.css("border-top-width"), 10) || 0; c.left += parseInt(a.css("border-left-width"), 10) || 0; c.width = a.width(); c.height = a.height(); c = { width: c.width + d.padding * 2, height: c.height + d.padding * 2, top: c.top - d.padding - 20, left: c.left - d.padding - 20}
        } else { a = U(); c = { width: d.padding * 2, height: d.padding * 2, top: parseInt(a[3] + a[1] * 0.5, 10), left: parseInt(a[2] + a[0] * 0.5, 10)} } return c
    }, Z = function () { if (t.is(":visible")) { b("div", t).css("top", L * -40 + "px"); L = (L + 1) % 12 } else clearInterval(K) };
    b.fn.fancybox = function (a) { if (!b(this).length) return this; b(this).data("fancybox", b.extend({}, a, b.metadata ? b(this).metadata() : {})).unbind("click.fb").bind("click.fb", function (c) { c.preventDefault(); if (!h) { h = true; b(this).blur(); o = []; q = 0; c = b(this).attr("rel") || ""; if (!c || c == "" || c === "nofollow") o.push(this); else { o = b("a[rel=" + c + "], area[rel=" + c + "]"); q = o.index(this) } I() } }); return this }; b.fancybox = function (a, c) {
        var g; if (!h) {
            h = true; g = typeof c !== "undefined" ? c : {}; o = []; q = parseInt(g.index, 10) || 0; if (b.isArray(a)) {
                for (var k =
0, C = a.length; k < C; k++) if (typeof a[k] == "object") b(a[k]).data("fancybox", b.extend({}, g, a[k])); else a[k] = b({}).data("fancybox", b.extend({ content: a[k] }, g)); o = jQuery.merge(o, a)
            } else { if (typeof a == "object") b(a).data("fancybox", b.extend({}, g, a)); else a = b({}).data("fancybox", b.extend({ content: a }, g)); o.push(a) } if (q > o.length || q < 0) q = 0; I()
        } 
    }; b.fancybox.showActivity = function () { clearInterval(K); t.show(); K = setInterval(Z, 66) }; b.fancybox.hideActivity = function () { t.hide() }; b.fancybox.next = function () {
        return b.fancybox.pos(p +
1)
    }; b.fancybox.prev = function () { return b.fancybox.pos(p - 1) }; b.fancybox.pos = function (a) { if (!h) { a = parseInt(a); o = l; if (a > -1 && a < l.length) { q = a; I() } else if (d.cyclic && l.length > 1) { q = a >= l.length ? 0 : l.length - 1; I() } } }; b.fancybox.cancel = function () { if (!h) { h = true; b.event.trigger("fancybox-cancel"); N(); e.onCancel(o, q, e); h = false } }; b.fancybox.close = function () {
        function a() { u.fadeOut("fast"); n.empty().hide(); f.hide(); b.event.trigger("fancybox-cleanup"); j.empty(); d.onClosed(l, p, d); l = e = []; p = q = 0; d = e = {}; h = false } if (!(h || f.is(":hidden"))) {
            h =
true; if (d && false === d.onCleanup(l, p, d)) h = false; else {
                N(); b(E.add(z).add(A)).hide(); b(j.add(u)).unbind(); b(window).unbind("resize.fb scroll.fb"); b(document).unbind("keydown.fb"); j.find("iframe").attr("src", M && /^https/i.test(window.location.href || "") ? "javascript:void(false)" : "about:blank"); d.titlePosition !== "inside" && n.empty(); f.stop(); if (d.transitionOut == "elastic") {
                    r = V(); var c = f.position(); i = { top: c.top, left: c.left, width: f.width(), height: f.height() }; if (d.opacity) i.opacity = 1; n.empty().hide(); B.prop = 1;
                    b(B).animate({ prop: 0 }, { duration: d.speedOut, easing: d.easingOut, step: T, complete: a })
                } else f.fadeOut(d.transitionOut == "none" ? 0 : d.speedOut, a)
            } 
        } 
    }; b.fancybox.resize = function () { u.is(":visible") && u.css("height", b(document).height()); b.fancybox.center(true) }; b.fancybox.center = function (a) {
        var c, g; if (!h) {
            g = a === true ? 1 : 0; c = U(); !g && (f.width() > c[0] || f.height() > c[1]) || f.stop().animate({ top: parseInt(Math.max(c[3] - 20, c[3] + (c[1] - j.height() - 40) * 0.5 - d.padding)), left: parseInt(Math.max(c[2] - 20, c[2] + (c[0] - j.width() - 40) * 0.5 -
d.padding))
            }, typeof a == "number" ? a : 200)
        } 
    }; b.fancybox.init = function () {
        if (!b("#fancybox-wrap").length) {
            b("body").append(m = b('<div id="fancybox-tmp"></div>'), t = b('<div id="fancybox-loading"><div></div></div>'), u = b('<div id="fancybox-overlay"></div>'), f = b('<div id="fancybox-wrap"></div>')); D = b('<div id="fancybox-outer"></div>').append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>').appendTo(f);
            D.append(j = b('<div id="fancybox-content"></div>'), E = b('<a id="fancybox-close"></a>'), n = b('<div id="fancybox-title"></div>'), z = b('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'), A = b('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>')); E.click(b.fancybox.close); t.click(b.fancybox.cancel); z.click(function (a) { a.preventDefault(); b.fancybox.prev() }); A.click(function (a) { a.preventDefault(); b.fancybox.next() });
            b.fn.mousewheel && f.bind("mousewheel.fb", function (a, c) { if (h) a.preventDefault(); else if (b(a.target).get(0).clientHeight == 0 || b(a.target).get(0).scrollHeight === b(a.target).get(0).clientHeight) { a.preventDefault(); b.fancybox[c > 0 ? "prev" : "next"]() } }); b.support.opacity || f.addClass("fancybox-ie"); if (M) { t.addClass("fancybox-ie6"); f.addClass("fancybox-ie6"); b('<iframe id="fancybox-hide-sel-frame" src="' + (/^https/i.test(window.location.href || "") ? "javascript:void(false)" : "about:blank") + '" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(D) } 
        } 
    };
    b.fn.fancybox.defaults = { padding: 10, margin: 40, opacity: false, modal: false, cyclic: false, scrolling: "auto", width: 560, height: 340, autoScale: true, autoDimensions: true, centerOnScroll: false, ajax: {}, swf: { wmode: "transparent" }, hideOnOverlayClick: true, hideOnContentClick: false, overlayShow: true, overlayOpacity: 0.7, overlayColor: "#777", titleShow: true, titlePosition: "float", titleFormat: null, titleFromAlt: false, transitionIn: "fade", transitionOut: "fade", speedIn: 300, speedOut: 300, changeSpeed: 300, changeFade: "fast", easingIn: "swing",
        easingOut: "swing", showCloseButton: true, showNavArrows: true, enableEscapeButton: true, enableKeyboardNav: true, onStart: function () { }, onCancel: function () { }, onComplete: function () { }, onCleanup: function () { }, onClosed: function () { }, onError: function () { } 
    }; b(document).ready(function () { b.fancybox.init() })
})(jQuery);
