﻿/*
**
*/

stepcarousel.setup({
    galleryid: 'mygallery', //id of carousel DIV
    beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
    panelclass: 'panel', //class of panel DIVs each holding content
    autostep: { enable: false, moveby: 1, pause: 3000 },
    panelbehavior: { speed: 500, wraparound: true, persist: true },
    defaultbuttons: { enable: true, moveby: 1, leftnav: ['images/prev.gif', 17, 80], rightnav: ['images/next.gif', -50, 80] },
    statusvars: ['startPage', 'endPage', 'totalPages'], //register 3 variables that contain current panel (start), current panel (last), and total panels
    contenttype: ['inline'] //content setting ['inline'] or ['external', 'path_to_external_file']
});
$(document).ready(function() {
    /*
    if ($.cookie('spiWebCatalog') != 'noIntro') {
        document.getElementById('intro').style.visibility = 'visible';
        $('#intro').jqm();
        $('#intro').jqmShow();
        $.cookie('spiWebCatalog', 'noIntro');
    }
    else {
        document.getElementById('intro').style.visibility = 'hidden';
    }
    */
    document.getElementById('intro').style.visibility = 'hidden';
});

function closeIntroduction() {
    $('#intro').jqmHide();
    return false;
}

function displayList(pageNumber) {
    $('#list').jqm({
        ajax: 'ListFixtures.aspx?page=' + pageNumber + "&catalogName=" + document.getElementById("catalogName").value,
        ajaxText: '<img src="images/busy.gif" style="display:block;margin-left:auto;margin-right:auto;" alt="loading" />'
    });
    $('#list').jqmShow();
    return false;
}

function displayFixture(linkIndex, fixture) {
    window.location.href = linkUrl[linkIndex].replace(/{{}}/g, fixture);
    return false;
}

function navigate(url) {
    window.location.href = url;
    return false;
}

function selectedCatalog(ctrl) {
    stepcarousel.stepTo('mygallery', ctrl.options[ctrl.selectedIndex].value);
    return false;
}

function gotoPage() {
    var CatalogNumber = document.getElementById('findInput').value;
    for (i = 0; i < fixtureList.length; i++) {
        if (fixtureList[i] == CatalogNumber) {
            stepcarousel.stepTo('mygallery', pageList[i]);
        }
    }
    return false;
}

var showCurrentPageTimerId;
var CurrentPage = 0;

function showCurrentPage() {
    if (startPage != CurrentPage) {
        var Tab = document.getElementById('tab' + startPage.toString());
        if (Tab != null) {
            var PrevTab = document.getElementById('tab' + CurrentPage.toString());
            if (PrevTab != null) {
                PrevTab.style.backgroundImage = 'url(images/tabRight.gif)';
                //PrevTab.style.color = '#000000';
            }
            Tab.style.backgroundImage = 'url(images/tabSelect.gif)';
            //Tab.style.color = '#ff0000';
        }
        var Page = document.getElementById('page' + startPage.toString());
        if (Page == null) {
            $('#infoBlock').fadeOut('slow');
        }
        else {
            var pageText = document.getElementById('pageText');
            pageText.innerHTML = Page.title;
            $('#infoBlock:hidden:first').fadeIn('slow');
        }
        CurrentPage = startPage;
    }
    return;
}

function pageInitialize() {
    showCurrentPageTimerId = setInterval('showCurrentPage();', 500);
}
function pageFinialize() {
    clearInterval(showCurrentPageTimerId);
}

window.onload = pageInitialize;
window.onunload = pageFinialize;
