﻿/// <reference path="jquery-1.3.2.js" />

function Test() {
    alert("test");
}

function ChangeImgUrlPreload(imageID, newUrl) {
    var id = '#' + imageID;
    $(id).attr('src', 'img/ajax-loader.gif');

    var image = new Image();
    $(image)
    // once the image has loaded, execute this code
    .load(function() {

        var img = $(id);
        $(id).fadeOut('normal', function() {

            $(id).attr('src', newUrl);
            $(id).fadeIn('normal');
        });
    })

    // *finally*, set the src attribute of the new image to our image
    .attr('src', newUrl);
}

function ChangeContentPreload(containerID, contentUrl) {
    var id = '#' + containerID;
    $(id).empty();
    $(id).append("<br /><br /><br /><br /><br /><br /><br /><br /><br /><img id='contentPanelLoader' src='img/ajax-loader.gif' />");
    $.ajax({
        url: contentUrl,
        type: "GET",
        dataType: "html",
        success: function(data, textStatus) {
            $(id).fadeOut('normal', function() {
                $(id).empty();
                $(id).append(data);
                $(id).fadeIn('normal');
            });
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            $(id).fadeOut('normal', function() {
                $(id).empty();
                $(id).append("error retrieving data");
                $(id).fadeIn('normal');
                alert("error retrieving data: " + errorThrown);
            });
        }
    });
}
