$(document).ready(function(){
	$('a.cl[@href^="http://"]');
    	
	$("div.tabs_cont h2").each(function(){
		if ($(this).attr("class") != 'norazb') replace_h($(this), 'h2', 32);
	});
	
	sifr_enable();
	menu_enable();
	
	$("input.input-text").not("div.content-main input.input-text").each(function(){
		input_text_enable($(this));
	});
	
	$("div.content-main input.input-text").not(".nowrap").each(function(){
		input_text_cont_enable($(this));
	});
	
	$(".button-image").each(function(){
		button_enable($(this));
	});	
	
	$(".icon").each(function(){
		icon_enable($(this));							
	});
	
	$("div.news").hide();
	
	$("select").each(function(){
		bind_select($(this));
	});
	
	$("input:radio").each(function(){
		bind_radio ($(this));
	});	

	$("input:checkbox").each(function(){
		bind_check ($(this));
	});	

	$("input.other").each(function(){
		var text_poll = $(this).parent().next();
		text_poll.hide().addClass("other_text");
		$(this).next().bind("click", function(){
			if ($(this).prev().attr("type") != 'radio') {
				text_poll.toggle("normal");
			}
			else {
				$(this).prev().bind("click", function(){ text_poll.show("normal"); });
				name = $(this).prev().attr("name");
				$("input:radio").not($(this).prev()).each(function(){
					if ($(this).attr("name") == name) $(this).next().bind("click", function(){
						text_poll.hide("normal");
					});
				});
			}
		});
	});

	if ($("div.content-main").height() < 500) $("p.top").hide();
	$("div.project_item:odd").css("margin-right", "0px");
	
	if ($("div.preview").length) preview();
	
	if ($("form#formCalc").length) group_depend();
	
	if (document.location.href.indexOf('en/') != -1) $("p.proposal").css("margin-top", "19px").find("a img").css("top", "-5px");
 
 	$("body").mousemove(function(e){	
       CoordX = e.pageX;
       CoordY = e.pageY;
    });	
});

function input_text_cont_enable(input){
		var wrap_cont;
		
		if (input.next().attr("class") == 'num') wrap_cont = input.next().andSelf();
		else wrap_cont = input;
		
		wrap_cont.wrapAll("<div class='input-wrap' style='width:" + (input.width()) + "px'></div>");
		input.after("<span style='padding-top:2px;background-repeat:no-repeat;'></span>").width(input.width()-18);
}

function preview (){
		
	$("div.project-image div.pager a.num").bind("click", function(){
		var image = $("div.project-image div.action img").hide();
		var a_link = $(this);
		imgPreloader = new Image();
		imgPreloader.src = a_link.attr("href");
		imgPreloader.onload = function(){
			$("div.project-image div.action a img").attr("src", a_link.attr("href"));
			$("div.project-image div.action a").attr("href", a_link.attr("href").split("thumb_")[0] + a_link.attr("href").split("thumb_")[1]);
			$("div.project-image div.pager a.active").removeClass("active");
			a_link.addClass("active");
			image.show();
		}
		return false;
	});
	
	$("div.action a").bind("click", function(){
		_open($(this), 0);
		return false;
	});
	
	$("div.preview img.icon").parent().bind("click", function(){
		_open($("div.action a"), 0);
		return false;
	});	
	
}

function icon_enable(el) {
	if (el.attr("src")){
		var hov = el;
		var img = el;
	}
	else {
		var hov = el;
		var img = el.find("img");
	}

	var src = img.attr("src");
	var src_hover = src.split(".gif")[0] + "_hover.gif";
	var preload = new Image();
	preload.src = src_hover;
	hov.bind("mouseover", function(){
		img.attr("src", src_hover);
	}).bind("mouseout", function(){
		img.attr("src", src);	
	});
}

function bind_radio (inp_radio) {
	
	var sel_hover;
	if (inp_radio.parents(".about").length) sel_hover = 'url(img/_bg_radio-hover.gif)';
	else sel_hover = 'url(img/bg_radio-hover.gif)';

	inp_radio.css({position:'absolute', left: '-1000px'}).next().andSelf().wrapAll('<div class="radio_item"></div>');
	
	var label = inp_radio.next();
	
	if (inp_radio.attr("checked")) label.addClass("active_rad");
	
	label.bind("mouseover", function(){
		if ($(this).attr("class").indexOf("active_rad") == -1) $(this).css("background-image", sel_hover);
	}).bind("mouseout", function(){
		if ($(this).attr("class").indexOf("active_rad") == -1) $(this).css("background-image", "none");
	}).bind("click", function(){
		var name = $(this).prev().attr("name");
		$("div.radio_item label.active_rad").each(function(){
			if ($(this).prev().attr("name") == name) $(this).removeClass("active_rad");
		});
		$(this).attr("style", "").addClass("active_rad");
	});
}

