jQuery(document).ready(function(){
	resize_steps();
	jQuery('#termuse').removeAttr('checked');
	
	jQuery(window).resize(function(){
		resize_steps();
	});

    //Пароль
    
    jQuery('.login-popup input.pass2').focusin(function(){
        jQuery(this).hide();
        jQuery(this).parent().find('input.pass').show(1,function(){
            jQuery(this).focus();    
        });
        
    });
    jQuery('.login-popup input.pass').blur(function(){
        if (jQuery(this).val()=="") {
            jQuery(this).hide();
            jQuery(this).parent().find('input.pass2').show();
        }
    });
//Пароль
//Почта
    jQuery('.login-popup input.email').focusin(function(){
        if (jQuery(this).val()=="Логин") {
            jQuery(this).val('');
        }
    });
    jQuery('.login-popup input.email').blur(function(){
        if (jQuery(this).val()=="") {
            jQuery(this).val('Логин');
        }
    });
//forgotpass login
//
    jQuery('.login-popup input.forgotpass_login').focusin(function(){
        if (jQuery(this).val()=="Логин или Email") {
            jQuery(this).val('');
        }
    });
    jQuery('.login-popup input.forgotpass_login').blur(function(){
        if (jQuery(this).val()=="") {
            jQuery(this).val('Логин или Email');
        }
    });
//Почта

//Имя
    jQuery('.register-popup input.name').focusin(function(){
        if (jQuery(this).val()=="Ваш логин") {
            jQuery(this).val('');
        }
    });
    jQuery('.register-popup input.name').blur(function(){
        if (jQuery(this).val()=="") {
            jQuery(this).val('Ваш логин');
        }
    });
//Имя
//Почта
    jQuery('.register-popup input.email').focusin(function(){
        if (jQuery(this).val()=="Электронная почта") {
            jQuery(this).val('');
        }
    });
    jQuery('.register-popup input.email').blur(function(){
        if (jQuery(this).val()=="") {
            jQuery(this).val('Электронная почта');
        }
    });
//Почта
//Пароль
    jQuery('.register-popup input.pass2').focusin(function(){
        jQuery(this).hide();
        jQuery(this).parent().find('input.pass').show().focus();
    });
    jQuery('.register-popup input.pass').blur(function(){
        if (jQuery(this).val()=="") {
            jQuery(this).hide();
            jQuery(this).parent().find('input.pass2').val("Пароль").show();
        }
    });
//Пароль
//Пароль2
    jQuery('.register-popup input.passto2').focusin(function(){
        jQuery(this).hide();
        jQuery(this).parent().find('input.passto').show().focus();
    });
    jQuery('.register-popup input.passto').blur(function(){
        if (jQuery(this).val()=="") {
            jQuery(this).hide();
            jQuery(this).parent().find('input.passto2').val("Пароль еще раз").show();
        }
    });
//Пароль2

jQuery('#show_pass').click(function(){
    jQuery('.register-popup input.pass2').val(jQuery('.register-popup input.pass').val()).show();
    jQuery('.register-popup input.pass').hide();

    jQuery('.register-popup input.passto2').val(jQuery('.register-popup input.passto').val()).show();
    jQuery('.register-popup input.passto').hide();
});
     jQuery('.check').click(function(){
		
        var ckeck = jQuery(this).find('input');
        
        if (!ckeck.attr('checked')) {
            jQuery(this).addClass('checked');
            ckeck.attr('checked',"checked");
        } else {
            jQuery(this).removeClass('checked');
            ckeck.removeAttr('checked');
        }
    });

/*
	jQuery('.enter').click(function(){
        tb_remove();
        setTimeout("tb_show('', '#TB_inline?height=205&width=740&inlineId=win1&modal=true', '')",300);
        return false;
    });
*/ 
    jQuery('.loadlinkvideo, .register, .forgotpass, .manual_popup').click(function(){
        tb_remove();
        var url_ = jQuery(this).attr('href');
        setTimeout("tb_show('', '"+url_+"', '')",300);
        return false;
    });
/*    
    jQuery('.forgotpass').click(function(){
        tb_remove();
        setTimeout("tb_show('', '#TB_inline?height=500&width=1000&inlineId=forgotpass&modal=true', '')",300);
        return false;
    });
*/ 
    
    var count_field  = 0;
    jQuery('.add_field').click(function(){
        count_field++;
        
        if(jQuery(this).attr('id') == 'add_metro' && count_field >= 5)
            return false;
        
        var line = jQuery('.contact_wrap .line:last');
        var item_munber = parseInt(line.find('select').attr('rel'))+1;
        
        var last_z_index = line.find('.jNiceWrapper').css('z-index');
        var clone = line.clone();
        clone.appendTo('.contact_wrap');
        new_line = jQuery('.contact_wrap .line:last');
        new_line.find('select').attr('id','field_type'+item_munber);
        new_line.find('select').attr('rel',item_munber);
        var newSelect = new_line.find('select');

        jQuery.jNice.SelectRemove(newSelect);
        jQuery.jNice.SelectAdd(newSelect);
    
        
        new_line.find('.jNiceWrapper').css('z-index',last_z_index-item_munber);
        
        return false;
    }); 
    
    jQuery('.addField').click(function(){
		var line = jQuery('.contact_wrap .line:last');
		var item_munber = parseInt(line.find('input').attr('rel'))+1;
		var last_z_index = line.find('.jNiceWrapper').css('z-index');
		var clone = line.clone();
		clone.appendTo('.contact_wrap');
		new_line = jQuery('.contact_wrap .line:last');
		new_line.find('input').attr('name','contacts_value[]');
		new_line.find('input').attr('rel',item_munber);
		new_line.find('select').attr('name','type_contacts[]');
		var newSelect = new_line.find('select');

		jQuery.jNice.SelectRemove(newSelect);
		jQuery.jNice.SelectAdd(newSelect);
	
		
		new_line.find('.jNiceWrapper').css('z-index',last_z_index-item_munber);
		
		return false;
	});
    
    
    
    
    
    
    
    
    
});




