$.fn.pause = function( duration )
{
   $( this ).animate( { dummy: 1 }, duration );
   return this;
};

$( document ).ready( function()
{
//	$("._login_link").click(function(e){
//		e.preventDefault();
//		removeIframe();
//	$.modal('<iframe src="/login/" width="600" height="255" scrolling="no" frameborder="0">', {
//		//closeHTML:"",
//		containerCss:{
//			backgroundColor:"#fff",
//			borderColor:"#0063dc",
//			height:255,
//			padding:0,
//			margin:0,
//			width:600
//		},
//		close:true,
//		overlayClose:true,
//		escClose:true
//		//onClose:modalClose
//	});
//		//$(document.body).append('<iframe id="login-iframe" scrolling="no" frameborder="0">');
//		//$('#login-iframe').attr('src', '/login/');
//		//$('#login-iframe').modal();
//	});
//
   $( '#login_link' ).fancybox(
   {
      "showCloseButton" : false,
      "width" : 600,
      "height" : 250,
//			   "autoDimensions":true,
      "scrolling" : "no"
   }
   );

   $( "#user-exit" ).click( function( e )
   {
      e.preventDefault();
      removeIframe();
      $( document.body ).append( '<iframe id="login-iframe" scrolling="no" frameborder="0">' );
      $( '#login-iframe' ).attr( 'src', HTTP_SERVER_BLOG + 'login/exit/' );
      //$( '#login-iframe' ).modal();
      setTimeout( function()
      {
         closeOnlyLoginModal();
      }
      , 2000 );
      $( '#user-login' ).attr( 'href', '' );
      $( '#user-login' ).text( '' );
      if ( $.browser.msie )
         {
            $( '.login-invitation' ).css( {display:'block'} );
         }
      else
         {
            $( '.login-invitation' ).css( {display:'table-cell'} );
         }
      $( '.profile' ).css( {display:'none'} );
   } );

   if ( userName.length > 0 )
      {
         if ( $.browser.msie )
            {
               $( '.login-invitation' ).css( {display:'none'} );
               $( '.profile' ).css( {display:'block'} );
            }
         else
            {
               $( '.login-invitation' ).css( {display:'none'} );
               $( '.profile' ).css( {display:'table-cell'} );
            }
      }
   else
      {
         if ( $.browser.msie )
            {
               $( '.login-invitation' ).css( {display:'block'} );
               $( '.profile' ).css( {display:'none'} );
            }
         else
            {
               $( '.login-invitation' ).css( {display:'table-cell'} );
               $( '.profile' ).css( {display:'none'} );
            }
      }
} );

function closeLoginModal( userId, userName )
{
//   setTimeout( function()
//   {
//      closeOnlyLoginModal();
//   }
//   , 2000 );
   $( '#user-login' ).attr( 'href', HTTP_SERVER_BLOG + 'settings/profile/' );
   $( '#user-login' ).text( userName );
   $( '.login-invitation' ).css( {display:'none'} );
   if ( $.browser.msie )
      {
         $( '.profile' ).css( {display:'block'} );
      }
   else
      {
         $( '.profile' ).css( {display:'table-cell'} );
      }
   $.fancybox.close();   
}

function formRegistration($this)
{
   $this.ownerDocument.location.href=HTTP_SERVER_BLOG+'/registration';
   $('#fancybox-content').css({height:420})
   //$.fancybox.resize();
//closeOnlyLoginModal();
//   $( document.body ).append( '<iframe id="login-iframe" scrolling="no" frameborder="0">' );
//   $( '#login-iframe' ).css( {height:'425px'} );
//   $( '#login-iframe' ).css( {width:'650px'} );
//   $( '#login-iframe' ).attr( 'src', '/registration/' );
//   $( '#login-iframe' ).modal();

}

function removeIframe()
{
   if ( ( typeof $( '#login-iframe' ) ) != 'undefined' )
      {
         $( '#login-iframe' ).remove();
      }
}

function closeOnlyLoginModal()
{
    $.fancybox.close();  
//   $.modal.close();
   removeIframe();
}


