﻿


/*Details page - change text */

function makeVis(divID) {
	document.getElementById(divID).style.display = "block";
}
function makeHis(divID) {
	document.getElementById(divID).style.display = "none";
}
function image1(){
	document.getElementById('visibleAreaObjectInfo').style.background = "url(/app/view/templates/default/img/infotextbg.jpg) top left no-repeat";
}
function image2(){
	document.getElementById('visibleAreaObjectInfo').style.background = "url(/app/view/templates/default/img/infotextbg_2.jpg) top left no-repeat";
}
function move_up() {
	document.getElementById("DetailContentObjectInfo").scrollTop = 0;
}



/* Details Page - changing images */
function changeImage(newImage) {
  document.im.src = newImage;
}



/*   Detailed Search - JQuery   */



$(function() {
	$('#gallery a').lightBox();
	//$('.flooooorplan a').lightBox();

});



$(document).ready(function() { // Hide the "view" div.


	$('div.view').hide(); // Watch for clicks on the "slide" link.
	$('div.slide').click(function() { // When clicked, toggle the "view" div.
		$('div.view').slideToggle(400); return false;
	});
});

function showContent(page){
	document.getElementById('text-o-bolgarii').style.display = 'none';
	document.getElementById('text-relef').style.display = 'none';
	document.getElementById('text-klimat').style.display = 'none';
	document.getElementById('text-transport').style.display = 'none';
	document.getElementById('text-naselenie').style.display = 'none';
	document.getElementById('text-denugi').style.display = 'none';
	document.getElementById(page).style.display = 'block';
};
function showContentInfo(page){
	document.getElementById('text1').style.display = 'none';
	document.getElementById('text2').style.display = 'none';
	document.getElementById('text3').style.display = 'none';
	document.getElementById('text4').style.display = 'none';
	document.getElementById('text5').style.display = 'none';
	document.getElementById('text6').style.display = 'none';
	document.getElementById('text7').style.display = 'none';
	document.getElementById('text8').style.display = 'none';
	document.getElementById('text9').style.display = 'none';
	document.getElementById(page).style.display = 'block';
};

jQuery(document).ready(function(){
  jQuery(".readFullContent").hide();
  jQuery(".subTitle").click(function(){
	if (jQuery(this).next(".readFullContent").css("display") == "block"){
  			jQuery(this).next(".readFullContent").slideUp();
	  }
	  else {
		  	jQuery(".readFullContent").slideUp();
			$('html, body').animate({ scrollTop: 242 }, 'slow');
			jQuery(this).next(".readFullContent").slideToggle(500);
	  }
  });
});
jQuery(document).ready(function(){
  jQuery(".readFullContent").hide();
  jQuery(".subTitle-Obg").click(function(){
	  if (jQuery(this).next(".readFullContent").css("display") == "block"){
  			jQuery(this).next(".readFullContent").slideUp();
	  }
	  else {
		  	jQuery(".readFullContent").slideUp();
			$('html, body').animate({ scrollTop: 850 }, 'slow');
			jQuery(this).next(".readFullContent").slideToggle(500);
	  }
  });
});
jQuery(document).ready(function(){
  jQuery(".readFullContent").hide();
  jQuery(".subTitle-ObgNS").click(function(){
	  if (jQuery(this).next(".readFullContent").css("display") == "block"){
  			jQuery(this).next(".readFullContent").slideUp();
	  }
	  else {
		  	jQuery(".readFullContent").slideUp();
			//$('html, body').animate({ scrollTop: 850 }, 'slow');
			jQuery(this).next(".readFullContent").slideToggle(500);
	  }
  });
});