function bind_check (input) {
	
	var sel_hover = 'url(img/bg_check-hover.gif)';

	input.css({position:'absolute', left: '-1000px'}).next().andSelf().wrapAll('<div class="check_item"></div>');
	
	var label = input.next();
	
	if (input.attr("checked")) label.addClass("active_check");
	
	label.bind("mouseover", function(){
		if ($(this).attr("class").indexOf("active_check") == -1) $(this).css("background-image", sel_hover);
	}).bind("mouseout", function(){
		if ($(this).attr("class").indexOf("active_check") == -1) $(this).css("background-image", "none");
	}).bind("click", function(){
		if ($(this).prev().attr("checked"))	$(this).css("background-image", "none").attr("style", "").removeClass("active_check");
		else $(this).attr("style", "").css("background-image", "none").addClass("active_check");
	});
}


var zindex = 100;

function bind_select(sel){						   

	zindex = zindex - 1; 
	sel.wrap("<div class=head_sel style=z-index:" + zindex + "></div>").hide();
	if ( $("div.head_sel").parent().hasClass("sell_") ) $("div.head_sel").addClass("sel_new");
	sel.hide();
	var head = sel.parent();	
	head.append("<span></span><div class=opt_sel></div>");
	

	var cont = head.children().eq(2);
	cont.width(head.width());
	var span = head.children().eq(1);
	
	var num_selected = 0;
	var i = 0;

	sel.children().each(function(){
		cont.append("<div id=" + $(this).val() + ">" + $(this).text() + "</div>");
		if ($(this).attr("selected")) num_selected = i;
		i++;
	});
	
	span.text(sel.children().eq(num_selected).text());	
	
	var opt = cont.children();
	
	cont.find(":first").css("padding-top", "4px");
	cont.find(":last").css({"padding-bottom": "2px", "margin-bottom": "1px"});	
	
	span.bind("click", function(){
		cont.toggle("normal");
	});	
		
	opt.bind("click", function(){
		sel.val($(this).attr("id"));
		if( $(this).html() != $("div.sel_new").find("span").html()) {
		   $("#ps2").submit();
		}
		span.text($(this).text());
		$(this).parent().hide("normal");
	});
}

function _display(cl){
	var div = $("." + cl);
	div.parent().children().not(div).css("top", "-100px");
	div.css("top", "0px");
}

var newstab_open = false;

function open_tab(a, cl){
	var div = $("." + cl);
	var tab = a.parent();
	
	$("div.tab.active").removeClass("active");
	tab.addClass("active");
	
	div.parent().children().not(div).hide();
	div.show();
	
	if ((cl == 'news') && !newstab_open) {
		sIFR.replaceElement(named({
			sSelector:"div.news h2",
			sFlashSrc:"img/plumb_read_noshadow.swf",
			sColor:"#333333",
			sLinkColor:"333333",
			sBgColor:"#333333",
			sHoverColor:"#333333",
			nPaddingTop:0,
			nPaddingBottom:0,
			sCase:"upper",
			sWmode:"transparent",
			sFlashVars:"textalign=left&offsetTop=0"
		}));	
		newstab_open = true;
	}
}

function button_enable(el){
	var hint_cont = $("#"+el.attr("class").split(" ")[0]);
	if (el.get(0).tagName.toUpperCase() == 'IMG') el_hover = el.parent();
	else el_hover = el;
	
	el.css("opacity", "0.5");
	
	el_hover.bind("mouseover", function(){
		if ($(this).find("img").length)	$(this).find("img").css("opacity", "1");
		else $(this).css("opacity", "1");
		if (hint_cont.length){
			var div = $(this).parent();
			while (div.get(0).tagName.toUpperCase() != "DIV") div = div.parent();
			var hint = div.find("div.hint");
			if (hint_cont.attr("style") != 'undefined' || hint_cont.attr("style") != '') hint.attr("style", hint_cont.attr("style"));			
			hint.html(hint_cont.html()).css("margin-top", 23 - hint_cont.height()/2);
		}
	})
	.bind("mouseout", function(){
		if ($(this).find("img").length)	$(this).find("img").css("opacity", "0.5");
		else $(this).css("opacity", "0.5");
		if (hint_cont.length) {
			var div =$(this).parent();
			while (div.get(0).tagName.toUpperCase() != "DIV") div = div.parent();
			var hint = div.find("div.hint");
			hint.html("").attr("style", "");
		}
	});
	
}

