﻿function gray()
{	var left = $("#left");
	var offset = left.offset();
	var g_width = offset.left;
	var g_height = left.height();
	var g_y = offset.top;
	$('#gray').css({ top:g_y+"px", width:g_width+"px", height:g_height+"px" });
	} ;

function resize()
{      
       if ($(window).width()>1000 && $(window).width()<1260) {
               var vid = $(window).width() * 0.7;
       } else {
               if ($(window).width()<1000)  {
                       var vid = 700;
               }
               if ($(window).width()>1260)  {
                       var vid = 800;
               }
       }
       
       if (vid < 800)
       {
               $('.right').css("width",vid);
       } else {
               $('.right').width(800);
       }
       
       if (vid < 700)
       {
               $('.right').width(700);
       }

} ;	


$(document).ready(function()
{
	$('#mask').bgiframe(); 
	
	resize();
	gray();
	$('.home_r').width($('.search_form_hold').width());
	$('#lupa').width($('.search_form_hold').width()-110);
	$(".j_pole").focus(function(e) {
		$(this).val("")});
	
	
	$('#mask').css("opacity","0");	
	$('a[name=modal]').click(function(e) {  
		$('.window').hide();  
        //Cancel the link behavior  
        e.preventDefault();  
        //Get the A tag  
        var id = $(this).attr('href');  
        //Get the screen height and width  
        var maskHeight = $(document).height();  
        var maskWidth = $(window).width();  
      
        //Set height and width to mask to fill up the whole screen  
        $('#mask').css({'width':maskWidth,'height':maskHeight});  
          
        //transition effect       
       	$('#mask').show();
		$('#mask').fadeTo('200', 0.7);
      
        //Get the window height and width  
        var winH = $(window).height();  
        var winW = $(window).width();  
                
        //Set the popup window to center  
        $(id).css('top',  winH/2-$(id).height()/2);  
        $(id).css('left', winW/2-$(id).width()/2);  
      
        //transition effect  
        $(id).fadeIn(200);   
      
    });  
      
    //if close button is clicked  
    $('.window .close').click(function (e) {  
        //Cancel the link behavior  
        e.preventDefault();  
        $('#mask, .window').hide();  
    });       
      
    //if mask is clicked  
    /*$('#mask').click(function () {  
        $(this).hide();  
        $('.window').hide();  
    });  */
	
	$(".check").click(function () {
		if ($(this).hasClass("checked")) { 
			$(this).removeClass("checked");
		} else {
			$(this).addClass("checked");
		}
	 });
	
	$(".select").click(function () {
		if ($(this).hasClass("selected") != true) {
			var allRadio = $(".select");
			allRadio.removeClass('selected');
			
			$(this).addClass("selected");
		} else {
			//$(this).removeClass("selected");
		}
	 });
	
	
	$(".delet_a").click(function () {
		if ($(this).parent().parent().hasClass("unselect")) { 
			$(this).parent().parent().removeClass("unselect");
			$(this).html("удалить");
		} else {
			$(this).parent().parent().addClass("unselect");
			$(this).html("вернуть");
		}
	 });
	
});
$(window).resize(function(){
	resize();
	gray();
	$('.home_r').width($('.search_form_hold').width());
	$('#lupa').width($('.search_form_hold').width()-110);
});