$(function() {
	$(".class table[border=1]").addClass("colored").each(function() {
		$("tr", $(this)).each(function(i) {
			if (!(i % 2)) $(this).addClass("table_row2")
		})
	})	

	$(".grayscale").mouseover(function() {
		grayscale($(this));
	}).mouseout(function() {
		grayscale.reset($(this));
	})

	$(".ingrayscale").mouseover(function() {
		grayscale.reset($(this));
	}).mouseout(function() {
		grayscale($(this));
	}).each(function() {
		grayscale($(this));
	});	
	
	
	$("ol").not(".minus ol").each(function() {
		var start = parseInt($(this).attr("start"));
		if (!start || start == -1) start = 1;
		
		var i = start;
		$(this).children().each(function() {			
			$(this).prepend("<span class='sq'>" + i + "</span> ");
			i++;
		});
	})
	
	$(".minus ol").each(function() {
		var start = parseInt($(this).attr("start"));
		if (!start || start == -1) start = 1;
		
		var i = start;
		$(this).children().each(function() {			
			$(this).prepend("<span class='sq_gray'>" + i + "</span> ");
			i++;
		});
	})

	$("img[over]").each(function() {
		$(this).attr("out", $(this).attr("src"));
	}).live("mouseenter", function() {
		$(this).attr("src", $(this).attr("over"));
	}).live("mouseleave", function() {
		$(this).attr("src", $(this).attr("out"));
	});

	$(".dotted").click(function(){
		$(".hide").slideToggle("slow");
	})
	

	$(".rightimg ul li").each(function() {
		var zakaz = $(this).text();				
		if ((zakaz == "Заказ услуг") && $(".rightimg canvas")) { 
			$(this).css("display", "none");
		}
	});

	$('a[rel*=#]').overlay({
		mask: {
			color: '#000',
			loadSpeed: 200,
			opacity: 0.5
		},

		closeOnClick: true,
		fixed: false,
		top: "center"
	});


	$('a[rel=lightbox]').lightBox(); 	

/*	$("a.news_header").mouseover(function(){			
		$("div.news_date", $(this)).css("background-color", "#bf2e1a");
		$("div.news_title", $(this)).css("text-decoration", "underline");
	}).mouseout(function(){			
		$("div.news_date", $(this)).css("background-color", "#A1A1A5");
		$("div.news_title", $(this)).css("text-decoration", "none");
	})*/
	

	$("#sell table td input[name=email], #sud table td input[name=email]").blur(function(){
		var mail =$(this).val();
		if (!/[_a-zA-Z0-9\-.]+@[_a-zA-Z0-9\-.]+/.test(mail)) {			
			mail = false;
		}

		if (mail === false) {
			$("#sell table td input[type=submit], #sud table td input[type=submit]").attr("disabled", "disabled");
			alert("Пожалуйста, введите адрес электронной почты");		
		}
	})

	$("#call table td input[name=phone], #sud table td input[name=phone], #sell table td input[name=phone]").blur(function(){		
		if($(this).val().length < 7){
			$("#call table td input[type=submit], #sud table td input[type=submit], #sell table td input[type=submit]]").attr("disabled", "disabled");
			alert("Пожалуйста, введите номер телефона");				
		} else {
			$("#call table td input[type=submit],  #sud table td input[type=submit], #sell table td input[type=submit]").attr("disabled", "");	
		}
	})

	$("#call table td.time span, #sud table td.time span, #sell table td.time span").click(function(){
		time = $(this).text();	
		$("#call table td.time span, #sud table td.time span, #sell table td.time span").css({"color" : "#7F0F00", "border-bottom" : "1px dotted #7F0F00", "font-weight" : "normal"});
		$(this).css({"color" : "#000000", "border" : "none", "font-weight" : "bold"});
		$("input#time").val(time);		
	})
	
	$(".a_blocks_title, .news_header").hover(function() {
		$(this).parent().addClass("hover");
	}, function() {
		$(this).parent().removeClass("hover");
	});
	
});

