// JavaScript Document

/*
function shChange() {
	sell = jQuery(".ch-sell");
	sell.toggle(
		function() {
			n = jQuery.inArray(this, sell);
			jQuery(this).addClass("ch-sell-a");
			if (n==0) {
				jQuery(".change-tb .str, .change-tb .sup").css("display",'none');
			}
			if (n==1) {
				jQuery(".change-tb .tpos").css("display",'none');
			}
			if (n==2) {
				jQuery(".change-tb .plink").css("display",'none');
			}
		},
		function() {
			n = jQuery.inArray(this, sell);
			jQuery(this).removeClass("ch-sell-a");
			if (n==0) {
				jQuery(".change-tb .str, .change-tb .sup").css("display",'inline');
			}
			if (n==1) {
				jQuery(".change-tb .tpos").css("display",'inline');
			}
			if (n==2) {
				jQuery(".change-tb .plink").css("display",'block');
			}
		}
	);
}

*/

function setView() {
    
    jQuery('#view').val(jQuery('#view_choice').val());
    document.getElementById('dform').submit();
}

function getElementPosition(elemId) {
    var elem = document.getElementById(elemId);

    var w = elem.offsetWidth;
    var h = elem.offsetHeight;

    var l = 0;
    var t = 0;

    while (elem)
    {
        l += elem.offsetLeft;
        t += elem.offsetTop;
        elem = elem.offsetParent;
    }

    return {"left":l, "top":t, "width": w, "height":h};
}

function shClient(cname,clink) {
	sell = jQuery('#'+clink);
	sb = jQuery('#'+cname);
	pos_parent = getElementPosition('cliend');
	pos_link = getElementPosition(clink);
	for (i=0; i<jQuery(".cdett").length; i++) {
		if (jQuery(".cdett").eq(i).attr("id")!=cname) {
			jQuery(".cdett").eq(i).addClass("dnone");
			jQuery(".reado").eq(i).addClass("dash");
		}
	}
	if (sb.hasClass("dnone")) {
		sell.removeClass("dash");
		sb.removeClass("dnone");
		sb.css("margin-top", (pos_link.top - pos_parent.top)-84+'px');
	}
	else {
		sell.addClass("dash");
		sb.addClass("dnone");
	}
}

function removeElement(nodeId) {
  document.getElementById(nodeId).parentNode.removeChild(
              document.getElementById(nodeId));
}

function remRegion(oid) {
	removeElement(oid);
	if (n>5) {
			jQuery("#addreg").css("visibility",'visible');
	}
	n--;
	nn--;
}

n = 1;
nn =1;

function addRegion(id_file) {
 	if (n<6) {
		var add_tb = document.getElementById(id_file);
 		var add_div = document.createElement('div');
 		add_div.setAttribute('id', 'or-'+nn);
 		add_tb.insertBefore(add_div,add_tb.firstChild);
 		add_div.innerHTML = '<table class="or-tb"><tr><td><select id="reg-'+nn+'-1" onchange="return AjaxGeo(this.value, '+nn+', 2);" name="reg['+nn+'][1]"><option value="0">Выберите...</option><option value="138">Австралия и Океания</option><option value="183">Азия</option><option value="241">Африка</option><option value="111">Европа</option><option value="225">Россия</option><option value="10002">Северная Америка</option><option value="166">СНГ (исключая Россию)</option><option value="10003">Южная Америка</option></select></td><td><select id="reg-'+nn+'-2" onchange="return AjaxGeo(this.value, '+nn+', 3);" name="reg['+nn+'][2]"><option value="0">Выберите...</option></select></td><td><select id="reg-'+nn+'-3" name="reg['+nn+'][3]"><option value="0">Выберите...</option></select></td><td><a href="javascript: remRegion(\'or-'+nn+'\')" class="dell f1">Удалить регион</a></td></tr></table>';
		if (n==5) {
			jQuery("#addreg").css("visibility", 'hidden');
		}
 		nn++;
		n++;
 	}
}

function total() {
	sum = jQuery("#cast3 .chk td input:checked");
	var tot = 0;
	for (i=0; i<sum.length; i++) {
		if (!sum.eq(i).attr("disabled"))	{
			tot = Math.round(100*(tot + parseFloat(sum.eq(i).attr("val1"))))/100;
		}
	}
	tot2 = Math.round(tot*kurs);
	tot = formatDigi2(tot);
	jQuery("#tot").html(tot+'');
	tot2 = formatDigi2(tot2);
	jQuery("#tot-by").html(tot2);
}

function formatDigi2(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0].replace(/ /, '');
	x2 = x.length > 1 ? ',' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ' ' + '$2');
	}
	return x1 + x2;
}

function formatDigi(digi)
{
	var parts = digi.split(",");
	var string = parts[0];
	var tmp = '';

	for(i = string.length; i >= 0 ; i--)
		tmp = ((i - string.length)%3 == 0 ? ' ' : null) + string.substr(i, 1) + tmp;

	if (parts[1] != '')
		tmp = tmp + "," . parts[1];

	return tmp;
}

function sellAll(tp, spec) {
	var obj = jQuery("input.r-"+tp);
	jQuery(".spec").removeClass("sa");
	jQuery(".spec h4 span").addClass("dash");
	jQuery("#cast3 .chk th").css("font-weight",'normal');
	if (jQuery("#cast3 td").hasClass("wb")) {
		jQuery("#cast3 td").removeClass("wb");
	}
	obj.attr({checked: 'checked'});
	jQuery(spec).removeClass("dash");
	jQuery(spec).parent().parent().addClass("sa");
	obj.parent().next().css("font-weight",'bold');
	obj.parent().parent().parent().parent().parent().next().addClass("wb");
	obj.parent().parent().parent().parent().parent().next().next().addClass("wb");
	obj.parent().parent().parent().parent().parent().next().next().next().addClass("wb");
	obj.parent().parent().parent().parent().parent().next().next().next().next().addClass("wb");

	total();
}