function input_text_enable(el){
	
	if (el.attr("type") == 'password') var pass = 1;
	else pass = 0;
	
	var str;
	
	if (!pass) el.after(' <span class="input-text"></span>');
	if ((el.val() != '')) {
		if (!pass) {
			el.next().text(el.val());
			el.css("background-position", el.next().width()+10 + 'px center');
		}
		else {
				str = el.val();
				var lft = str.length*8 + 10;
				el.css("background-position", lft + 'px center');
		}
	}
	
	el.bind("keyup + change", function(e){
			if (pass) {
				str = $(this).val();
				var lft = str.length*8 + 10;
			}
			else var lft = $(this).next().text($(this).val()).width()+10;

			$(this).css("background-position",  + lft + 'px center');
	}).bind("focus", function(){
		if (!$(this).val()) $(this).css("background-position", "10px center");	
	}).bind("blur", function(){
		if ($(this).val() == '') $(this).css("background-position", "0px center");	
	});
}

function sifr_enable(){
	if(typeof sIFR == "function"){
		sIFR.replaceElement(named({
			sSelector:"div.menu ul li span",
			sFlashSrc:"img/plumb_read.swf",
			sColor:"#FFFFFF",
			sLinkColor:"#FFFFFF",
			sBgColor:"#FFFFFF",
			sHoverColor:"#FFFFFF",
			nPaddingTop:0,
			nPaddingBottom:0,
			sCase:"upper",
			sWmode:"transparent",
			sFlashVars:"textalign=center&offsetTop=0"
		}));		

		sIFR.replaceElement(named({
			sSelector:"div.about h1",
			sFlashSrc:"img/plumb_read.swf",
			sColor:"#cc9999",
			sLinkColor:"cc9999",
			sBgColor:"#cc9999",
			sHoverColor:"#cc9999",
			nPaddingTop:0,
			nPaddingBottom:0,
			sCase:"upper",
			sWmode:"transparent",
			sFlashVars:"textalign=left&offsetTop=0"
		}));		
		
		sIFR.replaceElement(named({
			sSelector:"div.contacts h1",
			sFlashSrc:"img/plumb_read_noshadow.swf",
			sColor:"#333333",
			sLinkColor:"333333",
			sBgColor:"#333333",
			sHoverColor:"#333333",
			nPaddingTop:0,
			nPaddingBottom:0,
			sCase:"upper",
			sWmode:"transparent",
			sFlashVars:"textalign=left&offsetTop=0"
		}));
		
		sIFR.replaceElement(named({
			sSelector:"div.tab span",
			sFlashSrc:"img/plumb_read_noshadow.swf",
			sColor:"#333333",
			sLinkColor:"333333",
			sBgColor:"#333333",
			sHoverColor:"#333333",
			nPaddingTop:0,
			nPaddingBottom:0,
			sCase:"upper",
			sWmode:"transparent",
			sFlashVars:"textalign=center&offsetTop=0"
		}));	
		
		sIFR.replaceElement(named({
			sSelector:"div.proj h2, div.ads h2",
			sFlashSrc:"img/plumb_read_noshadow.swf",
			sColor:"#333333",
			sLinkColor:"333333",
			sBgColor:"#333333",
			sHoverColor:"#333333",
			nPaddingTop:0,
			nPaddingBottom:0,
			sCase:"upper",
			sWmode:"transparent",
			sFlashVars:"textalign=left&offsetTop=0"
		}));		
		
		sIFR.replaceElement(named({
			sSelector:"div.flash p",
			sFlashSrc:"img/plumb_read_blackshad.swf",
			sColor:"#ffffff",
			sLinkColor:"#ffffff",
			sBgColor:"#ffffff",
			sHoverColor:"#ffffff",
			nPaddingTop:0,
			nPaddingBottom:0,
			sCase:"upper",
			sWmode:"transparent",
			sFlashVars:"textalign=right&offsetTop=0"
		}));		
		
		
	}	
}

