this.showTt = function(){
/* CONFIG */

 xOffset = -10;
 yOffset = 5;

 // these 2 variable determine popup's distance from the cursor
 // you might want to adjust to get the right result

 /* END CONFIG */
 $("td.course").hover(function(e){
 c_date = this.title;
 $("#course_"+c_date).show();
 $("#course_"+c_date)
 .css("top",(e.pageY - xOffset) + "px")
 //.css("left",(e.pageX + yOffset) + "px")
 .css("right", "0px")
 .fadeIn("fast");
 },
 function(){
 $("#course_"+c_date).hide();
 });
 $("td.course").mousemove(function(e){
 c_date = this.title;
 $("#course_"+c_date)
 .css("top",(e.pageY - xOffset) + "px")
 //.css("left",(e.pageX + yOffset) + "px");
  .css("right", "0px")
 });
};

$(function() {
		$( "#dialog-modal" ).dialog({
			autoOpen: false,
			show: "blind",
			height: 550,
			width:810,
			modal: true,
			close: function(event, ui) {stepsClose();}
		});
	});

// starting the script on page load
$(document).ready(function(){
 showTt();
});

function getMonth(month, year)
{
	jsAjaxUtil.InsertDataToNode('/content/ajax_new.php?month='+month+'&year='+year+'&ajax=Y', 'cal', true);
}

function stepsClose()
{
	$("#dialog-modal-steps").hide(500);
        var pat = window.location.href;
        reg = /\?+/;
        if(reg.test(pat))
        {
               window.location.href = pat+"&dc=Y";
        }
        else
        {
                window.location.href = pat+"?dc=Y";
        }
}

function openMaster()
{
	$( "#dialog-modal" ).dialog( "open" );
	$( "#dialog-modal" ).dialog("option", "resizable", false);
	$("#dialog-modal-steps").show(500);
	hw = findDimensions();
	h = hw[0];
	w = hw[1];
	t = (h*1-520)/2;
	l = (w*1-720)/2;
	dialog_steps_top = 520 + t + 7;
	dialog_steps_left = l;
	$("#dialog-modal-steps").css("top", dialog_steps_top);
	$("#dialog-modal-steps").css("left", dialog_steps_left);
	
			return false;
}

/* определение размеров открытого окна браузера*/
function findDimensions(){
var width = 0, height = 0; // переменные с шириной и высотой окна
if(window.innerWidth){ // если браузер поддерживает метод window.innerWidth
width = window.innerWidth; // присвоить ширину методом window.innerWidth
height = window.innerHeight; // присвоить высоту методом window.innerWidth
} // иначе если браузер не поддерживает метод window.innerWidth,
else if(document.body && document.body.clientWidth){ // то если браузер поддерживает объект document.body и метод .clientWidth
width = document.body.clientWidth; // присвоить ширину методом document.body.clientWidth
height = document.body.clientHeight; // присвоить высоту методом document.body.clientWidth
}
if(document.documentElement && document.documentElement.clientWidth){ // если поддерживает метод document.documentElement.clientWidth
width = document.documentElement.clientWidth; // присвоить ширину методом document.documentElement.clientWidth
height = document.documentElement.clientHeight; // присвоить высоту методом document.documentElement.clientWidth
hw = new Array();
hw[0] = height;
hw[1] = width;
return hw;
}
}



function getTooltip(c_date)
{
$("#course_"+c_date).hide();
 $("#course_"+c_date).show();
 $("#course_"+c_date)
 //.css("left",(e.pageX + yOffset) + "px")
 .css("right", "0px")
}

function hideTooltip(c_date)
{
$("#course_"+c_date).hide();
}

function smallMasterClose()
{
	$("#master_small").fadeOut(100);
        var pat = window.location.href;
        reg = /\?+/;
        set_cookie('master_small', '0', '/');
        window.location.href = pat;
        /*if(reg.test(pat))
        {
               window.location.href = pat+"&dc=Y";
        }
        else
        {
                window.location.href = pat+"?dc=Y";
        }*/
}

function MasterOpen()
{
	$("#master_small").fadeOut(100);
	set_cookie('master_small', '0', '/');
	openMaster();
}

function smallMasterOpen(str)
{
	set_cookie('master_small', str, '/');
	$("#master_small").show(100);
}



function set_cookie (name, value, path, expires_year, expires_month, expires_day, domain, secure)
{
	var cookie_string = name + "=" + escape (value);
	if (expires_year)
	{
		var expires = new Date (expires_year, expires_month, expires_day);
		cookie_string += "; expires=" + expires.toGMTString();
	}
 
	if (path)
	{
		cookie_string += "; path=" + escape(path);
	}
 
	if (domain)
	{
		cookie_string += "; domain=" + escape(domain);
	}
	if (secure)
	{
		cookie_string += "; secure";
	}
	document.cookie = cookie_string;
}
 
function delete_cookie (cookie_name)
{
	var cookie_date = new Date (); 
	cookie_date.setTime (cookie_date.getTime() - 1);
	document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}
 
function get_cookie (cookie_name)
{
	if (document.cookie)
		alert(document.cookie);
	else
		alert("Не удалось получить cookies");
}
