/**
 * Loader animation
 */
function init_loader(target)
{
	$(target).append('<div class="loader"><img src="/img/template/loader-white.gif" width="32" height="32" alt="loading" /><br />Loading</div>');
}
function kill_loader(target)
{
	$('.loader', target).remove();
}
$( document ).ready( function() {
    /**
     * Aici ne ocupam de efectele de hover si mouseOut.
     */
    // lista rezultate
    $( '.modul_oferta_lr' ).mouseover( function() {
        $( this ).attr( 'class', 'modul_oferta_lr of_hover' );
    } ).mouseout( function() {
        $( this ).attr( 'class', 'modul_oferta_lr' );
    } );
	// lista rezultate - proiect nou
    $( '.modul_proiect_nou' ).mouseover( function() {
        $( this ).attr( 'class', 'modul_oferta_lr modul_proiect_nou of_hover' );
    } ).mouseout( function() {
        $( this ).attr( 'class', 'modul_oferta_lr modul_proiect_nou' );
    } );
    // ofertele similare
    $( '.modul_oferta_hp' ).mouseover( function() {
        $( this ).attr( 'class', 'modul_oferta_hp of_hover' );
    } ).mouseout( function() {
        $( this ).attr( 'class', 'modul_oferta_hp' );
    } );

    /**
     * Aici ne ocupam de inscrierea la newsletter.
     */
      //attach onSubmit to the form
      $( '#newsletter_subscribe' ).submit( function() {
          //When submitted do an ajaxSubmit
          $( this ).ajaxSubmit( {
              dataType: 'json',
              success: function( data, responseCode ) {
                  //Show flash message as first element after body
                  $( '#newsletter_message' ).attr( 'class', data.flash_class );
                  $( '#newsletter_message' ).html( data.text );
                  $( '#newsletter_message' ).fadeIn( 'slow' );

//                  $( '#flash-hide' ).hide();

                  //Show for 5 seconds
                  setTimeout( function() {
                      $( '#newsletter_message' ).hide();
                      $( '#flash-hide' ).show();
                  }, 5000 );



              }
          } );
          //return false to prevent normal submit
          return false;
      } );
} );
