<!--<?php
if($step == 'email'){
print <<<EOT
-->
<div class="popTop" onmousedown="read.move(event)" style="cursor:move"><span class="adel" onclick="closep();">close</span>導入我的郵件聯系人</div>
<div class="p15">
<div id="message"></div>
<form action="$normalUrl" method="post" name="EMAIL" onsubmit="return false">
<input type="hidden" name="step" value="addressList" id="step"/>
	<!--<p class="rightTip">請放心，網站不會記錄你的郵箱信息</p>-->
	<table width="100%">
    	<tr>
        	<td width="50" height="40">電子郵箱</td>
            <td width="165"><input id="username" name="username" type="text" class="input input_wa"></td>
            <td>&nbsp;
            <select class="select_wa" name="type" id="type">
                <option value="gmail">@gmail.com</option>
                <option value="163">@163.com</option>
                <option value="126">@126.com</option>
            </select>
            </td>
        </tr>
        <tr>
        	<td height="40">密碼</td>
            <td><input id="password" name="password" type="password" class="input input_wa"></td>
            <td>&nbsp;</td>
        </tr>
        <tr>
        	<td>&nbsp;</td>
            <td class="tar"><span class="btn2"><span><button onclick="getMailList()">導入</button></span></span></td>
            <td>&nbsp;</td>
        </tr>
    </table>
</form>
</div>
<!--
EOT;
} elseif ($step == 'msn') {print <<<EOT
-->
<div class="popTop" onmousedown="read.move(event)" style="cursor:move"><span class="adel" onclick="closep();">close</span>導入我的MSN聯系人</div>
<div class="p15">
<div id="message"></div>
<form action="$normalUrl" method="post" name="EMAIL" onsubmit="return false">
<input type="hidden" value="msn"  name="type" id="type"/>
<input type="hidden" name="step" value="addressList" id="step"/>
<div class="mb10">
	<table width="100%">
    	<!--<tr>
        	<td width="50" height="40">&nbsp;</td>
            <td><span class="mr20"><label for="msn"><input name="" id="msn" type="radio" value="">MSN</label></span>
            <label for="talk"><input name="" id="talk" type="radio" value="">Gtalk</label></td>
            <td>&nbsp;</td>
        </tr>
    	--><tr>
        	<td width="50" height="40">帳號</td>
            <td><input id="username" name="username"  type="text" class="input input_wa"></td>
            <td>&nbsp;
            </td>
        </tr>
        <tr>
        	<td height="40">密碼</td>
            <td><input id="password" name="password" type="password" class="input input_wa"></td>
            <td>&nbsp;

            </td>
        </tr>
        <tr>
        	<td>&nbsp;</td>
            <td><span class="btn2"><span><button onclick="getMailList()">導入</button></span></span></td>
            <td>&nbsp;

            </td>
        </tr>
    </table>
</div>
</form>
</div>
<!--
EOT;
} elseif ($step == 'csv'){print <<<EOT
-->
<div class="popTop" onmousedown="read.move(event)" style="cursor:move"><span class="adel" onclick="closep();">close</span>導入我的郵件聯系人</div>
<div class="p15">
<div id="message"></div>
<form action="$normalUrl" method="post" enctype="multipart/form-data" name="EMAIL"  onsubmit="return false">
	<input type="hidden" name="step" value="addressList" id="step"/>
	<input type="hidden" name="type" value="csv" id="type"/>
	<table width="100%">
    	<tr>
        	<td width="120" height="40">上傳csv格式地址簿</td>
            <td width="200"><input name="csv" id="csv" type="file" class="input input_wa"></td>
            <td>&nbsp;
            </td>
        </tr>
        <tr>
        	<td>&nbsp;</td>
          		<td><span class="btn2"><span><button onclick="getMailList()">導入</button></span></span></td>
            <td>&nbsp;
            </td>
        </tr>
    </table>
</form>
</div>
<!--
EOT;
} elseif ($step == 'simple') {print <<<EOT
-->
<div style="width:380px;">
<div class="popTop" onmousedown="read.move(event)" style="cursor:move"><span class="adel" onclick="closep();">close</span>發送邀請郵件</div>
<div class="p15">
<div id="message"></div>
	<input type="hidden" value="{$invcode}" name="invcodes" id="invcodes"/>
    <h6 class="mb5">邀請電子郵件正文,限200字節</h6>
		<textarea class="textareaA mb10" name="extranote" id="extranote">{$email_content}</textarea>
	 <h6 class="mb5">好友Email &nbsp;(同時發送多個電子郵箱時，每行一個)</h6>
	 <textarea class="textareaA" id="emailcontent"></textarea>
</div>
     <div class="p10 tac">
		<span class="btn2"><span><button  onclick="simpleInvite()">發送邀請</button></span></span>
     </div>
</div>
<!--
EOT;
} elseif ($step == 'addressList') {
$userListDisplay = empty($userList) ? 'style="display: none"' : '';
$emailListDisplay = empty($userList) ? '' : 'style="display: none"';
$_count = $friendCount + $notFriendCount;
print <<<EOT
-->
<div>
<div class="popTop" onmousedown="read.move(event)" style="cursor:move"><span class="adel" onclick="closep();">close</span>導入我的郵件聯系人</div>
<div class="mailFri p15">
<!--
EOT;
if($emailCount == 0){print <<<EOT
-->
	<div id="error">
       <div class="m_height">
          <div class="m_height">
	               <table width="100%">
	               		<tr><td colspan="3"><div class="p10">導出的聯系人列表為空，請確認您輸入了正確的電子郵箱名和密碼</div></td></tr>
	               </table>
	      </div>
       </div>
   </div>
<!--
EOT;
}else{print <<<EOT
-->
   <div id="message"></div>
   <div id="m_list1" $userListDisplay>
   <h6>你的聯系人中有<em>{$_count}</em>位已經在phpwind注冊，其中<em>{$friendCount}</em>位已經是你的好友。以下<em>{$notFriendCount}</em>位你可以加為好友</h6>
	   <div class="m_list">
		   <div class="m_all"><label><input name="friend_all" id="friend_all" type="checkbox" value="" onclick="checkAll(this,'friend[]')">全選</label></div>
	       <div class="m_height">
	           <ul class="half cc">
<!--
EOT;
foreach($userList as $key => $value){
print <<<EOT
-->
					<li><label for="$key">
					<dl>
						<dt><a href="{$db_userurl}{$value[uid]}" class="img_50"><i><img src="{$value[face]}"></i></a></dt>
						<dd><input name="friend[]" type="checkbox" id="$key" value="$key" class="fr">
						<p><a href="{$db_userurl}{$value[uid]}">{$value[username]}</a></p>
						<p>{$value[signature]}</p>
						</dd>
					</dl></label>
					</li>
	<!--
EOT;
}print <<<EOT
-->
	           </ul>
	       </div>
	   </div>
	   <div class="p10 tac">
		<span class="bt2 fr"><span><button onclick = "display('m_list1','m_list2')">跳 過</button></span></span>
	    <span class="btn"><span><button onclick="emailInvite('friend[]','addfriend')">加為好友</button></span></span>
	   </div>
   </div>
   <div id="m_list2" $emailListDisplay>
		<div class="m_list">
	       	<div class="m_all"><label for="email_all"><input name="email_all" id="email_all" type="checkbox" value="" class="mr15" onclick="checkAll(this,'email[]')">全選</label></div>
	           <div class="m_height">
	               <table width="100%" class="tA">
<!--
EOT;
foreach($emailList as $key => $value){
print <<<EOT
-->
	               	<tr>
	                   	<td width="25"><input name="email[]" type="checkbox" value="$key"></td>
	                    <td>{$value}</td>
	                    <td>{$key}</td>
	                </tr>
<!--
EOT;
}print <<<EOT
-->
	               </table>
	           </div>
    	</div>
		<h6>邀請郵件正文</h6>
		<textarea class="textareaA" style="width:593px;" name="extranote" id="extranote">{$inv_linkcontent}</textarea>
		<div id="message"></div>
        <div class="p10 tac">
			 <span class="btn2"><span><button onclick="emailInvite('email[]','sendmail')">發送邀請</button></span></span>
        </div>
   </div>
<!--
EOT;
}print <<<EOT
-->
</div>
<!--
EOT;
}print <<<EOT
-->
<script type="text/javascript">
function checkAll(obj,dst){
	var dst = document.getElementsByName(dst);
		for(var i = 0;i<dst.length;i++){
			dst[i].checked = obj.checked ?  true : false;
		}
}
function getMailList(){
	var type = getObj('type').value;
	var step = getObj('step').value;
	var from = document.EMAIL;
	if("" == type){
		showTips('請選擇電子郵箱類型');
		return false;
	}
	if("" == step){
		showTips('非法操作');
		return false;
	}
	if("csv" == type){
		var csv = getObj('csv');
		if("" ==csv.value){
			showTips('請上傳csv格式文件');
			return false;
		}
	}else{
		username = getObj('username').value;
		password = getObj('password').value;
		if("" == username){
			showTips('用戶名不能為空');
			return false;
		}
		if("" == password){
			showTips('密碼不能為空');
			return false;
		}
	}
	var url = '$normalUrl&step='+step+'&type='+type;
	showTips('正在加載中，請稍後...','message',1);
	ajax.send(url,from,function(){
		ajax.get();
	});
}

