﻿// JScript 文件
var ActionType=function(){      
      this.UrlHander;
      this.OP;
      this.Action_div;
}
ActionType.prototype= {    
    SendRequest:function()
    {
        var Action=this;
        var url=Action.UrlHander+"?op="+Action.OP+"&dt="+GetMyDate();  
             
        Request.sendGET(url,Action.Success_SendRequest,Action.Failture,Action);        
    },
    Success_SendRequest:function(response,obj)
    {
        if(response.responseText!="")
        { 
            var Action=obj;
            var ActionList=eval(response.responseText);
            Action.Action_div.innerHTML="";
            var Str="";
            var count=0;
            Str="<div class=\"ci_info_item9\" id=\"radiolist\">"
            for(i=0;i<ActionList.length;i++)
            {
               var item=ActionList[i];
               Str+="<div class=\"ci_info_item10\" style=\"width:160px;height:25px;\">";
               Str+="<input type=\"radio\" id=\"rdo"+item.ID+"\" value=\""+item.ID+"\" name=\"action\"/>";
               Str+="<img src=\"Images/user_moving/"+item.Icon+"\" />";
               Str+="<lable>"+item.Action+"</lable>"
               Str+="</div>";
               count++;
            }
            Str+="</div>";
            Str+="<div class=\"ci_info_item8\">";
            Str+="<input type=\"button\" value=\"发送\" class=\"bt5\" style=\"margin-left:240px;margin-top:2px;\" onclick=\"return SendRequestAction();\" />";
            Str+="</div>";
            Str+="<input type=\"hidden\" id=\"hid_count\" value=\""+item.ID+"\" />"; 
           Action.Action_div.innerHTML=Str;
        }
    },
    Failture:function()
    {
       alert("失败!");
    }    
}

function ActionTypeLoad(){
    var Action=new ActionType();
    Action.UrlHander=GetActionUrl();
    Action.OP="GetActionTypeList";
    Action.Action_div=$("Gift_Container");
    Action.SendRequest();
}

function GetActionUrl()
{ 
    return "Handler/ActionHandler.ashx";
}

   function GetMyDate()
   { 
        var date=new Date();
        var now = "";
        now = date.getFullYear()+"-"; //读英文就行了
        now = now + (date.getMonth()+1)+"-";//取月的时候取的是当前月-1如果想取当前月+1就可以了
        now = now + date.getDate()+" ";
        now = now + date.getHours()+":";
        now = now + date.getMinutes()+"";
        return now;

   }
   //提交
   function SendRequestAction()
   {
        var count=Number($("hid_count").value);
        var url=GetActionUrl()+"?op=SendAction&dt="+GetMyDate();
        url+="&FriendID="+$("SendUID").value;
       
        for(i=1;i<=count;i++)
        { 
            if($("rdo"+i).checked)
            {
                url+="&ActionID="+$("rdo"+i).value;
            }
        }
        Request.sendGET(url,SubmitAction,failture);  
   }
   //Send提交
   function SubmitAction(response)
   {
    if(response.responseText!=""){
        var str="";  
        str+="<div style='text-align:center;font-size:16;font-weight:bold;color:#666666;padding-top:50px;'>"
        str+=response.responseText;
        str+="<div style='padding-top:50px;'><input type='button' value='确定' class='bt5' onclick='CloseModeDialog(\"list_\");' /></div>"
        str+="</div>"
        $("Gift_Container").innerHTML=str;  
     }
   }
   
    function failture()
    {

    }
    
    function displayMoving(UID)
    {
        var title="选择动作";
        var nWidth=670;
        var nHeight=335;
        var contentHtml=GetActionTypeList();
        divModalDialog(nWidth,nHeight,"选择动作",contentHtml,"list_",1000);
        ActionTypeLoad();
        if(UID!=0)
        {
           $("SendUID").value=UID;
        }
    }        
        
      //div模式窗口
      function divModalDialog(iWidth,iHeight,title,icontentHtml,prefix,Zindex)
      {
            var contentHtml=icontentHtml;
            var titleHtml=title;

        	var ModeDialogGgIframe = document.getElementById(prefix+"ModeDialogGgIframe");
	        if(ModeDialogGgIframe!=null)document.removeElement();
	        if(document.getElementById(prefix+"ModeDialogMsgDiv")!=null)return;	
	        var msgw,msgh,bordercolor,titleheight;
            msgw =iWidth;
	        msgh =iHeight; 
	        var sWidth,sHeight;
	        sWidth=document.body.offsetWidth-20;
	        sHeight=document.body.offsetHeight;
	        
	        var bg=document.createElement("iframe");
            
	        bg.setAttribute('id',prefix+'ModeDialogGgIframe');
	        bg.className="ModeDialogGgIframe";
	        var bgwidth = document.body.scrollWidth > sWidth?document.body.scrollWidth:sWidth;
	        var bgheight = document.body.scrollHeight>(screen.height-147)?document.body.scrollHeight:(screen.height-147);
	        bg.style.width = bgwidth > msgw ? bgwidth : msgw + "px";
	        bg.style.height = bgheight > msgh ? bgheight : msgh + "px";
	        bg.style.zIndex = Zindex; 
	        //ModeDialogMsgDiv
	        var msg=document.createElement("div");
	        msg.setAttribute("id",prefix+"ModeDialogMsgDiv");
	        msg.className="ModeDialogMsgDiv";
	        msg.style.position = "absolute";
	        msg.style.left = Number(window.document.documentElement.offsetWidth)/2-msgw/2+document.documentElement.scrollLeft + "px";
	        msg.style.top = Number(document.documentElement.clientHeight)/2-msgh/2+document.documentElement.scrollTop + "px";
	        msg.style.width = msgw + "px";
	        msg.style.zIndex = Zindex+200;
	                	
	        //ModeDialogTitleDiv
	        var title=document.createElement("div");
	        title.setAttribute("id",prefix+"ModeDialogTitleDiv");
	        title.setAttribute("align","left");
	        title.setAttribute("title","关闭");
	        title.className="ModeDialogTitleDiv";
	        title.innerHTML= "<strong style='float:left'>"+titleHtml+"</strong><span style='float: right;cursor:pointer;' onclick=\"CloseModeDialog('"+prefix+"');\">关闭</span>";

	        var content=document.createElement("div")
	        content.setAttribute("id",prefix+"ModeDialogContenDiv");
	        content.style.width = msgw;
	        content.innerHTML = contentHtml;
	        document.body.appendChild(bg);
	        document.body.appendChild(msg);
	        msg.appendChild(title);
	        msg.appendChild(content);
      }
        function CloseModeDialog(prefix)
        {
	        document.getElementById(prefix+"ModeDialogMsgDiv").removeChild(document.getElementById(prefix+"ModeDialogContenDiv"));
	        document.getElementById(prefix+"ModeDialogMsgDiv").removeChild(document.getElementById(prefix+"ModeDialogTitleDiv"));
	        document.body.removeChild(document.getElementById(prefix+"ModeDialogMsgDiv"));
	        document.body.removeChild(document.getElementById(prefix+"ModeDialogGgIframe"));
        }
    
      //选择礼物
      function GetActionTypeList()
      {
        var Str="";
           Str+="<input type=\"hidden\" id=\"SendUID\" value=\"0\" />";
    
            Str+="<div id=\"Gift_Container\" class=\"uid_msg_giftBox uid_msg_width\">";
            Str+="<div class=\"uid_msg_gift_imgBox\">";
            Str+="数据加载中……"
            Str+="</div>";            
            Str+="</div>"; 
            Str+="</div>";
            return Str;
      }
      
      
