$(window).resize(function(){
		popup();
	});

 $(document).ready(function(){
		$.updnWatermark.attachAll();
		popup();
		menu();
		submenu();
	});

 function menu(){
	 	$(".menu li").hover(function(){
               if ($(this).attr('name')!='selected')
				$(this).toggleClass("mihov");
			},function(){
                if ($(this).attr('name')!='selected')
				$(this).removeClass("mihov");
			});
	 }

 function submenu(){
	 	$(".submenu li").hover(function(){
             if ($(this).attr('name')!='selected')
				$(this).toggleClass("smhov");
			},function(){
                 if ($(this).attr('name')!='selected')
				$(this).removeClass("smhov");
			});
 }

 function popup(){
		if($(".layer").length>0){
			t = ($(window).height()-$(".popup").height())/2;
			w = $(window).width();
			if(w<$(".main").width()) w = $(".main").width();
			$(".popup").css("margin-top",t+"px");
			$(".layer").css("height",$(document).height()+"px");
			$(".layer").css("width",w+"px");

			$(".popup .close").click(function(){
				$(".layer").css("display","none");
					if($.browser.msie&&$.browser.version==6){
					$(".main select").css("display","block");
					}
				});
		}
	 }

 function ShowPhotoDetailPopUp (src,name, id)
 {
 	
 	 var stop = self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
 	
 	 $(".popup").css("margin-top",stop+200+"px");
     
//name
     $('.layer').find('.tit').html(name);
     var prev = '';

     if ($("#spic"+(id-1)).length!=0)
         {
             
             var lsrc = $("#spic"+(id-1)).children('img').attr('src');
             var lname =$("#spic"+(id-1)).attr('name');
             prev += '<td class="prev"><div><a href="javascript:ShowPhotoDetailPopUp(\''+lsrc+'\', \''+lname+'\', '+(id-1)+')"><img height="63" width="52" src="/images/slide_prev.png" alt="Предыдущий" /></a></div></td>';
         }
           var next = '';
     if ($("#spic"+(id+1)).length!=0)
         {
             var rsrc = $("#spic"+(id+1)).children('img').attr('src');
             var rname =$("#spic"+(id+1)).attr('name');
             next += '<td class="next"><div><a href="javascript:ShowPhotoDetailPopUp(\''+rsrc+'\', \''+rname+'\', '+(id+1)+')"><img height="63" width="52" src="/images/slide_next.png" alt="Следующий" /></a></div></td>';
         }
     var photo_content = '<tr>'+
			prev+
			'<td><img width="600" src="'+src+'" alt="" /></td>'+
			next+
		'</tr>';
    $('.puphoto').html(photo_content);
    $(".layer").css("height", $(document).height()+stop+"px");
    $('.layer').show();
 }

