/* 
 * 星级
 */
$(document).ready(function(){
	$(".xz_star").each(function(k){

		$(this).children().children(".iconfont").each(function(j){
			$(this).click(function(){
				$(this).nextAll().css("color","#e2e2e2");
				$(this).prevAll().css("color","#ffc000");
				$(this).css("color","#ffc000");
				var t = $(this).index()+1;
				$(this).siblings(".star").val(t);
				
			});
		});
	});
    $(".tx_star").each(function(k){

        $(this).children().children(".iconfont").each(function(j){
            $(this).click(function(){
                $(this).nextAll().css("color","#e2e2e2");
                $(this).prevAll().css("color","#ffc000");
                $(this).css("color","#ffc000");
                var t = $(this).index()+1;
                $(this).siblings(".star").val(t);

            });
        });
    });
});
/* 
 * 添加评论
 */
function add_comment(){
	var query = new Object;
	query = $("form[name='comment']").serialize();
	$.ajax({
		type:"POST",
		url:APP+"Mobile/OrderInfo/add_comment",
		data:query,
		success:function(data){
			if(data.status==1){
				$.showSuccess(data.info,0,'hc');
				window.location.href=data.url;
			}else{
				$.showErr(data.info,0,'hc');
			}
		}
	});
}
/* 
 * 上传图片
 */
// function up_img(id){
//     $("input[name='header_imgs']").click();
// }
/* 
 * 上传图片
 */
function up_img(id){
    KindEditor.ready(function(K) {var editor = K.editor();
		K("#gallery_button"+id).click(function() {
			editor.loadPlugin("multiimage", function() {
				editor.plugin.multiImageDialog({
					clickFn : function(urlList) {
						var div = K("#gallery_View"+id);
						d = new Date();
						t = d.getTime();							
						K.each(urlList, function(i, data) {
							div.append("<dd><img src='" + data.url + "'><input type='hidden' name='goods_img["+id+"]["+t+"n"+i+"]' value='"+data.url+"'></dd>");
						});
						editor.hideDialog();
					}
				});
			});
		});
	});
}
function delete_img(obj){
    $(obj).parent().remove();
}
function get_upimg(id){
    $.ajaxFileUpload({
        url: APP + 'Home/File/upload',
        secureuri: false,
        fileElementId: 'header_img',
        dataType: 'json',
        success: function (data, status) {
            if (data.error == 0) {
                var div = $("#gallery_View" + id);
                d = new Date();
                t = d.getTime();
                var url = data.url + "?r=" + Math.random();
                div.append("<dd><img src='" + url + "'><input type='hidden' name='goods_img[" + id + "][" + t + "n]' value='" + url + "'><i onclick='delete_img(this)'>-</i></dd>");
                /* if (thumb != 'NULL') $("#" + thumb).attr("src", data.url + "?r=" + Math.random());
                 $("input[name='idno_imgs']").val(data.url);
                 $("input[name='" + name + "']").val(data.url);*/
            } else {
                //alert(data.message);
            }
            $(".fileuploading").hide();
        },
        error: function (data, status, e) {
            if (data.responseText.indexOf('<script') > 0) {
                strs = data.responseText.split("<script");
                arr = eval("(" + strs[0] + ")");
                if (arr['error'] == 0) {
                    var div = $("#gallery_View" + id);
                    d = new Date();
                    t = d.getTime();
                    var url = data.url + "?r=" + Math.random();
                    div.append("<dd><img src='" + url + "'><input type='hidden' name='goods_img[" + id + "][" + t + "n]' value='" + url + "'><i onclick='delete_img(this)'>-</i></dd>");
                } else {
                    //alert(arr['message']);
                }
                $(".fileuploading").hide();
                return;
            }
            //alert(data.responseText);
            $(".fileuploading").hide();
        }
    });
}