function sellType() {
	var stype = jQuery("#cast3 .chk :radio");
	stype.click(function(){
		sother = jQuery("#cast3 .chk input[name=\'"+jQuery(this).attr("name")+"\']");
		sother.parent().next().css("font-weight",'normal');
		sother.parent().parent().parent().parent().parent().next().removeClass("wb");
		sother.parent().parent().parent().parent().parent().next().next().removeClass("wb");
		sother.parent().parent().parent().parent().parent().next().next().next().removeClass("wb");
		sother.parent().parent().parent().parent().parent().next().next().next().next().removeClass("wb");

		jQuery(this).parent().next().css("font-weight",'bold');
		jQuery(this).parent().parent().parent().parent().parent().next().addClass("wb");
		jQuery(this).parent().parent().parent().parent().parent().next().next().addClass("wb");
		jQuery(this).parent().parent().parent().parent().parent().next().next().next().addClass("wb");
		jQuery(this).parent().parent().parent().parent().parent().next().next().next().next().addClass("wb");

		total();
	});
}

function desNext() {
	var dch = jQuery(".kxch input:checkbox");
	for (i=0; i<dch.length; i++) {
		if (!dch.eq(i).attr("checked")) {
			jQuery("#bnext").attr("disabled",'disabled');
		}
		else {
			jQuery("#bnext").removeAttr("disabled");
			break;
		}
	}
}

function chAll(ch) {
	chch = jQuery(".kxch input");
	if (ch.checked == true) {
		jQuery(".kxch input").attr({checked: 'checked'});
		jQuery("td, td a",chch.parent().parent()).css("color",'');
		jQuery("td a.dash",chch.parent().parent()).css("visibility",'visible');
		jQuery("td",chch.parent().parent().next()).css("color",'');
		jQuery("td",chch.parent().parent().next().next()).css("color",'');
		jQuery("td :radio",chch.parent().parent()).attr("disabled", '');
		jQuery("td :radio",chch.parent().parent().next()).attr("disabled", '');
		jQuery("td :radio",chch.parent().parent().next().next()).attr("disabled", '');

		total();

		desNext()
	}
	else {
		jQuery(".kxch input").removeAttr("checked");
		jQuery("td, td a", chch.parent().parent()).css("color",'#ccc');
		jQuery("td a.dash",chch.parent().parent()).css("visibility",'hidden');
		jQuery("td",chch.parent().parent().next()).css("color",'#ccc');
		jQuery("td",chch.parent().parent().next().next()).css("color",'#ccc');
		jQuery("td :radio",chch.parent().parent()).attr("disabled", 'disabled');
		jQuery("td :radio",chch.parent().parent().next()).attr("disabled", 'disabled');
		jQuery("td :radio",chch.parent().parent().next().next()).attr("disabled", 'disabled');

		total();

		desNext()
	}
}

function dess() {
	var chch = jQuery(".kxch input");
	chch.click(function(){
		if (this.checked == true) {
			jQuery("td, td a",jQuery(this).parent().parent()).css("color",'');
			jQuery("td a.dash",jQuery(this).parent().parent()).css("visibility",'visible');
			jQuery("td",jQuery(this).parent().parent().next()).css("color",'');
			jQuery("td",jQuery(this).parent().parent().next().next()).css("color",'');
			jQuery("td :radio",jQuery(this).parent().parent()).removeAttr("disabled");
			jQuery("td :radio",jQuery(this).parent().parent().next()).removeAttr("disabled");
			jQuery("td :radio",jQuery(this).parent().parent().next().next()).removeAttr("disabled");

			total();

			desNext()
		}
		else {
			jQuery("td, td a", jQuery(this).parent().parent()).css("color",'#9b9b9b');
			jQuery("td a.dash",jQuery(this).parent().parent()).css("visibility",'hidden');
			jQuery("td",jQuery(this).parent().parent().next()).css("color",'#9b9b9b');
			jQuery("td",jQuery(this).parent().parent().next().next()).css("color",'#9b9b9b');
			jQuery("td :radio",jQuery(this).parent().parent()).attr("disabled", 'disabled');
			jQuery("td :radio",jQuery(this).parent().parent().next()).attr("disabled", 'disabled');
			jQuery("td :radio",jQuery(this).parent().parent().next().next()).attr("disabled", 'disabled');

			total();

			desNext()
		}
	});
}

function hideForm(hblock) {
	jQuery("#"+hblock).hide();
	jQuery("#fonn").hide();
	jQuery("#pop").hide();
	jQuery("select, object").show();
}

function FormBlock(form_type) {
	var block = jQuery("#fonn");
	jQuery("select, object").hide();
	block.css("height", jQuery(".global").height() + 'px').css("width", jQuery(".global").width() + 'px');
	block.show();
	block.click(function() {
		hideForm(form_type);
	});
	var yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {
		yScroll = document.body.scrollTop;
	}
	var windowHeight;
	if (self.innerHeight) {
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		windowHeight = document.body.clientHeight;
	}
	var frmBlock = jQuery("#pop");
	var frm = jQuery("#"+form_type);
	frmBlock.css("visibility",'hidden');
	frmBlock.show();
	frm.show();
	frmBlock.css("top", windowHeight/2 + yScroll - frmBlock.height()/2 + 'px');
	frmBlock.css("visibility",'visible');
	document.getElementById(form_type+'-form').elements[0].focus();
}

