$def with(siminfo,Data)
<!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>sms detail</title>
<link type="text/css" rel="stylesheet" href="/static/style/sms_detail.css" />
<script src="/static/js/jquery-1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/static/js/plantform.js"></script>
<script type="text/javascript" src="/static/js/jquery.artDialog.source.js?skin=aero"></script>
<script type="text/javascript">
//var insert='<dd class="operate"><a class="delet"></a><a class="forword"></a><a class="mark"></a></dd>';
var sim_info = $:json_encode(siminfo);
$$(function(){
	SetSendButtonStatus();
	$$('.detailList dl').each(function(){
		$$(this).hover(function(){
			//$$(this).find('dd').after(insert);
			$$(this).find('dd.operate').show();
			$$(this).find('a').hover(function(){
				$$(this).addClass('hover');								   
				},function(){
				$$(this).removeClass('hover');		
			})
		},function(){
			//$$(this).find('dd').remove('.operate');
			$$(this).find('dd.operate').hide();						
		})
	})
	$$('.inChat').focus(function(){
		$$(this).addClass('inChatFocus');						
	})
	$$('.inChat').blur(function(){
		$$(this).removeClass('inChatFocus');						
	})
	$$('.inChat').keyup(function(){
		var data = {};
		data.content = $$('.inChat').val();
		data.number = $$('#smsDetailsWrap').attr('rel');
		$$.post("/SMS/input",data,function(){					
					},"json")					
	})
	$$('.sendButtom').live('click', function(){
		var data = {};
		data.number = $$('#smsDetailsWrap').attr('rel');
		data.content = $$('.inChat').val();
		data.SIMId = $$(this).attr('SIMId');
		$$.post("/SMS/send",data,function(){					
					},"json")
		$$('.inChat').val("");							
	})
	$$('.addPbmButtonn').click(function(){
		var data = {};
		data.number = $$('#smsDetailsWrap').attr('rel');
		$$.post("/SMS/addpb",data,function(){					
					},"json")						
	})
	$$("a[wording=addToCon]").click(function(){
		var data = {};
		data.number = $$(this).attr('rel');
		$$.post("/SMS/addpb",data,function(){					
					},"json")
	})
	$$(".smsData").click(function(){
		var data = {};
		var Protocol = $$(this).attr('rel');
		data.id= $$(this).parents('dl').attr('rel');
		if(Protocol == 1){
			$$.post("/SMS/GetMMSAttachment",data,function(){
						
						},"json")
		}
	})
	$$('.delet').bind('click',function(){
		var that = this;
		art.dialog({
			title: '$trans("WEBSMS_DEL_SMS")',
			content: '$trans("SMS_DELETE_WARNING_MESSAGES")',
			okVal: '$trans("PB_BUTTON_OK")',
			cancelVal: '$trans("PBMainView_WEB_CANCEL")',
			icon: 'question',
			background:'#fff',
			opacity: 0.7,
			lock: true,
			ok: function(){
				var data = {}; 
				data.id= $$(that).parents('dl').attr('rel');
				data.location = $$(that).parents('dl').attr('location');
				data.Protocol = $$(that).parents('dl').attr('Protocol');
				//提交数据
				$$.post("/SMS/Del",data,function(){
					
					},"json")
			},
			cancel: true
		})
	})

	$$('.forword').bind('click',function(){
		var data = {};
		data.content = $$(this).parent('dd').siblings('dd').text();
		data.Protocol = $$(this).parents('dl').attr('Protocol');
		$$.post("/SMS/forword",data,function(){
					
					},"json")						
	})
	$$('.mark').bind('click',function(){
		var data = {};
		data.number = $$(this).parents('dl').attr('number');
		$$.post("/SMS/reply",data,function(){
					
					},"json")							
	})
	function GetButtonLabel(simtype,simid,length){
		var label = "" ;
		if(length < 2){
			simid = 0;
		}
		if(simid == 1){
			if(simtype == 0){
				label = '$trans("WEBSMS_SEND_SMS_1_0")';
			}
			else if(simtype == 1){
				label = '$trans("WEBSMS_SEND_SMS_1_1")';
			}
			else if(simtype == 2){
				label = '$trans("WEBSMS_SEND_SMS_1_2")';
			}
			else{
				label = '$trans("WEBSMS_SEND_SMS_1_UNKWON")';
			}
		}
		else if(simid == 2){
			if(simtype == 0){
				label = '$trans("WEBSMS_SEND_SMS_2_0")';
			}
			else if(simtype == 1){
				label = '$trans("WEBSMS_SEND_SMS_2_1")';
			}
			else if(simtype == 2){
				label = '$trans("WEBSMS_SEND_SMS_2_2")';
			}
			else{
				label = '$trans("WEBSMS_SEND_SMS_2_UNKWON")';
			}
		}
		else if(simid == 0){
			if(simtype == 0){
				label = '$trans("WEBSMS_SEND_SMS_0_0")';
			}
			else if(simtype == 1){
				label = '$trans("WEBSMS_SEND_SMS_0_1")';
			}
			else if(simtype == 2){
				label = '$trans("WEBSMS_SEND_SMS_0_2")';
			}
			else{
				label = '$trans("WEBSMS_SEND_SMS_0_UNKWON")';
			}
		}
		else{
			if(simtype == 0){
				label = '$trans("WEBSMS_SEND_SMS_UNKWON_0")';
			}
			else if(simtype == 1){
				label = '$trans("WEBSMS_SEND_SMS_UNKWON_1")';
			}
			else if(simtype == 2){
				label = '$trans("WEBSMS_SEND_SMS_UNKWON_2")';
			}
			else{
				label = '$trans("WEBSMS_SEND_SMS_UNKWON_UNKWON")';
			}
		}
		return label;
	}
	function SetSendButtonStatus(){
		//$$.post("/SMS/GetSimInfo","",function(siminfo){
			var sim_string = "";
			var wording = "";
			for(i=0;i<sim_info.length;i++){
				wording = GetButtonLabel(sim_info[i].SIMType,sim_info[i].SIMId,sim_info.length);
				if(sim_info[i].SimReady){
					sim_string += '<label class="sendButtom fl" SIMId="' + sim_info[i].SIMId + '">' + wording + '</label>';
				}
				else{
					sim_string += '<label class="sendButtom_Disable fl" SIMId="' + sim_info[i].SIMId + '">' + wording + '</label>';
				}
			}
			$$("div.smsChat").append(sim_string);
	//	},"json")
	}
})
$$(function KeyDownFunction(){
	if (typeof window.event != 'undefined'){  
		document.onkeydown = function(){  
			var type = event.srcElement.type;  
			var code = event.keyCode;  
			return ((code != 8 && code != 13) ||  
					(type == 'text' && code != 13 ) ||  
					(type == 'textarea') ||  
					(type == 'submit' && code == 13))  
			}  
		}
	else{
		document.onkeypress = function(e){  
			var type = e.target.localName.toLowerCase();  
			var code = e.keyCode;  
			if ((code != 8 && code != 13) ||  
				(type == 'input' && code != 13 ) ||  
				(type == 'textarea') ||  
				(type == 'submit' && code == 13)) {  
				return true;  
			}
			else{  
				return false ;  
			}  
		}  
	} 
})
</script>
</head>

