Change these two function slightly because the IDs of the controls are changes afetr rendering
function hideModal() {
document.getElementById('<%= Panel1.ClientID %>').style.display = 'none';
}
function hidepanel2() {
document.getElementById('<%= Panel2.ClientID %>').style.display = 'none';
document.getElementById('<%= Panel1.ClientID %>').style.display = 'block';
}