<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Admin_SceneryReviews.aspx.vb"
    Inherits="TourEx.Web.Admin_SceneryReviews" %>
<%@ Import Namespace="TourEx.BLL" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>无标题页</title>
<link rel="stylesheet" type="text/css" href="Css/Style.css" />
<script type="text/javascript" src="../sys/js/jquery.js"></script>
<script type="text/javascript" src="../sys/js/AlertWindow.js"></script>
<link href="../sys/css/jquery-ui-1.7.2.custom.css" rel="Stylesheet" type="text/css" /> 
<link href="../sys/css/jquery.cropzoom.css" rel="Stylesheet" type="text/css" /> 
<script type="text/javascript" src="../sys/js/jquery.js"></script>
<script type="text/javascript" src="../sys/js/jquery-ui-1.8.2.custom.js"></script>
<script type="text/javascript" src="../sys/js/jquery.cropzoom.js"></script>
</head>
<body>
<ul class="navLocation">
	<li>您当前位置：<a href="Admin_Main.aspx">首页</a> &gt; <a href="Admin_SceneryList.aspx">景点管理</a>
		&gt; 景点点评</li>
</ul>
<div class="infoBox">
	<form runat="server" id="TourExForm" OnSubmit="return CheckForm();">
	<asp:HiddenField ID="R_Rating_0" runat="server" />
	<asp:HiddenField ID="R_Rating_1" runat="server" />
	<asp:HiddenField ID="R_Rating_2" runat="server" />
	<asp:HiddenField ID="R_Rating_3" runat="server" />
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
		<tr>
			<td width="100" class="infoBoxTd">景区：</td>
			<td><asp:Label ID="SceneryName" runat="server"></asp:Label></tr>
		<tr>
			<td class="infoBoxTd">类型：</td>
			<td class="reviewsPic">
				风景评分：<span v="0"><span id="str_0"></span></span>&nbsp;&nbsp; 
				食宿评分：<span v="1"><span id="str_1"></span></span>&nbsp;&nbsp; 
				交通评分：<span v="2"><span id="str_2"></span></span>&nbsp;&nbsp; 
				人文评分：<span v="3"><span id="str_3"></span></span>
			</td>
		</tr>
		<tr>
			<td class="infoBoxTd">
				我的印象：
			</td>
			<td>
				<asp:CheckBoxList ID="R_Impression" runat="server" RepeatDirection="Horizontal" 
					RepeatLayout="Flow">
				</asp:CheckBoxList>
			</td>
		</tr>
<asp:Repeater ID="Repeater" runat="server">
	<HeaderTemplate>
		<tr>
			<td class="infoBoxTd">图片：</td>
			<td>
				<ul class="reviews">
	</HeaderTemplate>
	<ItemTemplate>
					<li id="P_ID_<%#Eval("P_ID")%>">
						<img src="<%# UpFolder & Eval("P_Pic") & "?" & Eval("P_ID")%>" width="120" height="90" id="P_Pic_<%#Eval("P_ID")%>"/>
						<span><input type="text" value="<%#Eval("P_Title")%>" name="P_Title_<%#Eval("P_ID")%>" id="P_Title_<%#Eval("P_ID")%>"/></span>
						<input type="hidden" value="<%#Eval("P_Preview")%>" name="P_Preview_<%#Eval("P_ID")%>" id="P_Preview_<%#Eval("P_ID")%>" />
						<span><a href="javascript:;" onclick="$('#P_ID_<%#Eval("P_ID")%>').remove();">删除</a> <a href="javascript:;" onclick="ShowCropZoom(<%#Eval("P_ID")%>);">栽剪</a></span>
					</li>
	</ItemTemplate>
	<FooterTemplate>
				</ul>
			</td>
		</tr>
	</FooterTemplate>
</asp:Repeater>
		<tr>
			<td class="infoBoxTd">
				点评内容：
			</td>
			<td>
				<asp:TextBox ID="R_Text" runat="server" TextMode="MultiLine" Height="116px" 
					Width="493px"></asp:TextBox>
			</td>
		</tr>
		<tr>
			<td>&nbsp;
				
			</td>
			<td>
				<asp:Button ID="Submit1" runat="server" Text=" " cssclass="formInput01" />
			</td>
		</tr>
	</table>
	</form>
</div>
<div id="promptWindow" style="display:none">
    <div id="crop_container" style="width:500px"></div>
	<input name="crop" type="button" id="crop" value="确认" /><input name="restore" type="button" id="restore" value="还原" />
