$(function () {
	var cc = 0;
	var phone = $.cookie('phone');

	$('div.dv_menu_mid span').hover(function () {
		$('div#tab1').removeClass('active');
		$('div#tab2').removeClass('active');
		$(this.parentNode).addClass('active'); 
		$('div#tab1c').hide();
		$('div#tab2c').hide();
		$('div#' + this.parentNode.id + 'c').show();
	});
	
	$('div.payment_box_name a').click(function () {
		var hash = this.hash;
		if (location.hash != '' && cc == 0) hash = location.hash;
		$('div.payment_box_details').hide().filter(hash).show();
		cc ++;
		return false;	
	}).filter(':first').click();
	
	$('div.faq_box_bottom h4 a').click(function () {
		var hash = this.hash;
		if (location.hash != '' && cc == 0) hash = location.hash;
		$('div.faq_box_active').hide().filter(hash).show();
		cc ++;
		return false; 
	}).filter(':first').click();

	$('ul.tabs_menu li a').click(function () {
		var hash = this.hash;
		var selected = this;
		var parentNode = this.parentNode;
		if (location.hash != '' && cc == 0) {
			hash = location.hash;
			selected = $('ul.tabs_menu li a[href=' + hash + ']');
			parentNode = $(selected).parent();
			$(window).scrollTop(0);
		}
		$('ul.tabs_menu li a').show();
		$(selected).hide();
		$('ul.tabs_menu li span').remove();
		$(parentNode).append('<span>' + $(selected).text() + '</span>');
		$('ul.tabs_menu li').removeClass('t_active');
		$(parentNode).addClass('t_active');
		$('div.tab').hide().filter(hash).show();
		cc ++;
		return false; 
	}).filter(':first').click();

	$('div.toggle p a').click(function () {
		$('div' + this.hash).toggle('normal');
		return false; 
	}).click();

	$('div.drweb_page ul.dr_menu a').click(function () {
		var hash = this.hash;
		var selected = this;
		if (location.hash != '' && cc == 0) {
			hash = location.hash;
			selected = $('div.drweb_page ul.dr_menu a[href=' + hash +']');
		}
		$('div.dr_boxik').hide().filter(hash).show();
		$('div.drweb_page ul.dr_menu a').removeClass('active');
		$(selected).addClass('active');
		cc ++;
		return false;
	}).filter(':first').click();

	$('div.konst_shagi ul.k_menu a').hover(function () {
		var hash = this.hash;
		var selected = this;
		if (location.hash != '' && cc == 0) {
			hash = location.hash;
			selected = $('div.konst_shagi ul.k_menu a[href=' + hash +']');
		}
		$('div.k_box').hide().filter(hash).show();
		$('div.konst_shagi ul.k_menu a').removeClass('active');
		$(selected).addClass('active');
		cc ++;
		return false;
	}).filter(':first').hover();
	
	$('div#current_phone').click(function () {
		$('#region_phone').toggle('normal');
	});
	
	$('ul#region_phone li').click(function () {
		var text  = $(this).text();
		$.cookie('phone', text, { path: '/' , domain: '.hostlife.net'});
		$('div#current_phone').text(text);
		$('ul#region_phone').hide('normal');
	});
	
	if (phone != null) {
		$('div#current_phone').text(phone);
	}
});

