function initPage(){
	
	if ($('.position-tabs a').size()){
		$('.position-tabs a').removeClass("active").click(function(){
			$('.position-tabs a').removeClass("active");
			$(this).addClass("active");
			var id = $(this).attr('id');
			$(".block-without-styles .position").hide();
			$("#position_" + id).show();
			return false;
		});

		if (lookGetPage)
			$('#'+lookGetPage).click();
		else
			$('.position-tabs a').eq(0).click();
	}
/* рудимент от старого просмотра
	if ($('.gallery p').size()>1){
		$("a", $('.gallery p').eq(1)).click(function(){
			var title = $(this).attr('title');
			var rel = $("img", $(this)).eq(0).attr('src');
			$("a", $('.gallery p').eq(1)).removeClass("active");
			$(this).addClass('active');
			$("a", $('.gallery p').eq(0)).attr('title', title);
			$("a", $('.gallery p').eq(0)).attr('href', rr(rel, "_bb"));
			$("img", $('.gallery p').eq(0)).attr('title', title);
			$("img", $('.gallery p').eq(0)).attr('alt', title);
			$("img", $('.gallery p').eq(0)).attr('src', rr(rel, "_b"));
			
		});
		$("a", $('.gallery p').eq(1)).eq(0).click();
		
	}
*/
//	$("a.fancya").fancybox();
	
	$("a.popup-close").click(function(){
		var rel = 'div.small-popup-' + jQuery(this).attr('rel');
		if (jQuery(rel+':visible').size() > 0)
			jQuery(rel).hide(); 
		else
			jQuery(rel).fadeIn('fast'); 
		return false;
	});
	
	$("#advise-faq").submit(function(){
		var name = $("#username").val();
		var phone = $("#userphone").val();
		var question = $("#userquestion").val();
		if (!name || !phone || !question)
			alert("Заполните все поля");
		else{
			$.post("/ajax/sentMail.php", {"name":name, "phone": phone, "question": question}, function(a){
			if (a == 'done')
				alert("Спасибо, ваше сообщение отправлено.")
			return false;
			});
		}
		return false;
	});
	$("#enter-login").submit(function(){
		if ($("#type").val() == 1){
			$("#enter-login").attr("action","http://my.gdemoi.ru/");
			$("#login").attr("name","username");
			$("#log_in").attr("name","enter");
			//location.href="http://my.gdemoi.ru/?username="+$("#login").val()+"&password="+$("#password").val()+"&enter=1";
			return true;
		}else
			return true;
	});
}

function change_region(obj){
	$("tr.regions").hide();
	$("tr.regions[rel='"+$(obj).attr('rel')+"']").show();
	return true;
}

function change_city(city){
        $("tr.regions").hide();
        $("tr.regions[name='"+city+"']").show();
        return true;
}


function rr(src, zn){
	var q = src.lastIndexOf(".");
	return src.substr(0, q) + zn + src.substr(q);
}