function listSite() {
	jQuery(".sbgsell ins").toggle(
		function(){
			jQuery(".ss2").css("top",jQuery(".sbgsell ins").height()+5+'px');
			jQuery(".ss2 .ss2-top").css("margin-right",jQuery(".sbgsell ins").width()+29+'px')
			jQuery(".ss2").show();
		},
		function(){
			jQuery(".ss2").hide();
		});
}

function slideSearch() {
	jQuery("#acc h2 span").click(function(){
		if (jQuery(this).parent().parent().next("#acc .oacc").css("display")=='none') {
			jQuery(this).removeClass("ahide");
			jQuery(".obb",jQuery(this).parent().parent()).show();
			//jQuery(".osite",jQuery(this).parent().parent().parent()).show();
			jQuery(this).parent().parent().next("#acc .oacc").slideDown();
			jQuery(this).parent().find('input.services').attr('checked', 'checked');
			}
		else {
			jQuery(this).addClass("ahide");
			jQuery(".obb",jQuery(this).parent().parent()).hide();
			//jQuery(".osite",jQuery(this).parent().parent().parent()).hide();
			jQuery(this).parent().parent().next("#acc .oacc").slideUp();
			jQuery(this).parent().find('input.services').removeAttr('checked');
		}
	});
}

function chpayform(){

	frm = document.getElementById('fpay');
	if (frm.fio.value == '') {
		alert('Введите ваше "Фамилия Имя Отчество"');
		frm.fio.focus();
		return false;
	}	
	
	if (frm.email.value == '') {
		alert('Введите Email');
		frm.email.focus();
		return false;
	}
	
	if (frm.phone.value == '') {
		alert('Введите Контактный телефон');
		frm.phone.focus();
		return false;
	}
	
	if (frm.address.value == '') {
		alert('Введите Адресс');
		frm.address.focus();
		return false;
	}	
	
	if(!$("input:radio:checked").val()){
		alert('Способ оплаты не выбран');
		return false;
	}
	
	return true;
}

function chUrPayForm(){
	
	frm = document.getElementById('fpay');
	if (frm.company.value == '') {
		alert('Введите Наименование организации');
		frm.company.focus();
		return false;
	}
	
	if (frm.post_address.value == '') {
		alert('Введите Почтовый адресс');
		frm.post_address.focus();
		return false;
	}
	
	if (frm.ur_address.value == '') {
		alert('Введите Юридический адресс.');
		frm.ur_address.focus();
		return false;
	}
	
	if (frm.company_info.value == '') {
		alert('Введите Информацию о компании');
		frm.company_info.focus();
		return false;
	}
	
	if (frm.upn.value == '') {
		alert('Введите UPN');
		frm.upn.focus();
		return false;
	}
	
	if (frm.paynumber.value == '') {
		alert('Введите Расчетный счет');
		frm.paynumber.focus();
		return false;
	}
	
	if (frm.bankinfo.value == '') {
		alert('Введите Наименование, Код банка');
		frm.bankinfo.focus();
		return false;
	}
	
	if (frm.cinfo.value == '') {
		alert('Введите Контактное лицо');
		frm.cinfo.focus();
		return false;
	}
	
	if (frm.phone.value == '') {
		alert('Введите Контактный телефон');
		frm.phone.focus();
		return false;
	}
	
	if (frm.fax.value == '') {
		alert('Введите Факс');
		frm.fax.focus();
		return false;
	}
	
	if (frm.email.value == '') {
		alert('Введите Email');
		frm.email.focus();
		return false;
	}	
	
	if (frm.pnum.value == '') {
		alert('Введите Количество участников');
		frm.pnum.focus();
		return false;
	}	
	
	return true;
	
}

function isValidEmail(email)
{
 reg = /^\w+[-_\.]*\w+@\w+-?\w+\.[a-z]{2,4}$/;
	if (!email.match(reg))
		return false;
	else
		return true;
}

function chOrder() {
	frm = document.getElementById('orderform');
	if (frm.phone.value == '') {
		alert('Введите контактный телефон.');
		frm.phone.focus();
		return false;
	}
	if (frm.email.value != '' && !isValidEmail(frm.email.value)) {
		alert('Вы ввели неверный Email.');
		frm.email.focus();
		return false;
	}
	if (jQuery('.services:checked').length == 0
		&& jQuery('#ysu:checked').length == 0
		&& jQuery('#ta:checked').length == 0
		&& jQuery('#rca:checked').length == 0) {
		
		alert('Вы не выбрали услугу.');
		return false;
	}
	


/*
	if ((frm.site1.value == '') && (frm.nosite1.checked == false) && (frm.key_word1.value !='' || frm.region.value !='' || frm.position.value !='' || frm.your_mess.value !='' || frm.yandex.checked || frm.tut.checked || frm.google.checked || frm.yahoo.checked || frm.other1.checked)) {
		alert('Введите адресс вашего сайта');
		jQuery('#acc h2 span').eq(0).removeClass("ahide");
		jQuery('#acc h2 span').eq(0).parent().next("#acc .oacc").slideDown();
		frm.site1.focus();
		return false;
	}

	if (frm.other1.checked && frm.txother1.value == '') {
		alert('Введите необходимые поисковики.');
		jQuery('#acc h2 span').eq(0).removeClass("ahide");
		jQuery('#acc h2 span').eq(0).parent().next("#acc .oacc").slideDown();
		frm.txother1.focus();
		return false;
	}
	if ((frm.site2.value == '') && (frm.nosite2.checked == false) && (frm.key_word2.value !='' || frm.region2.value !='' || frm.your_mess2.value !='')) {
		alert('Введите адресс вашего сайта');
		jQuery('#acc h2 span').eq(1).removeClass("ahide");
		jQuery('#acc h2 span').eq(1).parent().next("#acc .oacc").slideDown();
		frm.site2.focus();
		return false;
	}
	if ((frm.site3.value == '') && (frm.nosite3.checked == false) && (frm.your_mess3.value !='' || frm.mail_bel.checked || frm.yandex_bel.checked || frm.tut_bel.checked || frm.odnoklassniki_bel.checked || frm.gis_meteo_bel.checked || frm.relax_bel.checked || frm.holiday_bel.checked || frm.pogoda_bel.checked  || frm.naviny_bel.checked || frm.other2.checked)) {
		alert('Введите адресс вашего сайта');
		jQuery('#acc h2 span').eq(2).removeClass("ahide");
		jQuery('#acc h2 span').eq(2).parent().next("#acc .oacc").slideDown();
		frm.site3.focus();
		return false;
	}
	if (frm.other2.checked && frm.txother2.value == '') {
		alert('Введите другие сайты.');

		jQuery('#acc h2 span').eq(2).removeClass("ahide");
		jQuery('#acc h2 span').eq(2).parent().next("#acc .oacc").slideDown();
		frm.txother2.focus();
		return false;
	}
*/
	if (document.getElementById('e11t3')) document.getElementById('e11t3').value='e11t33t11e';
	return true;
}

