﻿function OnOKShowBuzyBox()
{
    if ( document.getElementById('DropDownListCounty').value != '(任意)' || document.getElementById('DropDownListDrainArea').value != '(任意)' )
        showBuzyBox();
}

function showBuzyBox()
{
    var busyDlg = document.getElementById('PanelMsg');              
    if( busyDlg )
    {
        busyDlg.style.display = 'inline';      
    }
}
function disabledQuery()
{
    var obj1 = document.getElementById('queryStr')
    if(obj1)
        obj1.disabled = 'false';  
}
function openerRedir(sname, bb) {    
    
    
    if(window.opener != null)
    {
        if(!window.opener.closed)
        {
            if(bb != '')
            {
                window.opener.location = sname + encodeURI(bb) ; 
                window.opener.focus();
            }
            else
                window.open(sname , "666" , 'height=600, width=800, top=100, left=100, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes, status=yes').focus();
        }
        else    
            window.open(sname + encodeURI(bb), "666" , 'height=600, width=800, top=100, left=100, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes, status=yes').focus();
    }
    else 
        window.open(sname + encodeURI(bb), "666" , 'height=600, width=800, top=100, left=100, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes,location=yes, status=yes').focus();
    }
    function afa_mpget(objId) 
    {    
        var inp = document.getElementById(objId);
        if (!inp) inp = document.getElementById("ctl00_" + objId);   
        if (!inp) inp = document.getElementById("ctl00_ContentPlaceHolder1_" + objId);   
        if (!inp) inp = document.getElementById("ctl00_ContentPlaceHolder2_" + objId);
        return inp;
    }  
    
function replaceall(astr,strFind,strReplace)
{
var strOrg=astr;
var index = 0;
while(strOrg.indexOf(strFind,index) != -1)
{
strOrg = strOrg.replace(strFind,strReplace);
index = strOrg.indexOf(strFind,index);
}
return strOrg;
}


function PrintGridView(GridViewClientID,PageTitle)
{
    try
    {
   

        var TableID=document.getElementById(GridViewClientID);
        var btn = afa_mpget('PrinterSpan'); 
        var btn1 = afa_mpget('PrinterSpan2');         
        var prenextbtn = afa_mpget('PrevNextSpan');
        var prenextbtn2 = afa_mpget('PrevNextSpan2');
        var imgbtn = afa_mpget('ImageButton1');
        var imgbtn1 = afa_mpget('viewControl');       
        var display1,display2,display3,display4,display5,display6;        
        if( btn )
        {            
            display1 = btn.style.display;
            btn.style.display = 'none';
        }
        if( btn1 )
        {            
            display2 = btn1.style.display;
            btn1.style.display = 'none';
        }                
        if( prenextbtn )
        {            
            display3 = prenextbtn.style.display;
            prenextbtn.style.display = 'none';
        }
        if( prenextbtn2 )
        {            
            display4 = prenextbtn2.style.display;
            prenextbtn2.style.display = 'none';
        }
        if( imgbtn )
        {            
            display5 = imgbtn.style.display;
            imgbtn.style.display = 'none';
        }
        if( imgbtn1 )
        {            
            display6 = imgbtn1.style.display;
            imgbtn1.style.display = 'none';
        }

        var PrintWindow=window.open("","","SCROLLBARS=YES,toolbar=yes,WIDTH=800, HEIGHT=600, LEFT=100,TOP=50,RESIZABLE=YES"); 
        var PrintStyles="@media screen { .UserFriendlyButton {border: #2C59AA 1px solid; font-size:10px;filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0,  StartColorStr=#ffffff, EndColorStr=#C7D7FA);"        
        PrintStyles+="cursor: hand;	padding:2px 2px 0px 2px; width:50px;} }";
        PrintStyles+="#PrintOptionCell INPUT,.DrillDownAnchorTag {display:none;}";
        PrintStyles+="@media print {.UserFriendlyButton{display:none;}}";

        var OptionTable='<table cellpadding="0" cellspacing="0" >';
        OptionTable+='<tr>';
        OptionTable+='<td >&nbsp;&nbsp;<A onclick="javascript:window.print();" style="width: 60px;"><div  class="UserFriendlyButton" style="width: 55px"><img src="images/printer2.gif" alt="" /> 列印 </div></A></td>';
        OptionTable+='</tr></table><br /> ';

        PrintWindow.document.open();
        PrintWindow.document.write("<html>");   
        PrintWindow.document.write('<link href="style.css" rel="stylesheet" type="text/css" />');
        PrintWindow.document.write('<script type="text/javascript">function showTip(msg, ev){}function keepTip(msg){}function hideTip(){}function ppp(aa, bb){ }function openerRedir(){}function openRe( x,y,z){}function openerRedir(cc,dd){}</script>');
        PrintWindow.document.write('<head><title>'+PageTitle+'</title></head><style>'+PrintStyles+'</style>');
        PrintWindow.document.write('<body>');
        PrintWindow.document.write(OptionTable);    
        //var word ="fghjfghdfjvgdfgd";
        //alert(replaceall(word,"fg","A"));
        //alert(TableID.parentNode.innerHTML.replace("__doPostBack","ppp"));
        PrintWindow.document.write(replaceall(TableID.parentNode.innerHTML,"__doPostBack","ppp"));
        PrintWindow.document.write("<br>");
        PrintWindow.document.write("</body>");
        PrintWindow.document.write("</html>");
        PrintWindow.document.close();
        if( btn )
            btn.style.display = display1;
        if( btn1 )
            btn1.style.display = display2;
        if( prenextbtn )
            prenextbtn.style.display = display3;
        if( prenextbtn2 )
            prenextbtn2.style.display = display4; 
        if( imgbtn )
            imgbtn.style.display = display5;
        if( imgbtn1 )
            imgbtn1.style.display = display6;    
          
    }
    catch(e)
    {
        alert(e);
    }
}
