var i_url = 'http://yar-life.ru/i/';
$(document).ready(function(){
$("html#nojs").attr("id", "js");
$(".nojs").remove();
if(parent.location!=document.location){
parent.location=document.location;
}
$('dl.tabs dt').click(function(){$(this).siblings().removeClass('selected').end().next('dd').andSelf().addClass('selected');});
$("#add_favorite_link").click(function (){addBookmark();return false;});
$("#message").click(function(){$(this).empty();});
$("#alert").click(function(){$(this).empty();});
$(".i_search_tab").live("click", function(){
where = $(this).attr("id").replace(/\i_search_(\w+)/, "$1");
$(".i_search_seltab").addClass("i_search_tab").removeClass("i_search_seltab");
$(this).addClass("i_search_seltab").removeClass("i_search_tab");
$("#search_where").attr("value", where);
});
$(".menu_item").hover(function(){
menu_id = $(this).attr("id");
$(this).css("background","url("+i_url+"new/menu_bg_act.png) repeat-x");
var timer_id = setTimeout(function(){$('#'+menu_id+' .i_submenu').slideDown('fast');},200);
$(this).mouseleave(function(){if (('#'+menu_id+' .i_submenu:hidden')){clearTimeout(timer_id);}})
}, function(){menu_id = $(this).attr("id");$('#'+menu_id+' .i_submenu').slideUp('fast');$(this).css("background","none");});
$("#logo_text").mouseover(function(){var timer_id = setTimeout(function(){$('#logo_inform').slideDown('fast');},1500);$("#logo_text").mouseleave(function(){if ($("#logo_inform:hidden")){clearTimeout(timer_id);}});});
$("#logo_inform").mouseleave(function(){$(this).slideUp('fast');});
$('.subm').hover(function(){
$(this).css("background", "#80a0ae");
}, function(){
$(this).css("background", "#c4d3da");
});
if ($.browser.msie && $.browser.version <= 6) {
//код только для ИЕ шестой версии!
$("#i_top").before('<div id="updateBrowser" align="left"><a href="http://li.ru/go?www.microsoft.com/downloads/details.aspx?FamilyID=9ae91ebe-3385-447c-8a30-081805b2f90b&amp;displaylang=ru"  style="font-family: Arial; font-size: 12px; text-decoration: none; display: block; line-height: 18px; height: 20px; color: Black;">&nbsp;Ваш браузер устарел и имеет <b>критические уязвимости</b>. Нажмите здесь, чтобы установить новую версию.</a> Либо, рекомендуем загрузить один из <b>более безопасных и удобных</b> браузеров: <a href="http://li.ru/go?fx.yandex.ru/" target="_blank">Firefox</a>, <a href="http://li.ru/go?ru.opera.com/" target="_blank">Opera</a> или  <a href="http://li.ru/go?www.google.com/chrome" target="_blank">Google Chrome</a></div>');
$("#updateBrowser").slideDown("slow");
}
$(".rarrow_active").live("click", function()
{
var jq_module_id = "#"+$(this).parent().attr("id");
var module_id = jq_module_id.replace(/#manage_(\w+)/, "$1");
var slide_width = parseInt($(jq_module_id + " .i_slide_cont").width());
var slide_from = parseInt($(jq_module_id + " #"+module_id+"_slide_from").val());
var slides_count = parseInt($("#"+module_id+"_slide_count").val()) - 1;
$(jq_module_id + " #"+module_id+"_slide_from").val(slide_from+1);
if (slide_from > slides_count)
{
return false;
}
var next_slide = $(jq_module_id + " #"+module_id+"_slide_"+slide_from).next(".i_slide");
if (next_slide.size() == '0')
{
$.ajax({
dataType: "html",
url: "/js/ajax/slides.php?dir=next&module="+module_id+"&from="+slide_from,
cache: true,
beforeSend: function ()
{
img_load = '<img src="'+i_url+'loader.gif" alt="Загрузка..." class="slide_img_load" />'
$(jq_module_id + " .i_slide_cont").addClass("slide_load").append(img_load);
},
success: function(slide)
{
$(jq_module_id + " .i_slide_cont").removeClass("slide_load");
$(jq_module_id + " .slide_img_load").remove();
w = parseInt($(jq_module_id + " .i_slide_move").width())+slide_width;
$(jq_module_id + " .i_slide_move").css("width", w+"px").append(slide);
},
complete: function(slide)
{
$(jq_module_id + " .i_slide_move").animate({left: "-="+slide_width+"px"}, "slow");
l_active("manage_"+module_id);r_active("manage_"+module_id);
}
});
}
else
{
$(jq_module_id + " .i_slide_move").animate({left: "-="+slide_width+"px"}, "slow");
l_active("manage_"+module_id);r_active("manage_"+module_id);
}
return false;
});
$(".larrow_active").live("click", function()
{
var jq_module_id = "#"+$(this).parent().attr("id");
var module_id = $(this).parent().attr("id").replace(/manage_(\w+)/, "$1");
var slide_width = parseInt($(jq_module_id + " .i_slide_cont").width());
var slide_from = parseInt($(jq_module_id + " #"+module_id+"_slide_from").val());
$(jq_module_id + " #"+module_id+"_slide_from").val(slide_from-1);
if (slide_from < 0)
{
return false;
}
var prev_div = $(jq_module_id + " #"+module_id+"_slide_"+slide_from).prev(".i_slide");
if (prev_div.size() == '0')
{
$.ajax({
dataType: "html",
url: "/js/ajax/slides.php?dir=prev&module="+module_id+"&from="+slide_from,
cache: true,
beforeSend: function ()
{
img_load = '<img src="'+i_url+'loader.gif" alt="Загрузка..." class="slide_img_load" />'
$(jq_module_id + " .i_slide_cont").addClass("slide_load").append(img_load);
},
success: function(slide)
{
$(jq_module_id + " .i_slide_cont").removeClass("slide_load");
$(jq_module_id + " .slide_img_load").remove();
$(jq_module_id + " .i_slide_move").css("width", parseInt($(this).width())+slide_width+"px").prepend(slide);
},
complete: function()
{
$(jq_module_id + " .i_slide_move").animate({left: "+="+slide_width+"px"}, "slow");
l_active("manage_"+module_id);r_active("manage_"+module_id);
}
});
}
else
{
$(jq_module_id + " .i_slide_move").animate({left: "+="+slide_width+"px"}, "slow");
l_active("manage_"+module_id);r_active("manage_"+module_id);
}
return false;
});
$("#ban_728x90").show();
$("#ban_240x400").show();
$("#ban240x400").show();
$(".ban_240x400").show();
$("#full_banner").show();
$(".ban_468x60").show();
$("#full_banner_2").show();
});
function byId(obj_id)
{
return document.getElementById(obj_id);
}
function r_active (module)
{
var module_id = module.replace(/manage_(\w+)/, "$1");
jq_module_id = '#' + module;
slides_count = parseInt($("#"+module_id+"_slide_count").val()) - 1;
if ($(jq_module_id + " #"+module_id+"_slide_from").val() >= slides_count)
{
$(jq_module_id + " .i_slide_next").removeClass("rarrow_active").addClass("rarrow_inactive");
}
else
{
$(jq_module_id + " .i_slide_next").removeClass("rarrow_inactive").addClass("rarrow_active");
}
}
function l_active (module)
{
var module_id = module.replace(/manage_(\w+)/, "$1");
jq_module_id = '#' + module;
if ($(jq_module_id + " #"+module_id+"_slide_from").val() <= '0')
{
$(jq_module_id + " .i_slide_prev").removeClass("larrow_active").addClass("larrow_inactive");
}
else
{
$(jq_module_id + " .i_slide_prev").removeClass("larrow_inactive").addClass("larrow_active");
}
}
document.onkeydown = NavigateThrough;
function NavigateThrough (event)
{
if (!document.getElementById) return;
if (window.event) event = window.event;
if (event.ctrlKey)
{
var link = null;
var href = null;
switch (event.keyCode ? event.keyCode : event.which ? event.which : null)
{
case 0x25:
link = document.getElementById ('prev_link');
break;
case 0x27:
link = document.getElementById ('next_link');
break;
case 0x24:
href = '/';
break;
case 0x23:
href = '/about/contacts.html';
break;
}
if (link && link.href) document.location = link.href;
if (href) document.location = href;
}
}
function mousePageXY(e)
{
var x = 0, y = 0;
var coord=new Array();
if (!e) e = window.event;
if (e.pageX || e.pageY)
{
x = e.pageX;
y = e.pageY;
}
else if (e.clientX || e.clientY)
{
x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
}
coord[0]=x;coord[1]=y;
return coord;
}
function addBookmark(url, title)
{
if (!url) url = location.href;
if (!title) title = document.title;
//Gecko
if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) window.sidebar.addPanel (title, url, "");
//IE4+
else if (typeof window.external == "object") window.external.AddFavorite(url, title);
//Opera7+
else if (window.opera && document.createElement)
{
var a = document.createElement('A');
if (!a) return false; //IF Opera 6
a.setAttribute('rel','sidebar');
a.setAttribute('href',url);
a.setAttribute('title',title);
a.click();
}
else return false;
return true;
}
/* читаем куку */
function getCookie(sName)
{
var tmp='';
var aCookie = document.cookie.split("; ");
for (var i=0; i < aCookie.length; i++)
{
var aCrumb = aCookie[i].split("=");
if (sName == aCrumb[0])
{
tmp=unescape(aCrumb[1]);
}
}
return tmp;
}
/* пишем куку */
//TODO: домен куки!
function setCookie(name, value)
{
var curCookie = name + "=" + escape(value) +
"; expires=Wed, 28 May 2012 17:45:38 +0400" +
"; path=/" +
"; domain=.yarland.ru";
document.cookie = curCookie;
}
function get_win_width() {
var myWidth = 0;
if( typeof( window.innerWidth ) == 'number' ) //Non-IE
myWidth = window.innerWidth;
else if( document.documentElement && document.documentElement.clientWidth ) //IE 6+ in 'standards compliant mode'
myWidth = document.documentElement.clientWidth;
else if( document.body && document.body.clientWidth) //IE 4 compatible
myWidth = document.body.clientWidth;
return myWidth;
}
function get_win_height() {
var myHeight = 0;
if( typeof( window.innerHeight ) == 'number' ) //Non-IE
myHeight = window.innerHeight;
else if( document.documentElement && document.documentElement.clientHeight ) //IE 6+ in 'standards compliant mode'
myHeight = document.documentElement.clientHeight;
else if( document.body && document.body.clientHeight) //IE 4 compatible
myHeight = document.body.clientHeight;
return myHeight;
}
function get_scroll() {
var yPos = 0;
if (self.pageYOffset) {
yPos = self.pageYOffset;
} else if (document.documentElement && document.documentElement.scrollTop){
yPos = document.documentElement.scrollTop;
} else if (document.body) {
yPos = document.body.scrollTop;
}
return yPos;
}
$(document).ready(function()
{
$('dl.tabs #addfirmload').click(function(){
elm = $("#catalog_addfirm");
$.ajax({
dataType: "html",
url: "/templates/index/inc/add_firm.inc.html",
cache: true,
beforeSend: function ()
{
img_load = '<img src="'+i_url+'loader.gif" alt="Загрузка..." class="slide_img_load" />'
elm.empty().append(img_load);
},
success: function(slide)
{
elm.empty().append(slide);
}
});
});
$('dl.tabs #addsiteload').click(function(){
elm = $("#catalog_addsite");
$.ajax({
dataType: "html",
url: "/templates/index/inc/add_site.inc.html",
cache: true,
beforeSend: function ()
{
img_load = '<img src="'+i_url+'loader.gif" alt="Загрузка..." class="slide_img_load" />'
elm.empty().append(img_load);
},
success: function(slide)
{
elm.empty().append(slide);
}
});
});
$('dl.tabs .load_afisha').click(function(){
elm_id = $(this).attr("id").replace(/afisha_show_(\d+)/, "$1");
elm = $("#afisha_"+elm_id);
$.ajax({
dataType: "html",
url: "/templates/afisha/inc/i_afisha.inc.html?cat_id="+elm_id,
cache: true,
beforeSend: function ()
{
img_load = '<img src="'+i_url+'loader.gif" alt="Загрузка..." class="slide_img_load" />'
elm.empty().append(img_load);
},
success: function(slide)
{
elm.empty().append(slide);
}
});
});
$("#site_rules").change(function()
{
if ($(this).attr("checked") == true)
{
$("#add_site").removeAttr("disabled");
}
else
{
$("#add_site").attr("disabled", "disabled");
}
});
// Slides
$("#news_slide_from").val("0");
$("#experts_slide_from").val("0");
$("#realty_slide_from").val("0");
$("#auto_slide_from").val("0");
l_active('manage_news');r_active('manage_news');
l_active('manage_experts');r_active('manage_experts');
l_active('manage_realty');r_active('manage_realty');
l_active('manage_auto');r_active('manage_auto');
// Votes
$(".v-submit-but").click(function(){
var id = $(this).attr("id");
vote_id = id.replace(/^v-submit-(\d+)/, "$1");
var id_ar = new Array;
var ids = 'ids=';
var i = 0;
$(".ans-variant").each(function(){
if ($(this).attr("checked"))
{
ids += $(this).val()+';';
id_ar[i] = $(this).val();
i =+ 1;
}
});
if (ids == 'ids=')
{
alert('Ничего не выбрано');
return false;
}
else
{
$("html").css('cursor','wait');
$.ajax({
type: "POST",
data: "action=vote&vote_id="+vote_id+"&"+ids,
url: "/js/vote.php",
dataType : "json",
cache: false,
success: function(data){
$("html").css('cursor','auto');
alert(data['status']);
$("#vote_block"+vote_id).html(data['html']);
},
error: function (){
$("html").css('cursor','auto');
}
});
}
});
});