function menu_enable(){
	$("div.menu ul li ul").each(function(){
		$(this).css({top: "0px", display:"none"});
	});
	
	$("div.menu ul li").not("div.menu ul li ul li").bind("mouseover", function(){
		$(this).find("ul").show();
	}).bind("mouseout", function(){
		$(this).find("ul").hide();
	});
}

function open_reg(a_link, url){
	
	if (url.indexOf('login/registration') != -1) var reg_flag = 1;
	else var reg_flag = 0;
	
	if (url.indexOf('en/') != -1) var en_flag = 1;
	else var en_flag = 0;
	
	if ($("div.reg_item").length) return false;
	var img = a_link.children();
	var offset = img.offset();
	$("body").append("<div class='reg_item'><a href='javascript:void(0)' class='close_reg'><img class='button-image' src='img/ico-close.gif'></a><div class='info'>&nbsp;</div></div>");

	$("div.reg_item a.close_reg").bind("click", function(){
		$("div.reg_item div.info").add("div.reg_item a.close_reg img").fadeOut(function(){
			$("div.reg_item").animate({
				top: offset.top,
				left: offset.left,
				width: img.width(),
				height: img.height()						  
			}, function(){
				$("div.reg_item").remove();
				$('div.backgroundDiv').remove();
			});																	 
		});
	});
	
	var reg = $("div.reg_item");
	reg.css({top: offset.top, left: offset.left, width: img.width(), height: img.height(), display:'none'});

	var res = $.ajax({
		url: url,
		success: function (res) {
			
			code = res;
			$("div.reg_item div.info").html(code);
			
			if (navigator.userAgent.toLowerCase().indexOf('chrome') > -1) $("div.reg_item td").css("padding", "0px");
			
			var backgroundDiv = "<div class='backgroundDiv'></div>";
			$('body').append(backgroundDiv);
			$('div.backgroundDiv').css({'height':$(document).height(), opacity: '0', 'z-index':'9500'}).show();
			
			reg.animate({
				left: offset.left - 228 - (reg_flag*33),
				top: '130px',
				width: '280px',
				height: 287 + (reg_flag*73) + 'px'
			}, function(){
				$("div.reg_item div.info").fadeIn(function(){
					$("div.reg_item a.close_reg img").show();
					reg_bind(reg_flag, en_flag);																						   
				});
				
				sIFR.replaceElement(named({
					sSelector:"div.reg_item h2",
					sFlashSrc:"img/plumb_read_noshadow.swf",
					sColor:"#ffffff",
					sLinkColor:"#ffffff",
					sBgColor:"#ffffff",
					sHoverColor:"#ffffff",
					nPaddingTop:0,
					nPaddingBottom:0,
					sCase:"upper",
					sWmode:"transparent",
					sFlashVars:"textalign=left&offsetTop=0"
				}));		
				
			});
		}
	});
}

function reg_bind(reg_flag, en_flag){
	
			if (reg_flag) {
				if (en_flag) {
					var yes = "I think it is ok, register";
					var no = "Some required fields are empty";
				}
				else {
					var yes = "Вроде всё, регистрируюсь";
					var no = "Не все поля заполнены";
				}
			}
			else {
				if (en_flag) {
					var yes = "I think it is ok, refresh data!";
					var no = "Some required fields are empty";
				}
				else {
					var yes = "Вроде всё, обновить данные!";
					var no = "Не все поля заполнены";
				}
			}
	
			button_enable($("div.reg_item .button-image"));
			
			$("div.reg_item div.info input.input-text").each(function(){
				input_text_enable($(this));
			});
			var image_subm = $("div.reg_item img.popup-reg").css("opacity", "0.5");
			var subm = image_subm.parent();
			var hint = $("div.reg_item div.hint");
			var flag;

			subm.bind("mouseover", function(){
				flag = true;
				$("div.reg_item input.req").each(function(){
					if ($(this).val() == '') flag = false;
				});
				if (flag){
					hint.text(yes);					
					image_subm.css("opacity", "1");					
				}
				else {
					hint.text(no);
				}
			}).bind("mouseout", function(){
				image_subm.css("opacity", "0.5");		
				hint.text("");
			}).bind("click", function(){				
				if (reg_flag){
					flag = true;
					$("div.reg_item input.req").each(function(){
						if ($(this).val() == '') flag = false;
					});				
					if (flag) $("#registration_form").ajaxSubmit({success: processRegistration});
				}
				else {
					
					flag = true;
					$("div.reg_item input.req").each(function(){
						if ($(this).val() == '') flag = false;
					});				
					if (flag) {
						$("#profile_form").ajaxSubmit({success: processProfile});
					}
				}
			});
			
			$("div.reg_item img.captcha").css("opacity", "0.95");
}