var oGall = {
	sCurrentType:'gal-1',
	iCurrentScroll:0,
	changeType:function(iType) {
		var aTabs = [document.getElementById('gal-1'),document.getElementById('gal-2'),document.getElementById('gal-3'),document.getElementById('gal-4'),document.getElementById('gal-5')];
		for (var i=0;i<aTabs.length;i++) {
			var sKey = 'gal-'+iType;
			if (aTabs[i].id == sKey) {
				aTabs[i].style.display = '';
				if (iType < 5) {
					oGall.sCurrentType = sKey;
					var aLinks = aTabs[i].getElementsByTagName('a');
					if (aLinks.length == 0) continue;
					var oLink = aLinks[0];
					if (oLink.innerHTML == '') oLink = aLinks[1];
					oGall.showPic(oLink);
				} else {
					//video
				}
			} else {
				aTabs[i].style.display = 'none';
			}
			aTabs[i].scrollTop = 0;
		}
		oGall.iCurrentScroll = 0;
	},
	showPic:function(oNode) {
		var sPicName = oNode.getElementsByTagName('img')[0].src.split('/').pop();
		var aTmp = document.getElementById('im').src.split('/');
		aTmp.pop();
		aTmp.push(sPicName);
		document.getElementById('im').src = aTmp.join('/');
	},
	showVid:function(oNode) {
		var sVidName = oNode.getElementsByTagName('img')[0].getAttribute('class');
		var sVid = '<object width="552" height="401"><param name="movie" value="http://www.youtube.com/v/'+sVidName+'?fs=1&amp;hl=en_US" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><embed type="application/x-shockwave-flash" width="552" height="401" src="http://www.youtube.com/v/'+sVidName+'?fs=1&amp;hl=en_US" allowscriptaccess="always" allowfullscreen="true"></embed></object>';
		document.getElementById('vid').innerHTML = sVid;
	},
	showPrevious:function(){
		var oInf = oGall.getNodeNumber();
		if (oInf.number == 0) return;//oInf.number = oInf.count;
		var iNumToGo = oInf.number-1;
		if (iNumToGo % 5 == 0) oGall.moveFilmUp();//document.getElementById('navUpBtn').click();
		oGall.showPic(oInf.nodes[iNumToGo]);//oInf.nodes[iNumToGo].click();
	},
	showNext:function(){
		var oInf = oGall.getNodeNumber();
		if (oInf.number == oInf.count-1) return;//oInf.number = -1;
		var iNumToGo = oInf.number+1;
		if (iNumToGo % 5 == 0) oGall.moveFilmDown();//document.getElementById('navDownBtn').click();
		oGall.showPic(oInf.nodes[iNumToGo]);//oInf.nodes[iNumToGo].click();
	},
	getNodeNumber:function(){
		var aImgs = document.getElementById(oGall.sCurrentType).getElementsByTagName('a');

		for (var i=0; i<aImgs.length; ++i) {
			if (aImgs[i].getElementsByTagName('img')[0].src.split('/').pop() == document.getElementById('im').src.split('/').pop()) return {count:aImgs.length,number:i,nodes:aImgs};
		}
	},
	moveFilmUp:function(){
		if (0 >= oGall.iCurrentScroll) {
			oGall.iCurrentScroll = 0;
			return false;
		}
		oGall.iCurrentScroll -=340;
		$('#'+oGall.sCurrentType).animate({scrollTop:oGall.iCurrentScroll},'slow');
		return false;
	},
	moveFilmDown:function(){
		var oDiv = $('#'+oGall.sCurrentType);
		var aChildren = oDiv.children().toArray();
		var iLimit = -340;

		for (var i=0; i<aChildren.length; i++) {
			if (aChildren[i].innerHTML != '') {
				iLimit += 68;
			}
		}

		if (iLimit <= oGall.iCurrentScroll) {
			oGall.iCurrentScroll = iLimit;
			return false;
		}
		oGall.iCurrentScroll +=340;
		oDiv.animate({scrollTop:oGall.iCurrentScroll},'slow');

		return false;
	}
}

jQuery(document).ready(function(){
	jQuery('.showPreviousImage').click(function(){
		oGall.showPrevious();
	});
});