<body oncontextmenu="return false" onselectstart="return false" onkeydown="KeyDownFunction()">
	$if Data:
		<div id="smsDetailsWrap" rel = "$Data[0]['number']">
			<div class="clearfix">
    			<div class="sign fl"><img src="/static/imgs/contacts_default.png" width="34" height="34" /></div>
        		<a class="num">$Data[0]['name']</a>
    			<input type="button" class="addPbmButtonn" value='$trans("WEBSMS_ADDTO_CONTRACT")' name="addPbmName" id="addPbmName" />
			</div>
			<div class="smsChat clearfix">
   				<textarea class="inChat fl"></textarea>
			</div>
    		<div class="detailList">
				$for date in Data:
    				<h3>$date["date"]</h3>
					$for name in date["data"].keys():
        				<a rel="$date["data"][name][0]['Address'][0]" wording="addToCon">$name &nbsp; - &nbsp; $trans("WEBSMS_ADDTO_CONTRACT")</a>
						$for item in date["data"][name]:
							<dl class="clearfix" rel = "$item['SmsID']" number = "$item['Address'][0]" location = "$item['StorageLocation']" Protocol = "$item["Protocol"]">
							<dt>$item["showname"] &nbsp; : &nbsp; </dt>
							<dd class="smsData" rel="$item["Protocol"]">$item["Body"] &nbsp; - &nbsp; $item["time"]</dd>
							<dd class="operate"><a class="delet"></a><a class="forword"></a><a class="mark"></a></dd>
							</dl>
    			</div>
		</div>
</body>
</html>