function topMenu(){
	if (jQuery(".mlink").parent().width()>190) {
		jQuery(".mlink .ma-2").css("display",'block');
		jQuery(".mlink .ma-1").css("display",'none');
	}
	else {
		jQuery(".mlink .ma-1").css("display",'block');
		jQuery(".mlink .ma-2").css("display",'none');
	}
}



function shChk(ch,n){
		if (ch.checked) {
			document.getElementById('othertext'+n).style.visibility = 'visible';
		}
		else {
			document.getElementById('othertext'+n).style.visibility = 'hidden';
		}
}

function zPop(add) {
	window.open(add.href, "", "width=800, height=580, status=no, toolbar=no, menubar=no, location=no, scrollbars=yes");
}


function showHint(hint, frm) {
	jQuery(".osite, #"+hint).css("visibility",'hidden').show();
	var th = jQuery(frm);
	var block = jQuery(".osite");
	var frmpos = th.position();
	block.css("top",((frmpos.top+th.height()/2)-block.height()/2)+'px');
	jQuery(".osite, #"+hint).css("visibility",'visible');
}

function hideHint() {
	jQuery(".osite, .osite div").hide();
}

function showHint2(hint, frm) {
	jQuery(".calchint, #"+hint).css("visibility",'hidden').show();
	var th = jQuery(frm);
	var block = jQuery(".calchint");
	var frmpos = th.position();
	jQuery(frm).removeClass("dash").addClass("nodash");
	block.css("top",((frmpos.top+th.height()/2)-block.height()/2)+'px').css("left", frmpos.left+th.width()+'px');
	jQuery(".calchint, #"+hint).css("visibility",'visible');
}

function hideHint2(frm) {
	jQuery(".calchint, .calchint div").hide();
	jQuery(frm).removeClass("nodash").addClass("dash");
}


function zTabs(tab, block) {
		jQuery("#ztabs span").removeClass("dash").addClass("dash");
		jQuery(tab).removeClass("dash");
		jQuery(".zpans").hide();
		jQuery("#"+block).show();
}

function doCalc()
{
    if (jQuery("#isumma").val()!='') {
		iman = parseInt(jQuery("#isumma").val());
	}
	else {
			iman = 0;
	}
	var yan = iman/yakurs;
		jQuery("#sumyan").text(yan.toFixed(1));

	chk = document.getElementById('uyes');
	if(chk.checked)
	{
	    var kosht = iman*0.25;
			jQuery("#kosh-upr").show();
			jQuery("#sumupr").text(kosht.toFixed(0));
	}
	else
	{
	    jQuery("#kosh-upr").hide();
	}
}
/*
function cCalc(ch, yn) {
	if (ch.checked == true) {
		if (jQuery("#isumma").val()!='') {
			iman = parseInt(jQuery("#isumma").val());
		}
		else {
			iman = 0;
		}
		var yan = iman/yakurs;
		jQuery("#sumyan").text(yan.toFixed(1));
		if (yn == '1') {
			var kosht = iman*0.25;
			jQuery("#kosh-upr").show();
			jQuery("#sumupr").text(kosht.toFixed(0));
		}
		else {
			jQuery("#kosh-upr").hide();
		}
	}
}
*/
function parseStr(str)
{
    outstr = '';
    for (i=0;i<str.length;i++)
    {
        for(j=0;j<10;j++)
        {
            if(str.substr(i,1) === j.toString())
            {
                if((outstr.length == 0 && j > 0)||(outstr.length>0))
                    outstr = outstr + str.substr(i,1);
                break;
            }
        }
    }

    return outstr;
}

function formatNumber(num, offset)
{
    nstr = num.toString();
    ostr = '';

    for(i=(nstr.length-1),j=offset;i>=0;i--,j++)
    {
        if((j%3 == 0) && (j>0)) ostr = ' ' + ostr;
        ostr = nstr.substr(i,1) + ostr;
    }

    return ostr;
}

