﻿
// JavaScript Document
$(document).ready(function(){
	sh();
	$(window).resize(function () {
		//$('.main_left_right').width(0);
		sh();
	});
});

menu_change = 1;

$(window).scroll(function(){
			
			if($("#cursor").offset().top <= $("#search_clinic_outpading").offset().top){$("#maps_block").css('top', $("#search_clinic_outpading").offset().top);}
			else if($("#cursor").offset().top >= $("#container").offset().top+$("#container").height()-387){a = $("#container").offset().top+$("#container").height()-387; $("#maps_block").css('top', a+'px');}
			else {a = $("#cursor").offset().top; $("#maps_block").css('top', a+'px');}
		})

function sh() {

if($(window).width()-333 >= 616){ $("#maps_block").css('left', $(window).width()-333+'px'); }
else{$("#maps_block").css('left', '667px');}
//$('.maps_tabsle').width($('.search_clinic').width());
}



function showclose_window_newclinic (wind) {
	
	if($("#"+wind).attr("name") == 'true'){
		
		$("#new_clinic").css("top", $('#footer_left_registration').offset().top-$("#new_clinic").height()-70);
		$("#new_clinic").show('slow');
		$("#"+wind).attr("name", "false");
		}
	else {
		$("#new_clinic").hide("slow");
		
		$("#"+wind).attr("name", "true");
		}
	}
	
function showclose_window_remember_pass (wind) {

	if($("#"+wind).attr("name") == 'true'){
		
		$("#remember_pass").css("top", $('#footer_left_remember_pass').offset().top-$("#remember_pass").height());
		$("#remember_pass").show('slow');
		$("#"+wind).attr("name", "false");
		}
	else {
		$("#remember_pass").hide("slow");
		
		$("#"+wind).attr("name", "true");
		}
	}
	
	
	
function main_menu_change (id) {
		$(".left_main_menu_bookmark_active").removeClass("left_main_menu_bookmark_active");
		$("#bookmark_id_"+id).addClass("left_main_menu_bookmark_active");
		
		$('.news_selector a').attr('href',$("#bookmark_id_"+id+" h2").attr('title')).html($("#bookmark_id_"+id+" h2").html());
		$('#menu_news').load(URL+"ajax/content_catalog_news.htm",{'rubric_id':id});
	}
	
function menu_hover (id) {	
	$().mousemove( function(e) {
	   mouseX = e.pageX; 
	   mouseY = e.pageY;
	   	
	 });
	$("#left_main_menu_helpar_"+id).css("top", mouseY-200+'px');
	$("#left_main_menu_helpar_"+id).css("left", mouseX-10+'px');
}
function getElementPosition(elem)
{
	var offsetTrail = elem;
	var offsetLeft = 0;
	var offsetTop = 0;
	while (offsetTrail)
	{
		offsetLeft += offsetTrail.offsetLeft;
		offsetTop += offsetTrail.offsetTop;
		offsetTrail = offsetTrail.offsetParent;
	}
	if (navigator.userAgent.indexOf("Mac") != -1 &&	typeof document.body.leftMargin != "undefined")
	{
		offsetLeft += document.body.leftMargin;
		offsetTop += document.body.topMargin;
	}
	return {left:offsetLeft, top:offsetTop};
}
