﻿// JScript 文件
/*******************************************/
            //调用说明：date_obj为时间对象，date_templet为返回的日期格式模版（如：date_obj为“2006-9-23 12:34:10”；date_templet为“yy年mm月”，返回：“06年9月”）
            /*******************************************/
            function getFormatDate(date_obj,date_templet){
              var year,month,day,hour,minutes,seconds,short_year,full_month,full_day,full_day,full_hour,full_minutes,full_seconds;
              if(!date_templet)date_templet = "yyyy-mm-dd hh:ii:ss";
              year = date_obj.getFullYear().toString();
              short_year = year.substring(2,4);
              month = (date_obj.getMonth()+1).toString();
              month.length == 1 ? full_month = "0"+month : full_month = month;
              day = date_obj.getDate().toString();
              day.length == 1 ? full_day = "0"+day : full_day = day;
              hour = date_obj.getHours().toString();
              hour.length == 1 ? full_hour = "0"+hour : full_hour = hour;
              minutes = date_obj.getMinutes().toString();
              minutes.length == 1 ? full_minutes = "0"+minutes : full_minutes = minutes;
              seconds = date_obj.getSeconds().toString();
              seconds.length == 1 ? full_seconds = "0"+seconds : full_seconds = seconds;
              return date_templet.replace("yyyy",year).replace("mm",full_month).replace("dd",full_day).replace("yy",short_year).replace("m",month).replace("d",day).replace("hh",full_hour).replace("ii",full_minutes).replace("ss",full_seconds).replace("h",hour).replace("i",minutes).replace("s",seconds);
            }

            
            
            //去掉左右空格
	        function Trim(value)
	        {

		        var res = String(value).replace(/^[\s]+|[\s]+$/g,'');
		        return res;

	        }
                        
            //提交评论 
			function Insert(serviceid) 
            { 
			    
                var name=document.getElementById("name");
                var content=document.getElementById("content");
                var Hid=document.getElementById("Hid"); 
                var HsendMemberID=document.getElementById("HsenderMemberID"); //评论者的memberid（未登录则为0）
               
                var RadioPing;//评价
                if (Trim(name.value)!="" && Trim(content.value)!="")               
                {
                    if(serviceid==1)
                    {
                        if (document.getElementById("radio1").checked==true)//好评
                        {
                           RadioPing="0";
                        }
                        else if (document.getElementById("radio2").checked==true)//中评
                        {
                            RadioPing="1";
                        }
                        else//恶评
                        {
                            RadioPing="2";
                        }  
                    
                        Business_detail.InsertComment(Hid.value,name.value,content.value,InsertCallBack); 
                    } 
                    else
                    {
                         Service_Comment.InsertComment(Hid.value,name.value,content.value,InsertCallBack); 
                    }             
                    document.getElementById("div_comment").innerHTML="<img src='../images/loadding.gif'>加载中。。。";
                    alert("发表评论成功！");
                }
                else
                {
                    alert("姓名与评论内容不能为空！");
                }
            }
            
            function InsertCallBack(response)
            {
            
                        
　　　　            var ds = response.value;
                    if(ds != null && typeof(ds) == "object" && ds.Tables != null && ds.Tables[0].Rows.length!=0)
                    {   
                       var divContent="";
                       var CommentCount=ds.Tables[1].Rows[0].Ccount;
                       for(var i=0; i<ds.Tables[0].Rows.length; i++)
　　　　               {
　　　　                    divContent +="<table border='0' width='100%' cellpadding='3'><tr align='left' bgcolor='#FFFFFF'><td height='25' colspan='2' valign='bottom' class='word_black13w'>"
　　　　                                  +"留言<strong>"+CommentCount+"</strong>：</td></tr><tr align='left' valign='middle' bgcolor='#ECF7FF'><td height='32' colspan='2'>"
　　　　                                  +"<table width='99%'  border='0' align='center' cellpadding='0' cellspacing='0'><tr><td width='30%' class='word_black12weight'>姓名："+ds.Tables[0].Rows[i].name+" </td>"
　　　　                                  +"<td width='70%'><span class='word_black12weight'>日期：</span><span class='date12'>"+getFormatDate(ds.Tables[0].Rows[i].publish_time,'yyyy-mm-dd hh:ii:ss')+"</span></td></tr></table></td>"
　　　　                                  +"</tr><tr bgcolor='F7F7F7' ><td colspan='2' align='left' valign='top'><p >&nbsp;&nbsp;&nbsp;&nbsp;"+ds.Tables[0].Rows[i].content+"</p></td></tr></table>";
　　　　                    CommentCount--;
　　　　               }
                       document.getElementById("div_comment").innerHTML=divContent;
                       //document.getElementById("name").value="";
                       document.getElementById("content").value="";
                       
            
                    }
                    else
                    {
                        document.getElementById("div_comment").innerHTML="暂无评论";
                    }  
                    
                          
                
            }
            
        //切换图片    
        function changePic(_this)
        {
            var BigImg=document.getElementById('IMG3');
            BigImg.src=_this.src;
            
            
            //改变A标签的href
           //document.getElementByid('HRE3')
           // Bigaurl.href=_this.src
           var Phref=document.getElementById("HRE3");
           Phref.href = _this.src;

        }
        function DrawImage(ImgD,FitWidth,FitHeight) 
{ 
    var image=new Image(); 
    image.src=ImgD.src;
    if(image.width>0 && image.height>0) 
    { 
        if(image.width/image.height>= FitWidth/FitHeight) 
        { 
            if(image.width>FitWidth) 
            { 
                ImgD.width=FitWidth; 
                ImgD.height=(image.height*FitWidth)/image.width; 
            } 
            else 
            { 
                ImgD.width=image.width; 
                ImgD.height=image.height; 
            } 
        } 
        else 
        { 
            if(image.height>FitHeight) 
            { 
                ImgD.height=FitHeight; 
                ImgD.width=(image.width*FitHeight)/image.height; 
            } 
            else 
            { 
                ImgD.width=image.width; 
                ImgD.height=image.height; 
            } 
        } 
    } 
} 