function cCalc() {
    v = jQuery("#isumma").val();
    ps = parseStr(v);
    iman = parseInt(ps);

	if (!iman) {iman = calcDefaultValue;}
	jQuery("#isumma").val(formatNumber(iman,0));

	var yan = iman/yakurs;
	jQuery("#sumyan").text(formatNumber(yan.toFixed(1),1));

	var cmult = 0.20;
	if(yan >= 200) cmult = 0.15;
	if(yan > 1000) cmult = 0.10;

	var kosht = iman*cmult;
	jQuery("#sumupr").text(formatNumber(kosht.toFixed(0),0));
}

function selUpr(ch, yn) {
	if (ch.checked == true) {
		if (yn == '1') {
			jQuery("#kosh-upr").show();
		}
		else {
			jQuery("#kosh-upr").hide();
		}
	}
}

function gTabs(n,obj) {
	jQuery("li.ga",jQuery(obj).parent().parent()).removeClass("ga");
	jQuery(obj).parent().addClass("ga");
	jQuery("div.pgraph",jQuery(obj).parent().parent().parent()).css("display",'none');
	jQuery("#graph-"+n).css("display",'block');
}

function gTabs2(n,obj) {
	jQuery("li.ga",jQuery(obj).parent().parent()).removeClass("ga");
	jQuery(obj).parent().addClass("ga");
	jQuery(".apix0 .ctext-pp, .tbc .ctext-pp").css("display",'none');
	jQuery("div.pctext",jQuery(obj).parent().parent().parent()).css("display",'none');
	jQuery("#ctpix-"+n).css("display",'block');
	jQuery("#ctrek-"+n).css("display",'block');
}

function shYan(bn) {
	var bb = jQuery("#yanbn-"+bn);
	jQuery("body").bind("click", function(event){
		var t2 = jQuery(event.target);
		if(t2.is("#yan-ths-"+bn) || t2.parent().is("#yan-ths-"+bn)) {
			if (bb.css("display")=='none') {bb.show();}
			else {bb.hide();}
  		}
		else {
			bb.hide();
		}
	});
}

(function($) {
	$.fn.iTabs = function() {
		return this.each(function(){
			var tabs = $(this).find("li div");
			var blocks = $("div.itabs-item");
			tabs.bind("mouseenter", function(){
				var t = $(this);
				tabs.removeClass("tab-a");
				t.addClass("tab-a");
				blocks.hide();
				$("#"+t.attr("id")+"-block").show();
				if (t.attr("id")=="tab-promo") {
					$("div.idemo").css("visibility",'visible');
				}
				else {
					$("div.idemo").css("visibility",'hidden');	
				}
				if (t.attr("id")=="tab-consalt") {
					$("div.b-zakaz-index").hide();
				}
				else {
					$("div.b-zakaz-index").show();	
				}
			})
			if ($('#itabs li').eq(2).find('div').hasClass('tab-a')){
					$("div.b-zakaz-index").show();
				}
		});
	};
})(jQuery);

function eyeDemo(){
	var bw = $('span.ico-demo b img').width();
	var dw = $('span.ico-demo b').width();
	var bh = $('span.ico-demo b img').height();
	var dh = $('span.ico-demo b').height();
	$(window).mousemove(function(e){					
		var sh = $(window).height();
		var sw = $(window).width();
		var x = e.clientX;
		var y = e.clientY;
		var mw = (((bw-dw)/sw)*x);
		var mh = (((bh-dh)/sh)*y);
		//$('span.ico-demo em').html((bh-dh)-mh);
		$('span.ico-demo b img').css({margin: -((bh-dh)-mh) + 'px' + ' 0 0 ' + -((bw-dw)-mw) + 'px'} );
	});
}

function doCounter(speed, count) {

	var counts = function() {
	
	    count = count + 1;
	    $("#b-counter").html(formatNumber(count, 0));
	
	setTimeout(function(){counts()}, 1 / speed * 1000);
	}
    setTimeout(function(){counts()}, 1 / speed * 1000);
}

