$(document).ready(function() {
	$(".tabelHover tr").mouseover(function() { $(this).addClass('hover'); });
	$(".tabelHover tr").mouseout(function() { $(this).removeClass('hover'); });
	$(".tabelHover tr").click(function() { 
		link = $("a.linkRow", this).attr('href');
		if(link) document.location = link;
	});

	$(".lanseaza select[@name=id_categorie]").change(function() {
		$("#specifice").html("<br/><br/><center><img src=\"/img/ajax-loader.gif\"/></center>");
		$("#specifice").load("/cerere_de_oferta_detalii.obj?id_categorie=" + $(this).attr("value"), {}, function() { $(".in", this).hide(); $(".in", this).fadeIn(); });
	});

	$(".lan").click(function() {
		$(this).parent().hide();
		$(".autentificare").hide();
		$("#formLanseaza").html("<br/><br/><center><img src=\"/img/ajax-loader.gif\"/></center>");
		$("#formLanseaza").load("/lanseaza_cerere_de_oferta.obj?aj2=1", {}, function() { 
			$(".lanseaza", this).hide();
			$(".lanseaza h1", this).hide();

			$("#header").css("height","650px");
			$("#bodymare").css("background-position","0 -350px");

			$(".lanseaza", this).slideDown(1000); 
				$(".lanseaza select[@name=id_categorie]").change(function() {
				$("#specifice").html("<br/><br/><center><img src=\"/img/ajax-loader.gif\"/></center>");
				$("#specifice").load("/cerere_de_oferta_detalii.obj?id_categorie=" + $(this).attr("value"), {}, function() { $(".in", this).hide(); $(".in", this).fadeIn(); });
			});
		});
		return false;
	});

	//asta in alt fisier
	$(".register input[@name=furnizor], .contulMeu input[@name=furnizor]").click(function() {
		if($(this).attr("checked")) {
			$("input[@name=companie_nume], input[@name=companie_cui], input[@name=companie_regcom], input[@name=companie_telefon], textarea[@name=adresa], input[@name=oras], input[@name=judet], input[@name=companie_iban], input[@name=companie_banca]").each(function() {
				$(this).parent().addClass("req");
				$("label",$(this).parent()).append("<font style=\"color: red; font-weight: bold;\">*</font>");
			});
		} else {
			$("input[@name=companie_nume], input[@name=companie_cui], input[@name=companie_regcom], input[@name=companie_telefon], textarea[@name=adresa], input[@name=oras], input[@name=judet], input[@name=companie_iban], input[@name=companie_banca]").each(function() {
				$(this).parent().removeClass("req");
				$(this).parent().removeClass("err");
				$("label font",$(this).parent()).remove();
			});
		}
	});

	$(".linkDate").click(function() {
		$("#dateContact").load("/cerere_de_oferta/dateContact.act?id=" + $(this).attr("id").substring(4), {}, {});
		return false;
	});

	$(".butComanda").click(function() {
		$(".formComanda").html("");
		$(".formLans").html("");
		$(".formComanda", $(this).parent().parent()).html("<div style=\"text-align: center; clear: both; padding-top: 20px;\"><img src=\"/img/ajax-loader.gif\"/></div>");
		$(".formComanda", $(this).parent().parent()).load("/comanda_produs.obj?id=" + $(this).attr("id").substring(3), {}, function() { $("form", $(this)).hide(); $("form", $(this)).toggle('slow'); $(".anunturi li").removeClass("hover"); $(this).parent().addClass("hover"); });
		return false;
	});

	$(".ajDetalii").click(function() {
		var link = $(this);
		var dest = $(this).parent().parent();

		$(".det").remove();

		dest.after("<tr class=\"det\" id=\"row\"><td colspan=\"4\"><center><img src=\"/layout/standard/images/ajax-loader.gif\"/></center></td></tr>");		

		$.ajax({
		  url: '/inregistrare/login_tabel.act',
		  success: function(data) {
			dest.next().html(data);
			jqv();
		  }
		});

		return false;
	});
});