function display(hide,block){
	var hide = getObj(hide);
	var block = getObj(block);
	hide.style.display = 'none';
	block.style.display = 'block';

}
/*發送郵件邀請*/
function emailInvite(ckname,step){
	var url = '$normalUrl&step='+step;
	var checkBox = document.getElementsByName(ckname);
	var operateMessage = getObj('message');
	var value = '';
	var data = '';
	for(var i=0;i<checkBox.length;i++){
		if(checkBox[i].checked){
			value += value != '' ? ','+checkBox[i].value : checkBox[i].value;
		}
	}
	if(value == ''){
		if(step == 'addfriend'){
			showTips('請選擇一個要添加的好友');
		}else if(step == 'sendmail'){
			showTips('請選擇要發送的電子郵箱');
		}
		return false;
	}
	if(step == 'sendmail'){
		data = "extranote=" + getObj('extranote').value;
	}
	function callback(){
		var status = ajax.request.responseText;
		if(step == 'addfriend'){
			operateMessage.innerHTML = "";
			display('m_list1','m_list2');
		}else if(step == 'sendmail'){
			var status = ajax.request.responseText;
			if(status == 'mail_is_empty'){
				showTips('郵件地址不能為空');
			}else if(status == 'success'){
				showTips('發送好友邀請成功!','message',1);
			}else if(status == 'mail_limit'){
				showTips('郵件數超過上限20');
			}else if(status == 'mode_o_extra_toolang'){
				showTips('郵件正文過長');
			}
		}
	}
	data = data == '' ? 'value='+value : 'value='+value+'&'+data;
	ajax.send(url,data,callback,'','',true);
}
function simpleInvite(form){
	var email = getObj('emailcontent').value;
	if('' == email){
		showTips('請輸入電子郵箱');
		return false;
	}
	var email = email.replace(/\\n/ig,',').replace(/\\r/ig,'');
	var type = '$rg_allowregister';
	var step = '';
	var data = 'value='+email;
	if(type == 1){
		step = 'sendmail';
		data += "&extranote=" + getObj('extranote').value;
	}else{
		step = 'sendinvitecode';
		data += "&extranote=" + getObj('extranote').value;
		data += "&invcodes=" + getObj('invcodes').value;
	}
	url = '$normalUrl&step='+ step;
	ajax.send(url,data,function(){
		var status = ajax.request.responseText;
		if(status == 'mail_is_empty'){
			showTips('郵件地址不能為空');
		}else if(status == 'success'){
			showTips('發送好友邀請成功!','message',1);
		}else if(status == 'mail_limit'){
			showTips('郵件數超過上限20');
		}else if(status == 'mode_o_extra_toolang'){
			showTips('郵件正文過長,限200字節');
		} else {
			showTips(status);
		}
	});
}
function showTips(message,mid,type){
	if(!message) return false;
	var mdiv = mid ? getObj(mid) : getObj('message');
	mdiv.innerHTML = message;
	if(type){
		mdiv.className = "rightTip mb10";
	}else{
		mdiv.className = "wrongTip mb10";
	}
	mdiv.style.visibility = '';
	return this;
}

</script>
<!--
EOT;
?>-->