jQuery(document).ready(function(){
	jQuery('.showNextImage').click(function(){
		oGall.showNext();
	});
});

jQuery(document).ready(function(){
	jQuery('#navDownBtn').click(oGall.moveFilmDown);

	jQuery('#navUpBtn').click(oGall.moveFilmUp);
});


jQuery(document).ready(function(){
  //jQuery(".objectPrices").hide();
  jQuery(".button1").click(function(){
	$('html, body').animate({ scrollTop: 1440 }, 'slow');
    //jQuery(".objectPrices").slideToggle(500);
  });
  jQuery(".close_objectPrices").click(function(){
	$('html, body').animate({ scrollTop: 325 }, 'slow');
    //jQuery(".objectPrices").slideUp(500);
  });
  jQuery(".button3").click(function(){
	$('html, body').animate({ scrollTop: 1300 }, 'slow');
    //jQuery(".objectPrices").slideUp(500);
  });
});
jQuery(document).ready(function(){
	$.get('/app/view/templates/default/js/weatherinfo.php', function(data) {
	  $('.weatherinformation').html(data);
	});
	$.get('/app/view/templates/default/js/stats.php', function(data) {
	  //$('.FooterCounters').html(data);
	});
});

jQuery(document).ready(function(){
	jQuery(".button4").click(function(){
		$.get('/blocknot/add/'+document.getElementById('id_development').value,function(oData){
			document.getElementById('blocknotCount').innerHTML = oData;
		});
	});
});

jQuery(document).ready(function(){
	$(".topPhones").change(function () {
          var str = "";
          $("select option:selected").each(function () {
                str += $(this).val();
              });
			  $('#phone10000').css("display","none");
			  $('#phone20000').css("display","none");
			  $('#phone30000').css("display","none");
			  $('#phone40000').css("display","none");
			  $('#phone50000').css("display","none");
			  $('#phone60000').css("display","none");
			  $('#phone70000').css("display","none");
			  $('#phone80000').css("display","none");
			  $('#phone'+str).css("display","block");
			  //alert(str);
          //alert(str);
        })
        .change();

		$(".pricceRange1").click(function(){
			document.forms['pricceRange1'].submit();
		});
		$(".pricceRange2").click(function(){
			document.forms['pricceRange2'].submit();
		});
		$(".pricceRange3").click(function(){
			document.forms['pricceRange3'].submit();
		});
		$(".pricceRange4").click(function(){
			document.forms['pricceRange4'].submit();
		});
		$(".pricceRange5").click(function(){
			document.forms['pricceRange5'].submit();
		});
		$(".pricceRange6").click(function(){
			document.forms['pricceRange6'].submit();
		});
		$(".pricceRange7").click(function(){
			document.forms['pricceRange7'].submit();
		});
		$(".pricceRange8").click(function(){
			document.forms['pricceRange8'].submit();
		});
});

// LEFT FORM





//BLOKNOT SENT MAIL

jQuery(document).ready(function(){
	jQuery(".sendmailbloknot").click(function(){
		if(jQuery("#blocknotCount").html == "0"){
			alert("Нет элементов, добавленных.");
		}
	 //alert(jQuery(".printableArea").html());
	 jQuery(".MailFormBloknot").css("display","block");
	});
	jQuery(".clearAll").click(function(){
	 	$.get('/blocknot/clear',function(oData){
			document.getElementById('blocknotCount').innerHTML = "0";
			location.reload();
        });
	});
});



$(document).ready(function() { 
		var contentHeight = $(".content").css("height");
		var menuHeight = $(".leftMenu").css("height");
		contentHeight = contentHeight.slice(0,-2);
		menuHeight = menuHeight.slice(0,-2);
		Height = contentHeight - menuHeight;
		if (Height > 0) {
			$(".leftMenuSpacer").css("height",Height+"px");
		}
});





