
$(document).ready(function(){
    
	$(".rows").hover(function(e) {
	    var parid = '#title'+$(this).attr('id');        
        var ypos = $(this).pagey;
		$(this).find(parid).stop(true, true).animate({opacity: "show", top: ypos}, "slow");	
	   
	}, function() {
	    var parid = '#title'+$(this).attr('id');
        var ypos = $(this).pagey;
		$(this).find(parid).stop(true, true).animate({opacity: "hide"}, "fast");
	});
    

	$(".oldchessa").click(function(e) {
	  var ypos = $(this).pageY;
        var xpos = $(this).pageX;
	//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
		
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);
		
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(".oldchess").css('top', 10);
		$(".oldchess").css('left', 10);
	
		//transition effect
        
		$(".oldchess").fadeIn(2000);
	   });



$(".rows").click(function(e) {
	
	var planid = '#plan'+$(this).attr('id');
    if( $(planid).is(':hidden') ) {
    // код для visible

/*$(".rows").css({'z-index':-1});*/

        var ypos = $(this).pageY;
        var xpos = $(this).pageX;
	//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
		
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);
		
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(planid).css('top', ypos);
		$(planid).css('left', xpos);
	
		//transition effect
        
		$(planid).fadeIn(2000);
        }
	/*
	
	    var planid = '.plan'+$(this).attr('id');
        var ypos = $(this).pagey;
		$(this).find(planid).stop(true, true).animate({opacity: "show", top: ypos}, "slow");	*/
	   
	});
    
$("#mask").click(function() {
		/*$("div").hide();*/
        var planid = '#plan'+$(this).attr('id');
		
	/*	$(".rows").css({'z-index':0});*/
        /*alert($(".rows").css({'z-index':0}))*/
        var tmpz = '.'+$(this).parent('div').attr('class');
		$('#mask').hide();
		$('div.plan').hide();
        $('.oldchess').hide();
        		
	});  
    
 function saveData() {

alert('Данные добавлены.');
      }    
	
	/*
	//if mask is clicked
	$('#mask').click(function () {
		var tmpz = '.'+$(this).parent('div').attr('class');
		alert(tmpz);
		$(this).hide();
		$(tmpz).hide();
	});	*/
});


