<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="JuSNS.Web.home.gift.index" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Collections.Generic" %>

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title id="ptitle" runat="server">赠送礼物</title>
<script language="javascript" type="text/javascript" src="../../js/ajax.js"></script>
<script language="javascript" type="text/javascript" src="../../js/public.js"></script>
<script type="text/javascript" src="../../js/build/yahoo/yahoo-min.js"></script>
<script type="text/javascript" src="../../js/build/dom/dom-min.js"></script>
<script type="text/javascript" src="../../js/build/event/event-min.js"></script>
<script type="text/javascript" src="../../js/build/autocomplete/autocomplete-min.js"></script>
<link href="../../template/<% Response.Write(JuSNS.Config.UiConfig.SkinStyle); %>/css/base.css"   id="skinpath" type="text/css" rel="stylesheet" />

</head>
<body  id="yahoo-com" class="yui-skin-sam">
   <!--头部-->
   <%=this.GetHtmlShort()%> 
    <div id="divhead">
        <%=this.GetHtmlHead()%>
    </div>
    <div id="divbody">
        <div id="body_first">
            <div class="body_menu">
                <%=this.GetHtmlLeft()%>
            </div>
        </div>
        <div id="body_sec">
           <form id="form1" runat="server"> 
                <div id="body_mid">
                    <div class="body_frame">
                        <!--主题内容中-->
                        <div class="body_frame_otherinfo">
                            <div class="title">
                                <div class="l">
                                    <img src="../../template/<%Response.Write(JuSNS.Config.UiConfig.SkinStyle); %>/images/site/gift.gif" align="absmiddle" />
                                    <span class="bold shenlan font14 ocolor">礼物</span>
                                </div>
                                <div class="r">
                                    <a href="javascript:history.back();">返回上一级</a>                                   
                                </div>
                                <div class="c">
                                </div>
                            </div>
                            <div class="nav-menu">
                                <ul>
                                    <li class="current"><a href="../gift">赠送礼物</a></li>
                                    <li><a href="../gift/box.aspx?r=in">我收到的礼物</a></li>
                                    <li><a href="../gift/box.aspx?r=out">我赠送的礼物</a></li>
                                    <li><a href="../gift/set.aspx">设 置</a></li>
                                </ul>
                            </div>
                        </div>
                        
                        
                        
                        <div class="body_sec_all">
                            <div class="content nl">
                           <div class="nl w300"> 
                                <div class="pstr">
                                    <strong>赠送给：</strong>
                                    <span id="span_Receiver" runat="server"></span>
                                    <input id="giftUserID" style="width:220px;" class="f-text" runat="server"  onblur="changeState();" maxlength="20" title="按BackSpace键(退格键)显示所有好友列表，支持模糊搜索！" />
                                    <input id="Hid_UserID" name="Hid_UserID"  type="hidden" runat="server"></input>
                                    <div id="statescontainer"></div>
                                </div>
                            </div>  
                            <div class="nl w80" style="margin-top:-10px;">   
                                 <span id="gUserImage" class="h4image w60"></span>
                             </div>
                            </div>
                            <div class="content">
                                <div class="pstr bold">选择礼物：</div>
                                <div class="content">分类：<span id="giftClass" runat="server"></span></div>
                                <span class="gifts" id="showContentList">loading...</span>
                            </div>
                            <div class="content">
                                <div class="pstr bold">附言：</div>
                                <div class="nl"><asp:TextBox ID="gContent" onblur="changeState();" CssClass="f-text s50" TextMode="MultiLine" Height="100" MaxLength="300" runat="server"></asp:TextBox></div>
                                <div id="showImageContent" class="padding10 nl" style="margin-top:-20px;margin-left:6px;"></div>
                            </div>
                         
                            <div class="content">
                                <div class="pstr bold">选择赠送方式：</div>
                                    <select id="gType"  onblur="changeState();">
                                        <option value="0">公开赠送</option>
                                        <option value="1">悄悄地送</option>
                                        <option value="2">匿名赠送</option>
                                    </select>
                            </div>
                             
                             <div class="content">
                                <input type="button" id="sendbutton" class="f-button" value="送出礼物" onclick="sendGift(this);" />
                                <span style="display:none;" id="gift_slod" class="showSumbitflow">正在发送，请稍候……</span>
                             </div>
                             <div class="spline"></div>
                        </div>
                        </div>
                        <!--底部-->
                        <div class="divbottom">
                            <%=this.GetHtmlFoot()%>
                        </div>                          
                        
                        </div>
                        </form>
                        </div>
                        </div>
                        
