﻿function signin()
{
    var username = document.getElementById('txtUsernameStub').value;
    var password = document.getElementById('txtPasswordStub').value;
    
    document.getElementById('txtUsername').value = username;
    document.getElementById('txtPassword').value = password;
    
    document.getElementById('frmSignin').submit();
    return false;
}

function slideshowClick(elem)
{
    timerControl.stop();
    advanceSlide(elem);
}

function advanceSlide(elem)
{
    if (!$(elem).hasClass('current'))
    {
        $('#slideshow').find('a').removeClass('current');
        $(elem).addClass('current');
        var rel = elem.attr('rel');
        var visible = $('#slides').find("img:visible");
        visible.css('z-index', '-1');
        $('#slides').find("img[longdesc='" + rel + "']").css('z-index', '1');
        $('#slides').find("img[longdesc='" + rel + "']").fadeIn(500, function(){visible.hide();});
    }
}

var timerControl;

function slideshowAdvance()
{
    var elem = $('#slideshow').find(".current");
    var rel = elem.attr('rel');
    rel = rel - 0;
    rel = rel + 1;
    var elem_next;
    
    elem_next = $('#slideshow').find("a:has[rel='" + rel + "']");
    rel_next = elem_next.attr('rel');
    
    if (rel_next == undefined)
    {
        elem_next = $('#slideshow').find("a:has[rel='1']");
        rel_next = elem_next.attr('rel');
    }
    advanceSlide(elem_next);
}

jQuery(window).bind("load", function() {
    //jQuery("div#slider1").codaSlider()
    
    $('#slideshow').find('a').click(function(){slideshowClick($(this));});
});

$(document).ready(function(){
    timerControl = $.timer(7000, function (timer) {
        slideshowAdvance();
    })
});