function processRegistration(d) {
	if ($(".registration_errors", d).length) {
		var cap = $("input.cap_inp").val();
		$("#registration_form").html($("#registration_form", d).html());
		$("#registration_form table tr").toggle();		
		$("input.cap_inp").val(cap);
		$("#registration_form table tr.registration_errors td a").bind("click", function(){
			$("#registration_form table tr").toggle();
			reg_bind(true);
		});
	} else {
		$("#registration_form").after(d).remove();
	}
}
function processProfile(d) {
	if ($(".registration_errors", d).length) {
		$("#profile_form").html($("#profile_form", d).html());
		$("#profile_form table tr").toggle();		
		$("#profile_form table tr.registration_errors td a").bind("click", function(){
			$("#profile_form table tr").toggle();
			reg_bind();
		});
	} else {
		$("#profile_form").after(d).remove();
	}


	
}

function do_login() {
	$("#login_form").ajaxSubmit({success: function(d) {
			if (parseInt(d)==1) setTimeout("location.href = '/';",250);
		}
	});
}

function replace_h (el, tag, simvol_length){
	
	var str = el.text().split(" ");
	
	var new_str = '<'+ tag +'>';
	
	var sum = 0;

	for (var i = 0; i < str.length; i++){
		if (sum+str[i].length < simvol_length) {
			new_str += str[i] + ' ';
			sum += str[i].length + 1;
		}
		else {
			new_str = new_str.substr(0, new_str.length-1);
			new_str += '</' + tag + '><' + tag + '>' + str[i] + ' ';
			sum = str[i].length - 1;
		}
	}
	
	new_str = new_str.substr(0, new_str.length-1);
	new_str += '</'+ tag +'>';

	el.after(new_str).remove();
}

function ttt_toggle(el) {
	el.parent().next().toggle();
	var str = el.html().split("&nbsp;&nbsp;");
	if (str[0] == '+') el.html("&ndash;" + "&nbsp;&nbsp;" +  str[1]);
	else el.html("+" + "&nbsp;&nbsp;" + str[1]);
}

function do_vote() {
	var vote = $("input[@name='vote']:checked").val();
	if (vote==undefined) return;
	$("#poll_form").ajaxSubmit({success: function(d) {
		$("p.answer").html(d);
	}});
}

function remind_passwd() {
	$("#forgot_form").ajaxSubmit({success: function(d) {
		if ($("p.error", d).length) {
			$("div.forgot div.replace").hide().after("<div class='answer'>"+ $("p.error", d).html() + "</div>");
			$("div.forgot img.close").parent().removeAttr("onclick").bind("click", function(){
				$("div.forgot div.answer").remove();
				$("div.forgot div.replace").show();
			});
		}
		else {
			$("div.forgot div.replace").hide().after("<div class='answer'>"+ $("p", d).html() + "</div>");
			$("div.forgot img.close").parent().unbind("click").bind("click", function(){
				_display('first');
			});
		}
	}});
}

function counter (){
document.write('<a href=\"http://www.liveinternet.ru/click\" '+ 'target=liveinternet><img src=\"http://counter.yadro.ru/hit?t14.6;r'+ escape(document.referrer)+((typeof(screen)=='undefined')?'': ';s'+screen.width+'*'+screen.height+'*'+(screen.colorDepth? screen.colorDepth:screen.pixelDepth))+';'+Math.random()+ '\" alt=\"liveinternet.ru: показано число просмотров за 24 часа, посетителей за 24 часа и за сегодня\" '+ 'border=0 width=1 height=1 style=\"display:none\"></a>')
}

