
var mw;
var imgs = new Array();
var tmphonetop='';
var tmphonebottom='';
function toPrice(number) {
	return number.toString().replace(/(\d{1,3}(?=(\d{3})+(?:\.\d|\b)))/g,"\$1 ");
	}

function strechMe() {
	var mw = $("#topnav").width();
	$("#topnav ul li").css("margin-right",parseInt(mw/20,10));
	$("#topnav ul li:last-child").css("margin-right","0");
	var c = $("#container");
	var i = $("#innerfoot");
	var dw = $(document).width();
	var padding = 20;
	if (dw+20 > 1200) padding = 40;
	if (dw+20 > 1400) padding = 80;
	c.css({paddingLeft:padding,paddingRight:padding});
	i.css({paddingLeft:padding,paddingRight:padding});
}

$(function(){
	if ($.browser.opera) {
		$("#operafix").css("height","30px");
		$("#cmailbox").stop(false,false).animate({height:"520px"},100,function(){$(this).animate({height:"150px"},100);});
		}
	if ($.browser.msie && $.browser.version < 8) {
		$("div.faq").css("display","inline");
		$("div.faq div.response").css("margin-left","-40px").css("margin-top","28px");
		}
	});

$(function(){
	$("#sendmenow").click(function(){
		var oname = $("#oname").val();
		var ophone = $("#ophone").val();
		var oemail = $("#oemail").val();
		var osite = $("#osite").val();
		var omess = $("#omess").val();
		var oseo = ($("#oseo").is(":checked")) ? 1 : 0;
		var ocreate = ($("#ocreate").is(":checked")) ? 1 : 0;
		var oadv = ($("#oadv").is(":checked")) ? 1 : 0;
		$.ajax({
			url: "/EGGO_SITE/lib/mailer.php",
			type: "post",
			dataType: "json",
			data: {"name":oname,"phone":ophone,"email":oemail,"mess":omess,"seo":oseo,"site":osite,"create":ocreate,"adv":oadv},
			cache: false,
			success: function(rq){
				$("#xblur").css("height",$(document).height()+"px");
				if (rq.e == "ok") {
					$("#oname").val("");
					$("#ophone").val("");
					$("#oemail").val("");
					$("#osite").val("");
					$("#omess").val("");
					}
				$("#messages").html(rq.t);
				$("#popup").css("margin-top",(120+$(document).scrollTop())+"px");
				$("#closepopup").click(function(){
					$("#messages").html("");
					$("#popup").css("margin-top","-1000px");
					$("#xblur").css("height","0px");
					});
				}
			});
		return false;
		});
	});

$(function(){
	$("#xsendmenow").click(function(){
		var oname = $("#xoname").val();
		var ophone = $("#xophone").val();
		var oemail = $("#xoemail").val();
		var osite = $("#xosite").val();
		var omess = $("#xomess").val();
		var oseo = ($("#xoseo").is(":checked")) ? 1 : 0;
		var ocreate = ($("#xocreate").is(":checked")) ? 1 : 0;
		var oadv = ($("#xoadv").is(":checked")) ? 1 : 0;
		$("#xcmailbox").css("height","299px");
		$("#xmailform").css("margin-top","-1000px");
		$.ajax({
			url: "/EGGO_SITE/lib/mailer.php",
			type: "post",
			dataType: "json",
			data: {"name":oname,"phone":ophone,"email":oemail,"mess":omess,"seo":oseo,"site":osite,"create":ocreate,"adv":oadv},
			cache: false,
			success: function(rq){
				$("#xblur").css("height",$(document).height()+"px");
				if (rq.e == "ok") {
					$("#xoname").val("");
					$("#xophone").val("");
					$("#xoemail").val("");
					$("#xosite").val("");
					$("#xomess").val("");
					}
				$("#messages").html(rq.t);
				$("#popup").css("margin-top",(120+$(document).scrollTop())+"px");
				$("#closepopup").click(function(){
					$("#messages").html("");
					$("#popup").css("margin-top","-1000px");
					$("#xblur").css("height","0px");
					});
				}
			});
		return false;
		});
	});

