/*
*    编写人: 师金华
*    时  间: 2011-08-12
*    功  能: 全局动态加载,功能列表
*               1.动态加载页面Image的Alt属性
*    使  用: 
*               1.引用jquery-1.3.2.min.js
*               2.引用jquery.validate.min.js
*               2.引用global.js
*   
*   Copyright (c) 2011 simpleclick(www.simpleclick.co.uk)
*/

$(document).ready(function() {
    var host = (("https:" == document.location.protocol) ? "https://" : "http://");
    host = host + location.hostname;

    LoadImageAlt(host);
});


//加载Image的Alt属性
//参数:1当前域名
function LoadImageAlt(host) {
    var myimglist = $("img[src*='?nid=']");

    $(myimglist).each(function(i) {
        var src = $(this).attr("src");
        var nid = '';
        if (src != '') {
            nid = src.substring(src.indexOf('?nid=') + 5, src.lenght);
        }

        $.ajax({
            type: "POST",
            url: host + "/Image/LoadImageAlt/" + nid,
            success: function(msg) {
                if (msg != "") {
                    $("img[src='" + src + "']").attr("alt", msg);
                    $("img[src='" + src + "']").attr("title", msg);
                }
            },
            Cancel: function() {
            }
        });

    });
}
