<%@ Page Language="C#" AutoEventWireup="true"  Codebehind="selectSingleArea.aspx.cs" Inherits="PPFOR.Admin.CustomView.selectSingleArea"    Title="地区列表" %>
<!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 id="Head1">
    <title>地区选择</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
    <link href="../Css/global.css" rel="stylesheet" type="text/css" />
<script src="../JS/ajax.js" type="text/javascript"></script> 
<script type="text/javascript">
    function showLoadingMsg()
    {
        var objMsg=docEle('msg');
        if(objMsg)
        {
             objMsg.style.display='';
             var _scrollTop = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
             var _scrollLeft= Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);
             objMsg.style.margin=(_scrollTop - 60) + "px 0 0 " + (_scrollLeft - 102) + "px";   
        }   
    }     
    function hideLoadingMsg()
    {
        var objMsg=docEle('msg');
        if(objMsg)
        {
            objMsg.style.display='none';
        }        
    }     
    function showChildAreaList(objImage,aId)
    {
        var objTarget=docEle("child_" + aId);
        if(objImage.getAttribute("statue")!=null && objImage.getAttribute("statue")=="expand"){
            objImage.setAttribute("statue","collapse");
            objImage.src="/Admin/Images/collapse.gif"; 
            if(objTarget){
                objTarget.style.display='';
            }else{
                showLoadingMsg();
                DoAjax("/Admin/Sys/WebConfig/GetAreaList.aspx?type=2&bid=" + aId,"GET",null,fetchChildAreaList,aId);
            }
        } else {
            objImage.setAttribute("statue","expand");
            objImage.src="/Admin/Images/expand.gif"; 
            if(objTarget){
                objTarget.style.display='none';
            }
        }
    }
    function fetchChildAreaList(xmlHttp,bId)
    {
        if(xmlHttp.responseText!=null)
        {  
            var objParentRow=docEle('area_' + bId);             
            var newRow=objParentRow.parentNode.parentNode.insertRow(objParentRow.rowIndex+1); 
           
            newRow.id="child_" + bId;
            var objNewTd=newRow.insertCell(0);
            objNewTd.innerHTML=xmlHttp.responseText;            
        }
        setTimeout("hideLoadingMsg()",300);
    }
    function checkAreaSeletedChanged()
    {
        var cid=location.href.match(/(?!=\?|&)(cid=)([^=&?,]*)/i);  
        var bid=location.href.match(/(?!=\?|&)(bid=)([^=&?,]*)/i);  
        if(cid!=null && bid!=null && cid.length>2 && bid.length>2){
            var objTargetText=parent.document.getElementById(cid[2]);
            var objTargetBelong=parent.document.getElementById(bid[2]);
            if(objTargetText!=null && objTargetText.type=='text' && objTargetBelong.type=='hidden'){
                var areas=document.getElementsByName('areaSelected');
                if(areas!=null && areas.length>0){
                    for(var i=0;i<areas.length;i++){
                        if(areas[i].checked){     
                            objTargetBelong.value=areas[i].value;                      
                            objTargetText.value=areas[i].title;
                            if(document.all){
                                objTargetText.fireEvent("onchange");
                            } else {
                                var evt = document.createEvent('HTMLEvents');   
                                evt.initEvent('change',true,true);   
                                objTargetText.dispatchEvent(evt);   
                            }                    
                            break;
                        }
                    }
                }        
            }
        }
        parent.popup_close();
        return false;
    } 
</script>
</head>
<body>
<form action="selectSingleArea.aspx" id="form1" method="post">  
	<table id="showAreaList" style="margin:0;" border="0" cellpadding="0" cellspacing="0" class="forarea">	    
	<tbody>		    
	    <%=PPFOR_showAreaList %>
	    <tr style="display:none;">
            <td align="center" style="height:30px;">            
                <input type="button" id="select" value="确定" onclick="checkAreaSeletedChanged();return false;" class="inputbutton" onmouseover="this.className='inputbutton_hover'" onmouseout="this.className='inputbutton'"/>                
                <input type="button" id="cancel" onclick="parent.popup_close();" value="取消" class="inputbutton" onmouseover="this.className='inputbutton_hover'" onmouseout="this.className='inputbutton'"/>               
                <script type="text/javascript"> 
                    parent.popup_clearButtons();
                    parent.popup_addButton(document.getElementById('select'));
                    parent.popup_addButton(document.getElementById('cancel'));
                </script>
            </td>
        </tr> 
	</tbody>
	</table>   
</form>        
<div id="msg" style="position: absolute; z-index: 300; height: 120px; width: 204px; left: 50%; top: 50%; margin-left: -100px; margin-top: -80px; display:none;">
	<div id="Layer2" style="position: absolute; z-index: 300; width: 190px; height: 90px; background-color: #ffffff; border: 1px solid #79BDD3; font-size: 14px;">
		<div id="Layer4" style="height: 26px; background: none repeat scroll 0% 0% rgb(241, 245, 250); line-height: 26px; padding: 0px 3px; font-weight: bold; color:#0099CC">正在加载...</div>
		<div id="Layer5" style="height: 64px; line-height: 150%; padding: 0px 3px; text-align:center"><br/><img src="/Admin/Images/loading.gif" alt=""/><br/></div>
	</div>
	<div id="Layer3" style="position: absolute; width: 190px; height: 90px; z-index: 299; left: 4px; top: 5px; background-color: rgb(232, 232, 232);"></div>
	</div>
</body>
</html>