function parseExt(pack) {
	var ext = '';

	for (var l = 0; l < iextends.length; l++) {
		if (iextends[l]['iPack'] == pack && iextends[l]['checked'] == true) {
			ext += '<div class="ext"> '+iextends[l]['fvalue']+' --- '+iextends[l]['name']+' </div>';
			}
		}

	return ext;

	}

$(function(){
	$("#xcalcsendmenow").click(function(){
		var cname = $("#xcname").val();
		var cphone = $("#xcphone").val();
		var cemail = $("#xcemail").val();
		$("#xcalcbox").css("height","299px");
		$("#xcalcform").css("margin-top","-2000px");
		var pack = $("#xpacks").val();
		var packname = $("#xpacks option:selected").html();
		var xdesign = $("#xdesign option:selected").html();
		var ext = parseExt(pack);
		if (ext == "") ext = '<p>Не выбрано ни одной</p>';
		
		var itotal = (xseo) ? seopercents : total[pack];
		var iseo = (xseo) ? pos : 0;

		var headM = '<h2>В калькуляторе был заказан: пакет <em>'+packname+'</em> с '+xdesign+'</h2>';
		headM += '<h3>Общая сумма заказа: <em>'+(itotal+iseo)+' руб.</em></h3>';
		headM += '<h3>Из них на создание сайта: <em>'+itotal+' руб.</em>, на раскрутку <em>'+iseo+' руб.</em></h3>';
		headM += '<h3>Дополнительные услуги входящие в сумму заказа:</h3>';
		headM += ext;
		var cmess = headM + $("#xcmess").val();
		$.ajax({
			url: "/EGGO_SITE/lib/xmailer.php",
			type: "post",
			dataType: "json",
			data: {"name":cname,"phone":cphone,"email":cemail,"mess":cmess},
			cache: false,
			success: function(rq){
				$("#xblur").css("height",$(document).height()+"px");
				if (rq.e == "ok") {
					$("#xcname").val("");
					$("#xcphone").val("");
					$("#xcemail").val("");
					$("#xcmess").val("");
					}
				$("#messages").html(rq.t);
				$("#popup").css("margin-top",(120+$(document).scrollTop())+"px");
				$("#closepopup").click(function(){
					$("#messages").html("");
					$("#popup").css("margin-top","-1000px");
					$("#xblur").css("height","0px");
					});
				}
			});
		return false;
		});
	});



function iwidth() {
	mw = $("#leftcontent4").width();
	$("img.sizer").each(function(i){
		var iww = $(this).width();
		if (mw > 637) $(this).width(637);
		else $(this).width(mw);
		});
	}

/*$(function(){
	$(".sizer").mouseover(function(){
		var iw = $(this).width();
		$(this).stop(false,false).animate({width:"637px"},200)
		.mouseout(function(){
			$(this).stop(false,false).animate({width:iw+"px"},200);
			});
		});
	});*/

var noactive = true;
var noread = true;

function autoEquallyFloatHeight(e,p) {
	var ew = e.eq(0).width();
	var pw = p.width();
	var dcnt = (pw/ew|0);
	var imax;
	var clines = (e.length/dcnt|0)+1;
	e.css("height","100%");
	for (var line=0; line<clines; line++) {
		imax = 0;
		for (var d=(dcnt*line); d<(dcnt*line)+dcnt; d++) {
			if (imax < e.eq(d).height()) {
				imax = e.eq(d).height();
				}
			}
		for (var n = (dcnt*line); n<(dcnt*line)+dcnt; n++) {
			e.eq(n).height(imax);
			}
		}
	}

function ifocus() {
	noactive = false;
	}

function iblur() {
	noactive = true;
	}

function popupshow() {
	$("#xmailform").css("margin-top",(60+$(document).scrollTop())+"px");
	$("#xblur").css("height",$(document).height()+"px");
	$("#xcmailbox").stop(false,false).animate({height:"670px"},600);
	return false;
	}

