//var pref = {1:994, 2:374, 3:375, 4:995, 5:7, 6:996, 7:373, 8:7, 9:992, 10:993, 11:998, 12:380, 13:49, 14:972, 15:1, 16:1, 17:33, 18:358, 19:46, 20:30, 21:420, 22:421, 23:48, 24:385, 25:44, 26:34, 27:976}; 
Kolizeo = {
	module: null,
	logging: false,
	credit_time:[0,0],
	begin_time:0,
	start_time:'',
	pass_time:0,
	chat_status:true,
	consultant_id:0,
	current_url:window.location.pathname,
	months: ["january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december"],

	post:function(sUrl, aData, fData, sType){
		
		var domenname = $("#domenname").val();
		//alert('http://' + domenname + sUrl);
		if (domenname == "kolizeo.ru") {
			$.post('http://www.' + domenname + sUrl, aData, fData, sType);
		} else {
			$.post('http://' + domenname + sUrl, aData, fData, sType);
		}
	},
	scrollTo: function(obj){
		var top = obj ? $(obj).offset().top-10 : 0;
		//if ($(document).scrollTop() > top){
			if (!$.browser.opera)
				$('html, body').animate({scrollTop: top}, 1000 );
				else 
					//$('body').scrollTop(0);
					$("html:not(:animated)").animate({scrollTop: top}, 1000); //плавный скроллинг в опере 
		 //}
	},
	
	consultant_browsegallery:function(id){
		var html = $("#hidden_gallery").html();
		oPopup.show({
		width:731,
		html: html
		});
				
	},

	consultant_change_img:function(sUrl,sName,obj,wI,hI){
		
		if (wI > 670){
			$('.bigimg').css('width','670px')
		}else{
			$('.bigimg').css('width','auto')
		}
		if (hI > 420){
			$('.bigimg').css('height','420px')
		}else{
			$('.bigimg').css('height','auto')
		}
		if(wI/hI > 670/420){
			$('.bigimg').css('height','auto')
		}else{
			$('.bigimg').css('width','auto')
		}

		$(".nav2").removeClass("nav2");
		$(obj.parentNode).addClass("nav2");
		if(sUrl){
			$('.bigimg:visible').attr("src", sUrl);
			$('.altname:visible').html(sName);
		}
	},
							
	isEmail:function(sEmail){
		var re = /^(?:[-a-z\d\+\*\/\?!{}`~_%&'=^$#]+(?:\.[-a-z\d\+\*\/\?!{}`~_%&'=^$#]+)*)@(?:[-a-z\d_]+\.){1,60}[a-z]{2,6}$/i;
		if (sEmail && re.test(sEmail)){
			return(true);
		}else{
			return(false);
		}
	},
	backurl:function(r){
		if(r){
			var backurl = Cookie.get("backurl");
			if(backurl){
				Cookie.set("backurl", "", "/")
				window.location = backurl;
			}
		}
	},
	popup_faq_url: function(url){
		window.opener.location=url; 
		window.opener.focus(); 
		window.close();
		return false;
	},
	
	login: function(){
		if(this.logging) return false;
		var hData = {};
		var prefix = $("#pref_msisdn").val();
		var msisdn1 = $("#msisdn1").val(); 
		//var pref = {ru:7, us:1, ca:1, fr:33, lt:370, lv:371, ee:372, by:375, ua:380, uk:44, de:49, kz:7, il:972};
		
		//		var msisdn2 = $("#msisdn2").val();
		
		if(prefix=="" || msisdn1=="") {return false;}
		hData.login = pref[prefix] + msisdn1;
		hData.login2 = msisdn1;
		hData.password = $("#zpas").val();
		hData.remember = 1;
					
		if(hData.login!="" && hData.password !=""){
			if(!$.browser.msie){$('#login_button').animate({opacity: 0.3}, 400)};
			Kolizeo.logging = true;
			$.post("/login", hData, function(data){
				if(data.success){
					Kolizeo.reload();
				} else {
					Kolizeo.logging = false;
					if(!$.browser.msie){$('#login_button').animate({opacity: 1}, 400)};
					oPopup.alert("Неверная пара телефон/пароль<br /><br /><a href='/forgot/'>Забыли пароль?</a>", {width:280, blockSite:true});
				}
			}, "json");
		}
		return false;
	},
	reload: function(){
		var url = window.location.href;
		if(url.indexOf('#')>-1) url = url.split('#')[0];
		window.location = url;
	},
	url: function(data, url, resetField){
		if(!url) url = window.location.pathname;
		var a = url.split("/");
		if(this.module && a[1] == this.module) a.splice(0, 1);
		var c1 = a[1] ? a[1] : "index";
		//var c2 = a[2] ? a[2] : "ajax-handler";
		var c2 = "ajax-handler";
		var p = {};
		for(var i=3; i<a.length; i = i + 2){
			p[a[i]] = a[i+1] ? a[i+1] : "";
		}
		for(i in data) p[i] = data[i];
		var s = "/" + c1 + "/" + c2;
		for(i in p) 
			if(i != resetField)
				s+= ("/" + i + "/" + p[i]);
		if(this.module) s = "/" + this.module + s;
		return s;
	},
	tab: function(id){
			$(".symbol_submenu_item").removeClass("item_select");
			$("#" + id).addClass("item_select");
			$(".tab_block").hide();
			$("#" + id + "_block").show();
			var tabname = $("#" + id).attr("tabname");
			Cookie.set("taburl", tabname, "/");
			
		var yr = new Date();
		var yr = yr.getFullYear();

		var day = ' - гороскоп на сегодня - KOLIZEO';
		var zavtra = ' - гороскоп на завтра - KOLIZEO';
		var mon = ' - гороскоп на сегодня, на завтра, на месяц - KOLIZEO';
		var yr = ' - гороскоп на '+ yr +' год - KOLIZEO';
		var lm = ' - любовный гороскоп на сегодня, на завтра, на месяц - KOLIZEO';
		var tm = ' - таро гороскоп на сегодня, на завтра, на месяц - KOLIZEO';
		var sim = ' - описание знака - KOLIZEO';
		
		var url = window.location.href;

		if(url.indexOf('#')>-1) url = url.split('#')[0];
		var tabs = {tab0:'day', tab1:'zavtra', tab2:'another', tab3:'year', tab4:'love', tab5:'taro', tab6:'symbol'};
		window.location = url + '#' + tabs[id];
		
		zod = document.title.indexOf('-');
		zod = document.title.substring(0, zod);
		var titles = {tab0:day, tab1:zavtra, tab2:mon, tab3:yr, tab4:lm, tab5:tm, tab6:sim};
		document.title = zod + titles[id];

	},
	
	showDiv: function(id){
		id = id || "operators_list";
		//$("#" + id).show();
			if ($("#"+ id).is(':hidden') )
				{
					$("#"+ id).show();
					} 
			else
				{
					$("#"+ id).hide();
					}
	},
	ar_flver:function(){
		var d, n = navigator, m, f = 'Shockwave Flash';
		if((m = n.mimeTypes) && (m = m["application/x-shockwave-flash"]) && m.enabledPlugin && (n = n.plugins) && n[f]) {d = n[f].description}
		else if (window.ActiveXObject) { try { d = (new ActiveXObject((f+'.'+f).replace(/ /g,''))).GetVariable('$version');} catch (e) {}} 
		return d ? d.replace(/\D+/,'').split(/\D+/) : [0,0];
	},
	
	changeAvatar: function(errors){
		if (errors==1){
			 error="<br><span style=\"color:red; text-align:center;\">максимальный допустимый размер 2Мб</span>";
			 } else {
			 	 error='<br><span style=\"text-align:center;\">максимальный допустимый размер 2Мб</span>';
			 }
		var url = window.location.pathname || '';
		oPopup.show({
			width: 270,
			action: "/profile/index/upload-avatar",
			html : "<input type='file' name='avatar' /><input type='hidden' name='url' value='"+url+"'/><br>"+error+"<br>",
			buttons: [{text:'Закачать фото', handler: function(){
				this.popup.submit();
				return false;
				
			}
			
			}],
			onClose: function(){
						if (errors==1){
				window.location.href="/profile/";
				}
						}
		});
	},
	deleteAvatar: function(){
		window.location = "/profile/index/delete-avatar";
	},
	log: function(sText){
		if($.browser.mozilla && typeof(console) != 'undefined'){
			console.log('Kolizeo: ' + sText);
		};
	},

	logon: function(consultant_id, is_error){
		Kolizeo.consultant_id = consultant_id;
		var error='';
		if (is_error==1){
			error='Неверная пара телефон/пароль';
		}
		if (is_error==2){
			error='Введите телефон/пароль';
		}
		
		var p = oPopup.show({
			z_index:10000,
			width:615,
			items: [{type:'phone', label:'Ваш полный номер телефона', name:'login'}, {type:'password', label:'Пароль', name:'password'}],
			html: '<span class="f12">Для создания чата с консультантом Вам необходимо авторизоваться или <a href="/registration/">зарегистрироваться</a>. Если Вы уже являетесь клиентом Колизео, введите Ваши данные:</span><img src="/images/pixel.gif" width="250" height="20"><div style="position: absolute; top: 100px; left: 410px; color: red;">'+error+'</div><div style="position:absolute;padding:50px 0 0 0px;"><a href="/forgot/">Забыли пароль?</a></div>',
			buttons:[{text:'Войти', width: 80, handler: function(){
				var t2 = this.popup;
				var hData = t2.getData();
				hData.login = hData.prefix_msisdn+hData.msisdn1;
				hData.remember = 1;
				if(hData.login!="" && hData.password !=""){
					$.post("/login", hData, function(data){
						if(data.success){
							//$('#form')[0].submit();
							t2.close();
							Kolizeo.user = true;
							KolizeoChat.create(Kolizeo.consultant_id);
						} else {
							oPopup.closeAll();
							Kolizeo.logon (consultant_id, 1);
							//oPopup.alert("Неверная пара телефон/пароль", {width:280, blockSite:true, z_index: 10005});
						}
					}, "json");
				} else{
				  oPopup.closeAll();
				  Kolizeo.logon (consultant_id, 2);
				  //oPopup.alert("Неверная пара телефон/пароль", {width:280, blockSite:true, z_index: 10005});
				  return false;
				}
			}}]
		});
		initControls(p.jContainer);
	},
	logon2: function(consultant_name, consultant_id, is_error){
		Kolizeo.consultant_id = consultant_id;
		var what=consultant_id;
		var error='';

		if (what){
				messege="заказа встречи с консультантом";
			}else{
				messege="данного действия";
		}

		if (is_error==1){
			error='Неверная пара телефон/пароль';
		}
		if (is_error==2){
			error='Введите телефон/пароль';
		}
		var p = oPopup.show({
			z_index:10000,
			width: 540,
			items: [{type:'phone', label:'Ваш полный номер телефона', name:'login'}, {type:'password', label:'Пароль', name:'password'}],
			html: '<span class="f12">Для '+messege+' Вам необходимо авторизоваться или <a href="/gethoroscope/index/name/'+consultant_name+'">зарегистрироваться</a>. Если Вы уже являетесь клиентом Колизео, введите Ваши данные:</span><img src="/images/pixel.gif" width="250" height="20"><br><div style="position:absolute;padding:33px 0 0 326px; color:red;">'+error+'</div><div style="position:absolute;padding:50px 0 0 0px;"><a href="/forgot/">Забыли пароль?</a></div>',
			buttons:[{text:'Продолжить', width: 120, handler: function(){
				var t2 = this.popup;
				var hData = t2.getData();
				hData.login = hData.prefix_msisdn+hData.msisdn1;
				hData.remember = 1;
				if(hData.login!="" && hData.password !=""){
					$.post("/login", hData, function(data){
						if(data.success){
							t2.close();
							Kolizeo.user = true;
							if (what) {
								Consultant.meet(consultant_id);
								}else{
								window.location = '/profile/form2/index/name/'+consultant_name;
							}
						} else {
							oPopup.closeAll();
							Kolizeo.logon1 (consultant_id, 1);
							//oPopup.alert("Неверная пара телефон/пароль", {width:280, blockSite:true, z_index: 10005});
						}
					}, "json");
				} else{
				  oPopup.closeAll();
				  //Kolizeo.logon1 (consultant_id, 2);
				  oPopup.alert("Неверная пара телефон/пароль<br /><br /><a href='/forgot/'>Забыли пароль?</a>", {width:280, blockSite:true, z_index: 10005});
				  return false;
				}
			}}]
		});
		initControls(p.jContainer);
	},
	forcedLogon: function(service, consultant_id, backurl, price, is_error){
	    //alert(service + ' consultant_id = '+ consultant_id + ' backurl = ' + backurl + ' ' + price);
		if(!backurl) backurl = window.location.href;
		Kolizeo.service = service;
		Kolizeo.controller_id = consultant_id;
		Kolizeo.consultant_id = consultant_id;/* хз */
		Cookie.set("backurl", backurl, "/");
		var what = "данного действия";
		var w = 540;
		var error='';
		if(service=="chat"){ what = "создания чата с консультантом"; w=615;}
		
		if (is_error==1){
			error='Неверная пара телефон/пароль';
		}
		if (is_error==2){
			error='Введите телефон/пароль';
		}
		var p = oPopup.show({
			z_index:10000,
			width: w,
			items: [{type:'phone', label:'Ваш полный номер телефона', name:'login'}, {type:'password', label:'Пароль', name:'password'}],
			html: '<span class="f12">Для ' + what + ' Вам необходимо авторизоваться или <a href="/registration/?service='+service+'& idcons='+consultant_id+'">зарегистрироваться</a>. Если Вы уже являетесь клиентом Колизео, введите Ваши данные:</span><img src="/images/pixel.gif" width="350" height="20"><div style="position: absolute; top: 100px; left: 410px; color: red; width: 110px">'+error+'</div><div style="position:absolute;padding:50px 0 0 0px;"><a href="/forgot/">Забыли пароль?</a></div>',
			
			buttons:[{text:'Войти', width: 80, handler: function(){
				var t2 = this.popup;
				var hData = t2.getData();
				hData.login = hData.prefix_msisdn+hData.msisdn1;
				hData.remember = 1;
				
				if(hData.login!="" && hData.password !=""){
					$.post("/login", hData, function(data){
						if(data.success){

							t2.close();
							Kolizeo.user = true;

							if(service=="set_comment_to_cons"){
											//Kolizeo.scrollTo('#comment_form'); не я комментировал
								$("#login_block").html('<div style="padding:15px 0px 0px 12px;"><div class="logout_form" style="margin-left:188px;margin-top:4px;"><a href="/logout/" style="margin-top:3px; margin-left:1px;"><img src="/images/blocks/logout.png" width="34px" height="33px"></a></div><div><table width="180"><tr><td style="height:28px"><br />Здравствуйте, '+ data.user_name +'!</td><td align="right"><nobr><a href="/profile/wallet/" style="font-weight:bold">Мой счет</a></nobr></td></tr></table><div style="padding-top:5px"><div><a href="/cabinet/">Личный кабинет</a></div><br><span>У вас на счету <a href="/profile/wallet/" class="user_balance" style="font-weight:bold">'+ data.balance +'</a></span></div></div></div>');
								
							}

							if(service=="chat"){
								KolizeoChat.create(Kolizeo.consultant_id);
							}
							if(service=="call" || service=="meet"){
								//alert('data.balance='+data.balance+' price='+price);
								if(data.balance>-1)
									if(price)
										if (data.balance < price){
								
						//	window.location = backurl;
						errormsg = '<div class="f12"><p>';
						if(service=='call') errormsg = errormsg +'Извините, сумма на Вашем счету недостаточна для заказа обратного звонка. Минимальная длительность звонка для выбранного консультанта 1 минута, тариф консультанта '+ price +'р., стоимость минимального заказа '+ price +'р. Пожалуйста, пополните счет.';
						if(service=='meet') errormsg = errormsg +'Извините, сумма на Вашем счету недостаточна для заказа личной встречи.<br>Стоимость минимального заказа '+price+'р. Пожалуйста, пополните счет.';
						errormsg = errormsg +'</p>';
						oPopup.alert_with_block(errormsg,{width:510, buttons: [{text:'Пополнить счет', handler: function(){
						Cookie.set("backurl", window.location.pathname, "/");
						window.location = '/profile/wallet/?from_consultant='+consultant_id;
						return false;
							}}]});

							}
							else
							{
							window.location = backurl;
							}
						
							}
						} else {
							oPopup.closeAll();
							Kolizeo.forcedLogon (service, consultant_id, backurl, price, 1);
							//oPopup.alert("Неверная пара телефон/пароль", {width:280, blockSite:true, z_index: 10005});
						}
					}, "json");
				} else{
				  oPopup.closeAll();
				  Kolizeo.forcedLogon (service, consultant_id, backurl, price, 2);
				  //oPopup.alert("Неверная пара телефон/пароль", {width:280, blockSite:true, z_index: 10005});
				  return false;
				}
			}}]
		});
		initControls(p.jContainer);
	},
	
	logon1: function(consultant_id, is_error){
		Kolizeo.consultant_id = consultant_id;
		var what=consultant_id;
		var error='';
		
		if (what){ 
				messege="заказа встречи с консультантом";
			}else{
				messege="данного действия";
		}
		
		if (is_error==1){
			error='Неверная пара телефон/пароль';
		}
		if (is_error==2){
			error='Введите телефон/пароль';
		}
		var p = oPopup.show({
			z_index:10000,
			width: 540,
			items: [{type:'phone', label:'Ваш полный номер телефона', name:'login'}, {type:'password', label:'Пароль', name:'password'}],
			html: '<span class="f12">Для '+messege+' Вам необходимо авторизоваться или <a href="/registration/">зарегистрироваться</a>. Если Вы уже являетесь клиентом Колизео, введите Ваши данные:</span><img src="/images/pixel.gif" width="250" height="20"><br><div style="position:absolute;padding:33px 0 0 326px; color:red;">'+error+'</div><div style="position:absolute;padding:50px 0 0 0px;"><a href="/forgot/">Забыли пароль?</a></div>',
			buttons:[{text:'Продолжить', width: 120, handler: function(){
				var t2 = this.popup;
				var hData = t2.getData();
				hData.login = hData.prefix_msisdn+hData.msisdn1;
				hData.remember = 1;
				if(hData.login!="" && hData.password !=""){
					$.post("/login", hData, function(data){
						if(data.success){
							t2.close();
							Kolizeo.user = true;
							if (what) {
								Consultant.meet(consultant_id);
								}else{
								window.location = '/profile/wallet/index/sum_select/'+$("#sum_select").val()+'/sum_input/'+$("#sum_input").val();
							}
						} else {
							oPopup.closeAll();
							Kolizeo.logon1 (consultant_id, 1);
							//oPopup.alert("Неверная пара телефон/пароль", {width:280, blockSite:true, z_index: 10005});
						}
					}, "json");
				} else{
				  oPopup.closeAll();
				  Kolizeo.logon1 (consultant_id, 2);
				  //oPopup.alert("Неверная пара телефон/пароль", {width:280, blockSite:true, z_index: 10005});
				  return false;
				}
			}}]
		});
		initControls(p.jContainer);
	},
	
	//склонение окончаний
	declension: function(num, expr) {
	    var result = expr['2'];
	    var count = num % 100;
	    if (!(count >= 5 && count <= 20)) {
	        count = count % 10;
	        if (count == 1) {
	            result = expr['0'];
	        } else if (count >= 2 && count <= 4) {
	            result = expr['1'];
	        }
	    }
	    return result;
	}
};


function qweeery(){
		alert(1);
}
function nextStep(oid){
	if(oid){
		window.location = '/consultant/call/id/'+oid;
	}else{
		var backurl = Cookie.get("backurl");
		if(backurl){
			Cookie.set("backurl", "", "/")
			window.location = backurl;
		}else{
			window.location = '/profile/wallet';
		}
	}
}

function ajaxGoroskopLoader(tab){
	function goroskopResponse(tab, data) {
		if(data.res){
			$('#ajax_box_' + tab).html(data.res);
		}else{
			$('#ajax_box_'+tab).html('Данных не найдено');
		}
	}

	var goroskopPath = '/goroskop/';
	var id = $('#ajax_box_' + tab).parents('.tab_block').find('.input_for_value').val();
	var sign = $('#ajax_box_' + tab).parents('.tab_block').attr('sign');
	var year = $('#ajax_box_' + tab).parents('.tab_block').attr('year');
	var url = window.location.href;
	if(url.indexOf('#')>-1) url = url.split('#')[0];

	$('#ajax_box_'+tab).html('<div style="height:120px" align="center"><img src="/images/ajax.gif"></div>');
	if (tab == 'another' || tab == 'love' || tab == 'taro') {
		var myear = parseInt(id/100); //id contains year+month value
		var mid = id - myear*100;
		$.post(goroskopPath+'ajax-month/', {month:mid, sign:sign, year:myear, tab:tab}, function(data){
			goroskopResponse(tab, data);
		}, "json");
		window.location = url + '#' + tab + '+' + id;
	} else if (tab == 'year') {
		$.post(goroskopPath+'ajax-year/', {year:id, sign:sign, tab:tab}, function(data){
			goroskopResponse(tab, data);
		},"json");
		window.location = url + '#' + tab + '+' + id;
	} else if (tab == 'day') {
		$.post(goroskopPath+'ajax-day/', {sign:sign}, function(data){
			goroskopResponse(tab, data);
		},"json");
	} else if (tab == 'zavtra') {
		$.post(goroskopPath+'ajax-zavtra/', {sign:sign}, function(data){
			goroskopResponse(tab, data);
		},"json");
	} else if (tab == 'symbol') {
		$.post(goroskopPath+'ajax-symbol/', {sign:sign}, function(data){
			goroskopResponse(tab, data);
		},"json");
	}
}

function anhor_reload_new(){
	var url = window.location.href;
	var tabs = {day:'tab0', zavtra:'tab1', another:'tab2', year:'tab3', love:'tab4', taro:'tab5', symbol:'tab6'};
	var months = {1:'Январь', 2:'Февраль', 3:'Март', 4:'Апрель', 5:'Май', 6:'Июнь', 7:'Июль', 8:'Август', 9:'Сентябрь', 10:'Октябрь', 11:'Ноябрь', 12:'Декабрь'};
	if (url.indexOf('#')>-1) {
		var anhor = url.split('#')[1];
		if (anhor.indexOf('+')>-1) {
			var anhors = anhor.split('+');
			Kolizeo.tab(tabs[anhors[0]]);
			if (anhors[0] == 'year') {
				var yearId = parseInt(anhors[1]);
				var year = yearId + 2009;
				$('#ajax_box_' + anhors[0]).parents('.tab_block').find('.input_for_value').val(yearId);
				$('#ajax_box_' + anhors[0]).parents('.tab_block').find('.input_for_text').val(year + ' год');
			} else {
				var id = anhors[1];
				var year = parseInt(id/100); //id contains year+month value
				var month = id - year*100;
				$('#ajax_box_' + anhors[0]).parents('.tab_block').find('.input_for_value').val(id);
				$('#ajax_box_' + anhors[0]).parents('.tab_block').find('.input_for_text').val(months[month]+' '+year+' г.');
			}
			ajaxGoroskopLoader(anhors[0]);
		} else {
			Kolizeo.tab(tabs[anhor]);
			ajaxGoroskopLoader(anhor);
		}
	}
}

// old horoscopes, need to be delete later
function ajaxYear(tab){
	var yid = $('#ajax_box_' + tab).parents('.tab_block').find('.input_for_value').val();
	var msign = $('#ajax_box_' + tab).parents('.tab_block').attr('sign');
	var myear = $('#ajax_box_' + tab).parents('.tab_block').attr('year');
	$('#ajax_box_'+tab).html('<div style="height:120px" align="center"><img src="/images/ajax.gif"></div>');

	$.post('/ajax-year/',{year:yid, sign:msign, tab:tab},function(data){
		if(data.res){
			$('#ajax_box_' + tab).html(data.res);
		}else{
			$('#ajax_box_'+tab).html('Данных за указанный промежуток времени не найдено');
		}
	},"json")

	var url = window.location.href;
	if(url.indexOf('#')>-1) url = url.split('#')[0];
	window.location = url + '#' + tab + '+' + yid;

	//window.location = window.location.href + '/mid/' + mid;
}

// old horoscopes, need to be delete later
function ajaxMonth(tab){
	var mid = $('#ajax_box_' + tab).parents('.tab_block').find('.input_for_value').val();
	var msign = $('#ajax_box_' + tab).parents('.tab_block').attr('sign');
	//var myear = $('#ajax_box_' + tab).parents('.tab_block').attr('year');
	var myear = parseInt(mid/100); //mid contains year+month value
	mid = mid - myear*100;
	$('#ajax_box_'+tab).html('<div style="height:120px" align="center"><img src="/images/ajax.gif"></div>');

	$.post('/ajax-month/',{month:mid, sign:msign, year:myear, tab:tab},function(data){
		if(data.res){
			$('#ajax_box_' + tab).html(data.res);
		}else{
			$('#ajax_box_'+tab).html('Данных за указанный промежуток времени не найдено');
		}
	},"json")

	var url = window.location.href;
	if(url.indexOf('#')>-1) url = url.split('#')[0];
	window.location = url + '#' + tab + '+' + mid;

	//window.location = window.location.href + '/mid/' + mid;
}

// old horoscopes, need to be delete later
function anhor_reload(){
	var url = window.location.href;
	var tabs = {day:'tab0', another:'tab1', year:'tab2', love:'tab3', taro:'tab4', symbol:'tab5'};
	var months = {3:'Март 2010 г.', 4:'Апрель 2010 г.', 5:'Май 2010 г.', 6:'Июнь 2010 г.', 7:'Июль 2010 г.', 8:'Август 2010 г.', 9:'Сентябрь 2010 г.', 10:'Октябрь 2010 г.', 11:'Ноябрь 2010 г.', 12:'Декабрь 2010 г.', 1:'Январь 2011 г.', 2:'Февраль 2011 г.'};
	if(url.indexOf('#')>-1){
		var anhor = url.split('#')[1];
		if(anhor.indexOf('+')>-1){
			var anhors = anhor.split('+');
			Kolizeo.tab(tabs[anhors[0]]);
			var year = (new Date()).getFullYear();
			$('#ajax_box_' + anhors[0]).parents('.tab_block').find('.input_for_value').val(year*100 + parseInt(anhors[1]));
			$('#ajax_box_' + anhors[0]).parents('.tab_block').find('.input_for_text').val(months[anhors[1]]);
			ajaxMonth(anhors[0]);
		}else{
			Kolizeo.tab(tabs[anhor]);
		}
	}
}

function anhor_reload_number(){
	var url = window.location.href;
	var months = {3:'Март 2010 г.', 4:'Апрель 2010 г.', 5:'Май 2010 г.', 6:'Июнь 2010 г.', 7:'Июль 2010 г.', 8:'Август 2010 г.', 9:'Сентябрь 2010 г.', 10:'Октябрь 2010 г.', 11:'Ноябрь 2010 г.', 12:'Декабрь 2010 г.', 1:'Январь 2011 г.', 2:'Февраль 2011 г.'};
	if(url.indexOf('#')>-1){
		url = url.split('#')[1];
		$('#numer_select').val(url);
		$('.input_for_text', '#container_for_numer_select').val(months[url]);
		ajaxNumer();
	}
}

function ajaxNumer(month, year){
	var month = $('#numer_select').val();
	var year = $('#ajax_numer').attr('year');
	$('#ajax_numer').html('<div style="height:120px" align="center"><img src="/images/ajax.gif"></div>');
	$.post('/ajax-numer/',{month:month, year:year},function(data){
		$('#ajax_numer').html(data);
		var url = window.location.href;
		if(url.indexOf('#')>-1) url = url.split('#')[0];
		window.location = url + '#' + month;
//		alert(data);
//		if(data.res){
//			$('#ajax_box_' + tab).html(data.res);
//		}
	})

}

function anhor_reload_number_new(){
	var months = {1:'Январь', 2:'Февраль', 3:'Март', 4:'Апрель', 5:'Май', 6:'Июнь', 7:'Июль', 8:'Август', 9:'Сентябрь', 10:'Октябрь', 11:'Ноябрь', 12:'Декабрь'};
	var url = window.location.href
	
	if(url.indexOf('#')>-1){
		var id = url.split('#')[1];
		var year = parseInt(id/100); //mid contains year+month value
		var month = id - year*100;
		
		$('#numer_select').val(id);
		$('.input_for_text', '#container_for_numer_select').val(months[month]+' '+year+' г.');

		ajaxGoroskopNumer();
	}
}

function ajaxGoroskopNumer(){
	var id = $('#numer_select').val();
	var year = parseInt(id/100); //mid contains year+month value
	var month = id - year*100;
	
	$('#ajax_numer').html('<div style="height:120px" align="center"><img src="/images/ajax.gif"></div>');
	$.post('/goroskop/ajax-numer/', {month:month, year:year}, function(data){
		$('#ajax_numer').html(data);
	});

	var url = window.location.href;
	if(url.indexOf('#')>-1) url = url.split('#')[0];
	window.location = url + '#' + id;
}


function paywithback(){
	Cookie.set("backurl", window.location.href);
	//Cookie.set("backurl", "/consultant/index/id/" + Consultant.id +"#chat", "/");
	window.location = '/profile/wallet/';
}

function initControls(where){
	$('.check_item, .check_item_s', where).unbind().click(function(){
		var j = $(this);
		var input = $("#" + j.attr("input"));
		if(j.hasClass('check_item_s')){
			j.addClass('check_item').removeClass('check_item_s');
			input.val(0);
		}else{
//			var c = 0;
//			if(j.hasClass('prior')){
//				$('.inpt_prior').each(function(){
//					if(this.value=="1") c = c+1;
//				});
//				if(c == 3) return false;
//			}
			j.addClass('check_item_s').removeClass('check_item');
			input.val(1);
		}
		var on_change = input.attr("on_change");
		if(on_change) eval(on_change);
	})
	$('.gcheck_item', where).click(function(){
		var j = $(this);
		if(j.hasClass('gcheck_item_s')){
			j.addClass('gcheck_item').removeClass('gcheck_item_s');
		}else{
			j.addClass('gcheck_item_s').removeClass('gcheck_item');
		}
		if(j.attr("on_change")) eval(j.attr("on_change")); 
	})
	$('.option_item, .option_item_s, .option_witem, .option_witem_s', where).click(function(){
		var j = $(this);
		var input = $("#" + j.attr("input"));
		var newValue = j.attr("val");
		input.val(newValue);
		j.parents('.option_block').find('.option_item_s').addClass('option_item').removeClass('option_item_s')
		j.parents('.option_block').find('.option_witem_s').addClass('option_witem').removeClass('option_witem_s')
		if(j.hasClass('option_item')){
			j.addClass('option_item_s').removeClass('option_item');
		}
		if(j.hasClass('option_witem')){
			j.addClass('option_witem_s').removeClass('option_witem');
		}
		var on_change = input.attr("on_change");
		if(on_change) eval(on_change);
	})
	select_move(where);
}

function setCookieCounter(){
	if($.browser.msie){
		var cie = document.getElementById("KolizeoCounter");
		if(cie){
			var cv = document.getElementById("KolizeoCounter").getValues();
			Cookie.set("counter_var", cv, "/")
			window.setTimeout("setCookieCounter();", 4000);
		}
	}else{
		var cff = document.getElementById("KolizeoCounterFF");
		if(cff){
			var cv = document.getElementById("KolizeoCounterFF").getValues();
			Cookie.set("counter_var", cv, "/")
			window.setTimeout("setCookieCounter();", 4000);
		}
	}
}

$(function(){
	window.setTimeout("setCookieCounter();", 4000);

//	$('#operators_info').click(function(){
//		if($(this).attr('state')=='0'){
//			$(this).html('Свернуть');
//			$(this).parents('#operator_list').find('#arrow_status').addClass('arr_up').removeClass('arr_down');
//			$(this).attr('state','1');
//			$('#operators_list').show();
//		}else{
//			$(this).html('Подробные тарифы');
//			$(this).parents('#operator_list').find('#arrow_status').addClass('arr_down').removeClass('arr_up');
//			$(this).attr('state','0');
//			$('#operators_list').hide();
//		}
//	});
	$('.zlog, #zpas', '.zlogin_textblock').keypress(function(event){
			if(event.keyCode == '13') Kolizeo.login();
		}
	)
	
// close select options //
	$('body').click(function(event){
		if(!($(event.target).hasClass('select_right')) && !($(event.target).hasClass('select_op')) && !($(event.target).hasClass('jScrollPaneDrag'))){
		if(!($(event.target).hasClass('jScrollArrowDown'))){ 
		if(!($(event.target).hasClass('jScrollArrowUp'))) {
		if(!($(event.target).hasClass('select_op_item'))){
		if(!($(event.target).hasClass('select_op_inner'))){
		if(!($(event.target).hasClass('jScrollPaneContainer'))){
		if(!($(event.target).hasClass('jScrollPaneDragTop'))){
		if(!($(event.target).hasClass('jScrollPaneDragBottom'))){
			//alert(event.target.className);
			$('.select_op').hide();
			$('#login_block #container_for_pref_msisdn .select_right').removeClass('dn');
			$('#login_block #container_for_pref_msisdn .select_left').removeClass('crn');
		}
		}
		}
		}
		}
		}
		}
		}
		
	})
// close select options //
	
	
	$('.menu_item').hover(function(){
		$('.menu_item').removeClass('menu_selected');
		$(this).addClass('menu_selected');
	},function(){
		$('.menu_item').removeClass('menu_selected');
	})
	$('.submenu_item').hover(function(){
		$('.submenu_item').removeClass('submenu_selected');
		$(this).addClass('submenu_selected');
	},function(){
		$('.submenu_item').removeClass('submenu_selected');
	})
	$('.scroll_item').hover(function(){
		$('.scroll_item').removeClass('item_selected');
		$(this).addClass('item_selected');
	},function(){
		$('.scroll_item').removeClass('item_selected');
	})
	$('.img_next').hover(function(){
		$('.img_next').removeClass('next_selected');
		$(this).addClass('next_selected');
	},function(){
		$('.img_next').removeClass('next_selected');
	})
	$('.img_prev').hover(function(){
		$('.img_prev').removeClass('prev_selected');
		$(this).addClass('prev_selected');
	},function(){
		$('.img_prev').removeClass('prev_selected');
	})
	$('.input input, .sinput input, .zlog, .zpas, #message_body').focus(function(){
		if($(this).attr('default')==$(this).val()){
			$(this).val('');
			$(this).removeClass('fsi');
		}
	})
	$('.input input, .sinput input, .zlog, .zpas, #message_body').blur(function(){
		if($(this).val()==''){$(this).val(
			$(this).attr('default'));
			$(this).addClass('fsi');
		}
	})
	$('.password_default').click(function(){
			var b = $(this).parents('.sinput').find('.password_default');
			b.html('');
			$(this).parents('.sinput').find('.second_default').focus()
	});
	$('.second_default').focus(function(){
			var b = $(this).parents('.sinput').find('.password_default');
			b.html('');
	});
	$('.second_default').blur(function(){
		if($(this).val()==''){
			var b = $(this).parents('.sinput').find('.password_default');
			b.html(b.attr('default'));
		}
	});
	
	$('.phone_default').click(function(){
			var b = $(this).find('.sphone_default');
			b.val('');
			$(this).find('.sphone_default').focus()
	});
	$('.sphone_default').focus(function(){
			var b = $(this).find('.sphone_default');
			b.val('');
	});
	$('.sphone_default').blur(function(){
		if($(this).val()==''){
			var b = $(this).find('.sphone_default');
			b.val(b.attr('default'));
		}
	});
	
	$('.rasp_day').hover(function(){
		$(this).addClass('rasp_day_hover');
	},function(){
		$(this).removeClass('rasp_day_hover');
	});

	initControls();
	Catalog.init();
	JMessages.init();
	
	FlashCookie.init();
	
	$('.select_op_item', '.compatibility_bg2, .com_blank_inner').click(function(data){
		var val = $(data.target).attr('val');
		var zodiac = ['','oven','telec','bliznetsi','rak','lev','deva','vesy','scorpion','strelets','kozerog','vodoley','riby'];
		var oElem = $(this).parents('.change_zodiac').find('.change_zodiac_img')[0];
		var iWidth = oElem.width;
		var iHeight = oElem.height;
		var small_zodiac='';
		if(iWidth == 43){
			small_zodiac='zodiac_43x46/';
		}
		do{
			oElem = oElem.parentNode;
		}while(oElem.tagName.toUpperCase() != 'DIV');
		oElem.innerHTML = '<img width="'+iWidth+'" height="'+iHeight+'" src="/images/zodiac/'+small_zodiac+val+'.png" class="change_zodiac_img">';
		var zid = $('#change_zodiac_1').val();
		var zwith = $('#change_zodiac_2').val();
		$('.compatibity_but').attr('href','/sovmestimost/id/' + zodiac[zid] + '/with/' + zodiac[zwith]); //old horoscope
		$('.compatibity_but_goroskop').attr('href','/goroskop/sovmestimost/id/' + zodiac[zid] + '/with/' + zodiac[zwith]); //new goroskop
	});
	
//		var div = document.getElementById("koliplaydiv");
//		if(div){
//			so = new SWFObject("/swf/KolizeoAudioPlayer.swf", "koliplay", "463", "20", "10");
//			so.addParam("quality", "high");
//			so.addParam("allowFullScreen", "true");
//			so.addParam("wmode", "transparent");
//			so.addParam("scale", "noscale");
//			so.addParam("allowScriptAccess", "always");
//			so.addParam("flashvars", "audioURL=/files/audio/2afina.mp3");
//			so.write("koliplaydiv");			
//		}

// если якорь аудио блок, то плеер плей
	var ankor = window.location.hash; 
		if(ankor=="#audio_block"){
			setTimeout(function(){
					x=getMovie("KolizeoAudioPlayer");
					x.playAudio();
			}, 1000);
		}
		
		if(ankor=="#video_block"){
			var flv_path = $('#flv').val();
			if (flv_path) {
			Battle.video(flv_path);
			}
		}

	
// параметр error используется при загрузке фоток
	var ankor = window.location.search; 
		if(ankor=="?error1"){
		ph_open_pop('upload','', '', 1);
		}
		if(ankor=="?error2"){
		ph_open_pop('upload','', '', 2);
		}
		if(ankor=="?error3"){
		Kolizeo.changeAvatar(1);
		}
})

function select_move(where){
//	alert('asd');
	$('.select_right', where).unbind().click(function(){
		var obj=$(this).parents('.select').find('.select_op');
		if(obj.css('display')=='none'){
			$('.select_op').hide();
			obj.show();
			if(obj.hasClass('lgnsel')){
				$('#login_block #container_for_pref_msisdn .select_right').addClass('dn');
				$('#login_block #container_for_pref_msisdn .select_left').addClass('crn');
			}
			if(!obj.hasClass('initok')){
				$('#paneScroll', obj).jScrollPane({arrowSize:9, showArrows:true});
				obj.addClass('initok');
			}
			//document.getElementById('ph_file').style.zIndex='1';
		}else{
			obj.hide();
			$('#login_block #container_for_pref_msisdn .select_right').removeClass('dn');
			$('#login_block #container_for_pref_msisdn .select_left').removeClass('crn');
		}
	});
	$('.select_op_item', where).unbind().click(function(){
		var input = $(this).parents('.select').find('.input_for_value');
		if($(this).attr("val")!=="-1")
		{
		var oldValue = input.val();
		var newValue = $(this).attr("val");
		input.val(newValue);
		input.attr('const', $(this).html());
		
		if(oldValue != newValue && input.attr("on_change")){
			eval(input.attr("on_change"));
		}
		
		$(this).parents('.select').find('.input_for_text').val($(this).html());
		$(this).parents('.select').find('.select_op').hide();
		$('#login_block #container_for_pref_msisdn .select_right').removeClass('dn');
		$('#login_block #container_for_pref_msisdn .select_left').removeClass('crn');
	  }
	  
	});
	$('.select_op_item', where).hover(function(){
		$(this).addClass('select_op_item_select');
	},function(){
		$(this).removeClass('select_op_item_select');
	});
}

function sopi_show(count){
//	$('.select_op_item', '.hidesel').css('display','block');

	$('#sel_with_hide div').each(function(elem){
			$(this).css('display','block');
			$(this).removeClass('hidesel');
	});
	var vall = $("#prefix_msisdn").attr('const');
	//alert(vall);
	    var scrollblock = 115;
			var height_count = (count * 20)+100;
		  var sel_height = height_count + 31;
		  var select_op = height_count + 4;
		//alert('asd');
		
			$("#container_for_prefix_msisdn div.sel_right_13").css('height', '235px');
		  $("#container_for_prefix_msisdn div.sel_left_13").css('height', '235px');
		  $("#container_for_prefix_msisdn div.select_op_inner_I0").css('height', '208px');
		  $("#container_for_prefix_msisdn div.select_op_inner_I1").css('height', '208px');
			$("#container_for_prefix_msisdn div.scroll-pane").css('height', '208px');
			$("#container_for_prefix_msisdn div.scroll-pane").attr('id', 'paneScroll');
		  $("#container_for_prefix_msisdn div.sel_right_13").removeClass('sel_right_isn_13');
		  $("#sel_with_hide").css('height', select_op+'px');
	    $("#sel_with_hide").css('width', scrollblock+'px');
	    $("#container_for_prefix_msisdn div.all_cntry").css('display', 'none');
	   // $("#sopi").html('');
//alert(vall);
setTimeout("$('#container_for_prefix_msisdn div.select_op').css('display','block'); $('#container_for_prefix_msisdn div.scroll-pane').jScrollPane({arrowSize:8, showArrows:true}); ",100);   
setTimeout("$('#prefix_msisdn').attr('const','"+vall+"');",500);
	
//	 if (a.length<7)
//	{
//		var scrollblock=198;
//		var height_count=a.length * 17;
//		var sel_height = height_count + 31;
//		var select_op = height_count + 4;
//		$("#meet_day_time div.sel_right").addClass('sel_right_isn');
//		$("#meet_day_time div.sel_right").css('height', sel_height+'px');
//		$("#meet_day_time div.sel_left").css('height', sel_height+'px');
//		$("#meet_day_time div.select_op_inner_I0").css('height', select_op+'px');
//		$("#meet_day_time div.select_op_inner_I1").css('height', select_op+'px');
//		$("#meet_day_time div.scroll-pane").css('height', select_op+'px');
//		$("#meet_day_time div.scroll-pane").attr('id', 'paneScroll2');
//		$("#container").css('height', select_op+'px');
//	}
	
}

function sopi_show2(count){
//	$('.select_op_item', '.hidesel').css('display','block');

	$('#sel_with_hide div').each(function(elem){
			$(this).css('display','block');
			$(this).removeClass('hidesel');
	});
	var vall = $("#pref_msisdn").attr('const');
	//alert(vall);
	    var scrollblock = 115;
			var height_count = (count * 20)+80;
		  var sel_height = height_count + 31;
		  var select_op = height_count + 4;
		//alert('asd');
		
			$("#container_for_pref_msisdn div.sel_right_13").css('height', '226px');
		  $("#container_for_pref_msisdn div.sel_left_13").css('height', '226px');
		  $("#container_for_pref_msisdn div.select_op_inner_I0").css('height', '208px');
		  $("#container_for_pref_msisdn div.select_op_inner_I1").css('height', '208px');
			$("#container_for_pref_msisdn div.scroll-pane").css('height', '208px');
			$("#container_for_pref_msisdn div.scroll-pane").attr('id', 'paneScroll');
		  $("#container_for_pref_msisdn div.sel_right_13").removeClass('sel_right_isn_13');
		  $("#sel_with_hide").css('height', select_op+'px');
	    $("#sel_with_hide").css('width', scrollblock+'px');
	    $("#container_for_pref_msisdn div.all_cntry").css('display', 'none');
	   // $("#sopi").html('');
//alert(vall);
setTimeout("$('#container_for_pref_msisdn div.select_op').css('display','block'); $('#container_for_pref_msisdn div.scroll-pane').jScrollPane({arrowSize:8, showArrows:true}); ",100);   
setTimeout("$('#pref_msisdn').attr('const','"+vall+"');",500);
	
//	 if (a.length<7)
//	{
//		var scrollblock=198;
//		var height_count=a.length * 17;
//		var sel_height = height_count + 31;
//		var select_op = height_count + 4;
//		$("#meet_day_time div.sel_right").addClass('sel_right_isn');
//		$("#meet_day_time div.sel_right").css('height', sel_height+'px');
//		$("#meet_day_time div.sel_left").css('height', sel_height+'px');
//		$("#meet_day_time div.select_op_inner_I0").css('height', select_op+'px');
//		$("#meet_day_time div.select_op_inner_I1").css('height', select_op+'px');
//		$("#meet_day_time div.scroll-pane").css('height', select_op+'px');
//		$("#meet_day_time div.scroll-pane").attr('id', 'paneScroll2');
//		$("#container").css('height', select_op+'px');
//	}
	
}


//function select_op_item(obj){
//		var input = $(obj).parents('.select').find('.input_for_value');
//		var oldValue = input.val();
//		var newValue = $(obj).attr("val");
//		input.val(newValue);
////		if(oldValue != newValue && input.attr("on_change")){
////			eval(input.attr("on_change"));
////		}
//		$(obj).parents('.select').find('.input_for_text').val($(obj).html());
////		$(this).parents('.select').find('.select_op').hide();
//}

function start(){
	var fb_h = new FadingBanner("entry_img_box", "horizontal", 465, 215, "#ffffff", 5000);
	$('.entry_img').each(function(i){
		img=$(this).attr('src');
		bannerLink=$(this).attr('link');
		fb_h.add(i, img, 465, 215, bannerLink);
	});
	fb_h.start();
}

function sortFields(obj){
	var select_type = $(obj).parents('.sort_bar').attr('field');
	$('.sort_bar').each(function(i){
		var caption = $(this).attr('caption');
		var sWidth = ['65', '70', '95', '80', '75'];
		var field = $(this).attr('field');
		var html = '<a href="#" onclick="sortFields(this);return(false)">' + caption + '</a>';
		var html_selected = '<div class="sort" style="width:' + sWidth[i] + 'px">'+
													'<div class="sort_center">'+
														'<a href="#" onclick="sortFieldOrder(this, \'desc\');return(false)">' + caption + '</a>'+
														'<img src="/images/arrdown.gif" width="7" height="4" style="margin:0 -5px 2px 5px;position:relative">'+
													'</div>'+
													'<div class="sort_left f0"><div class="sort_right f0">&nbsp;</div></div>'+
												'</div>';
		if(select_type == field){
			$(this).html(html_selected);
		}else{
			$(this).html(html);
		}
	});
	$('#table_buy').html('<div align="center" style="padding: 100px;"><img width="64" height="64" src="/images/ajax64.gif"></div>');
	Catalog.url = Kolizeo.url({field:select_type}, Catalog.url);
	$.post(Catalog.url,{},function(data){
		$('#table_buy').html(data);
		Catalog.init();
	})
}

function sortFieldOrder(obj, order){
	var caption = $(obj).parents('.sort_bar').attr('caption');
	var field = $(obj).parents('.sort_bar').attr('field');
	order = order=='asc' ? 'desc' : 'asc';
	var order_type = order=='asc' ? 'Ascending' : 'Descending';
	var orderImg = order=='asc' ? 'arrtop.gif' : 'arrdown.gif';
	var html = '<a href="#" onclick="sortFieldOrder(this, \'' + order + '\');return(false)">' + caption + '</a>'+
	'<img src="/images/'+ orderImg +'" width="7" height="4" style="margin:0 -5px 2px 5px;position:relative">';
	var b =$(obj).parents('.sort_center');
	b.html(html);
	$('#table_buy').html('<div align="center" style="padding: 100px;"><img width="64" height="64" src="/images/ajax64.gif"></div>');
	Catalog.url = Kolizeo.url({field:field, order:order_type}, Catalog.url);
	$.post(Catalog.url,{},function(data){
//	$.post(Kolizeo.url({field:field, order:order_type}),{},function(data){
		$('#table_buy').html(data);
		Catalog.init();
	})
}

function cancelBuying(id){
	$.post("/profile/buying/cancel", {id : id}, function(){
		Catalog.reload();
	});
}

function checkLength(obj){
	var txt = $(obj).val();
	var txtlength = txt.length;
	if(txtlength >= 450){
		$(obj).val(txt.substring(0,449));
		if(oPopup.busy()) return false;
		return oPopup.alert('Превышен лимит в 450 символов');
	};
}

function slide_scroll(){
	var slide = $('#slideshow0');
	$(slide).serialScroll({
		prev:'#move_block0 a.prev',
		next:'#move_block0 a.next',
		items:'td.slide0',
		duration:300,
		force:true,
		axis:'x',
		stop:true,
		lock:false,
		step:1,
		cycle:false,
		visible_image_count:3
	});

	var slide1 = $('#slideshow1');
	slide1.serialScroll({
		prev:'#move_block1 a.prev',
		next:'#move_block1 a.next',
		items:'td.slide1',
		duration:300,
		force:true,
		axis:'x',
		stop:true,
		lock:false,
		step:1,
		cycle:false,
		visible_image_count:3
	});

	var slide2 = $('#slideshow2');
	slide2.serialScroll({
		prev:'#move_block2 a.prev',
		next:'#move_block2 a.next',
		items:'td.slide2',
		duration:300,
		force:true,
		axis:'x',
		stop:true,
		lock:false,
		step:1,
		cycle:false,
		visible_image_count:3
	});
}

function slide_scroll2(){
	var slide = $('#slideshow_s');
	$(slide).serialScroll({
		prev:'#move_block_s div.cprev',
		next:'#move_block_s div.cnext',
		items:'td.slide_s',
		duration:300,
		force:true,
		axis:'x',
		stop:true,
		lock:false,
		step:1,
		cycle:false,
		visible_image_count:2
	});
}
function faq_answer(id){
	$('.popup_links').hide();
	if($('.answer','#question_'+id).css('display')=='none'){
		$('.answer','#question_'+id).show();
	}else{
		$('.answer','#question_'+id).hide();
	}
}

var is_click=0;

function prepayment_more(sHTML){
	is_click = 1;
	oPopup.show({
		width: 534,
		html: '<div class="diary_text">'+sHTML+'</div>',
		caption:'Как звонить дешевле?',
		buttons:[ {text:'Закрыть окно', width: 122} ],
		z_index: 10000,
		blockSite: true
	});
}

function meet_more(sCaption, sHTML){
	is_click = 1;
	oPopup.show({
		width: 534,
		html: '<div class="diary_text">'+sHTML+'</div>',
		caption: sCaption,
		buttons: [ {text:'Закрыть окно', width: 122} ],
		z_index: 10000,
		blockSite: true
	});
}

function chat_more(sCaption, sHTML){
	is_click = 1;
	oPopup.show({
		width: 534,
		html: '<div class="diary_text">'+sHTML+'</div>',
		caption: sCaption,
		buttons: [ {text:'Закрыть окно', width: 122} ],
		z_index: 10000,
		blockSite: true
	});
}

//function faq_answer_popup(id){
//	window.location = "/faq/popupfaq/id/"+id+"/#an"+id;
//}


 function show_description_stat_item(id){
		var t = this;
		t.popup = oPopup.show({width: 534, html: '<div style="text-align:center;padding:50px;height:300px"><img src="/images/ajax64.gif" /></div>'});
		$.post("/profile/stat/itemstat/id/" + id, {}, function(data){
			t.popup.jContainer.find("form").html(data);
		});
		return false;
	}

Consultant = {
	callDay: null,
	id: null,
	searchBySpec: function(){
		var specs = [];
		var domenname = $("#domenname").val();
		$("#search_by_spec_block input").each(function(){
			if(this.value=="1") specs.push(this.id.substr(15)); 
		});
		if(specs.length>0){
			var key = specs.join("-");
			window.location ="http://"+ domenname +"/consultants/index/specialization/"+ key +"/";
		} else {
			oPopup.alert("Отметьте галочкой интересующий вас пункт и нажмите кнопку Найти", {width:310, blockSite:true});
			//window.location = "/consultants/"; //"Отметьте галочкой интересующий вас пункт и нажмите кнопку "Найти"."
			}
		return false;
	},
	searchByTheme: function(){
		var specs = [];
		var domenname = $("#domenname").val();
		$("#search_by_theme_block input").each(function(){
			if(this.value=="1") specs.push(this.id.substr(16)); 
		});
		if(specs.length>0){
			var key = specs.join("-");
			window.location = "http://"+domenname+"/consultants/index/theme/" + key +"/";
		} else {
			oPopup.alert("Отметьте галочкой интересующий вас пункт и нажмите кнопку Найти", {width:310, blockSite:true});
			//window.location = "/consultants/";
		}
		return false;
	},
	searchByService: function(){
		var specs = [];
		var domenname = $("#domenname").val();
		$("#search_by_service_block input").each(function(){
			if(this.value=="1") specs.push(this.id.substr(18)); 
		});
		if(specs.length>0){
			var key = specs.join("-");
			window.location = "http://"+domenname+"/consultants/index/service/" + key +"/";
		} else {
			oPopup.alert("Отметьте галочкой интересующий вас пункт и нажмите кнопку Найти", {width:310, blockSite:true});
			//window.location = "/consultants/";
		}
		return false;
	},
	addToFavorites: function(id){
		return ("Не реализовано еще");
	},
	addComment: function(id){
		if(!Kolizeo.user){
			oPopup.alert("Добавление отзыва досупно только авторизванным пользователям");
			return false;
		}
		$("#comment_form").show();
		$('.com_right_button').hide();
	},


	dial: function(id, type, sip, price, e){
		if(is_click==0){
			if(type==1){
				if(!Kolizeo.user){
					if(type==1)
					{
						window.location = "/wallet/?from_consultant="+id;
					}
					else
						{
							Kolizeo.forcedLogon("call", id, "/consultant/call/id/" + id, price);
						}
					//Kolizeo.forcedLogon("call", id, "/consultant/call/id/" + id, price);
					
				}else{
					window.location = "/consultant/call/id/" + id;
				}
			} else {
				oPopup.show({ 
					caption: "Звонить прямо сейчас", 
					html: '<div class="f12"><p>Для того, чтобы позвонить выбранному консультанту, наберите с мобильного телефона номер <span class="purple f13"><b>07047</b></span>, следуя подсказкам голосового меню, наберите добавочный номер консультанта <span class="purple"><b>'+sip+'</b></span>.</p><p>Звонок будет тарифицироваться со счета вашего мобильного номера. Стоимость звонка в среднем <span class="purple f13"><b>70 рублей</b></span> (с НДС).</p></div><div id="operator_list"><img src="/images/pixel.gif" class="arr_down" id="arrow_status" width="5" height="5"> <a href="#" class="f12" id="operators_info" state="0" onclick="Kolizeo.showDiv();return false">Подробные тарифы</a></div><br><div id="operators_list" style="display:none"><div class="lstt f14" style="text-align:center">Тарифы сотовых операторов</div><div class="dots f0 mp10"></div><table width="100%" class="operator_table"><tr><th>Оператор</th><th width="140">Стоимость услуги, руб./мин, с НДС</th><th width="120">Длительность нетарифицируемого соединения, секунд</th></tr><tr><td class="first">Билайн</td><td>69,98</td><td>2</td></tr><tr><td class="first">МегаФон</td><td>70,80</td><td>5</td></tr><tr><td class="first">МТС</td><td>67,73</td><td>5</td></tr><tr><td class="first">U-tel</td><td>70,80</td><td>5</td></tr><tr><td class="first">Сибирьтелеком</td><td>70,80</td><td>6</td></tr><tr><td class="first">TELE2</td><td>70,80</td><td>4</td></tr><tr><td class="first">Скайлинк</td><td></td><td></td></tr><tr><td class="second">Московская Сотовая Связь</td><td>70,80</td><td>5</td></tr><tr><td class="second">Уралвестком</td><td>70,80</td><td>10</td></tr><tr><td class="first">Остальные операторы</td><td></td><td></td></tr><tr><td class="second">АКОС</td><td>71,46</td><td>10</td></tr><tr><td class="second">Енисейтелеком</td><td>70,80</td><td>5</td></tr><tr><td class="second">Астрахань GSM</td><td>70,80</td><td>3</td></tr><tr><td class="second">Нижегородский филиал ЗАО «НСС»</td><td>70,80</td><td>5</td></tr></table><br><span style="color:#808080;font-style:italic;font-size:12px">Уточняйте тарифы у вашего оператора связи.</span><br></div><br/>',
					buttons:[ {text:'Закрыть окно', width: 122} ], 
					z_index: 10000, 
					top: e.offsetTop,
					blockSite: true
				});
			}
		}else{
			is_click=0;
		}
		return false;
	},

        dial2: function(id, type, sip, ph, price, e){
		if(is_click==0){
			if(type==1){
				if(!Kolizeo.user){
					if(type==1)
					{
						window.location = "/wallet/";
					}
					else
						{
							Kolizeo.forcedLogon("call", id, "/consultant/call/id/" + id, price);
						}
					//Kolizeo.forcedLogon("call", id, "/consultant/call/id/" + id, price);

				}else{
					window.location = "/consultant/call/id/" + id;
				}
			} else {
				oPopup.show({
					caption: "Звонить прямо сейчас",
					html: '<div class="f12"><p>Для того, чтобы позвонить выбранному консультанту, наберите с мобильного телефона номер <span class="purple f13"><b>'+ph+'</b></span>, следуя подсказкам голосового меню, наберите добавочный номер консультанта <span class="purple"><b>'+sip+'</b></span>.</p><p>Звонок будет тарифицироваться со счета вашего мобильного номера. Стоимость звонка в среднем <span class="purple f13"><b>70 рублей</b></span> (с НДС).</p></div><div id="operator_list"><img src="/images/pixel.gif" class="arr_down" id="arrow_status" width="5" height="5"> <a href="#" class="f12" id="operators_info" state="0" onclick="Kolizeo.showDiv();return false">Подробные тарифы</a></div><br><div id="operators_list" style="display:none"><div class="lstt f14" style="text-align:center">Тарифы сотовых операторов</div><div class="dots f0 mp10"></div><table width="100%" class="operator_table"><tr><th>Оператор</th><th width="140">Стоимость услуги, руб./мин, с НДС</th><th width="120">Длительность нетарифицируемого соединения, секунд</th></tr><tr><td class="first">Билайн</td><td>69,98</td><td>2</td></tr><tr><td class="first">МегаФон</td><td>70,80</td><td>5</td></tr><tr><td class="first">МТС</td><td>67,73</td><td>5</td></tr><tr><td class="first">U-tel</td><td>70,80</td><td>5</td></tr><tr><td class="first">Сибирьтелеком</td><td>70,80</td><td>6</td></tr><tr><td class="first">TELE2</td><td>70,80</td><td>4</td></tr><tr><td class="first">Скайлинк</td><td></td><td></td></tr><tr><td class="second">Московская Сотовая Связь</td><td>70,80</td><td>5</td></tr><tr><td class="second">Уралвестком</td><td>70,80</td><td>10</td></tr><tr><td class="first">Остальные операторы</td><td></td><td></td></tr><tr><td class="second">АКОС</td><td>71,46</td><td>10</td></tr><tr><td class="second">Енисейтелеком</td><td>70,80</td><td>5</td></tr><tr><td class="second">Астрахань GSM</td><td>70,80</td><td>3</td></tr><tr><td class="second">Нижегородский филиал ЗАО «НСС»</td><td>70,80</td><td>5</td></tr></table><br><span style="color:#808080;font-style:italic;font-size:12px">Уточняйте тарифы у вашего оператора связи.</span><br></div><br/>',
					buttons:[ {text:'Закрыть окно', width: 122} ],
					z_index: 10000,
					top: e.offsetTop,
					blockSite: true
				});
			}
		}else{
			is_click=0;
		}
		return false;
	},
//	dial: function(id, type, sip){
//
//
//		if(type==1){
//			window.location = "/consultant/call/id/" + id;
//		} else {
//			oPopup.show({
//				caption: "Звонить прямо сейчас",
//				html: '<div class="f12"><p>Для того, чтобы позвонить выбранному консультанту, наберите с мобильного телефона номер <span class="purple f13"><b>07047</b></span>, следуя подсказкам голосового меню, наберите добавочный номер консультанта <span class="purple"><b>'+sip+'</b></span>.</p><p>Звонок будет тарифицироваться со счета вашего мобильного номера. Стоимость звонка в среднем <span class="purple f13"><b>70 рублей</b></span> (с НДС).</p></div><div id="operator_list"><img src="/images/pixel.gif" class="arr_down" id="arrow_status" width="5" height="5"> <a href="#" class="f12" id="operators_info" state="0" onclick="Kolizeo.showDiv();return false">Подробные тарифы</a></div><br><div id="operators_list" style="display:none"><div class="lstt f14" style="text-align:center">Тарифы сотовых операторов</div><div class="dots f0 mp10"></div><table width="100%" class="operator_table"><tr><th>Оператор</th><th width="140">Стоимость услуги, руб./мин, без НДС</th><th width="120">Длительность нетарифицируемого соединения, секунд</th></tr><tr><td class="first">Билайн</td><td>59,31</td><td>2</td></tr><tr><td class="first">МегаФон</td><td>60</td><td>5</td></tr><tr><td class="first">МТС</td><td>57,4</td><td>5</td></tr><tr><td class="first">U-tel</td><td>60</td><td>5</td></tr><tr><td class="first">Сибирьтелеком</td><td>60</td><td>6</td></tr><tr><td class="first">TELE2</td><td>60</td><td>4</td></tr><tr><td class="first">Скайлинк</td><td></td><td></td></tr><tr><td class="second">Московская Сотовая Связь</td><td>60</td><td>5</td></tr><tr><td class="second">Уралвестком</td><td>60</td><td>10</td></tr><tr><td class="first">Остальные операторы</td><td></td><td></td></tr><tr><td class="second">АКОС</td><td>60,56</td><td>10</td></tr><tr><td class="second">Енисейтелеком</td><td>60</td><td>5</td></tr><tr><td class="second">Астрахань GSM</td><td>60</td><td>3</td></tr><tr><td class="second">Нижегородский филиал ЗАО «НСС»</td><td>60</td><td>5</td></tr></table><br><span style="color:#808080;font-style:italic;font-size:12px">Уточняйте тарифы у вашего оператора связи.</span><br></div><br/>',
//				buttons:[ {text:'Закрыть окно', width: 122} ],
//				z_index: 10000,
//				blockSite: true
//			});
//		}
//		return false;
//	},
        consultantInfo: function(url, e){
            var posit=e.offsetTop;
            if(e.offsetTop>1520){posit=1520;}
                $.ajax({
                    type: "GET",
                    url: url,
                    data: '',
                    success: function(msg){
                        oPopup.show({
			caption: "",
			html: "<div style='width:471px; overflow:hidden;'>"+msg+"</div>",
			buttons:[ {text:'Закрыть окно', width: 122} ],
			z_index: 10000,
			top: posit,
			blockSite: true,
                        width: 540
                        });
                    }
                })

        },
        horoscope: function(e){
           var ofst = e.offsetTop+500;
                oPopup.show({
                caption: "Получить горосоп",
		html: "<center>"+$('#login-block').html()+"<br /><br /><br /><br /><br /></center>",
		buttons:[ {text:'Закрыть окно', width: 122} ],
		z_index: 10000,
		top: ofst,
		blockSite: true
                });

        },
	sms_chat: function(sms_ext, sms_number){
			if (!sms_number) sms_number = 5558;
		
			oPopup.show({
//				caption: "Отправьте консультанту SMS с вопросом",
//html: '<div class="f12"><p>Для того, чтобы отправить SMS-сообщение с Вашим вопросом, отправьте на короткий номер <span class="purple f13"><b>5558</b></span> текст <span class="purple f13"><b>'+sms_ext+'</b></span> Любой Ваш вопрос.<br /><br />Отправка сообщения будет тарифицироваться со счета вашего мобильного номера. Стоимость одного сообщения в среднем 59 рублей (с НДС)</p></div><br/> <div id="operator_list"><img src="/images/pixel.gif" class="arr_down" id="arrow_status" width="5" height="5"><a href="#" class="f12" id="operators_info" state="0" onclick="Kolizeo.showDiv();return false">Подробные тарифы</a></div><br><div id="operators_list" style="display:none"><div class="lstt f14" style="text-align:center">Тарифы сотовых операторов</div><div class="dots f0 mp10"></div><table width="100%" class="operator_table"><tr><th>Оператор</th><th width="140">Сервисный номер</th><th width="120">Стоимость исходящих SMS для абонента с учётом НДС</th></tr><tr><td class="first">Билайн</td><td>5558</td><td>60,00</td></tr><tr><td class="first">МегаФон</td><td>5558</td><td>59,00</td></tr><tr><td class="first">МТС</td><td>5558</td><td>60,00</td></tr><tr><td class="first">Остальные</td><td>5558</td><td>58,88</td></tr></table><br><span style="color:#808080;font-style:italic;font-size:12px">Уточняйте тарифы у вашего оператора связи.</span><br></div><br/>',
				caption: "КАК ОТПРАВИТЬ SMS КОНСУЛЬТАНТУ",
html: '<p style="font-size:14px"><span mce_style="color: #00cccc;" style="color: rgb(0, 204, 204);">Экспресс прогноз по SMS</span> – это услуга, которой можно воспользоваться в любой ситуации.</p><p><b>Для того, чтобы отправить смс консультанту:</b></p><p style="font-size:14px">1. Сформулируйте свою проблему, свой вопрос.<br>2. Отправьте SMS-сообщение на номер '+sms_number+' с текстом '+sms_ext+' день, месяц, год рождения, Ваше имя, Ваш вопрос.<br>Например: '+sms_ext+' Меня зовут Ольга. Родилась 25.12.1983. Когда я выйду замуж?<br>3. Получив Ваше SMS, специалист проведет анализ и даст Вам ответ в течение ближайших 30 минут. Ответы на сложные вопросы требуют затраты большего времени.</p>',
				buttons:[ {text:'Закрыть окно', width: 122} ],
				z_index: 10000,
				blockSite: true
			});
		
		return false;
	},
	course_cookie: function(id){
		// кука для редиректа на страницу консультанта после внесения денег на счет
		Cookie.set("back_to_course", id, "/"); 
	},
	
	meet1: function(id, params, price){
		//тупо. Но колизейщики попросили
		 params='meet=1';
		    params = id+"/?"+params;
		    type=1;
		    if(!Kolizeo.user){
						if(type==1)
						{
							//window.location = "/wallet/";
							//window.location = "/wallet?from_consultant=" + id + "&meet=1";
							window.location = "/consultant/index/id/" + id;
						}
						else
							{
								Kolizeo.forcedLogon("meet", id, "/consultant/meet/id/" + id, price);
							}
						//Kolizeo.forcedLogon("call", id, "/consultant/meet/id/" + id, price);
						
					}else{
						window.location = "/consultant/meet/id/" + id;
					}
		
	},


	meet: function(id, params, price){
		if(is_click == 0){
		//	params='meet=1';
		//	params = id+"/?"+params;
			type=1;
			if(!Kolizeo.user){
						if(type==1)
						{
							window.location = "/wallet/?from_consultant="+id+"&meet=1";
						}
						else
							{
								Kolizeo.forcedLogon("meet", id, "/consultant/meet/id/" + id, price);
							}
						//Kolizeo.forcedLogon("call", id, "/consultant/meet/id/" + id, price);

					}else{
						window.location = "/consultant/meet/id/" + id;
					}

		  /*
		if(!Kolizeo.user){
			Kolizeo.forcedLogon("meet", id, "/consultant/meet/id/" + params, price);
				} else{window.location = "/consultant/meet/id/" + params;}
		*/
		}else{
			is_click = 0;
		}
	},
	
	
//	meet: function(id, params){
//
//	    params='meet=1';
//	    if(params){
//		    window.location = "/consultant/meet/id/" + id + "/?"+params;
//	    	}else{
//			window.location = "/consultant/meet/id/" + id;
//			}
//	},
	chooseMeetMonth: function(consultantId, newMonth, direction){
		//alert(newMonth);
		$("#meet_day_info1").hide();
		$("#meet_day_info1_text").hide();
		var m=new Date();
		month = m.getUTCMonth()+1;
		var _m = $("#_m").val();
		var new_m = eval(_m)+eval(direction);
		f=0;
		if(_m==month && direction==-1){
			f=1;
		}
		var str = "";
		
		//$("#md").html(str);
		var enbl;
		var tmp1;
		var monthes;
		var day;
		var beg_monthtime= $("#beg_month").val();
		$.post("/consultant/month", {id:consultantId, newMonth:newMonth}, function(data){
				if(data.success){
					
					
					monthes = '<a href="#" onclick="Consultant.chooseMeetMonth('+consultantId+','+data.prev_month+',-1);return false;"><img src="/images/arrow_left.png"></a>&nbsp;&nbsp;'+
				  data.month_name+
					'&nbsp;&nbsp;<a href="#" onclick="Consultant.chooseMeetMonth('+consultantId+','+data.next_month+',1);return false;"><img src="/images/arrow_right.png"></a>';
					if((_m-1)==month && direction==-1){
						monthes = data.month_name+
						'&nbsp;&nbsp;<a href="#" onclick="Consultant.chooseMeetMonth('+consultantId+','+data.next_month+',1);return false;"><img src="/images/arrow_right.png"></a>';
					}
					$("#_m").val(new_m);
					Consultant.tt = data.tt;;
					if(Consultant.tt_h){
						Consultant.tt_h = data.tt_h;
					}
										
					for(var i=0; i<data.days.length; i +=1){
						enbl = "";
						tmp1 = "";
						day=data.days[i].day!=-1?data.days[i].day:"&nbsp;";
						if(!data.days[i].enabled)
							enbl = "disabled";
						else{
							tmp1 = 'onclick="Consultant.chooseMeetDay(this, \''+data.days[i].date+'\', \''+data.days[i].date_f+'\')"';
						}
						str=str+'<div class="day '+enbl+'" '+tmp1+'>'+day+'</div>';
					}
					$("#md").html(str);
					$("#monthes").html(monthes);
					


				} else {
					alert("Что-то случилось!");
				}
			}, "json");
	},

	chooseMeetDay: function(obj, dt, day_name){
		$("div.meet_calend div.day").removeClass("selected");
		$(obj).addClass("selected");
		$("#meet_day_info1").show();
		$("#meet_day_info1_text").show();
		//$("#meet_day_info").show();
		$("#meet_day_name").html(day_name);
		var periods = Consultant.tt[dt];
		var hours = Consultant.tt_h[dt];
		//alert(Consultant.tt[dt]);
		periods = periods.join("<br>");
		$("#meet_day_periods").html(periods);
		Consultant.meet_day = dt;
var errmsg = "";
		var a=Array();
		var k=0;
		var q,q1,q2;
		if(hours[0][0][0]==-1){
			errmsg = "&bull;&nbsp;Нет свободного времени для проведения встречи. Выберите другой день.<br>";
			$("#meet_warning_gl").css("display","block");
			
		}
		
		for(var i=0;i<hours.length;i++)
		{
			for(var j=0;j<hours[i].length;j++)
			{
				if(hours[i][j][0]>=0){
					a[k]=hours[i][j];
					k++;
				}
				/*else{
					alert(k);
					}*/
			}
		}
		//alert(a.length);

//$('#meet_day_time div.select_op').css('display','block');    
	 $("#meet_hours_text").attr('value','');
	 $("#meet_hours").attr('value','');
	 
	$("#container div").each(function (elem) {
       
       $(this).hide();
       $(this).attr('val',elem);
       $(this).html("");
       
      });
		//alert(a.length);
	
     if (a.length<7)
	{
		var scrollblock=198;
		var height_count=a.length * 17;
		var sel_height = height_count + 31;
		var select_op = height_count + 4;
		$("#meet_day_time div.sel_right").addClass('sel_right_isn');
		$("#meet_day_time div.sel_right").css('height', sel_height+'px');
		$("#meet_day_time div.sel_left").css('height', sel_height+'px');
		$("#meet_day_time div.select_op_inner_I0").css('height', select_op+'px');
		$("#meet_day_time div.select_op_inner_I1").css('height', select_op+'px');
		$("#meet_day_time div.scroll-pane").css('height', select_op+'px');
		$("#meet_day_time div.scroll-pane").attr('id', 'paneScroll2');
		$("#container").css('height', select_op+'px');
	}
	else
		{
			var scrollblock = 180;
			var height_count=a.length * 17;
		  var sel_height = height_count + 31;
		  var select_op = height_count + 4;
		
			$("#meet_day_time div.sel_right").css('height', '150px');
		  $("#meet_day_time div.sel_left").css('height', '150px');
		  $("#meet_day_time div.select_op_inner_I0").css('height', '123px');
		  $("#meet_day_time div.select_op_inner_I1").css('height', select_op+'px');
			$("#meet_day_time div.scroll-pane").css('height', '123px');
			$("#meet_day_time div.scroll-pane").attr('id', 'paneScroll');
		  $("#meet_day_time div.sel_right").removeClass('sel_right_isn');
		  $("#container").css('height', select_op+'px');
				
	  }
	  
	  $("#container").css('width', scrollblock+'px');
	  
		
		$("#container div").each(function (elem) {
       if(elem == k){
         return false;}
       $(this).show();
       $(this).attr('val',(a[elem][0]>9?a[elem][0]:"0"+a[elem][0])+":"+(a[elem][1]>9?a[elem][1]:"0"+a[elem][1])+":00");
       
       
       
       q=(a[elem][0]*60+a[elem][1])+90;
       q1=parseInt(q/60);
       q2=q-q1*60;
       //
       
       
       $(this).html((a[elem][0]>9?a[elem][0]:"0"+a[elem][0])+":"+(a[elem][1]>9?a[elem][1]:"0"+a[elem][1])+" - "+(q1>9?q1:"0"+q1)+":"+(q2>9?q2:"0"+q2));
       
      });
//alert('asd');      
$('#meet_day_time div.select_op').css('display','block');    
$('#paneScroll').jScrollPane({arrowSize:8, showArrows:true});
			//alert(k);
		
		if(errmsg != ''){
			$("#meet_warning_gl .war_cc").html(errmsg);
			Kolizeo.scrollTo('#meet_warning_gl');
			return false;
		}
		
		
		
	},
	changeMeetPeriod: function(){
		var mp = $("#meet_period").val();
		var price = Math.round(mp / 60 * Consultant.meet_price);
		$("#meet_price").html(price);
		if(price > Kolizeo.user.balance){
			$("#meet_warning").show();
			var period_info = $("#meet_period").val();
			var periods = {60:"1 час",75:"1 час 15 минут", 90:"1 час 30 минут",105:"1 час 45 минут",120:"2 часа",135:"2 часа 15 минут",150:"2 часа 30 минут",165:"2 часа 45 минут",180:"3 часа"};
			$("#meet_warning_period").html(periods[period_info]);
		} else {
			$("#meet_warning").hide();
		}
	},
	
	gotoReviews: function(){
		Kolizeo.scrollTo("#reviews_block");
	},
	gotoTimetable: function(){
		Kolizeo.scrollTo("#timetable_block");
	},
	gotoAudio: function(){
		Kolizeo.scrollTo("#audio_block");
	},

	changeStatus: function(){
		var status = $("#consultant_status").val();
		if(status==2){
			oPopup.show({
				width:480,
				html:"<p style='font-size:14px;'>Статус 'Занят' не может быть выставлен вручную.</p>",
				buttons: [{text:'Закрыть окно', handler: function(){
						this.popup.close();
						return false;
					}}],
				onClose: function(){
						Kolizeo.reload();
						}
					});
		}else{
		$("#status_save_image").show();
		$.post("/profile/index/change-status", {status: status} , function(data){
			$("#status_save_image").hide();
		});
		}
		
	},
	changeStatusBackToBusy: function(){
//	    var status = $("#consultant_status").val();
//	    if(status==-1){
//		this.changeStatus();
//	    }else{
	oPopup.show({
		width:480,
		html:"<p style='font-size:14px;'>Статус 'Занят' не может быть изменён вручную.</p>",
		buttons: [{text:'Закрыть окно', handler: function(){
				this.popup.close();
				return false;
			}}],
		onClose: function(){
				Kolizeo.reload();
				}
			});
//	    }
	},
	selectDay: function(obj, date){
		$(".rasp_day").removeClass("rasp_day_selected");
		$(obj).addClass("rasp_day_selected");
		this.callDay = date;
	},
	orderCall: function(id){
		this.id = id;
		var phone = $("#use_number").val();
		if(!this.callDay){
			oPopup.alert("Выберите день звонка");
			return false;
		}
		var hour = $("#time_hour").val();
		var minute = $("#time_minute").val();
		if(hour!="" && !isNaN(hour) && hour>=0 && hour<=24){
			if(minute=="" || isNaN(minute) || !(minute >=0 && minute<=60)) minute = "00";
			var time = (hour.length > 1 ? hour : "0" + hour) + ":" + (minute.length > 1 ? minute : "0" + minute) + ":00" 
		} else {
			oPopup.alert("Укажите корректное время звонка");
			return false;
		}
		$("#reg_ajax").show();$("#reg_btn").hide();
		$.post("/consultant/ajax-callback", {consultant_id : this.id, phone: phone, date: this.callDay + " " + time}, function(data){
			$("#reg_btn").show();$("#reg_ajax").hide();
			if(data.success){
				oPopup.alert(data.message);
			} else {
				oPopup.alert(data.error);
			}
		}, "json");


		return false;
	},
	orderMeet: function(id){
		this.id = id;
		var meet_subject = $("#meet_subject").val();
		//var meet_period = $("#meet_period").val();
		var meet_period = 60;
		var meet_comment = $("#meet_comment").val();
		var phone = $("#use_number").val();
		var errmsg = "";
		var hour = $("#time_hour").val();
		var minute = $("#time_minute").val();
		var meet_time = $("#meet_hours").val();
		var qq = $("#qq").val();


		
		if(!this.meet_day){
			errmsg = errmsg + "&bull;&nbsp;Выберите день встречи<br>";
			$("#meet_warning_gl").css("display","block");
			
		}

		if(!meet_subject){
			errmsg = errmsg + "&bull;&nbsp;Укажите тему встречи<br>";
			$("#meet_warning_gl").css("display","block");
			
		}
		/*if(hour!="" && !isNaN(hour) && hour>0 && hour<=22){
			if(minute=="" || isNaN(minute) || !(minute >=0 && minute<=59))
				{
					errmsg = errmsg + "&bull;&nbsp;Укажите корректное время встречи<br>";
					$("#meet_warning_gl").css("display","block");
			
				}
			
			var time = (hour.length > 1 ? hour : "0" + hour) + ":" + (minute.length > 1 ? minute : "0" + minute) + ":00" 
			var time_end = (hour.length > 1 ? (parseInt(hour)+parseInt(2)): "2") + ":" + (minute.length > 1 ? minute : "0" + minute) + ":00" 
		} else {
			$("#container_for_time_hour").addClass("warning");
			$("#time_minute, #time_hour").css("background-color","transparent");
			$("#container_for_time_minute").addClass("warning");
			errmsg = errmsg + "&bull;&nbsp;Укажите корректное время встречи";
			$("#meet_warning_gl").css("display","block");
			
			
		}
    */

		if(meet_time==""){
			errmsg = errmsg + "&bull;&nbsp;Выберите время встречи<br>";
			$("#meet_warning_gl").css("display","block");
		}

		if(qq==0){
			errmsg = errmsg + "&bull;&nbsp;Ознакомьтесь с информацией о проведении личных встреч<br>";
			$("#meet_warning_gl").css("display","block");
		}

		if(errmsg != ''){
			$("#meet_warning_gl .war_cc").html(errmsg);
			Kolizeo.scrollTo('#meet_warning_gl');
			return false;
		}
		$("#reg_ajax").show();$("#reg_submit").hide();
		// Добавляем к параметру phone строчный символ a, так как получаем 404 ошибку при заказе личной встрчи
		$.post("/consultant/order-meet/", {consultant_id : this.id,meet_time: meet_time, phone: phone, date: this.meet_day + " " + meet_time,datetime_end: this.meet_day + " " + meet_time, meet_subject: meet_subject, meet_period: meet_period, meet_comment: meet_comment, d_h: hour, d_m: minute, only_date: this.meet_day}, function(data){
			if(data.success){
				if(data.cid != 24)
				window.location = "/profile/orders/index/id/" + data.insertid + "/result/ok";
				
			} else {
				
				oPopup.alert(data.error);
				$("#reg_submit").show();$("#reg_ajax").hide();
			}
		}, "json");
		return false;
	},
	showMap: function(x, y, caption, desc){
		oPopup.alert('<div id="YMapsID" style="width:600px;height:400px"></div>', {width: 667});
		var map = new YMaps.Map(document.getElementById("YMapsID")); 
		map.setCenter(new YMaps.GeoPoint(x, y), 16); 
		var placemark = new YMaps.Placemark(new YMaps.GeoPoint(x, y));
    placemark.name = caption;
   	placemark.description = desc;
    map.addOverlay(placemark);
    placemark.openBalloon();
    
    map.addControl(new YMaps.TypeControl());
    map.addControl(new YMaps.ToolBar());
    map.addControl(new YMaps.Zoom());
    map.addControl(new YMaps.MiniMap());
    map.addControl(new YMaps.ScaleLine());
    map.addControl(new YMaps.SearchControl());
    
	},
	showMapList: function(x, y, caption, desc){
		var map = new YMaps.Map(document.getElementById("YMapsID")); 
		map.setCenter(new YMaps.GeoPoint(x, y), 16); 
		var placemark = new YMaps.Placemark(new YMaps.GeoPoint(x, y));
    placemark.name = caption;
   	placemark.description = desc;
    map.addOverlay(placemark);
    placemark.openBalloon();

    map.addControl(new YMaps.TypeControl());
    map.addControl(new YMaps.ToolBar());
    map.addControl(new YMaps.Zoom());
    map.addControl(new YMaps.MiniMap());
    map.addControl(new YMaps.ScaleLine());
    map.addControl(new YMaps.SearchControl());

	},
	showCallback: function(){
		$("#callback_form").show();
	},
	
	chat: function(id, cons_id){
		if(is_click == 0){
			type=1;
			if(!Kolizeo.user){
					if(type==1)
					{
						window.location = "/wallet/?from_consultant="+id+"&chat=1";
					}
					else
						{
							Kolizeo.forcedLogon("chat", id, window.location.href + "#chat");
						}
					
				}else{
					KolizeoChat.create(cons_id);
				}		
		
		
			/*
			if(Kolizeo.user){
				KolizeoChat.create(cons_id);
			} else {
				Kolizeo.forcedLogon("chat", id, window.location.href + "#chat");
			}
			*/
		}else{
			is_click = 0;
		}
	}
	
	
	
}

Catalog = {
	jCont: null,
	cache: {},
	url: null,
	order: "rating",
	dir: false,
	init: function(where){
		if(!this.jCont) this.jCont = $(".ajax-catalog");
		$(".ajaxed", where).click(function(){
			var j = $(this);
			Catalog.jCont = j.parents(".ajax-catalog");
			var url = j.attr("href");
			if(Catalog.jCont.size() < 1) window.location = url;
			url = url.replace("/index/index/", "/index/ajax-handler/");
			url = url.replace("/client/", "/ajax-handler/");
			if(url==j.attr("href") && url.indexOf('ajax-handler')==-1){
				url = url.replace("index", "ajax-handler");
			}
			Catalog.load(url);
			return false;
		});
	},
	hide: function(){
		var x = Math.round(this.jCont.width()/2)-32;
		var y = Math.round(this.jCont.height()/2)-32;
		this.jCont.css("height", this.jCont.height());
		var j = $('<img src="/images/ajax.gif" />').css("margin-left", x).css("margin-top", y);
		this.jCont.html(j);
	},
	load: function(url, force){
		this.url = url;
		//if(!this.cache[wUrl]) this.cache[wUrl] = this.jCont.html();
		Catalog.hide();
		//if(this.cache[url]){
		//	Catalog.show(this.cache[url]);
		//} else {
			$.post(url, {}, function(data){
				Catalog.cache[url] = data;
				Catalog.show(data);
			});
		//}
	},
	reload: function(){
		if(!this.url) this.url = Kolizeo.url({});
		this.load(this.url);
	},
	show: function(html){
		this.jCont.html(html);
		this.jCont.css("height", "auto");
		this.init(this.jCont);
	},
	changePerPage: function(){
		var itemsPerPage = $("#itemsPerPage").val();
		var url = Kolizeo.url({perpage: itemsPerPage}, this.url);
		this.load(url);
	},
	changeOnline: function(){
		var online = $("#catalog_online").hasClass("gcheck_item_s") ? 1 : 0;
		var url = Kolizeo.url({online: online}, this.url);
		this.load(url);
	},
	changeFilter: function(field, input_id){
		var value = $("#" + input_id).val();
		hData = {};
		hData[field] = value;
		var url = Kolizeo.url(hData, this.url);
			this.load(url);
			//alert(url);
	},
	sort: function(obj, onlyrating){
		var t = this;
		var jp = $(obj).parents(".sort_bar");
		var order = jp.attr("field");
		if(order == t.order) t.dir = !t.dir; else t.dir = false;
		t.order = order;
		$(".sort_bar").each(function(){
			var j = $(this);
			var field = j.attr("field");
			var caption = j.attr("caption");
			if(field == order){
				var html = '<div class="sort"><div class="sort_center"><a href="#" onclick="return Catalog.sort(this, '+onlyrating+')">' + caption + '</a><img height="4" width="7" style="margin: 0pt -5px 2px 5px; position: relative;" src="/images/' + (t.dir ? 'arrdown':'arrtop') + '.gif"></div><div class="sort_left f0"><div class="sort_right f0">&nbsp;</div></div></div>';
			} else {
				if(onlyrating == true){onr = false}else{onr = true};
				var html = '<a href="#" onclick="return Catalog.sort(this, '+onr+')"  style="padding-left:10px">'+caption+'</a>';
			}
			j.html(html);
		});

		var url = Kolizeo.url({order: order, onlyrating: onlyrating, dir: t.dir ? "asc" : "desc"}, this.url);
		this.load(url);
		return false;
	},

	sort_comments: function(obj, onlyrating){
		var t = this;
		var jp = $(obj).parents(".sort_bar");
		var order = jp.attr("field");
		var cname = $('#const_list').attr('const');
		
		if(order == t.order) t.dir = !t.dir; else t.dir = false;
		t.order = order;
		$(".sort_bar").each(function(){
			var j = $(this);
			var field = j.attr("field");
			var caption = j.attr("caption");
			if(field == order){
				var html = '<div class="sort"><div class="sort_center"><a href="#" onclick="return Catalog.sort_comments(this, '+onlyrating+')">' + caption + '</a><img height="4" width="7" style="margin: 0pt -5px 2px 5px; position: relative;" src="/images/' + (t.dir ? 'arrdown':'arrtop') + '.gif"></div><div class="sort_left f0"><div class="sort_right f0">&nbsp;</div></div></div>';
			} else {
				if(onlyrating == true){onr = false}else{onr = true};
				var html = '<a href="#" onclick="return Catalog.sort_comments(this, '+onr+')"  style="padding-left:10px">'+caption+'</a>';
			}
			j.html(html);
		});

//		var url = Kolizeo.url({order: order, onlyrating: onlyrating, dir: t.dir ? "asc" : "desc"}, this.url);
		dir = t.dir ? "asc" : "desc";
		url = "/consultants/ajax-handler-comments/order/" + dir+ "/cname/"+cname;
		this.load(url);
		return false;
	},

	setPeriod: function(sFrom, sTo){
		var url = Kolizeo.url({period_from: sFrom, period_to: sTo}, this.url);
		this.load(url);
	},

        setPeriod_in_stat: function(sFrom, sTo){
            //var url = Kolizeo.url({period_from: sFrom, period_to: sTo}, this.url);
		url = "/profile/stat/ajax-handler/period_from/" + sFrom + "/period_to/" + sTo;
                this.load(url);
	}
}


JMessages = {
	jCont: null,
	cache: {},
	url: null,
	order: "msg_date",
	dir: false,
	init: function(where){

		if(!this.jCont) this.jCont = $(".ajax-message");
		$(".ajaxed", where).click(function(){
			var j = $(this);
			JMessages.jCont = j.parents(".ajax-message");
			if(!JMessages.jCont) return true;
			var url = j.attr("href");
			url = url.replace("index", "ajax-handler");
			JMessages.load(url);
			return false;
		});
		},
	hide: function(){
		var x = Math.round(this.jCont.width()/2)-32;
		var y = Math.round(this.jCont.height()/2)-32;
		this.jCont.css("height", this.jCont.height());
		var j = $('<img src="/images/ajax.gif" />').css("margin-left", x).css("margin-top", y);
		this.jCont.html(j);
	},
	load: function(url, force){
		this.url = url;
		//if(!this.cache[wUrl]) this.cache[wUrl] = this.jCont.html();
		JMessages.hide();
		//if(this.cache[url]){
		//	Catalog.show(this.cache[url]);
		//} else {
			$.post(url, {}, function(data){
				JMessages.cache[url] = data;
				JMessages.show(data);
			});
		//}
	},
	reload: function(){
		if(!this.url) this.url = Kolizeo.url({});
		this.load(this.url);
	},
	show: function(html){
		this.jCont.html(html);
		this.jCont.css("height", "auto");
		this.init(this.jCont);
	},
	changePerPage: function(){
		var itemsPerPage = $("#itemsPerPage").val();
		var url = Kolizeo.url({perpage: itemsPerPage}, this.url);
		this.load(url);
	},
	changeOnline: function(){
		var online = $("#messages_online").hasClass("gcheck_item_s") ? 1 : 0;
		var url = Kolizeo.url({online: online}, this.url);
		this.load(url);
	},
	changeFilter: function(field, input_id){
		var value = $("#" + input_id).val();
		hData = {};
		hData[field] = value;
		var url = Kolizeo.url(hData, this.url);
		this.load(url);
	},
	sort: function(obj){
		var t = this;
		var jp = $(obj).parents(".sort_bar");
		var order = jp.attr("field");
		if(order == t.order) t.dir = !t.dir; else t.dir = false;
		t.order = order;
		$(".sort_bar").each(function(){
			var j = $(this);
			var field = j.attr("field");
			var caption = j.attr("caption");
			if(field == order){
				var html = '<div class="sort"><div class="sort_center"><a href="#" onclick="return JMessages.sort(this)">' + caption + '</a><img height="4" width="7" style="margin: 0pt -5px 2px 5px; position: relative;" src="/images/' + (t.dir ? 'arrdown':'arrtop') + '.gif"></div><div class="sort_left f0"><div class="sort_right f0">&nbsp;</div></div></div>';
			} else {
				var html = '<a href="#" onclick="return JMessages.sort(this)"  style="padding-left:10px">'+caption+'</a>';
			}
			j.html(html);
		});
		var url = Kolizeo.url({order: order, dir: t.dir ? "asc" : "desc"}, this.url);
		this.load(url);
		return false;
	},
	setPeriod: function(sFrom, sTo){
		var url = Kolizeo.url({period_from: sFrom, period_to: sTo}, this.url);
		this.load(url);
	}
}



Comment = {
	button:null,
	oflag:0,
	add: function(button, otype, oid){
	var comment_text="";    
	    if(!Kolizeo.user){
	    comment_text = $('#comment_text').val();
	    Cookie.set("set_comment", oid, '/');
	    Cookie.set("set_comment_text", comment_text, '/');
	    Kolizeo.forcedLogon('set_comment_to_cons', 1, window.location.href + '#comment_set');
		    }
		    else{
	    Cookie.set("set_comment_text", '', '/');
		if(otype=='chat'){
			otype = 'consultant';
			Comment.oflag = 1;
		};
		this.button = button;
		var text = $("#comment_text").val();
		var tt=text.replace(/\s*/g,'');
		var order_id = Kolizeo.page_order ? Kolizeo.page_order : 0;
		if((text && text != "" && tt.length > 0) || Comment.oflag){
			$(button).css("opacity", 0.4);
			$.post("/comment/add", {text: text, otype: otype, oid: oid, rate: Rating.value, order_id: order_id}, function(data){
//				if(data != "[error]") Kolizeo.reload();
					oPopup.show({
						width:480,
						html:"<p style='font-size:14px;'>Спасибо за Ваше мнение, оно важно для нас! Мы рассмотрим Ваш отзыв, и он вскоре будет опубликован, если его формулировка не нарушает условий пользования сайтом Kolizeo.ru. Благодарим, что Вы воспользовались сервисами Колизео!</p>",
						buttons: [{text:'Закрыть окно', handler: function(){
								this.popup.close();
								return false;
							}}],
						onClose: function(){
							$(Comment.button).css("opacity", 1);
							$("#comment_text").val("");
							if(Comment.oflag){
								//var pt = $('#chat_id').attr('chat_id');
								//window.location = pt;
								$('#comment_form').hide();
							}
						}
					});
			});
		}
		    }
	},
	orderadd: function(button, oid){
		this.button = button;
		var text = $("#comment_text").val();
		var tt=text.replace(/\s*/g,'');
		var order_id = oid ? oid : 0;
		if(text && text != "" && tt.length > 0){
			$(button).css("opacity", 0.4);
			$.post("/comment/orderadd", {text: text, order_id: order_id}, function(data){
				oPopup.show({
					width:480,
					html:"<p style='font-size:14px;'>Комментарий добавлен.</p>",
					buttons: [{text:'Закрыть окно', handler: function(){
							this.popup.close();
							return false;
						}}],
					onClose: function(){
						$(Comment.button).css("opacity", 1);
						$("#xt").val("");
						window.location = '/cabinet/orders/';
					}
				});
			});
		}
	}
}
function nextJump(obj, limit){
	var j = $(obj);
	var s = j.val();
	if(s.length>=limit){
		j.parents('.table_items').find('.w7').each(function(){
			this.focus();
		});
	}
}

function changestatus(gender){
	if(gender=='1'){
		if($('#family_status','#container_for_family_status').val()=='2'){
			$('.input_for_text','#container_for_family_status').val('Женат')
		}
		$('.select_op_item','#container_for_family_status').eq(1).html('Женат')
                
                if($('#family_status','#container_for_family_status').val()=='3'){
			$('.input_for_text','#container_for_family_status').val('Холост')
		}
		$('.select_op_item','#container_for_family_status').eq(2).html('Холост')
                
                if($('#family_status','#container_for_family_status').val()=='4'){
			$('.input_for_text','#container_for_family_status').val('Разведен')
		}
		$('.select_op_item','#container_for_family_status').eq(3).html('Разведен')

                if($('#family_status','#container_for_family_status').val()=='5'){
			$('.input_for_text','#container_for_family_status').val('Вдовец')
		}
		$('.select_op_item','#container_for_family_status').eq(4).html('Вдовец')

	}else{
		 if($('#family_status','#container_for_family_status').val()=='2'){
			$('.input_for_text','#container_for_family_status').val('Замужем')
		}
		$('.select_op_item','#container_for_family_status').eq(1).html('Замужем')
                
                  if($('#family_status','#container_for_family_status').val()=='3'){
			$('.input_for_text','#container_for_family_status').val('Не замужем')
		}
		$('.select_op_item','#container_for_family_status').eq(2).html('Не замужем')

                if($('#family_status','#container_for_family_status').val()=='4'){
			$('.input_for_text','#container_for_family_status').val('Разведена')
		}
		$('.select_op_item','#container_for_family_status').eq(3).html('Разведена')

                if($('#family_status','#container_for_family_status').val()=='5'){
			$('.input_for_text','#container_for_family_status').val('Вдова')
		}
		$('.select_op_item','#container_for_family_status').eq(4).html('Вдова')
	}
}

function flashSubmit(){
	oSubscribe.submit();
}
function flashBannerClick(){
	window.location = '/registration/index/from_company/101';
}
function key_press(event){
		event = event || window.event;
		if(event.keyCode != 13) {return;}
		if (event.preventDefault) {   
			event.preventDefault();
		} else {  
			event.returnValue = false;
		}
	 KolizeoChat.say();

}
function prevstep(){

	var cnt = eval($('.neworder').attr('countnew'))-1;
	var item = eval($('.neworder').attr('current'));
	if(item>0){
		var pos = eval(item)-1;
		var kids = $('.newordera').children();
		kids.hide();
		$(kids.get(pos)).show();
		$('.neworder').attr('current', pos);
		if(pos==0){
			$('.prevnew').addClass('l_t');
			$('.prevnew').removeClass('l_a');
		}
		if(cnt>pos){
			$('.nextnew').addClass('r_a');
			$('.nextnew').removeClass('r_t');
		}
	}

}

function add_backUrl(){
	Cookie.set("backurl", window.location.pathname, "/");
}

function nextstep(){
	var cnt = eval($('.neworder').attr('countnew'))-1;
	var item = eval($('.neworder').attr('current'));
	if(cnt>item){
		var pos = eval(item)+1;
		var kids = $('.newordera').children();
		kids.hide();
		$(kids.get(pos)).show();
		$('.neworder').attr('current', pos);
		if(pos>0){
			$('.prevnew').addClass('l_a');
			$('.prevnew').removeClass('l_t');
		}
		if(cnt==pos){
			$('.nextnew').addClass('r_t');
			$('.nextnew').removeClass('r_a');
		}
	}
}
//function helpbubble(){
//	oPopup.show({ html:'<div style="font-size: 20px; padding-bottom: 5px;" class="lstt purple">Кто наши консультанты?</div>'+
//											'<p>•&nbsp;Дипломированные астрологи и преподаватели из Школ Астрологии</p><p>•&nbsp;Психологи с высшим психологическим образованием</p><p>•&nbsp;Экстрасенсы, ясновидящие, парапсихологи, биоэнерготерапевты, эниологи и другие эзотерики с многолетним опытом работы</p><p>•&nbsp;Предсказатели по картам ТАРО, специалисты гаданию на рунах, гаданию по книге перемен</p>'+
//											'<br><div style="font-size: 20px; padding-bottom: 5px;" class="lstt purple">Как позвонить?</div>'+
//											'<p>•&nbsp;С мобильного телефона по короткому номеру 07047. Стоимость минуты незначительно отличается в зависимости от оператора связи, но в среднем составляет 70 рублей за 1 минуту разговора (с учетом НДС) с поминутным округлением в большую сторону.</p><p>•&nbsp;С любого телефона по номеру 8&nbsp;800 10 07047. Cтоимость минуты составит 49 рублей. Тарификация поминутная. Для совершения звонка Вам необходимо предварительно пополнить счет одним из способов оплаты.</p>'+
//											'<br><div style="font-size: 20px; padding-bottom: 5px;" class="lstt purple">Сколько времени нужно для получения консультации?</div>'+
//											'<p>На самом деле это очень индивидуально. По нашим наблюдениям:</p><p>•&nbsp;10 минут обычно достаточно, чтобы наш Консультант &ndash; астролог, экстрасенс, биоэнерготерапевт или психолог ответил на интересующий Вас вопрос. За 10 минут производится расклад карт ТАРО, экспресс-астропрогноз, экстрасенсорный просмотр или биоэнергокоррекция.</p><p>•&nbsp;20 минут обычно достаточно для получения одной или нескольких полноценных консультаций. Консультант &ndash; астролог, экстрасенс, биоэнерготерапевт или психолог рассмотрит Вашу жизненную ситуацию, сделает астрологический обзор, и предоставит  консультацию по одному или нескольким вопросам.</p><p>•&nbsp;30 минут обычно достаточно для проведения комплексного астрологического или эзотерического сеанса, или для  нескольких полноценных консультаций. Консультант &ndash;  астролог, экстрасенс, биоэнерготерапевт или психолог рассмотрит  Вашу жизненную ситуацию и предоставит  консультацию по одному или нескольким вопросам.</p><br>Посмотрите, какие вопросы обычно задают клиенты. Может быть, среди них есть похожие на Ваш?'
//							});
//}

Rating = {
	value: 5,
	set: function(obj, i){
		$("#rating_block div").removeClass("select");
		var j = $(obj.parentNode);
		j.addClass("select");
		this.value = i;
	}
}

var Cookie = {set : function(sName, sValue, sPath, sExpire){document.cookie = sName + '=' + (window.encodeURI? encodeURI(sValue) : escape(sValue)) +			((sExpire == null)? '' : ('; expires=' + sExpire.toGMTString())) +			((sPath == null)? '' : ('; path=' + sPath));},	get : function(sName) {var sSearch = sName + '=';if(document.cookie.length > 0) {var iOffset = document.cookie.indexOf(sSearch);if(iOffset != -1) {iOffset += sSearch.length;var iEnd = document.cookie.indexOf(';', iOffset);if(iEnd == -1) {iEnd = document.cookie.length;}return window.decodeURI?					decodeURI(document.cookie.substring(iOffset, iEnd)) :					unescape(document.cookie.substring(iOffset, iEnd))					;}}return '';}}

Format = {
	d2: function(n){return (n < 10) ? '0' + n : n;},
	sqlDate: function(year, month, day){return year + "-" + this.d2(month) + "-" + this.d2(day);}
};

function show_adress_field()
{
	
	if ($("#field_adress_for_catalog").is(':hidden') )
	{
		$("#field_adress_for_catalog").show();
		$('#sub_fio').attr("value", $('#first_name').attr("value")+" "+$('#surname').attr("value"));
		
		} 
			else
			{
				$("#field_adress_for_catalog").hide();
					}
}
	
	function sms_answer_show(answer_id, btn_id)
{
	
	if ($("#"+answer_id).is(':hidden') )
	{
		$("#"+answer_id).show();
		$("#"+btn_id).hide();
		} 
			else
			{
				$("#"+answer_id).hide();
					}
	}
	
	function sms_checkLength(obj, obj2){
		var txt = $("#"+obj).val();
		var txtlength = txt.length;
		$("#"+obj2).html(txtlength);

//                if(txtlength >= 70){
//			$("#"+obj).addClass('sms_error_len');
//		}else{
//			$("#"+obj).removeClass('sms_error_len');
//		}
		if(txtlength >= 140){$("#"+obj).val(txt.substr(0,140));}
}

	function find_client_orders(obj){
	var clientname = $("#"+obj).val();
	alert ("1111");
	};
	
	function paint_input(obj){
		var val = $(obj).val();
		var def = $(obj).attr('default');
		if(val != def){
			$(obj).parents('.crb').removeClass('pinput');
		}else{
			$(obj).parents('.crb').addClass('pinput');
		}
	}
	function form_rules(obj){
		oPopup.alert("Для того чтобы воспользоваться нашими услугами, пожалуйста, подтвердите условия пользовательского соглашения", {onClose: function(){
			$(obj).addClass('check_item_s').removeClass('check_item');
			$('#rules').val('1');
		}});
	}
	
	function valid(obj, txt){
		var tx = $(obj).val();
		var cl = $(obj).attr('id');
		if(txt=='text'){
			if(tx!=''){
				$(obj).parents('.crb').removeClass('pinput');
				$('#validate_result_for_' + cl).addClass('ok')
			}else{
				$(obj).parents('.crb').addClass('pinput');
				$('#validate_result_for_' + cl).removeClass('ok')
			}
		}

		if(txt=='phone'){
			var prt = $(obj).parents('.table_items');
			//var pref = {ru:7, us:1, ca:1, fr:33, lt:370, lv:371, ee:372, by:375, ua:380, uk:44, de:49, kz:7, il:972};
			var prefix_msisdn = $('#prefix_msisdn', prt).val();
			var msisdn1 = $('#msisdn1', prt).val();
			var msisdn2 = $('#msisdn2', prt).val();
			if (msisdn1.length == 3 && msisdn2.length == 7){
				var phone = pref[prefix_msisdn] + msisdn1 + msisdn2;
			}else{
				var phone = "";
			}
			if(tx!=''){
				$.post('/registration/control/',{type:'phone', val:phone},function(data){
					if(data.result){
						$(obj).parents('.crb').removeClass('pinput');
						$('#validate_result_for_' + cl).addClass('ok')
					}else{
						$(obj).parents('.crb').addClass('pinput');
						$('#validate_result_for_' + cl).removeClass('ok')
					}
				},"json")
			}else{
				$(obj).parents('.crb').addClass('pinput');
				$('#validate_result_for_' + cl).removeClass('ok')
			}
		}

		if(txt=='password2'){
			var ps = $('#password').val();
			if(tx!='' && tx == ps){
				$(obj).parents('.crb').removeClass('pinput');
				$('#validate_result_for_' + cl).addClass('ok')
			}else{
				$(obj).parents('.crb').addClass('pinput');
				$('#validate_result_for_' + cl).removeClass('ok')
			}
		}

		
		if(txt=='email' || txt=='password'){
			
			if(tx!=''){//alert('asd');
				$.post('/registration/control/',{type:txt, val:tx},function(data){
					if(data.result){
						$(obj).parents('.crb').removeClass('pinput');
						$('#validate_result_for_' + cl).addClass('ok')
					}else{
						$(obj).parents('.crb').addClass('pinput');
						$('#validate_result_for_' + cl).removeClass('ok')
					}
				},"json")
			}else{
				$(obj).parents('.crb').addClass('pinput');
				$('#validate_result_for_' + cl).removeClass('ok')
			}
		}

		if(txt=='data'){
			if($('#birth_date_day').val()!='' && $('#birth_date_month').val()!='' && $('#birth_date_year').val()!=''){
				$(obj).parents('.crb').removeClass('pinput');
				$('#validate_result_for_birth_date_year').addClass('ok');
			}else{
				$(obj).parents('.crb').addClass('pinput');
				$('#validate_result_for_' + cl).removeClass('ok');
			}
		}

	}
	
	
	Calendar = {
		dates: {1: null, 2: null, 3:null},
		showed: false,
		monthNames: {1:"Январь", 2:"Февраль", 3:"Март", 4:"Апрель", 5:"Май", 6:"Июнь", 7:"Июль", 8:"Август", 9:"Сентябрь", 10:"Октябрь", 11:"Ноябрь", 12:"Декабрь"},
		monthLength: {1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31},
		buildMonth: function(n){
			var t = this;
			year = t.dates[n].year; month = t.dates[n].month; day = t.dates[n].day;
			var days = "";
			var d = new Date(year, month-1, 1);
			var wday = d.getDay();
			if(wday==0) wday = 7;
			for(var i=1; i< wday; i++) days += '<div class="day empty"> </div>';
			for(var i=1; i<=this.monthLength[month]; i++) days += '<div class="day'+(this.dates[n].day==i ? ' selected':'')+'" onclick="Calendar.setDay(this, '+n+', '+i+')">' + i + '</div>';
			return '<table><tr><td width="45" style="text-align:right"><img src="/images/calend_left.gif" onclick="Calendar.prevYear('+n+')" class="ctrl"></td><td width="80" style="text-align:center" class="choose">'+year+'</td><td width="45"><img src="/images/calend_right.gif" onclick="Calendar.nextYear('+n+')" class="ctrl"></td></tr></table><table><tr><td width="45" style="text-align:right"><img src="/images/calend_left.gif" onclick="Calendar.prev('+n+')" class="ctrl"></td><td width="80" style="text-align:center" class="choose">'+this.monthNames[month]+'</td><td width="45"><img src="/images/calend_right.gif" onclick="Calendar.next('+n+')" class="ctrl"></td></tr></table><div class="days">'+days+'</div>';
		},
		show: function(){
			if(this.showed) this.close();
			var t = this;
			var d = new Date();
			var d_year = d.getFullYear();
			var d_month = d.getMonth()+1;
			var d_month_select = d.getMonth()+2;
			var d_day = d.getDate();
			
			if(!t.dates[1]) t.dates[1] = {year : d_year, month: d_month, day: d_day};
			if(!t.dates[2]) t.dates[2] = {year : d_year, month: d_month_select, day: 1};
			if(!t.dates[3]) t.dates[3] = {year : d_year, month: d_month_select, day: 1};
			var html =  '<div class="fcalend"><div class="calend_x" onclick="Calendar.close()"> </div><div class="fcalend_inner"><span style="font-size:12px;font-weight:bold">ВЫБЕРИТЕ НАЧАЛЬНЫЙ И КОНЕЧНЫЙ ПЕРИОД</span> <div class="dots f0 mp10" style="padding-bottom:4px"></div><table><tr><td width="170" id="period_1">' + t.buildMonth(1) + '</td><td width="170" id="period_2">' + t.buildMonth(2) + '</td></tr></table></div></div>';
			var p = $("#filter_period_caption").position();
			$(html).appendTo("body").css({left: p.left - 434, top: p.top - 120}).show();
			this.showed = true;
			this.clicked = {1: false, 2: false};
		},

//	show_in_stat: function(){
//		if(this.showed) this.close();
//		var t = this;
//                    current_date = new Date();
//                    cur_y = current_date.getFullYear();
//                    cur_m = current_date.getMonth() + 1;
//                    cur_d = current_date.getDate();
//                        if(!t.dates[1]) t.dates[1] = {year : cur_y, month: cur_m, day: 1};
//                        if(!t.dates[2]) t.dates[2] = {year : cur_y, month: cur_m, day: cur_d};
//                        var html =  '<div class="fcalend"><div class="calend_x" onclick="Calendar.close_in_stat()"> </div><div class="fcalend_inner"><span style="font-size:12px;font-weight:bold">ВЫБЕРИТЕ НАЧАЛЬНЫЙ И КОНЕЧНЫЙ ПЕРИОД</span> <div class="dots f0 mp10" style="padding-bottom:4px"></div><table><tr><td width="170" id="period_1">' + t.buildMonth(1) + '</td><td width="170" id="period_2">' + t.buildMonth(2) + '</td></tr></table></div></div>';
//                        var p = $(".ajax-catalog").position();
//                        $(html).appendTo("body").css({left: p.left + 268, top: p.top - 100}).show();
//                        this.showed = true;
//                        this.clicked = {1: false, 2: false};
//	},
//
//	close_in_stat: function(){
//		$(".fcalend").remove();
//		this.showed = false;
//		$("#filter_period_caption").html(this.formatPeriod());
//		var d1 = this.dates[1]; var d2 = this.dates[2];
//		Catalog.setPeriod_in_stat(Format.sqlDate(d1.year, d1.month, d1.day), Format.sqlDate(d2.year, d2.month, d2.day));
//	},

	next: function(n){
		var d = this.dates[n];
		d.month = d.month + 1;
		if(d.month == 13){
			d.month = 1; d.year++;
		}
		this.dates[n] = d;
		$("#period_" + n).html(this.buildMonth(n));
	},
	prev: function(n){
		var d = this.dates[n];
		d.month = d.month - 1;
		if(d.month == 0){
			d.month = 12; d.year--;
		}
		this.dates[n] = d;
		$("#period_" + n).html(this.buildMonth(n));
	},
	nextYear: function(n){
		this.dates[n].year++;
		$("#period_" + n).html(this.buildMonth(n));
	},
	prevYear: function(n){
		this.dates[n].year--;
		$("#period_" + n).html(this.buildMonth(n));
	},
	setDay: function(obj, n, day){
		
		var j = $(obj);
		j.parents(".days").find("div.day").removeClass("selected");
		j.addClass("selected");
		this.dates[n].day = day;
		this.clicked[n] = true;
		if(this.clicked[1] && this.clicked[2]) this.close();
	},
	close: function(){
		
			if(this.dates[2].day>=this.monthLength[this.dates[2].month])
			{
				if(this.dates[2].month>=12)
				{
					this.dates[3].day=1;
					this.dates[3].month=1;
					this.dates[3].year=this.dates[2].year+1;
				}
				else
					{
						this.dates[3].day=1;
						this.dates[3].month=this.dates[2].month+1;
					}
			}
			else
				{
					this.dates[3].day++;
				}
	  
		$(".fcalend").remove();
		this.showed = false;
		$("#filter_period_caption").html(this.formatPeriod());
		var d1 = this.dates[1]; var d2 = this.dates[2];  var d3 = this.dates[3];
		$('#table_buy').html('<div align="center" style="padding: 100px;"><img width="64" height="64" src="/images/ajax64.gif"></div>');
		Catalog.url = Kolizeo.url({dt_start:Format.sqlDate(d1.year, d1.month, d1.day), dt_end:Format.sqlDate(d3.year, d3.month, d3.day)}, Catalog.url);
		$.post(Catalog.url,{},function(data){
			$('#table_buy').html(data);
			Catalog.init();
		})

//		Catalog.setPeriod(Format.sqlDate(d1.year, d1.month, d1.day), Format.sqlDate(d2.year, d2.month, d2.day));
	},
	formatPeriod: function(){
		var d1 = this.dates[1]; var d2 = this.dates[2];
		var sFrom = Format.d2(d1.day) + "." + Format.d2(d1.month) + (d1.year != d2.year ? ("." + d1.year) : "");
		var sTo = Format.d2(d2.day) + "." + Format.d2(d2.month) + "." + d2.year;
		return sFrom + " - " + sTo;
	}
	
}

FlashCookie = {
	oF: null,
	init: function(){
		var div = document.getElementById("flashcookiediv");
		if(div){
			so = new SWFObject("/swf/flashcookie.swf" , "flashCookie", "1", "1", "10");
			so.addParam("quality", "high");
			so.addParam("allowFullScreen", "true");
			so.addParam("wmode", "transparent");
			so.addVariable("type", "video");
			so.addParam("scale", "noscale");
			so.addParam("allowScriptAccess", "always");
			so.write("flashcookiediv");
			this.oF = document.getElementById("flashCookie");
			if(this.oF){
				Kolizeo.log("FC inited");
			}
		}
	},
		get: function(key){
			try{
				var x = this.oF.getVal(key);
				if(x=="undefined") x = null;
				Kolizeo.log("FC get: " + key + " = " + x);
				return x;
			} catch(ex) {
				q=Cookie.get(key);
				return q;
			}
	},
	set: function(key, value){
		try{
			this.oF.setVal(key,value);
			Kolizeo.log("FC SET: " + key + " = " + value);
		} catch(ex) {
			var today = new Date();
			Cookie.set(key, value, "/", new Date( today.getTime() + 90 * 1000 * 60 * 60 * 24 ));
		}
	}

}

function ph_open_pop(type,name, idd, errors)
{
	
if(type=='upload')
{
	var error=errors;
	if (error===1) error="Размер&nbsp;загружаемого&nbsp;файла&nbsp;должен быть&nbsp;не&nbsp;более&nbsp;2&nbsp;мегабайт";
	if (error===2) error="Выберите&nbsp;фото&nbsp;в&nbsp;&nbsp;формате&nbsp;jpg";
	if (!error) error="";
oPopup.show(
{
			width:510, 
			action: "/profile/photos/",
			html:'<div class="ph_upload_main"><h1>Загрузка фотографии</h1></div><br>'+
			'<div style="opacity:0.0; filter:alpha(opacity=0);" class="phpadff phopad"><input type="file" size="36" name="ph_file" id="ph_file" accept="image/*" onchange="document.getElementById(\'ph_file_em\').value=document.getElementById(\'ph_file\').value" style="cursor:pointer; height:20px;"></div>'+
			'<table width="100%" border="0" class="ph_pop_contain">'+
			'<tr>'+
			'<td align="right" valign="middle" style="width:100px;">Название:</td>'+
			'<td align="left" style="padding:0 0 0 10px;"><div class="sinput" style="width:200px;"><input type="text" name="ph_name" id="ph_name" value="" style="width:180px; height:12px;"><div class="sinput_left"><div class="sinput_right">&nbsp;</div></div></div></td>'+
			'</tr>'+
			'<tr>'+
			'<td align="right" valign="middle" style="width:100px;">Файл:</td>'+
			'<td align="left" style="padding:0 0 0 10px;"><div class="sinput" style="width:200px;float:left;">'+
			'<input type="text" name="ph_file_em" id="ph_file_em" value="" style="width:180px; height:12px;" readonly="readonly"><div class="sinput_left"><div class="sinput_right">&nbsp;</div></div></div>'+
			'<div style="float:left; width:auto; margin:0 0 0 2px;"><div class="ph_button_left"></div><div class="ph_button_center" style="float:left; height:19px; background:url(\'/images/cbutton_violet_lit.png\') repeat-x left top; font-size:13px; color:white; padding:1px 0 0 0; cursor:pointer;">Обзор...</div><div class="ph_button_right" style="float:left; width:10px; height:19px; background:url(\'/images/rbutton_violet_lit.png\') no-repeat left top;"></div>'+
			'</td>'+
			'</tr>'+
			'<tr>'+
			'<td align="right" valign="middle" style="width:100px;"></td>'+
			'<td align="left" style="padding:0 0 0 10px;">JPG до 2 Мб</td>'+
			'</tr>'+
			'<tr>'+
			'<td colspan="2" align="center" style="padding:0;color:red;">'+error+'</td>'+
			'</tr>'+
			'</table>',
//			buttons: [{text:'Загрузить', handler: function(){
//				$('#ph_name').focus();
//				if ($('#ph_file').val()==''){
//				alert('Вы не выбрали фото для загрузки');
//				}else{
//					this.popup.submit();
//				}
//				return false;
//			}}],
			'upload_photo':true
}
);
}
else if(type=='edit')
{
		oPopup.show(
{
			width:450, 
			action: "/profile/photos/",
			html:'<div class="ph_upload_main"><h1>Изменение фотографии</h1></div><br>'+
			'<input type="hidden" name="ph_edit" value="'+idd+'"/>'+
			'<table width="100%" border="0" class="ph_pop_contain">'+
			'<tr>'+
			'<td valign="middle" width="30px;">Название:</td>'+
			'<td><div class="sinput" style="width:200px;">'+
			'<input type="text" name="ph_name" id="ph_name" value="'+name+'" style="width:180px; height:12px;">'+
			'<div class="sinput_left"><div class="sinput_right">&nbsp;</div></div></div>'+
			'</td>'+
			'</tr>'+
			'</table>',
			buttons:[{text: "Сохранить",  handler: function(){
				this.popup.submit();
				return false;
			}}]
}
);
	
}
else if(type=='delete')
{
	if (!name) name="фото без названия";
	oPopup.show(
{
			width:400, 
			action: "/profile/photos/",
			html:'<div class="ph_upload_main"><h1>Удаление фотографии</h1></div><br/>'+
			'<input type="hidden" name="ph_del" value="'+idd+'"/><table width="100%" border="0" class="ph_pop_contain"><tr><td><div align="center" style="padding:10px">Вы действительно желаете удалить "'+name+'"?</div></td></tr></table>',
			
			buttons:[{text: "Да",  handler: function(){
				this.popup.submit();
				return false;
			}},{text: "Нет", width: 60}]
}
);
}

}

function res_pic(path,width,height,name)
{
	clheight=document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
	height2= clheight-50;
	mass=height2/height;
	width2 = width*mass;

	var xx = window.open(name+'.html','','width = '+width2+'px, height = '+(height2+55)+'px, location = no, scrollbars = yes, toolbar=no, resizable=no');
	//xx.document.location.hash = name+'html';
	xx.document.write('<html>');
	xx.document.write('<head>');
	xx.document.write('<title>'+name+'</title>');
	xx.document.write('</head>');
	xx.document.write('<body style="margin:0; padding:5px; overflow:auto;" onload="document.getElementById(\'href\').editable = true">');
	xx.document.write('<div><img src="'+path+'" width="'+(width2-10)+'" height="'+height2+'"/></div>');
	xx.document.write('<table width="100%" border="0" cellpadding="3" cellspasing="0" style="color:#06a2c1; font-style:italic;"><tr><td>'+name+'</td><td width="180px" style="color:#4C4C4C;">Ссылка на изображение: </td><td><input type="text" value="'+path+'"  readonly="true"  style="width:100%;border:solid 1px #4C4C4C; color:#4C4C4C;"></td></tr></table>');
	xx.document.write('</body>');
	xx.document.write('</html>');
}


function CourseZapis()
{
	if(document.getElementById('date_course1').value>0)
	{
		document.getElementById('CourseForm').submit();
	}else
		{
		
			
				oPopup.show({
					width: 534,
					html: '<div class="diary_text"></div>',
					caption:'Не выбрана дата курса!',
					buttons:[ {text:'Закрыть окно', width: 122} ],
					z_index: 10000,
					blockSite: true
				});		
			
		}
}

function Elem(sObject){
	return(document.getElementById(sObject));
}

function clickRegSelect(sName){
	var oTable = Elem('reg_table_'+sName);
	if(oTable){
		if(oTable.className=='reg_table'){
			oTable.className='reg_table_show';
		}else{
			oTable.className='reg_table';
		}
	}
}

function clickRegElem(oElem, iParam){
	if(oElem){
		if(iParam==1){
			oElem.className='fon_select';
		}else{
			oElem.className='fon';
		}
	}
}

function setRegValue(oElem, sName){
	if(oElem){
		var iValue = parseInt(oElem.getAttribute('val'));
		if(iValue>0){
			var oRegText = Elem('reg_text_'+sName);
			var oRegValue = Elem('reg_value_'+sName);
			if(oRegText && oRegValue){
				oRegText.value = oElem.innerHTML;
				oRegValue.value = iValue;
				clickRegSelect(sName);
			}
		}else{
			var oTR = Elem('reg_tr_all_country');
			var oTBody = Elem('reg_tbody_'+sName);
			if(oTR && oTBody){
				oTR.parentNode.removeChild(oTR);
				oTBody.className='show';
			}
		}
	}
}

function limitLength(o,max)
{
	if (o.value.length >= max) 
	{
		oPopup.alert("Длина текста в этом поле ограничена " + max + " символами.", {width:280, blockSite:true});
		return false;
	}
	return true;
}

function message_send()
{
	window.parent.oPopup.show({
				width:480,
				html:"Ваше сообщение отправлено в службу поддержки Колизео. В ближайшее время наши специалисты свяжутся с Вами по указанному адресу эл. почты или по телефону.",
				buttons: [{text:'Закрыть окно', handler: function(){
						this.popup.close();
						return false;
					}}]
				/*onClose: function(){
						//window.location.href="/feedback/frame/";
						}*/
					});
}

function message_error()
{
	window.parent.oPopup.show({
				width:480,
				html:"<br><div align='center' style='color:red;'><b>Формат загружаемого файла не поддерживается</b></div>",
				buttons: [{text:'Закрыть окно', handler: function(){
						this.popup.close();
						return false;
					}}]
				/*onClose: function(){
						//window.location.href="/feedback/frame/";
						}*/
					});
				//	alert('asd');
				//	document.getElementById('category').value='asd';
						
}

function spam_popup()
{
	window.parent.oPopup_spam.show({
				width:480,
				html:"<br><div align='center' style='color:red;'><b>Формат загружаемого файла не поддерживается</b></div>",
				buttons: [{text:'Закрыть окно', handler: function(){
						this.popup.close();
						return false;
					}}]
				/*onClose: function(){
						//window.location.href="/feedback/frame/";
						}*/
					});
				//	alert('asd');
				//	document.getElementById('category').value='asd';
}
  function spam_close()
 {
  $('#spam_popup').remove();
  document.body.style.height='auto';
  document.body.style.overflow='auto';
 }


	function getDataActs(){
		var hData = {};
		$("#fuck1 input").each(function(){
			hData[this.name] = (this.value != $(this).attr("default")) ? this.value : "";
		});
		
		return hData;
	}
	function submitActs(){
		//alert(page);
		var t = this;
		var hData = getDataActs();

    $.post("/cabinet/akts/data", hData, function(data){
	  //$('#butt_send').hide();  $('#ajax_send').show();
			if(data.success){
				oPopup.alert("Спасибо! Вы подписаны на рассылку гороскопов Колизео.");
			} else {
				oPopup.alert("<div align='center' style='padding-bottom:10px'>" + data.error + "</div>");				
			}
		}, "json");
		return false;
}	

