// ::::::GOOGLE ANALYTICS:::::::::
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

try {
    var pageTracker = _gat._getTracker("UA-6325831-4");
    pageTracker._trackPageview();
} catch (err) { }
//
//
// ::::::Functions called at startup:::::::::
$(document).ready(function () {
    searchBoxInterface();
    anchorClick();

});


// ::::::Makes the searchbox work a little nicer:::::::::
function searchBoxInterface() {
    $('#searchbox .n_search_lbl').show();
    $('#searchbox .n_search_txt').focus(function (e) {
        $('#searchbox .n_search_txt').toggleClass('n_search_txt_focus', true);
    }).blur(function () {
        $('#searchbox .n_search_txt').toggleClass('n_search_txt_focus', false);
        if (this.value == '') {
            $('#searchbox .n_search_lbl').show();
        }
    }).keydown(function (e) {
        if (this.value == '') {
            $('#searchbox .n_search_lbl').hide();
        }
    });
    $('#searchbox .n_search_lbl').click(function () {
        $('#searchbox .n_search_txt').focus();
    });
}

// ::::::When an anchor is used there will be an animation:::::::::
function anchorClick() {
    $(".anchor_link_a").click(function (event) {
        event.preventDefault();
        var full_url = this.href;
        var parts = full_url.split("#");
        var anch_target = parts[1];

        $('html,body').animate({ scrollTop: document.getElementById(anch_target).offsetTop }, 500);
    });
}

































function startSlide(imagenumber) {
    clearInterval(interval);
    slideShow(imagenumber);
}

function slideShow(imagenumber) {
    counter = imagenumber;
    $('#gallery a').removeClass('show');
    $('#gallery a:eq(' + (imagenumber - 1) + ')').addClass('show')
    $('#gallery a').css({ opacity: 0.0 });
    $('#gallery a:eq(' + (imagenumber - 1) + ')').animate({ opacity: 1.0 }, 1000);


    $('#gallery .caption').css({ opacity: 0.7 });
    $('#gallery .caption').css({ width: $('#gallery a').find('img').css('width') });
    $('#gallery .content').html(getCaption(imagenumber))
    .animate({ opacity: 0.7 }, 400);
    interval = setInterval('gallery()', 6000);
}

function gallery() {
    var iCurrent = counter;
    var iNext = counter + 1;
    if (iNext > imagescount) {
        iNext = 1;
        counter = 0;
    }
    var current = $('#gallery a:eq(' + (iCurrent - 1) + ')')
    var next = $('#gallery a:eq(' + (iNext - 1) + ')')
    next.css({ opacity: 0.0 })
    .addClass('show')
    .animate({ opacity: 1.0 }, 1000);
    current.animate({ opacity: 0.0 }, 1000)
    .removeClass('show');
    $('#gallery .content').html(getCaption(iNext));
    counter++;
}

function getCaption(imagenumber) {
    var caption = "";
    for (var p = 1; p <= imagescount; p++) {
        if (p == imagenumber) {
            caption += "<img class=\"spanlink\" onclick=\"startSlide(" + p + ");\" src=\"images/jImages/icons/jimages_link_logo_pink.png\">";
        }
        else {
            caption += "<img class=\"spanlink\" onclick=\"startSlide(" + p + ");\" src=\"images/jImages/icons/jimages_link_logo_dark.png\">";
        }
    }
    return caption;
}