function calchide() {
	$("#xcalcbox").stop(false,false).animate({height:"299px"},600,function(){$("#xcalcform").css("margin-top","-2000px");$("#xblur").css("height","0px");});
	return false;
	}

function calcshow() {
	$("#xcalcform").css("margin-top",(60+$(document).scrollTop())+"px");
	$("#xblur").css("height",$(document).height()+"px");
	$("#xcalcbox").stop(false,false).animate({height:($("#xcalcbox table").eq(0).height()+320)+"px"},600);
	return false;
	}

function popuphide() {
	$("#xcmailbox").stop(false,false).animate({height:"299px"},600,function(){$("#xmailform").css("margin-top","-1000px");$("#xblur").css("height","0px");});
	return false;
	}

function ishow() {
	$("#cmailbox").stop(false,false).animate({height:"520px"},600);
	noread = false;
	}

function ihide() {
	$("#cmailbox").stop(false,false).animate({height:"150px"},1000);
	}

$(function(){
	$("#xcmailbox").css("position","relative");
	});

$(function(){
	$("#mailform").mouseover(function(){ishow();})
	.mouseout(function(){
		noread = true;
		if (noactive) ihide();
		});
	});

$(function(){
	$("a.gopopup").click(function(){
		popupshow();
		return false;
		});
	});

$(function(){
	$("a.gocalc").click(function(){
		calcshow();
		return false;
		});
	});

$(function(){
	$("#xclose").click(function(){
		$("#xcmailbox").css("height","299px");
		$("#xmailform").css("margin-top","-1000px");
		$("#xblur").css("height","0px");
		return false;
		});
	});

$(function(){
	$("#xclosecalc").click(function(){
		$("#xcalcbox").css("height","299px");
		$("#xcalcform").css("margin-top","-2000px");
		$("#xblur").css("height","0px");
		return false;
		});
	});

$(function(){
	$("#xblur").click(function(){
		$("#xcmailbox").css("height","299px");
		$("#xmailform").css("margin-top","-1000px");
		$("#xblur").css("height","0px");
		popuphide();
		calchide();
		return false;
		});
	});

$(function(){
	var hs = new Array();
	hs['6e44af5940855d3708417695f58e46e7'] = "/about/partners/";
	hs['6007c2c2e02715cac9d8a365152bac27'] = "/service/";
	hs['234b2d1a142b0064e329efa60033edef'] = "/about/nashi-sotrudniki/";
	hs['918393f77173ade396c857410ebc4b77'] = "/about/vacancy/";
	hs['f34bb62f734d1cecaa4de6a8b8efab52'] = "/about/";
	hs['d234fa1e015c1bf530a3e12b529f1d62'] = "/contacts/";
	hs['d38fe1b33524696d4d460b4c8e8ee3b6'] = "https://passport.webmoney.ru/asp/certview.asp?wmid=168352365015";
	var hashlink;
	$("a").each(function(i){
		hashlink = $(this).attr("hashLink");
		if (hashlink != "" || hashlink != "undefined") {
			$(this).attr("href",hs[hashlink]);
			}
		});
	});

/*function makePages(pholder,p,all) {

	var after = "";
	var before = "";
	var pages = "";

	pages += '<span class="flush">&nbsp;</span>';
	for (var i =1; i <= all; i++) {
		if (i == parseInt(p.substring(6),10)) {
			 if (i > 1) before = '<a class="leftedge" href="#page_'+(i-1)+'">Предыдущая</a>';
			if (i < all) after = '<a class="rightedge" href="#page_'+(i+1)+'">Следующая</a>';
			pages += ' <span class="active">'+i+'</span> ';
			}
		else pages += ' <a href="#page_'+i+'">'+i+'</a> ';
		}
	pages += '<span class="flush">&nbsp;</span>';

	pholder.html(before+pages+after);
	}

function splitToPages(elems,perpage,pholder) {
	var all;
	var link = "#page_1";
	var pps = elems.length/perpage;
	if (Math.floor(pps) == pps) all = pps;
	else all = Math.floor(pps)+1;

	elems.hide();
	elems.slice(0,perpage).show();
	makePages(pholder,link,all);

	pholder.find("a").live("click",function(){
		link = $(this).attr("href");
		elems.hide();
		elems.slice((link.substring(6)-1)*perpage,((link.substring(6)-1)*perpage+perpage)).show();
		autoEquallyFloatHeight($("#leftcontent3 div.evs"),$("#leftcontent3"));
		makePages(pholder,link,all);
		return false;
		});

	}*/

