$().ready(function() {

  // SEARCH BOX ===========================================
  $('#search').click(function()
  { thisSearch  = $(this).val();
    if (thisSearch == 'Cauta' || thisSearch == 'Caută')
    { $(this).val(''); }; 
    return false;   
  });
  
  $('#search').blur(function()
  { thisSearch  = $(this).val();
    if (thisSearch.length == 0)
    { $(this).val('Cauta'); };        
  });
  
  $('#startsearch').click(function()
  { thisSearch  = $('#search').val();
    if (thisSearch.length > 0 && thisSearch != 'Cauta' && thisSearch != 'Caută')
    { $('#searchform').submit();     
    } else  { alert('Va rugam sa introduceti criteriile de cautare!');  }; 
    return false;   
  });

  // ======================================================
  
  // MENU DISPLAY =========================================
  $(".meniu-element").mouseover(function(){  
    $('.meniu-element-links',this).addClass('active');
    $(".submeniu", this).show();
  }).mouseout(function(){
    $(".submeniu", this).hide();
    $('.meniu-element-links',this).removeClass('active');
  });
  // ======================================================
  
  // TOOLTIPS =============================================
    $(".saytooltip").tooltip();
    $(".saytooltip2").tooltip({ position: "top center", offset: [5, 183 - ($(document).width()/2)] });
    $(".saytooltip3").tooltip({ position: "top center", offset: [5, ($(document).width()/2) - 183 ] });
    $(".saytooltip4").tooltip({ position: "bottom center", opacity: 0.9, tipClass: "tooltipbottom" });    
    $(".saytooltip5").tooltip({ position: "top right"});
    $(".saytooltip6").tooltip({ position: "top left"});
  // ======================================================
  
  // BUG OVERLAY ==========================================
    //var commonBugOverlay = $('#this_site_bug').overlay({mask: {
		//color: '#000000', loadSpeed: 100, opacity: 0.6  }, api: true});
    //var commonBugOverlay = $('#this_site_bug').data("overlay"); 
    //$("#btn_opopupcancel").click(function()  { commonBugOverlay.close(); return false; });
    
		  $("#this_site_bug").fancybox(
            {    'titleShow'          : false,
                 'showCloseButton'    : false,
                 'hideOnOverlayClick' : false,
                 'overlayShow'        : true,
                 'centerOnScroll'     : true,
                 'overlayOpacity'     : 0.5,
                 'overlayColor'       : '#000000',
                 'scrolling'          : 'no',
                 'onComplete'         : function()  {   $('#bvnumele').focus(); },
                 'onClosed'           : function()  {   $('.mytextb, .mytextareab').removeClass('newerroralertred'); }
            });    
        
    $("#btn_opopupcancel").click(function()  { $.fancybox.close(); return false; });
    $("#btn_opopupsend").click(function()  
    { thisBugCLname = $('#bvnumele').val();
      thisBugCLmail = $('#bvemail').val();
      if (thisBugCLname.length > 0 && thisBugCLmail.length > 0 && IsValidEmail(thisBugCLmail) == true )
      { $('#report_site_bug_form').submit();  }
      else
      { alert('Atentie!\n\nVa rugam sa completati toate datele!\nVerificati ca adresa de email sa fie valida!\n\nVa multumim!');
        $('#bvnumele').focus();  };      
      return false;     
    });    
  // ======================================================
// - init ready end ==     });
// text blink
  $('.blinkme').blink({delay:3000});
});
  // FRONT-PAGE NEWSLETTER
  function fpp_newsletter()
  {
    fpn_holder  = $('#frp_newsletter');
    fpn_btnsbn  = $('#frp_btn_newsletter');
    fpn_value   = fpn_holder.val();
    if (fpn_value.length > 0 && fpn_value != 'Adresa dvs. de email')
    { send_to_url = 'http://www.vintage.ro/index.php?idp=index&ida=fp_newsletter';    
      if (IsValidEmail(fpn_value) == true)
      { fpn_btnsbn.attr('disabled', true);
        fpn_holder.attr('disabled', true);
        $.ajax({
          type: 'POST',
          url: send_to_url,
          data: { nemail: fpn_value},
          success: function(reponsedata)
            {              
              if (reponsedata == '1')
              { alert('Adresa dvs. a fost inregistrata cu succes!\n\nVa multumim!'); }
              else if (reponsedata == '2')
              { alert('Adresa dvs. a fost deja inregistrata!\n\nVa multumim!');  }
              else
              { alert('Adresa dvs. a fost inregistrata cu succes!\n\nVa multumim!'); };
              fpn_holder.val('Adresa dvs. de email');        
              fpn_holder.removeAttr('disabled');
              fpn_btnsbn.removeAttr('disabled');                                        
            },
          error: function()
            {
              fpn_holder.val('Adresa dvs. de email');        
              fpn_holder.removeAttr('disabled');
              fpn_btnsbn.removeAttr('disabled');              
            },
          dataType: 'html'});          
      }
      else
      { alert('Atentie!\n\nVa rugam sa introduceti o adresa de email valida!\n\nVa multumim!'); };
    }
    else
    { alert('Atentie!\n\nVa rugam sa introduceti o adresa de email valida!\n\nVa multumim!'); };
    return false;  
  };
  
  function fbDebug(theMessage)
  {
    //console.log(theMessage);
  };        
  function cookieDate()
  { returnText =  ''; 
    date = new Date();
    returnText  = date.setTime(date.getTime() + parseInt(3 * 24 * 60 * 60 * 1000));
    return returnText;  };
  // the same height ======================================  
    function v_equalHeight(group) 
    { var tallest = 0;
      group = $(group);
    	group.each(function() 
        {
    		  var thisHeight = $(this).height();
    		  if(thisHeight > tallest) 
          { tallest = thisHeight; };
    	});
    	group.height(tallest);
    };
  // ======================================================
  // AJAX LOADER ==========================================
    function spajax_do1(container)
    {
      if (container.length > 0)
      { 
        $(container).html('<div id="spajx_container_loader" style="width: 100%; padding: 10px 0px 10px 0px; text-align: center;"><center><img src="http://www.vintage.ro/pub/sym/img/ajaxloadercart04.gif" border="0"></center></div>');
      };
    };  
  // ======================================================  
  // ONLOAD FUNCTIONS =====================================
    window.onbeforeunload = function() 
    {               
    };
  // ======================================================  
