//首页所用的feedback的js文件 基于jquery
$(document).ready(function() {
    var cidlist = $.cookie('feedcidlist');
    var input = window.location.search;    var re = /\?cid=([0-9]+)/;    re.exec(input);
    var cid = RegExp.$1; 
    var content = $("#content").val();
    
    if(cidlist == null || cidlist.indexOf(cid) == -1)
    {   
        $("#WriteMessage").toggle(
            function() {
		        $(".FeedbackPannel").animate({
			        height: 'show',
			        opacity: 'show'
		        }, 'slow');
    		    
		    },
            function() {
		        $(".FeedbackPannel").animate({
			        height: 'hide',
			        opacity: 'hide'
		        }, 'slow');
		    }
    		
	    );
	    
	    $("#FeedbackCancel").click(function() {
		        $("#WriteMessage").trigger("click");
		    }
        );
        
	    $("#FeedbackSumbit").click(function(){
	                if($("#vcode").val() != '')
                    {
                        $.post("./tool/GetSession.aspx?name=vcode&time="+Math.random(),function(data){
                            if($("#vcode").val() == data)
                            {
                    	        var input = window.location.search;                                var re = /\?cid=([0-9]+)/;                                re.exec(input);
                                var cid = RegExp.$1;
                                                                 
                                var content = $("#content").val();
	                            if (content != '')
	                            {
	                                 $.post("./Feedback.aspx",{cid:cid,content:content},function(){
	                                        alert("提交成功！");
	                                        $("#WriteMessage").remove(); 
                                            $("#FeedbackPannel").slideUp("slow");
                                            content += ','+cid
                                            $.cookie('feedcidlist',content,{expires: 1});
                                        });
	                            }
	                            else
	                            {
	                                alert("请输入内容");
	                                return;
	                            }
	                        }
	                        else
	                        {
	                            alert("验证码错误,请重新输入");
	                        }
                        });
                    }
                    else
                    {
                        alert("请输入验证码");
                        return ;
                    }
	    });
	}//if
	else
	{
	     $("#WriteMessage").hide();
	}
})