$(function(){
	//if (document.location == "http://www.eggo.ru/response/1/") splitToPages($(".response"),10,$("#paginator"));
	/*if (document.location == "http://www.eggo.ru/articles/") splitToPages($(".article"),10,$("#paginator"));
	if (document.location == "http://www.eggo.ru/portfolio/sozdanie-saytov/") splitToPages($(".evs"),12,$("#paginator"));
	if (document.location == "http://www.eggo.ru/portfolio/sozdanie-saytov/bydate/") splitToPages($(".evs"),12,$("#paginator"));
	if (document.location == "http://www.eggo.ru/portfolio/sozdanie-saytov/byname/") splitToPages($(".evs"),12,$("#paginator"));*/
	});

window.onload = function() {
	iwidth();
	autoEquallyFloatHeight($("#rightcontent2 div.evs"),$("#rightcontent2"));
	autoEquallyFloatHeight($("#leftcontent3 div.evs"),$("#leftcontent3"));
	strechMe();
	}

window.onresize = function() {
	iwidth();
	autoEquallyFloatHeight($("#rightcontent2 div.evs"),$("#rightcontent2"));
	autoEquallyFloatHeight($("#leftcontent3 div.evs"),$("#leftcontent3"));
	strechMe();
	}

var mailboxBinder = setInterval(function(){if(noactive && noread){ihide();}},2000);

$(function(){
	$("#moscow_region").click(function(){

		$("#switch_regions .region_item span").addClass("ishref");						   
		$("#moscow_region span").removeClass("ishref");						   
		//if(tmphonetop!='') $("#actual_phones").html(tmphonetop); else $("#actual_phones").html('+7 (499) 156-40-38, 156-40-47');
		//if(tmphonebottom!='') $("#bottom_phones").html(tmphonebottom); else $("#bottom_phones").html('телефон: +7 (499) 156-40-38 </span>');
		
		if(c_reg=='yandex' || c_reg=='google' || c_reg=='rambler' ||  c_reg=='mail'){ 
						$("#actual_phones").html('+7 (495) 648-66-37');
						$("#bottom_phones").html('+7 (495) 648-66-37');
						 }else if(c_reg=='direct'){ 
						$("#actual_phones").html('+7 (495) 648-66-39');
						$("#bottom_phones").html('+7 (495) 648-66-39');
						 }else if(c_reg=='adwords'){ 
						$("#actual_phones").html('+7 (495) 648 69 62');
						$("#bottom_phones").html('+7 (495) 648 69 62');
						 }else if(c_reg=='mediatarget'){ 
						$("#actual_phones").html('+7 (495) 648-66-27');
						$("#bottom_phones").html('+7 (495) 648-66-27');
						 }else{ 
						$("#actual_phones").html('+7 (499) 156-40-38, 156-40-47');
						$("#bottom_phones").html('+7 (499) 156-40-38');
						}
		
		
		
		$.cookie('region_cook', 'msk',{
				 expires: 365,
				 path: '/'
				 });
		return false;
		});
	});
$(function(){
	$("#spb_region").click(function(){

		tmphonetop=$("#actual_phones").html();
		tmphonebottom=$("#bottom_phones").html();
		$("#switch_regions .region_item span").addClass("ishref");	
		$("#spb_region span").removeClass("ishref");	
		$("#actual_phones").html('+7 (812) 385-54-06');
		$("#bottom_phones").html('телефон: +7 (812) 385-54-06 </span>');
		$.cookie('region_cook', 'spb',{
				 expires: 365,
				 path: '/'
				 });

		return false;
		});
	});