</body>
</html>
<script type="text/javascript">
    new Form.Element.Observer($('Hid_UserID'),1,changevalue);
   if(document.getElementById("Hid_UserID").value!="")
   {
    changevalue();
   } 
	function changevalue()
	{
    	 var  options={  
				   method:'get',  
				   parameters:"t=image&UserID="+$('Hid_UserID').value,
				   onComplete:function(transport)
					{  
						var returnvalue=transport.responseText;
						if (returnvalue.indexOf("??")>-1)
						{
                                document.getElementById("gUserImage").innerHTML = "";
                         }
						else
						{
						    document.getElementById("gUserImage").innerHTML=returnvalue;
						}
					}  
			   }; 
	    new  Ajax.Request('index.aspx?no-cache='+Math.random(),options);    	    
	} 


    function changeState()
   {
        document.getElementById("gift_slod").innerHTML="";
        document.getElementById("gift_slod").style.display="none";
   } 
    function sendGift(obj)
   {
        document.getElementById("sendbutton").disabled=true;
        document.getElementById("gift_slod").style.display="";
        if(document.getElementById("Hid_UserID")!=null)
        {
            var hidid=document.getElementById("Hid_UserID").value;
        }
        var content=document.getElementById("gContent").value;
        var gtype =document.getElementById("gType").value;
        if(document.getElementById("gIDhidden")!=null)
        {
            var gIDhidden = document.getElementById("gIDhidden").value;
        }
        else
        {
		    document.getElementById("gift_slod").innerHTML="请选择礼物！";
            document.getElementById("sendbutton").disabled=false;
        }
    	 var  options={  
				   method:'get',  
				   parameters:"rID="+hidid+"&content="+escape(content)+"&gtype="+gtype+"&gid="+gIDhidden+"",
				   onComplete:function(transport)
					{  
						var returnvalue=transport.responseText;
						if (returnvalue.indexOf("??")>-1)
						{
                                document.getElementById("gift_slod").innerHTML = "Error!";
                                document.getElementById("sendbutton").disabled=false;
                         }
						else
						{
						    if(returnvalue=="succ")
						    { 
							    document.getElementById("gift_slod").innerHTML="<span class=\"green\">礼物已经赠送成功！</span>";
							 }
							 else
							 {
							    document.getElementById("gift_slod").innerHTML=returnvalue;
							 }
                            document.getElementById("sendbutton").disabled=false;
						}
					}  
			   }; 
	    new  Ajax.Request('../../inc/ajax/gift/save.aspx?no-cache='+Math.random(),options);    
   } 
   
   function showGInfo(gid)
   {
        changeState();
        var st =document.getElementById("showImageContent");
        document.getElementById("gContent").focus();
    	 var  options={  
				   method:'get',  
				   parameters:"r="+gid,
				   onComplete:function(transport)
					{  
						var returnvalue=transport.responseText;
						if (returnvalue.indexOf("??")>-1)
						{
                                st.innerHTML = "Error!";
                         }
						else
						{
							    st.innerHTML = returnvalue;
						}
					}  
			   }; 
	    new  Ajax.Request('../../inc/ajax/gift/getinfo.aspx?no-cache='+Math.random(),options);    
   }
   
   ShowGiftList("1","","n");
   function ShowGiftList(page,classID,n)
   {
        var st =document.getElementById("showContentList");
        //st.innerHTML = "loading....";
    	 var  options={  
				   method:'get',  
				   parameters:"&classID="+classID+"&n="+n+"&page="+page,
				   onComplete:function(transport)
					{  
						var returnvalue=transport.responseText;
						if (returnvalue.indexOf("??")>-1)
						{
                                st.innerHTML = "Error!";
                         }
						else
						{
					        
							    st.innerHTML = returnvalue;
						}
					}  
			   }; 
	    new  Ajax.Request('../../inc/ajax/gift/list.aspx?no-cache='+Math.random(),options);    
   }
</script>
<script type="text/javascript">
<%
    JuSNS.Home.Friend friend = new JuSNS.Home.Friend();
    Dictionary<int, string> dct = friend.GetFriends(UserID,"");
    string s_List = "";
    foreach (KeyValuePair<int, string> kvp in dct)
    {
        s_List += "\"" + kvp.Value + "<span style='display:none;'>" + kvp.Key.ToString() + "</span>\",";
    }
    s_List = s_List.TrimEnd(',');
%>
YAHOO.example.statesArray = [<% Response.Write(s_List); %>];

YAHOO.example.ACJSArray = new function() {
    this.oACDS = new YAHOO.widget.DS_JSArray(YAHOO.example.statesArray);

    this.oAutoComp = new YAHOO.widget.AutoComplete('giftUserID','statescontainer', this.oACDS);
    //this.oAutoComp.prehighlightClassName = "yui-ac-prehighlight";
    this.oAutoComp.typeAhead = true;
    this.oAutoComp.useShadow = true;
    this.oAutoComp.minQueryLength = 0;
};
</script>