var ie=navigator.userAgent
var k=navigator.userAgent.indexOf('MSIE')
var ver=parseInt( ie.substring(k+5, ie.indexOf('.',k) ))

if(ver>=4 || isNaN(ver)) {
nav0=new Image();	nav0.src=''

centrmap=new Image();	centrmap.src='pic/map_rostov_centr.gif';

temp=new Image();
}

function MOver(nn) {
if(ver>=4 || isNaN(ver)) {
	temp.src=nn.src;
	eval("nn.src="+nn.name+".src")
	}
}

function MOut(nn) {
if(ver>=4 || isNaN(ver)) {
	nn.src=temp.src;
	}
}

function Toggle(div) {
	$(div).slideToggle("normal");
}

/* --------------------------------------- */

function FormatPrice(s) {
var sformat="";
var sraw=s.attr("value").replace(/ /g,"");
if(sraw.length>3) {
	for(i=1;i<(Math.floor(sraw.length/3))+1;i++) {
		sformat=" "+sraw.substr(sraw.length-3*i,3)+sformat;
	}
	sformat=sraw.substr(0,sraw.length-3*(i-1))+sformat;
	s.attr("value",sformat);
}
}

function showNewsForm() {
	//$("#twtr-widget-1").hide();
	//if(Browser.Engine.trident){ return true; }
	winFormLogin1=new StickyWin.Modal({content:$('news-form'),closeClassName:'close-block',useIframeShim:false});
	winFormLogin1.show();
	winFormLogin1.pin(false);
	return false;
}

var RecaptchaOptions = {
    theme : 'clean'
};

/* ============ Highslide JS ============ */
hs.graphicsDir = '/templates/skin/new/js/highslide/graphics/';
hs.align = 'center';
//hs.outlineType = 'custom';
hs.outlineType = 'rounded-white';
//hs.wrapperClassName = 'dark';
hs.fadeInOut = true;
hs.dimmingOpacity = 0.5;
hs.wrapperClassName = 'draggable-header';

// Add the controlbar
if (hs.addSlideshow) hs.addSlideshow({
	//slideshowGroup: 'group1',
	interval: 5000,
	repeat: false,
	useControls: true,
	fixedControls: 'fit',
	overlayOptions: {
		opacity: .75,
		position: 'bottom center',
		hideOnMouseOut: true
	}
});

// Russian language strings
hs.lang = {
	cssDirection: 'ltr',
	loadingText: 'Загружается...',
	loadingTitle: 'Нажмите для отмены',
	focusTitle: 'Нажмите чтобы поместить на передний план',
	fullExpandTitle: 'Развернуть до оригинального размера',
	creditsText: '',
	creditsTitle: 'Перейти на домашнюю страницу Highslide JS',
	previousText: 'Предыдущее',
	nextText: 'Следующее',
	moveText: 'Переместить',
	closeText: 'Закрыть',
	closeTitle: 'Закрыть (esc)',
	resizeTitle: 'Изменить размер',
	playText: 'Слайдшоу',
	playTitle: 'Начать слайдшоу (пробел)',
	pauseText: 'Пауза',
	pauseTitle: 'Приостановить слайдшоу (пробел)',
	previousTitle: 'Предыдущее (стрелка влево)',
	nextTitle: 'Следующее (стрелка вправо)',
	moveTitle: 'Переместить',
	fullExpandText: 'Оригинальный размер',
	number: 'Изображение %1 из %2',
	restoreTitle: 'Нажмите чтобы закрыть изображение, нажмите и перетащите для изменения местоположения. Для просмотра изображений используйте стрелки.'
};

/* ------ jQuery ------ */

jQuery(function($){
	$("input.tel").mask("+7 (999) 999-99-99");
	$("#MapForm td input[name=longitude]").mask("99.999999");
	$("#MapForm td input[name=latitude]").mask("99.999999");
	$("#MapFormAll").hide();
	$(".content img[align=left]").css("margin","0px 20px 10px 0px");
	$(".content img[align=right]").css("margin","0px 0px 10px 20px");
	$(".content img[align=left]").css("width","150px");
	$(".content img[align=left]").css("height","auto");
	
	if(window.location.toString().indexOf("/topic/add/")!=-1 || window.location.toString().indexOf("/topic/edit/")!=-1) { 
		$("#header").css("height","0px"); 
		$("#header").css("overflow","hidden");
		$("#promo").css("display","none");
	}
	if(window.location.toString().indexOf("/blog/")!=-1) { 
		$("div.blogs:eq(0)").hide();
		$("div.blogs:gt(0)").hide();
	}
	
	if(window.location.toString().indexOf("/map")!=-1 && window.location.hash.toString()!="") { 
		//alert(window.location.hash);
		//$("#mts").toggleClass("active");
		//$("#mts").html();
		//alert($("#mts").hasClass());
		$("#menu").html("--");
	}
	
	if(window.location.toString().indexOf("/map")!=-1) { 
		$("#menu").html("");
	}
	
	$(".content img").each(function (i) {
		if ($(this).css("float") == "left") { 
			$(this).css("margin","0px 20px 10px 0px"); 
			$(this).css("width","150px"); 
			$(this).css("height","auto"); 
			}
	});
	
	if(document.body.clientWidth < 1200) { 
		$("#content").css("width","58%");
		$("#sidebar").css("width","37%");
	}
	
	$(window).resize(function() {
		if(document.body.clientWidth < 1200) { 
			$("#content").css("width","58%");
			$("#sidebar").css("width","37%");
		} else { 
			$("#content").css("width","63%");
			$("#sidebar").css("width","33%");
		}
	});
	
	$("#content table").attr("border","0");
	if($("#content table").attr("class")!="clear") {
		$("#content table").attr("class","tab");
	}

$("input.price").keyup(function() { // форматирование цены в строке ввода
	//FormatPrice($(this));
});

$("a#twiterrostov").click(function() { // раскрытие твиттера
      	$("#twit_widget").slideToggle("slow");
	return true;
});

$("#MapFormButton").click(function() { // раскрытие формы добавления карты
      	$("#MapFormAll").slideToggle("slow");
	return false;
});

$("#chdate_topic_date_add").click(function() { // добавление даты
	var today = new Date();
	var mm = (today.getMonth()+1)<9 ? "0"+String(today.getMonth()+1) : String(today.getMonth()+1);
	if($("#chdate_topic_date_add").attr("value")=="") {
      		$("#chdate_topic_date_add").attr("value",today.getFullYear()+"-"+mm+"-"+today.getDate()+" "+today.getHours()+":"+today.getMinutes()+":"+today.getSeconds());
      	}
	return false;
});

$(".logo a img").hover(
	function () {
		$(this).attr("src","/templates/skin/new/images/logo_smsrostov-over.png");
      	}, 
      	function () {
        	$(this).attr("src","/templates/skin/new/images/logo_smsrostov.png");
        return false;
	});

});

