
$(document).ready(function(){	
	catalog_menu();
	basket_link();
	input_mask();
	popup();
	subscribe();
	video();
	comments();
	hovers();
	if($(".slideshow").length) slideshow();
	pictures();
	$.updnWatermark.attachAll();
});

$(window).resize(function(){	
});

function catalog_menu(){
		$(".catalog_menu li").hover(function(){
				$(this).toggleClass("hover");
			},function(){
				$(this).removeClass("hover");				
			});
		$(".catalog_menu .item,.catalog_menu .preview").click(function(){ 
			href = $(this).parents("li").find(".item a").attr('href');
			if(href) window.location = href;
		});		
	}
function basket_link(){
		if($(".basket_line .title a").length&&$(".basket_line .title a").attr('href')){
				$(".basket_line").css('cursor','pointer');
				$(".basket_line").click(function(){
						href = $(".basket_line .title a").attr('href');
						window.location = href;												 
					});
			}
	}
function slideshow(){ 
		$('.slideshow .s_pictures').cycle({
			fx:'fade', 
			speed:'slow',
			timeout: 6000, 
			delay: -1000,
			next:'.next', 
			prev:'.prev' 
		});
	} 
function popup(){
		$(".call a").click(function(){
				ShowPopup($(".l_call"));
				return false;
			});
	 	$(".layer .popup .close").click(function(){
				PopupClose($(this).parents('.layer'));
			});	
		if($(".layer.l_call .popup .errortext").length||$(".layer.l_call .popup .success").length) {
				ShowPopup($(".l_call"));				
			}
		$(".v_photo .name a").click(function(){
			$(this).parents(".v_photo").find(".preview a").click();
			return false;
		});
	}
function PopupClose(layer){
		if($.browser.msie) $(layer).css("display","none");			
		else $(layer).fadeOut("2000");
	}
function ShowPopup(layer){
		w = $(document).width();
		h = $(document).height();
		$(".layer").css("height",h+"px");
		s_t = $(window).scrollTop();
		if(s_t) $(".layer .layertab").css('margin-top',s_t+'px');
		$(".layer .layertab").css('height',$(window).height()+'px');
		
		if($.browser.msie) $(layer).css("display","block");			
		else $(layer).fadeIn("2000");
	}	
function video(){
		$(".video.v_file a").click(function(){
				cls = $(this).parents(".video").attr("class");
				if(cls.indexOf('v_active')==-1){
					$(".video_detail .player").html(' ');
					video = $(this).parents(".video").find(".video_player").html();
					//alert(video);
					$(".video.v_active").removeClass("v_active");					
					$(this).parents(".video").addClass("v_active");					
					$(".video_detail").html(video);	
				}
				return false;
			});
	}
function comments(){
		$(".review_form .f_title a").click(function(){
				$(this).parents(".review_form").toggleClass("r_show");
				return false;										
			});
	}
function input_mask(){
	$("#input_phone").mask("9 (999) 999-9999");
}
function hovers(){
		$(".gallery img").hover(function(){$(this).addClass('hover');},function(){$(this).removeClass('hover');});
		$(".video .preview,.video .name a").hover(function(){$(this).parents('.video').addClass('hover');},function(){$(this).parents('.video').removeClass('hover');});
		$("#asd_share_buttons a").hover(function(){$(this).addClass('ihov');},function(){$(this).removeClass('ihov');});
	}
function subscribe(){
		$(".subscribe .submit").click(function(){
				email = $(this).parents(".subscribe").find(".input input").val();
				//alert(email);
				url = '/include/add_suscribe.php';
				$.get(url,{email:email}, function(data){
						if(data) {$(".subscribe .message").html(data);$(".subscribe .message").css('display','block');}
						else {$(".subscribe .message").css('display','none');$(".subscribe .message").html('');}
					});	
			});
}
function pictures(){
	if($(".contentdiv img[align=left]").length) $(".contentdiv img[align=left]").addClass('pic_l');
	if($(".contentdiv img[align=right]").length) $(".contentdiv img[align=right]").addClass('pic_r');
 }	
