﻿$(document).ready(function() {
var a = window.location.hash;
if(a == "#back") {
	$("#aff-tab4").addClass("tab-selected");
	$("#left-bar-tab4").show();

	$("#left-bar-tab5").hide();
	$("#left-bar-tab3").hide();
	$("#left-bar-tab2").hide();
	$("#left-bar-tab1").hide();
	$("#aff-tab1").removeClass("tab-selected");
	$("#aff-tab2").removeClass("tab-selected");
	$("#aff-tab3").removeClass("tab-selected");
	$("#aff-tab5").removeClass("tab-selected");
}

$("close").click(function () {
	$(this).toggleClass("open");
});

$(".aff-tab-menu > span").hover (
function() {
	$(this).toggleClass("tab-hovered");
});

$(".aff-tab-menu > span").click ( function() {
	$(".aff-tab-menu > span").removeClass("tab-selected");
	$(this).addClass("tab-selected");
});

$("#aff-tab1").click ( function() {
	$("#left-bar-tab2").hide();
	$("#left-bar-tab3").hide();
	$("#left-bar-tab4").hide();
	$("#left-bar-tab5").hide();
	$("#left-bar-tab1").show();
});
$("#aff-tab2").click ( function() {
	$("#left-bar-tab1").hide();
	$("#left-bar-tab3").hide();
	$("#left-bar-tab4").hide();
	$("#left-bar-tab5").hide();
	$("#left-bar-tab2").show();
});
$("#aff-tab3").click ( function() {
	$("#left-bar-tab2").hide();
	$("#left-bar-tab1").hide();
	$("#left-bar-tab4").hide();
	$("#left-bar-tab5").hide();
	$("#left-bar-tab3").show();
});
$("#aff-tab4").click ( function() {
	$("#left-bar-tab3").hide();
	$("#left-bar-tab2").hide();
	$("#left-bar-tab1").hide();
	$("#left-bar-tab5").hide();
	$("#left-bar-tab4").show();
});
$("#aff-tab5").click ( function() {
	$("#left-bar-tab3").hide();
	$("#left-bar-tab2").hide();
	$("#left-bar-tab1").hide();
	$("#left-bar-tab4").hide();
	$("#left-bar-tab5").show();
});

$(".object-preview").click (
function() {
	var picID = this.id;
	$(".object-preview").removeClass("preview-selected");
	$(this).addClass("preview-selected");
	$.post(
		"/object/ajaxgetimage.php",
		{picID: picID},
		function(data) {
			$(".objects-photo-current").html(data)
		}
	)
}
);

$(".office-preview").click (
function() {
	var picPath = this.name;
	$.post(
		"/object/ajaxgetimage.php",
		{picPath: picPath}, 
		function(data) {
			$(".officePhotoDetail").html(data)
		}
	)
}
);

$('#officeGallery').jqm({
	trigger: '.officeTrigger',
    overlay: 70, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'dialogOverlay'})

$('#dialog').jqm({
    trigger: '#dialogTrigger',
    overlay: 70, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'dialogOverlay'})
/**/

$('#forma-events').jqm({
    trigger: '#openForma',
    overlay: 70, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'dialogOverlay'})

$('#shema-window-khm').jqm({
    trigger: '#shema-window-khm-trigger',
    overlay: 70, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'dialogOverlay'})
	
$('#shema-window0').jqm({
    trigger: '#shema0',
    overlay: 70, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'dialogOverlay'})
$('#shema-window1').jqm({
    trigger: '#shema1',
    overlay: 70, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'dialogOverlay'})
$('#shema-window2').jqm({
    trigger: '#shema2',
    overlay: 70, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'dialogOverlay'})
$('#shema-window3').jqm({
    trigger: '#shema3',
    overlay: 70, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'dialogOverlay'})
$('#shema-window4').jqm({
    trigger: '#shema4',
    overlay: 70, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'dialogOverlay'})
$('#shema-window5').jqm({
    trigger: '#shema5',
    overlay: 70, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'dialogOverlay'})
$('#shema-window6').jqm({
    trigger: '#shema6',
    overlay: 70, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'dialogOverlay'})
$('#shema-window7').jqm({
    trigger: '#shema7',
    overlay: 70, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'dialogOverlay'})
$('#shema-window8').jqm({
    trigger: '#shema8',
    overlay: 70, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'dialogOverlay'})
$('#shema-window9').jqm({
    trigger: '#shema9',
    overlay: 70, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'dialogOverlay'})
$('#shema-window10').jqm({
    trigger: '#shema10',
    overlay: 70, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'dialogOverlay'})
$('#shema-window11').jqm({
    trigger: '#shema11',
    overlay: 70, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'dialogOverlay'})	
$('#shema-window12').jqm({
    trigger: '#shema12',
    overlay: 70, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'dialogOverlay'})	
$('#shema-window13').jqm({
    trigger: '#shema13',
    overlay: 70, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'dialogOverlay'})	
$('#shema-window14').jqm({
    trigger: '#shema14',
    overlay: 70, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'dialogOverlay'})
$('#form-project').jqm({
    trigger: '#open-project',
    overlay: 70, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'dialogOverlay'})	
$('#shemaBilding').jqm({
    trigger: '#open-bilding-shema',
    overlay: 70, /* 0-100 (int) : 0 is off/transparent, 100 is opaque */
    overlayClass: 'dialogOverlay'})		
	
  // Close Button Highlighting. IE doesn't support :hover. Surprise?
  $('input.jqmdX')
  .hover(
    function(){ $(this).addClass('jqmdXFocus'); }, 
    function(){ $(this).removeClass('jqmdXFocus'); })
  .focus( 
    function(){ this.hideFocus=true; $(this).addClass('jqmdXFocus'); })
  .blur( 
    function(){ $(this).removeClass('jqmdXFocus'); });

});