</div>
<script type="text/javascript">
    $('#Submit1').val('审核发放<%=WebSet.BonusName %>');
	var UpFolder='<%=UpFolder%>';
	var MaxW,MaxH,M='?'+Math.random();
	MaxW = <%=WebCache.Sys.Read("SceneryReviews")(4)%>;
	MaxH = <%=WebCache.Sys.Read("SceneryReviews")(5)%>;
    function ShowCropZoom(id)
    {
        var pic=$('#P_Pic_'+id).attr('src')+M;
        var Img = new Image();
        Img.onreadystatechange = function ()
        {
            ShowWindow();
            var H,W,P,SZ;
            W=MaxW/Img.width==MaxH/Img.height?MaxW:MaxW+100;//如果比率相同
            P=MaxW/W;
            H=MaxH/P;
            SZ=W/Img.width*100;
            var cropzoom = $('#crop_container').cropzoom({
                width:W,height:H,bgColor: '#CCC',enableRotation:true,enableZoom:true,zoomSteps:1,rotationSteps:1,
                selector:{centered:true,borderColor:'blue',borderColorHover:'yellow',startWithOverlay:false,hideOverlayOnDragAndResize:true,
	              showPositionsOnDrag:false,w:MaxW,h:MaxH,maxWidth:MaxW,maxHeight:MaxH
                },
                image:{
                    source:pic,width:Img.width,height:Img.height,minZoom:10,maxZoom:200,startZoom:SZ,snapToContainer:false
                }
            });
            $('#crop').unbind("click").click(function(){ 
                cropzoom.send('ProcessImage.ashx','POST',{'id':id,'t':'Scenery'},function(rta){
                    if(rta.substring(0,4)=='Err:')
                    {
                        alert(rta.substring(3));HideWindow();
                    }else{
                        if($('#P_Preview_'+id).val()==0)$('#P_Preview_'+id).val(1);
                        $('#P_ID_'+id).removeAttr('style');
                        M='?'+Math.random()
                        $('#P_Pic'+id).attr('src',UpFolder+rta+M);
                        HideWindow();
                    }
                });
            });
            $('#restore').unbind("click").click(function(){
                cropzoom.restore();
            });
            $('div[id$="_selector"]').unbind("dblclick").dblclick(function(){$('#crop').click();});
        }
        Img.src = pic;
    }
	function CheckForm()
	{
		if($("input[id^='R_Impression_']:checked").length==0){alert('请选择印象！');return false;} 
		if($("#R_Text").val()==''){alert('请填写内容！');return false;}
		var P= $('input[id^="P_Preview_"]') 
        for(var i = 0;i<P.length;i++){   
		    if($(P[i]).val()==0){alert('请裁剪图片!');return false;} 
        }
		return true;
	}
	var noselectpic = '../Images/Rstars.gif';
	var selectpic = '../Images/Rstar.gif';
	var strarray = new Array('1分','2分','3分','4分','5分');
	for(var i=0;i<4;i++)
	{
		var v=$('#R_Rating_'+i).val();
		var t='';
		for(var j=0;j<5;j++)
		{
			t+='<img src="'+(v>j?selectpic:noselectpic)+'"/>';
		}
		$('span[v="'+i+'"]').prepend(t); 
		$('#str_'+i).text(strarray[v-1]);
	}
	$('span[v]').each(function(){
		$(this).find('img').each(function(i){
			var P = $(this).parent();
			$(this).hover(function(){
				P.find('img').slice(i).attr('src',noselectpic);
				P.find('img').slice(0,i+1).attr('src',selectpic);
				$('#str_'+P.attr('v')).text(strarray[i]);
			  },function(){
				var V = parseInt($('#R_Rating_' + P.attr('v')).val());
				if(V==0)
				{
					P.find('img').attr('src',noselectpic);
					$('#str_'+P.attr('v')).text('');
				}else{
					P.find('img').slice(V-1).attr('src',noselectpic);
					P.find('img').slice(0,V).attr('src',selectpic);
					$('#str_'+P.attr('v')).text(strarray[V-1]);
				}
			});
			$(this).click(function(){
				$('#R_Rating_' + P.attr('v')).val(i+1);
				$('#str_'+P.attr('v')).text(strarray[i]);
			 });
            $('div[id$="_selector"]').dblclick(function(){$('#crop').click();});
		});
	});
	$('input[id^="P_Preview_"]').each(function(){
	    if($(this).val()==0) $(this).parent().css('border','#cccccc 1px solid');
	});

</script>
</body>
</html>