function resize_steps(){
	if (jQuery(window).width()<1280) {
			var padding_right = 10;
			var padding_top = 0;
	} else {
		var padding_right = 30;
		var padding_top = 16;
		
	}
	
	
	jQuery('.number_1').css("padding-right",padding_right+"px");
	jQuery('.number_2').css("padding-right",padding_right+"px");
	jQuery('.number_3').css("padding-right",padding_right+"px");
	
	jQuery('.number_1').css("padding-top",padding_top+"px");
	jQuery('.number_2').css("padding-top",padding_top+"px");
	jQuery('.number_3').css("padding-top",padding_top+"px");
	
	var container = jQuery('.bluetop_center');
	var socials = jQuery('li.socials');
	var login_btn = jQuery('li.login_btn');
	var width = (container.width() - socials.width() - 121 - login_btn.width())/2 - (130+padding_right);
	jQuery('.number_1').width(width);
	jQuery('.number_2').width(120);
	jQuery('.number_3').width(width);
	
	
	var panel_width = jQuery('.panel-img').width();
	var container_top4 = jQuery('.content_top4');
	var count = Math.floor(container_top4.width() / (panel_width));
	var new_width = count*panel_width + (count-1)*24;
	jQuery('#mygallery').width(new_width);
	jQuery('#mygallery').height(jQuery('.belt').height());
    
	rectangle_resize();
	small_rectangle_resize();
	
	
}

function rectangle_resize() {
	//restaurant_full_info
	//vat parent = jQuery('');

	if (jQuery(window).width()<1265) {
		jQuery('.restaurant_full_info .rectangle:gt(20)').hide();
		jQuery('.restaurant_full_info .rectangle:last').show();
		jQuery('.restaurant_full_info .rectangles').width(144);
		jQuery('.restaurant_full_info').css('padding-left','15px');
		jQuery('.restaurant_full_info .rectangle').css('padding-left','15px');
	} else {
		jQuery('.restaurant_full_info .rectangle:gt(20)').show();
		jQuery('.restaurant_full_info .rectangles').width(288);
		jQuery('.restaurant_full_info').css('padding-left','23px');
		jQuery('.restaurant_full_info .rectangle').css('padding-left','23px');
	}
	
}

function small_rectangle_resize() {
	//restaurant_full_info
	

	if (jQuery(window).width()<1265) {
		jQuery('.want_invte .want_invite_profile:gt(7)').hide();
		jQuery('.want_invte').width(139);
		jQuery('.want_invte .want_invte_title').css('padding-left','12px');
		jQuery('.want_invte .want_invite_profile').css('padding-left','12px');
	} else {
		jQuery('.want_invte .want_invite_profile:gt(7)').show();
		jQuery('.want_invte').width(289);
		jQuery('.want_invte .want_invte_title').css('padding-left','21px');
		jQuery('.want_invte .want_invite_profile').css('padding-left','21px');
	}
	
}