function calc0(){
	
	var id_bitrix = 'cmstype_id_2';
	var image_host = 'content_id_9';	
	
	var lang_koef = 1;
	if ($("#languages_id_3").attr("checked")) lang_koef += LangKoeff['En'];
	if ($("#languages_id_4").attr("checked")) lang_koef += LangKoeff['It'];
	if ($("#languages_id_5").attr("checked")) lang_koef += LangKoeff['Ua'];	
	
	if (document.location.href.indexOf('en/') != -1) var chas = ' h.';
	else var chas = ' ч.';

	if ($("input#" + id_bitrix).attr("checked")) var ergo = 0;
	else var ergo = 1;

	var sum = 0;
	$("form#formCalc input:checkbox, form#formCalc input:radio").not("#"+image_host).each(function(){
		var input = $(this);
		if (input.attr("checked")){
			var value = parseFloat(input.val());
			if (input.parent().next(".other_text").length) value *= parseFloat(input.parent().next(".other_text").children().eq(0).val());
			value *= lang_koef;
			sum += value;
			sum += ergo*hours[input.attr("id")]['license'];
		}
	});
	
	sum += !ergo*hours[id_bitrix]['license'];
	if ($("#"+image_host).attr("checked")) sum += parseInt($("#"+image_host).parent().next().find("input").val())*hours[image_host]['license'];	
	
	$("span#result_price").text(parseInt(sum));
	
	var arr=['D', 'TD', 'WT', 'WD', 'C', 'CM', 'M'];
	var hours_exp = {};
	for (var x in arr) hours_exp[arr[x]] = 0;
	
	var license = 0;

	$("form#formCalc input:checked").each(function(){
			var id = $(this).attr("id");
			var koef = 1;
			if ($(this).parent().next(".other_text").length) koef = parseFloat($(this).parent().next(".other_text").children().eq(0).val());
			if (id != image_host) license += hours[id]['license'];
			for (var x in arr) {
				hours_exp[arr[x]] += (hours[id][arr[x]] * koef);
			}
	});
	
	if (!ergo) license = hours[id_bitrix]['license'];
	
	var i = 0;
	$("td.cost").not(":last").each(function(){
		$(this).text(parseInt(hours_exp[arr[i]]) + chas);
		i++;
	});
	
	$("td.cost:last").each(function(){
		$(this).html(license + '&euro;');
	});
}

function group_depend() {
	$("form#formCalc input.important").each(function(){
		var inp = $(this);
		var start = -1;
		var i = 0;
		var end = -1;
		
		inp.parent().addClass("item_inportant");
		
		$(this).parents(".spisok").find("div.check_item, div.other_text").each(function(){
			i++;
			if ($(this).attr("class").indexOf("other_text") == -1) {
				var input = $(this).find("input");
				if (input.attr("id") == inp.attr("id")) start = i;
				else if ((start != -1) && (end == -1) && ((input.attr("class").indexOf("undepend") != -1) || (input.attr("class").indexOf("important") != -1))) end = i-1;
			}
		});
		if (end == -1) end = i;
		$(this).parents(".spisok").find("div.check_item, div.other_text").slice(start, end).wrapAll('<div class="block_depend"></div>');
		
//		if (inp.attr("class").indexOf("important") != -1) inp.parent().next(".block_depend").show();
	});
	
	$("form#formCalc input.important").bind("change", function(){
		if ($(this).attr("checked")){
			$(this).parent().next(".block_depend").show();
		}
		else {
			$(this).parent().next(".block_depend").hide().find("input:checkbox").each(function(){
				$(this).removeAttr("checked");
				$(this).next("label").removeClass("active_check");
			});
		}
	});
	
	$("form#formCalc input, div.head_sel").bind("click", function(){
		calc0();											  
	});
	
	calc0();
}

function reset_form(el){
	
	var form = el.parents("form:first");
	if (form.length) {
		form.get(0).reset();
		
		form.find("input:radio").each(function(){
			if (!$(this).attr("checked")) $(this).next("label").removeClass("active_rad");
			else $(this).next("label").addClass("active_rad");		
		});
		
		form.find("input:checkbox").each(function(){
			if (!$(this).attr("checked")) $(this).next("label").removeClass("active_check");
			else $(this).next("label").addClass("active_check");
		});	
		
		form.find("div.other_text").hide();
		//form.find("div.block_depend").hide();
		form.find("input:checkbox").each(function(){
			if ($(this).attr("checked")) $(this).parent().next(".block_depend").show();
			else $(this).parent().next(".block_depend").hide();
		});
		
		calc0();
	}
}

function hnt_port (el, str){
	el.parents("div.client_lnk:first, div.sercices_lnk:first").find("div.hint").text(str);
}