﻿/**
    author: chris brown.
    date: 11-08-08
    page ref: /TheTeam.aspx
*/
$(document).ready(function() {

    var team_section = 0;

    $(".next_section").click(function() {
        if (($(".team_section").length - 1) > team_section) {
            var new_team_section = team_section + 1;
        }
        else {
            var new_team_section = 0;
        }
        $(".team_container").scrollTo($(".team_section:eq(" + new_team_section + ")"), 600, { axis: 'x' });
        team_section = new_team_section;
    });

    $(".prev_section").click(function() {
        if (team_section != 0) {
            var new_team_section = team_section - 1;
        }
        else {
            var new_team_section = $(".team_section").length - 1;
        }
        $(".team_container").scrollTo($(".team_section:eq(" + new_team_section + ")"), 600, { axis: 'x' });
        team_section = new_team_section;
    });

    $(".team_photo").click(function() {
        $(".img_frame").html('<img src="images/template/loading_dark2.gif" alt="loading" style="margin:100px 0 0 130px;" />');
        var user_id = $(this).attr("rel");
        $(".user_information").fadeOut();
        $.ajax({ type: "GET",
            url: "js/ajaxhandler.aspx",
            data: "Method=GetUser&UserId=" + user_id + "&Date=" + new Date().getDate(),
            success: function(xml) {
                var $desc = $(xml).find('Description').text();
                var $pic = $(xml).find('Picture').text();
                var $firstN = $(xml).find('Firstname').text();
                var $surN = $(xml).find('Surname').text();
                var name = '<h2>' + $firstN + ' ' + $surN + '</h2>';
                $(".img_frame").html("<img src='Resize.axd?ImgType=user&img=" + $pic + "&max_width=280&max_height=280' />");
                $(".user_information").html(name + $desc);
                $(".user_information").fadeIn();
            }
        });

    });

});