ksevelyar, как вариант...
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<!--
<link rel="stylesheet" type="text/css" href="tmp.css" />
-->
<style type="text/css">
#win {
width: 150px;
padding: 10px;
border: 1px solid;
display: none;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
$('#btn_win').click(function(){
var val=$(this).text();
if (val=='Open') {
$(this).text('Close');
$('#win').show();
setTimeout(function (){
$(document).bind('click',close);
},100);
} else {
closeWin();
};
});
});
function close() {
var e=event.target||event.srcElement;
if (e.id=='win'||$(e).parents('#win').length>0) {
return false;
}
closeWin();
};
function closeWin() {
$('#btn_win').text('Open');
$('#win').hide();
$(document).unbind('click',close);
};
</script>
</head>
<body>
<a id='btn_win' href='#'>Open</a>
<div id='win'>
<form>
<input type='text' />
<input type='button' value='Save' />
</form>
</div>
</body>
</html>