$(window).resize(function(){
	});

$(document).ready(function(){	
	register_form();
    popup_form()
	catalog_menu();
	delivery();
    hide_block();
	// $.updnWatermark.attachAll();
	menu();
    importprices();
	register();
	product();
	filter_phone();
	/*catalog_sect();*/
 });

function filter_phone() {
	$('input[name=NEW_PERSONAL_PHONE]').change(function() {
		$(this).val($(this).val().replace(/[^0-9]/g, ''));
	})
}

function register_form(){
		$("input.b_register").click(function(){
				$("input.it_login").attr("value",$("input.it_email").val());
			});
	}
function popup_form(){
		$(".popup_link span").click(function(){
			$(".popup_form").toggleClass("pf_show");
		});	
		$(".popup_form .close span").click(function(){
			$(".popup_form").removeClass("pf_show");
		});	
		$(".popup_form .formtab .input_text.required").keyup(function(){
			if($(".popup_form .formtab .input_text.required[value!='']").length!=3) {
					$(".popup_form .button").addClass("disabled");
					$(".popup_form .button").attr("disabled","disabled");
				}
			else {
					$(".popup_form .button").removeClass("disabled");
					$(".popup_form .button").attr("disabled","");									
				}
		})
		$(".popup_form .button[disabled!='disabled']").click(function(){
			$(this).parents(".popup_form").removeClass("pf_show");										
		});	
	}

function product(){
	$(".gallery.gallprod .gpic").hover(function(){												
			src=$(this).find("span").html();
			$(".product .detail_picture img").attr("src",src);
			$(".gallery.gallprod .gpic.act").removeClass("act");
			$(this).toggleClass("act");
		},function(){			
		});
	}

function register(){
	$(".regtable .input_email").change(function(){			
			$(".regtable .input_login").attr("value",$(this).val())
		});
	}

function catalog_menu(){
	/*$(".catalog_menu span.link").click(function(){
		$(this).parent("li").toggleClass("ulshow");
		});*/
		$(".catalog_menu li").hover(function(){
				$(this).toggleClass("cmhov");
			},function(){
				$(this).removeClass("cmhov");
			});
	}
	
 function importprices(){
        $(".import_form .import_file").change(function(){
			fname = $(".import_form .import_file").val();
			$(".import_form").removeClass("if_sucss");
			$(".import_form").removeClass("if_err");
			if(fname.indexOf(".csv")>0) $(".import_form").toggleClass("if_sucss");
			else $(".import_form").toggleClass("if_err");
            });

	}
function menu(){
	$(".menu .mitem").hover(function(){
			$(this).toggleClass("hover");
		},function(){
			$(this).removeClass("hover");
		});	
	}
	
function catalog_sect(){
	$(".catalog_sect .col .sect a").hover(function(){			
			$(this).parents(".sect").css("background-image","url("+$(this).parents(".sect").find(".sect_pic_h").html()+")")
		},function(){
			$(this).parents(".sect").css("background-image","url("+$(this).parents(".sect").find(".sect_pic").html()+")")
		});	
	}		
	
function delivery(){
	$(".hide_tit .ht_pay").click(function(){
			$(".hide_tit .ht_act").removeClass("ht_act");	
			$(this).toggleClass("ht_act");	
			$(".hb_pay").css("display","block");
			$(".hb_deliv").css("display","none");
		});
	$(".hide_tit .ht_deliv").click(function(){
			$(".hide_tit .ht_act").removeClass("ht_act");	
			$(this).toggleClass("ht_act");	
			$(".hb_deliv").css("display","block");
			$(".hb_pay").css("display","none");
		});	
	
	}	
function hide_block(){
	$(".hide_block .link span").click(function(){
			$(this).parents(".hide_block").find(".block").slideToggle('fast')		
		});
}

function show_default_value(el) {
	if ($(el).val() == '' || $(el).val() == $(el).data('default')) {
		$(el).val($(el).data('default'));
		$(el).addClass('default');
	}
}
function hide_default_value(el) {
	if ($(el).val() == $(el).data('default')) {
		$(el).val('');
		$(el).removeClass('default');
	}
}
function init_default_values() {
	$('input[type=text], textarea').each(function() {
		if ($(this).data('default') !== undefined) {
			show_default_value(this);
			$(this).bind({
				focus: function() {hide_default_value(this)},
				blur: function() {show_default_value(this)}
			});
		}
	});
}
function clear_default_values() {
	$('input[type=text], textarea').each(function() {
		hide_default_value(this);
		$(this).unbind('focus');
		$(this).unbind('blur');
	});
}
