this.tooltip = function() {
    xOffset = 10;
    yOffset = 20;
    $("#rezultate tr.tooltip, .produs-special-info .produs-detalii .link_prod_special").hover(function(e) {
        this.t = this.title;
        this.title = "";
        $("body").append("<p id='tooltip'>" + this.t + "</p>");
        $("#tooltip").css("top", (e.pageY - xOffset) + "px").css("left", (e.pageX + yOffset) + "px").fadeIn("fast");
    }, function() {
        this.title = this.t;
        $("#tooltip").remove();
    });
    $("#rezultate tr.tooltip, .produs-special-info .produs-detalii .link_prod_special").mousemove(function(e) {
        $("#tooltip").css("top", (e.pageY - xOffset) + "px").css("left", (e.pageX + yOffset) + "px");
    });
};

$(document).ready(function(){
    $("label:contains('*')").each(function(){
        $(this).html($(this).html().replace(/\*/, ' <span class="x">*</span>'));
    });
$("dd:not(:first)").hide();
  $("dt a").click(function() {
    if ($(this).parent().next().is(":hidden")) {
      $("dd:visible").slideUp();
      $(this).parent().next().slideDown();
    }
    return false;
  });
    $("#rezultate tr,#rezultatele tr").mouseover(function(){
       $(this).addClass("hover");
    }).mouseout(function(){
       $(this).removeClass("hover");
    });
    $("#rezultate tr:odd").addClass("impar");
    $("#rezultate tr:even").addClass("par");
    $("#rezultatele tr:odd").addClass("impar");
    $("#rezultatele tr:even").addClass("par");
    $("#tree").treeview({
        animated:"normal",
        persist: "cookie"
    });
    $("#categorii_speciale #produs-special").quickpaginate({ 
      perpage: 10, pager : $("#paginator")
    });
    tooltip();
});

function go(url){
  document.location.href = url;
}

function getXMLHTTP(){
  var xmlhttp = false;
  try {
    xmlhttp = new XMLHttpRequest();
  }
  catch (e){
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e){
      try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (el){
        xmlhttp = false;
      }
    }
  }
  return xmlhttp;
}

function cauta_modele(marca){
  var strURL = "views/modules/search.models.php?marca=" + marca;
  var req = getXMLHTTP();
  if (req){
    req.onreadystatechange = function(){
      if (req.readyState == 4){
        if (req.status == 200){
          document.getElementById('lista_modele').innerHTML = req.responseText;
        }
        else {
          alert("Eroare XMLHTTP:\n" + req.statusText);
        }
      }
    };
    req.open("GET", strURL, true);
    req.send(null);
  }
}

function cauta_ani(marca, model){
  var strURL = "views/modules/search.years.php?marca=" + marca + "&model=" + model;
  var req = getXMLHTTP();
  if (req){
    req.onreadystatechange = function(){
      if (req.readyState == 4){
        if (req.status == 200){
          document.getElementById('lista_ani').innerHTML = req.responseText;
        }
        else {
          alert("Eroare XMLHTTP:\n" + req.statusText);
        }
      }
    };
    req.open("GET", strURL, true);
    req.send(null);
  }
}