//Script map
// Когда DOM готов...
$(document).ready(function () {

/*$("#office19").hover(function(){	$("#sexyOffice").html("<h3>Офис 18, <small>24кв.м.</small></h3>");});
$("#office20").hover(function(){	$("#sexyOffice").html("<h3>Офис 19, <small>15кв.м.</small></h3>");});
$("#office21").hover(function(){	$("#sexyOffice").html("<h3>Офис 20, <small>28кв.м.</small></h3>");});
$("#office22").hover(function(){	$("#sexyOffice").html("<h3>Офис 21, <small>41кв.м.</small></h3>");});
$("#office23").hover(function(){	$("#sexyOffice").html("<h3>Офис 22, <small>36кв.м.</small></h3>");});
$("#office24").hover(function(){	$("#sexyOffice").html("<h3>Офис 23, <small>23кв.м.</small></h3>");});
$("#office25").hover(function(){	$("#sexyOffice").html("<h3>Офис 24, <small>14кв.м.</small></h3>");});
$("#office26").hover(function(){	$("#sexyOffice").html("<h3>Офис 25, <small>25кв.м.</small></h3>");});

$("#office19").click(function(){	window.location="http://new.hmaobin.ru/object/105/?floor=2&office=161#sss"; return false;});
$("#office20").click(function(){	window.location="http://new.hmaobin.ru/object/105/?floor=2&office=162#sss"; return false;});
$("#office21").click(function(){	window.location="http://new.hmaobin.ru/object/105/?floor=2&office=163#sss"; return false;});
$("#office22").click(function(){	window.location="http://new.hmaobin.ru/object/105/?floor=2&office=164#sss"; return false;});
$("#office23").click(function(){	window.location="http://new.hmaobin.ru/object/105/?floor=2&office=165#sss"; return false;});
$("#office24").click(function(){	window.location="http://new.hmaobin.ru/object/105/?floor=2&office=166#sss"; return false;});
$("#office25").click(function(){	window.location="http://new.hmaobin.ru/object/105/?floor=2&office=167#sss"; return false;});
$("#office26").click(function(){	window.location="http://new.hmaobin.ru/object/105/?floor=2&office=168#sss"; return false;});*/

	maxwid = $(".inner").width() - 680;
	maxhei = $(".inner").height() - 375;
	strelkaTop = false;
	if($(".inner").width()> 680) { $("#strelka-right").show(); $("#outer").addClass("bordered");}
	if($(".inner").height()> 375) { $("#strelka-bottom").show(); $("#outer").addClass("bordered"); }
	$('html').mouseup(function (event) {
		$('#outer').data('down', false);
		$("#outer").css({'cursor' : 'url(/bitrix/templates/main/img/grab.cur), default'});
	});

$(".strelka").hover(
function(){	$(this).addClass("strelka-hovered"); },
function(){	$(this).removeClass("strelka-hovered");});

$("#strelka-top").mousedown( function(){ strelkaTop = true; $(this).addClass("strelka-top-clicked");});
$("#strelka-top").mouseup( function(){ strelkaTop = false; $(this).removeClass("strelka-top-clicked");});
$("#strelka-bottom").mousedown( function(){$(this).addClass("strelka-bottom-clicked");});
$("#strelka-bottom").mouseup( function(){$(this).removeClass("strelka-bottom-clicked");});
$("#strelka-left").mousedown( function(){$(this).addClass("strelka-left-clicked");});
$("#strelka-left").mouseup( function(){$(this).removeClass("strelka-left-clicked");});
$("#strelka-right").mousedown( function(){$(this).addClass("strelka-right-clicked");});
$("#strelka-right").mouseup( function(){$(this).removeClass("strelka-right-clicked");});

setInterval(function(){if (strelkaTop==true) { st=$("#outer").scrollTop()+5; $("#outer").scrollTop(st);}	},10);


  $('#outer').mousedown(function (event) {
    $(this)
      .data('down', true)
      .data('x', event.clientX)
	  .data('y', event.clientY)
      .data('scrollLeft', this.scrollLeft)
	  .data('scrollTop', this.scrollTop);
	  if (($('.inner').width()<=680)&&($('.inner').height()<=375)) $(this).data('down', false);
    // вернуть false, чтобы избежать выделение текста и перетаскивания ссылок внутри окна прокрутки
    return false;
  })
  .mouseup(function (event) {
    // Когда мышь отжата (mouse up), «выключить» индикатор down
    $(this).data('down', false);
	$("#outer").css({'cursor' : 'url(/bitrix/templates/main/img/grab.cur), default'});
  })
  .mousemove(function (event) {
	// если мышь нажата – начать эффект перетаскивания (drag)
    if ($(this).data('down') == true) {
      //this.scrollLeft // - это scrollbar, появившийся из-за слишком большого контента (overflowing content)
      // Новая позиция высчитывается по формуле: начальная позиция скролла + начальная X-координата нажатой мышки – новая X-координата
      this.scrollLeft = $(this).data('scrollLeft') + $(this).data('x') - event.clientX;
	  this.scrollTop = $(this).data('scrollTop') + $(this).data('y') - event.clientY;
	  //Если положения мышки по x равна разници ширины между inner и oter то скрываем стрелку в лево
	  if(this.scrollLeft == maxwid ) $("#strelka-right").hide();
	  
	  //Если положения мышки по y равна разници высоты между inner и oter то скрываем стрелку в в низ
	  if(this.scrollTop == maxhei ) $("#strelka-bottom").hide();
	  
	  //Если положения мышки по y равна 0 то показывем стрелку в в низ
	  if(this.scrollTop == 0 ) $("#strelka-bottom").show();
	  
	  //Если положения мышки по y равна разници высоты между inner и oter то показывем стрелку в верх
	  if(this.scrollTop == maxhei ) $("#strelka-top").show();
	  
	  //Если положения мышки по y равна 0 то скрываем стрелку в верх
	  if(this.scrollTop == 0 ) $("#strelka-top").hide();
	  
	  //Если положения мышки по x равна 0 то скрываем стрелку в лево
	  if(this.scrollLeft == 0 ) $("#strelka-left").hide();
	  
	  //Если положения мышки по X равна 0 то показываем стрелку в право
	  if(this.scrollLeft == 0 )	$("#strelka-right").show();
	  
	  //Если кордината по X меньше 0 и небольше разници ширины между inner и oter показываем обе стрелки
	  if(this.scrollLeft>0 && this.scrollLeft<maxwid) {
		$("#strelka-right").show();
		$("#strelka-left").show();
	  }
	  //Если кордината по y меньше 0 и небольше разници высоты между inner и oter показываем обе стрелки
	  if(this.scrollTop > 0 && this.scrollTop < maxhei) {
		$("#strelka-top").show();
		$("#strelka-bottom").show();
	  }
	  if($(".inner").width() == 680) { $("#strelka-right").hide(); $("#strelka-bottom").hide();}
    }
  })
	.mousedown(function (event) {//если мышка нажата то меняем курсор
     $("#outer").css({'cursor' : 'url(/bitrix/templates/main/img/grabber.cur), move'});
  })
	.css({
    'overflow' : 'hidden', // изменить на hidden для пользователей с поддержкой JS -moz-grabbing 
    'cursor' : 'url(/bitrix/templates/main/img/grab.cur), move' // добавить курсор с изображением лапки
  });
});

// И наконец, вызываем событие, если мышка вышла за пределы прокручиваемой области
// Мы не вызываем событие mouse up (так как мышь все еще нажата)
$(window).mouseout(function (event) {
  if ($('#outer').data('down')) {
    try {
      // *try* (попробовать) вычислить элемент, на который перешла мышка после того,
      //как покинула область
      // и если мы мы действительно вышли за пределы этой области,
      //то отключаем индикатор события mouse down
      if (event.originalTarget.nodeName == 'BODY' || event.originalTarget.nodeName == 'HTML' || event.originalTarget.nodeName == 'DIV#wrapper') {
        $('#outer').data('down', false);
      }
    } catch (e) {}
  }
});

$(document).ready(function()
{
		
	var status = $("#form-operator-status").html();
	$("#form-header").html(status);
	
});
$(document).ready(function(){
var whois = $("#out_onc #SITEHELP_CONTAINER_527 img" ).attr("src");
var thy = whois.substr(-7);

var itog = "/img/online" + thy; 
$("#out_onc #SITEHELP_CONTAINER_527 img" ).attr("src", itog);
});