jQuery(document).ready(function() {

	jQuery('#arda').click(function() {
	
		jQuery.ajax({
            type: "POST",
            url: "/addon/quiz.php",
            data: 'answer=y',
            success: function(msg) {
                    // success handler code here
                }
        });
	});
	
	jQuery('.addrepphrase').click(function() {

                var selHtml = "";

                jQuery('form[name='+this.id+'] input:checkbox:checked').each( function () {
                        
                        if($(this).hasClass("title")) {
                            if (selHtml.length > 0) selHtml = selHtml+"</ul>";
                            selHtml = selHtml+"<span style=\"font-size:14px; font-weight: bold; padding:0; margin:0; \">"+escapeHtml(jQuery(this).parent().text())+"</span><ul>";
                        }
                        else if($(this).is("[name=checkbox]"))  {
                            selHtml = selHtml+"<li type=\"circle\" style=\"font-size:12px; font-weight: 200; padding:0; margin:2px 0 2px 15px;\">"+escapeHtml(jQuery(this).parent().text())+"</li>";
                        }
                        else {
                            selHtml = selHtml+"<li type=\"disc\" style=\"font-size:12px; font-weight: 200; padding:0; margin:2px 0 2px 30px;\">"+escapeHtml(jQuery(this).parent().text())+"</li>";
                        }
                } );
                selHtml +="</ul><br />";
		
		var iframe = jQuery(this).parent().find('textarea').htmlarea('pasteHTML', selHtml);
		
		jQuery(iframe).append(selHtml);
	
	});

        function escapeHtml(text) {
          return text
              .replace(/&/g, "&amp;")
              .replace(/</g, "&lt;")
              .replace(/>/g, "&gt;")
              .replace(/"/g, "&quot;")
              .replace(/'/g, "&#039;");
        }

	
	jQuery('#arnet').click(function() {
	
		jQuery.ajax({
            type: "POST",
            url: "/addon/quiz.php",
            data: 'answer=n',
            success: function(msg) {
                    // success handler code here
                }
        });
	});
	
	jQuery('#market_type').change(function() {
	
		if (jQuery(this).val() == 'other')
			jQuery('#othertext4').css('visibility', 'visible');
		else
			jQuery('#othertext4').css('visibility', 'hidden');
			
		if (jQuery(this).val() == 'shop.by')
			jQuery('#market_method').val('автоматически(shop.by)');
	});
	
	jQuery('#wordstat').click(function() {
	
		jQuery('.loading-fade').css('display', 'block');
		jQuery('.loading-img').css('display', 'block');
		
		var word = jQuery("#tovar").val();
		
		jQuery.ajax({
            type: "POST",
            url: "/addon/ajax_wordstat.php",
            data: 'word=' + encodeURIComponent(word),
            success: function(obj) {

                    	jQuery('#c_zam').html(obj);
                    	jQuery('#l_zam').html(word);
                    	jQuery('#l_zam').attr('href', 'http://wordstat.yandex.ru/?cmd=words&page=1&text='+encodeURIComponent(word)+'&geo=149&text_geo=%D0%91%D0%B5%D0%BB%D0%B0%D1%80%D1%83%D1%81%D1%8C');
                    	
                    	jQuery('.loading-fade').css('display', 'none');
						jQuery('.loading-img').css('display', 'none');
						jQuery('.rpopsearch-result').css('display', 'block');
                }
        });
	});
	
	jQuery('#tovar').keyup(function(event) {
	
		if (event.keyCode != '13') {
     		return false;
   		}

		jQuery('.loading-fade').css('display', 'block');
		jQuery('.loading-img').css('display', 'block');
		
		var word = jQuery("#tovar").val();
		
		jQuery.ajax({
            type: "POST",
            url: "/addon/ajax_wordstat.php",
            data: 'word=' + encodeURIComponent(word),
            success: function(obj) {

                    	jQuery('#c_zam').html(obj);
                    	jQuery('#l_zam').html(word);
                    	jQuery('#l_zam').attr('href', 'http://wordstat.yandex.ru/?cmd=words&page=1&text='+encodeURIComponent(word)+'&geo=149&text_geo=%D0%91%D0%B5%D0%BB%D0%B0%D1%80%D1%83%D1%81%D1%8C');
                    	
                    	jQuery('.loading-fade').css('display', 'none');
						jQuery('.loading-img').css('display', 'none');
						jQuery('.rpopsearch-result').css('display', 'block');
                }
        });
	});
	
	jQuery('#more_news').click(function() {
	
		jQuery('.item').show();
		jQuery(this).hide();
	
	});

});

(function($) {
	$.fn.gTab = function() {
		return this.each(function(){
			var tab = $(this).find(".tab-title");
			var block = $(this).find(".tab-content");
			tab.bind("click", function(){
				tab.parent().removeClass("ga");
				block.hide();
				$(this).parent().addClass("ga");
				block.eq(tab.index($(this))).show();
				return false;
			})
		});
	};
})(jQuery);

(function($) {
	$.fn.markFaq = function(o) {
		var optoin = {start: 0};
    	var o = $.extend(optoin, o);
		return this.each(function(){
			var qwt = $(this).find(".slide-qwst p");
			var ans = $(this).find(".slide-ans p");
			var fprev = $(this).find("a.faq-prev");
			var fnext = $(this).find("a.faq-next");
			qwt.eq(o.start).show();
			ans.eq(o.start).show();
			if (qwt.length<2) {
				fprev.hide();
				fnext.hide();
			}
			else {
				if (o.start == 0) {
				fprev.addClass("faq-prev-d").css("display",'block');
				fnext.addClass("faq-next-a").css("display",'block');
				}
				else if (o.start == qwt.length-1) {
					fprev.addClass("faq-prev-a").css("display",'block');
					fnext.addClass("faq-next-d").css("display",'block');
				}
				else {
					fprev.addClass("faq-prev-a").css("display",'block');
					fnext.addClass("faq-next-a").css("display",'block');
				}
				var qn = o.start;
				fprev.bind("click", function(){
					if (qn<=0) {
						return false;
					}
					else {
						qn = qn - 1;
						qwt.hide();
						ans.hide();
						qwt.eq(qn).show();
						ans.eq(qn).show();
						fnext.removeClass("faq-next-d").addClass("faq-next-a");
						if (qn==0) {
							fprev.removeClass("faq-prev-a").addClass("faq-prev-d")
						}
						else {
							fprev.removeClass("faq-prev-d").addClass("faq-prev-a");
						}
						return false;
					}
				});
				fnext.bind("click", function(){
					if (qn>=qwt.length-1) {
						return false;
					}
					else {
						qn = qn + 1;
						qwt.hide();
						ans.hide();
						qwt.eq(qn).show();
						ans.eq(qn).show();
						fprev.removeClass("faq-prev-d").addClass("faq-prev-a");
						if (qn>=qwt.length-1) {
							fnext.removeClass("faq-next-a").addClass("faq-next-d")
						}
						else {
							fnext.removeClass("faq-next-d").addClass("faq-next-a");
						}
						return false;
					}
				});
			}
		});
	};
})(jQuery);

(function($) {
	$.fn.mapMenu = function() {
		return this.each(function(){
			var $this = $(this);
			var $ddmenu = $this.find("ul");
			var $link = $this.find("i");
			$link.bind("click", function(){
				if ($ddmenu.css("display")=='none') {
					$ddmenu.show();
					$link.addClass('dd-a');
				}
				else {
					$ddmenu.hide();
					$link.removeClass('dd-a');
				}
			});			
		});
	};
})(jQuery);

(function($) {
	$.fn.LitsoType = function() {
		return this.each(function(){
			var $this = $(this);
			var $rdb = $this.find(".litso-type input:radio");
			var $form = $this.find("div.form-block");
			var $lab = $this.find(".litso-type label");
			$rdb.bind("click", function(){
				$lab.css("font-weight",'normal');
				$("label[for='"+$(this).attr("id")+"']", $this).css("font-weight",'bold');
				$form.hide();
				$("#"+$(this).attr("id")+"-form").show();
			});			
		});
	};
})(jQuery);


$(document).ready(function(){


	function switch_smm(obj, obj_i_1, obj_s_1, obj_b_1, obj_i, obj_s, obj_b){
		$(obj).bind('click', function(event){
		$(obj_i_1).removeClass('sws-1');
		$(obj_s_1).removeClass('sws-1');
		$(obj_b_1).removeClass('sws-1');

		$(obj_i).addClass('sws-1');
		$(obj_s).addClass('sws-1');
		$(obj_b).addClass('sws-1');
	})
	}
		switch_smm(".switch-smm-2 span", ".switch-smm-1 .swi.sws-1", ".switch-smm-1 .sws.sws-1", ".switch-smm-1 .swb.sws-1",  ".switch-smm-2 .swb", ".switch-smm-2 .swi", ".switch-smm-2 .sws");
		switch_smm(".switch-smm-1 span", ".switch-smm-2 .swi.sws-1", ".switch-smm-2 .sws.sws-1", ".switch-smm-2 .swb.sws-1",  ".switch-smm-1 .swb", ".switch-smm-1 .swi", ".switch-smm-1 .sws")
		$('.switch-smm-2 span').bind('click', function(){
			$('.open-actv').hide();
			$('.hide-actv').show();

		})
		$('.switch-smm-1 span').bind('click', function(){
			$('.open-actv').show();
			$('.hide-actv').hide();

		})






	$('#zoom-smm1 a, #zoom-smm1 span').bind('click', function(event){
		event.preventDefault();
		event.stopPropagation();
		if ($('.zoom-smm-1').css('display') == 'none'){
		$('.zoom-smm-1').show();}
		else if ($('.zoom-smm-1').css('display') == 'block'){
		$('.zoom-smm-1').hide();
		}
		if( $(".zoom-smm-2").css('display') == 'block'){
			$(".zoom-smm-2").hide();
		}
		})
	$('#zoom-smm2 a, #zoom-smm2 span').bind('click', function(event){
		event.preventDefault();
		event.stopPropagation();
		if ($('.zoom-smm-2').css('display') == 'none'){
		$('.zoom-smm-2').show();}
		else if ($('.zoom-smm-2').css('display') == 'block'){
		$('.zoom-smm-2').hide();
		}
		if( $(".zoom-smm-1").css('display') == 'block'){
		$(".zoom-smm-1").hide();
		}

		})
	$(".zoom-smm-1").bind('click', function(event){
		event.stopPropagation();

	})
		$(".zoom-smm-2").bind('click', function(event){
		event.stopPropagation();
	})
	$('body, .zoom-exit, .zoom-exit2').bind('click', function(event){
		$(".zoom-smm-1").hide();
		$(".zoom-smm-2").hide();
	})
	$('.site1a').bind('mouseover', function(event){
		event.preventDefault();
		$(this).css('width', '345px');
		$(".site1").animate({'width': '360px'});
		$('.site2').stop().animate({'width': '110px'});
		$('.site3').stop().animate({'width': '130px'});
	})

	$('.site1a').bind('mouseout', function(event){
		event.preventDefault();
		$(this).css('width', '110px');
		$('.site1').stop().animate({'width': '110px'});
		$('.site2').stop().animate({'width': '110px'});
		$('.site3').stop().animate({'width': '130px'});

	})


	$('.site2a').bind('mouseover', function(event){
		event.preventDefault();
		$(this).css('width', '360px');
		$('.site1a').css('z-index', '-1');
		$(".site2").stop().animate({'width': '365px'});
		$('.site1').stop().animate({'width': '110px'});
		$('.site3').stop().animate({'width': '130px'});
		if ($(".site2").css('width') == '365px'){
			$(".site2").stop().animate({'width': '110px'})
		}
	})
		$('.site2a').bind('mouseout', function(event){
		$(this).css('width', '89px');
		$('.site1a').css('z-index', '4');
		event.preventDefault();
		$('.site1').stop().animate({'width': '110px'});
		$('.site3').stop().animate({'width': '130px'});
		$(".site2").stop().animate({'width': '110px'})
	})
	$('.site3 a').bind('mouseover', function(event){
		event.preventDefault();
		$('.site1a').css('z-index', '-1');
		$('.site2a').css('z-index', '-1');
		$(this).parent().stop().animate({'width': '365px'});
		$('.site1').stop().animate({'width': '110px'});
		$('.site2').stop().animate({'width': '110px'});

	})
	$('.site3 a').bind('mouseout', function(event){
		event.preventDefault();
		$('.site1a').css('z-index', '4');
		$('.site2a').css('z-index', '4');
		$('.site1').stop().animate({'width': '110px'});
		$('.site2').stop().animate({'width': '110px'});
		$(this).parent().stop().animate({'width': '130px'})
	})

	/****za-kliki****/
	$('.gmenu-smm li span').eq(1).bind('click', function(){
		$('#zoom-smm2').show();
		$('#zoom-smm1').hide();
		$('.gmenu-smm li').eq(0).removeClass();
		$('.gmenu-smm li').eq(1).addClass('ga-smm');
	})
	$('.gmenu-smm li span').eq(0).bind('click', function(){
		$('#zoom-smm2').hide();
		$('#zoom-smm1').show();
		$('.gmenu-smm li').eq(1).removeClass();
		$('.gmenu-smm li').eq(0).addClass('ga-smm');
	})



})

/*
    Выход на Россию
*/
$(document).ready(function(){


    var keywords = new Array ("пластиковые окна", "межкомнатные двери", "офисная мебель", "молоко оптом")
    var i = 0

	$("#pr-saitovr").click(function(e){
		e.preventDefault();
		e.stopPropagation();
		$("#prods-r").show();
		$("#kont-rr").hide();
	});

	$("#csr-r").click(function(e){
		e.preventDefault();
		e.stopPropagation();
		$("#prods-r").hide();
		$("#kont-rr").show();
	});
	$("body").click(function(){
		$("#prods-r").hide();
		$("#kont-rr").hide();
	})
	$(".zoomr-exit").click(function(){
		$(this).parent().hide();
	})
	$(".refresh").mousedown(function(){
		$(this).css("background-position" , "-71px 0");
	})
		$(".counter-r li span").next("em").hide();

	$(".refresh").mouseup(function(){
		$(this).css("background-position" , "0px 0");
            if (i < 3){
                i++
            }
            else{
                i = 0
            }
			function showF(id1){

			$(".counter-r span").eq(id1).animate({"opacity":"0"}, 2000);
				$(".counter-r span").eq(id1).next("em").show(2000);

			$(".counter-r span").eq(id1).queue(function(){

			$(".counter-r span").eq(id1).next("em").eq(0).hide();
			$(this).dequeue();
			})
            $("#keyword").animate({"opacity":"0"}, 500);
			$(".counter-r span").eq(id1).queue(function(){
			    setTimeout(function(){$("#keyword").animate({'opacity': '1'}).text(keywords[i])}, 1000);
                if (i == 0){
    				$("#1").text("4");
                    $("#2").text("1");
                    $("#3").text("8");
                    $("#4").text("7");
                    $("#5").text("5");
                    $("#6").text("0");
                }
                if (i == 1){
    				$("#1").text("2");
                    $("#2").text("6");
                    $("#3").text("6");
                    $("#4").text("1");
                    $("#5").text("8");
                    $("#6").text("0");
                }
                if (i == 2){
    				$("#1").text("0");
                    $("#2").text("6");
                    $("#3").text("5");
                    $("#4").text("6");
                    $("#5").text("9");
                    $("#6").text("8");
                }
                if (i == 3){
    				$("#1").text("0");
                    $("#2").text("0");
                    $("#3").text("2");
                    $("#4").text("0");
                    $("#5").text("6");
                    $("#6").text("1");
                }
				$(this).dequeue();
			})
				$(".counter-r span").eq(id1).animate({'opacity': '1'}, 700);

			}
			setTimeout(function(){showF('0')}, 500);
			setTimeout(function(){showF('1')}, 1400);
			setTimeout(function(){showF('2')}, 800);
			setTimeout(function(){showF('3')}, 1100);
			setTimeout(function(){showF('4')}, 2000);
			setTimeout(function(){showF('5')}, 1700);



	});
	$(".refresh").hover(function(){
		$(this).css("background-position" , "-35px 0")
	}, function(){
		$(this).css("background-position" , "0 0")
	})
	$(".cp-list .counter-r li i").css("opacity", ".1")

	$(".wtk i").hover(function(){
		$(this).css("background-position", "0 -63px")
	}, function(){
		$(this).css("background-position", "0 0")
	})
	$(".wtk i").mousedown(function(){
		$(this).css("background-position", "0 -126px")
	});
	$(".wtk i").mouseup(function(){
		$(this).css("background-position", "0 0");
		var pt = $(".mstr").position();
		var point = $(".online-consul").offset().top;
		$("html, body").animate({scrollTop : point}, 500)
	});
    $(".b-rzakaz").mouseup(function(){
		$(this).css("background-position", "0 0");
		var pt = $(".mstr").position();
		var point = $(".online-consul").offset().top;
		$("html, body").animate({scrollTop : point}, 500)
	});
	$(".sendbz").hover(function(){
		$(this).css("background-position", '0 -57px')
	},function(){
		$(this).css("background-position", '0 0px')
	})
	$(".sendbz").mousedown(function(){
		$(this).css("background-position", '0 -114px')
	})
	$(".sendbz").mouseup(function(){
		$(this).css("background-position", '0 0px')
	})
		function proverka(pole){
			if ($(pole).val().length <= 0){
				$(pole).parents(".sendform").addClass("error");
				$(pole).parents(".sendform").next(".senderror").show();
				return false;
			}
			else {
				$(pole).parents(".sendform").removeClass("error");
				$(pole).parents(".sendform").next(".senderror").hide();
			}

		}
		$(".sendbz").click(function(){
			proverka("#yourname");
			proverka("#yourphone");
		})
		$(".sendzs table td input").focus(function(){
			$(this).parents(".sendform").addClass("ifocus");
		})
		$(".sendzs table td input").blur(function(){
			$(this).parents(".sendform").removeClass("ifocus");
		})
	$(".sendzs table td textarea").focus(function(){
		$(this).parents(".sendformta").addClass("focus")
	})
	$(".sendzs table td textarea").blur(function(){
		$(this).parents(".sendformta").removeClass("focus")
	})


})





