// JavaScript Document

Cufon.replace(".main h1", {
	fontFamily: "EtelkaLig",
	textShadow: "1px 0px #CCCCCD, 1px -1px #AFAFAF"
});

Cufon.replace(".promo .submenu h3", {
	fontFamily: "EtelkaReg"
});

Cufon.replace(".hm", {
	fontFamily: "EtelkaReg"
});

Cufon.replace("h4.tel", {
	fontFamily: "EtelkaReg"
});

Cufon.replace(".btn_blue", {
	fontFamily: "EtelkaReg"
});

Cufon.replace(".btn_mini", {
	fontFamily: "EtelkaReg"
});

function wizard() {
	$(".wizard .wbtn").hover(function () {
		$(".wizard .ico").addClass("over");
	}, function () {
		$(".wizard .ico").removeClass("over");
	});

}

function turnkey() {
	$("#turnkey h2").click(function() {
		$(this).toggleClass("open close");
		$(this).parent("#turnkey").parent('.included').children(".ls").slideToggle();
		//$(".ls").slideToggle();
	});
}



function show_hide() {
$('.showhide').click(function(){
$("div#" + $(this).attr('rel')).toggle();
$(this).parent("div").parent("div").toggleClass("open");
 return false;
 });
} 


function full_list() {
$('.full-list-btn').click(function(){
$("ul#" + $(this).attr('rel')).slideToggle();
$(this).toggleClass("open");
 return false;
 });
} 

function faq() {
	$(".faq .level2 .question").click(function() {
		$(this).parent("li").toggleClass("open");
		$(this).parent("li .answer").slideToggle();
		return false;
		
	});
	
		$(".faq .level1 .node a").click(function() {
		$(this).parent(".node").parent(".level1").toggleClass("open");
		
		return false;
		
	});
	
}

function fancybox_init() {
   $('a.fancy_ajax').fancybox({
      'type' : 'ajax',
      'overlayOpacity' : 0
   });
}

function menuOver() {
	$(".inner .alternate_menu ul li a").hover(function () {
		$(this).parent("li").addClass("over");

	}, function () {
		$(this).parent("li").removeClass("over");
	});
	
	
	$(".main-menu ul li a").hover(function () {
		$(this).parent("li").addClass("over");

	}, function () {
		$(this).parent("li").removeClass("over");
	});	
	
}

function cost_list() {
	$("table.cost_list tr").each(function() {
		$("td:last", this).addClass("r");
	});
}

//Обработка группового чекбокса в форме расчета
function check_group_action() {
   $('input.check_group').click(function(){
      if ($(this).attr('rel')) {
         if ($(this).attr('checked') == true) {
            $('div#' + $(this).attr('rel') + ' input:checkbox').attr({'checked' : true});
            $("div#" + $(this).attr('rel')).show();  
            $(this).parent("div").parent("div").addClass("open");
         }
         else {
            $('div#' + $(this).attr('rel') + ' input:checkbox').attr({'checked' : false});
           /* $("div#" + $(this).attr('rel')).hide();  
            $(this).parent("div").parent("div").removeClass("open");*/
         }
                
      }
   });
}


// Виджет addthis 
function addthis_user(){
	
	var defaultText = $('#sendLinkToEmail').val();
	$('#sendLinkToEmail').focusin(function(e){
		if($(this).val()==defaultText)
			$(this).val('');
	}).focusout(function(e){
		var spaces = $(this).val().match( /^(\s)*$/ )
		if(spaces){
			$(this).val(defaultText);
			
		}
	});
}


   fix_no_count = function() {
    $(".fb_share_no_count .fb_share_count_inner").text("0");
     $(".fb_share_no_count").removeClass("fb_share_no_count");
    }
   


function radio_btns(){
	$('input[type="radio"]').ezMark();
}


$(function(){
	turnkey();
	wizard();
	faq();
	show_hide();
	fancybox_init();
	menuOver();
	cost_list();
	check_group_action();
	addthis_user();
	radio_btns();
	full_list();
 var to = window.setTimeout(fix_no_count, 1500);
}); 



