﻿//服装和宠物图片
jQuery(document).ready(function() {
    jQuery.ajax({
        url: "/Web/GetLeftPicLink?r=" + Math.random(),
        type: 'get',
        data: {picTypeId:7},
        dataType: 'json',
        //async: (false),
        beforeSend: function(XMLHttpRequest) {

        },
        success: function(json) {
            if (json!= '') {
                jQuery("#leftPicLink").html(json);
            }
        }
    });
});


//服装和宠物图片
jQuery(document).ready(function() {
    jQuery.ajax({
        url: "/Web/ClothAndPet?r=" + Math.random(),
        type: 'get',
        data: {},
        dataType: 'json',
        //async: (false),
        beforeSend: function(XMLHttpRequest) {

        },
        success: function(json) {
            if (json.clothPic != '') {
                jQuery("#clothPic").html(json.clothPic);
            }

            if (json.petPic != '') {
                jQuery("#petPic").html(json.petPic);
            }
        }
    });
});



//下一张
function GetNext(picType) {
    var id = 0;
    if (picType == 3) {
        jQuery("#clothPic img").each(function() {
            id = jQuery(this).attr("id");
        });
    }
    else {
        jQuery("#petPic img").each(function() {
            id = jQuery(this).attr("id");
        });
    }
    jQuery.ajax({
        url: "/Web/GetNextPic?r=" + Math.random(),
        type: "get",
        data: { publishType: picType, picId: id },
        dataType: "json",
        beforeSend: function(XMLHttpRequest) {
            if (picType == 3) {
                jQuery("#clothNext").unbind('click').removeAttr('onclick');
            }
            else {
                jQuery("#picNext").unbind('click').removeAttr('onclick');
            }
        },
        success: function(json) {
            if (json != '') {
                if (picType == 3) {
                    jQuery("#clothPic").html(json);
                    jQuery("#clothNext").unbind('click').removeAttr('onclick').click(function() { GetNext(3) });
                }
                else {
                    jQuery("#petPic").html(json);
                    jQuery("#picNext").unbind('click').removeAttr('onclick').click(function() { GetNext(4) });
                }
            }
        }

    });
}
//上一张
function GetPrevious(picType) {
    var id = 0;
    if (picType == 3) {
        jQuery("#clothPic img").each(function() {
            id = jQuery(this).attr("id");
        });
    }
    else {
        jQuery("#petPic img").each(function() {
            id = jQuery(this).attr("id");
        });
    }

    jQuery.ajax({
        url: "/Web/GetPreviousPic?r=" + Math.random(),
        type: 'get',
        data: { publishType: picType, picId: id },
        dataType: 'json',
        //async: (false),
        beforeSend: function(XMLHttpRequest) {
            if (picType == 3) {
                jQuery("#clothPre").unbind('click').removeAttr('onclick');
            }
            else {
                jQuery("#picPre").unbind('click').removeAttr('onclick');
            }
        },
        success: function(json) {
            if (json != '') {
                if (picType == 3) {
                    jQuery("#clothPic").html(json);
                    jQuery("#clothPre").unbind('click').removeAttr('onclick').click(function() { GetPrevious(3) });
                }
                else {
                    jQuery("#petPic").html(json);
                    jQuery("#picPre").unbind('click').removeAttr('onclick').click(function() { GetPrevious(4) });
                }
            }
        }
    });
}


