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

 $(document).ready(function(){	
		gallery();
		warehousing();
		shops();
		awards();
		popup();		
		rightcol();
	});
 
 
 function gallery(){
	 	$(".pic img.prev").click(function(){
				src = $(this).parents(".pic").find(".picsrc").html();
				descr = $(this).parents(".pic").find(".picdescr").html();				
				h = $(this).parents(".pic").find(".picheight").html();
				w = $(this).parents(".pic").find(".picwidth").html();
				gall_popup(h,w,src,descr);
				/*$(".layer .popup .photo").html("<img height='"+h+"' width='"+w+"' src='"+src+"' alt='"+descr+"' title='"+descr+"' />");
				$(".layer .popup .label").html(descr);
				if(w>300) $(".layer .popup").css("width",w+"px");	*/			
				
			});
	 }
	 
function warehousing(){
	 	$(".warehousing span.link").click(function(){
				//src = $(this).parents(".pic").find(".picsrc").html();
				text = $(this).parents(".warehousing ").find(".text").html();				
				//h = $(this).parents(".pic").find(".picheight").html();
				//w = $(this).parents(".pic").find(".picwidth").html();
				text_popup(text);			
			});
	 }
	 
 function awards(){
	 	$(".award .prev img").click(function(){
				src = $(this).parents(".award").find(".pic_src").html();
				descr = $(this).parents(".award").find(".text_descr").html();				
				h = $(this).parents(".award").find(".pic_height").html();
				w = $(this).parents(".award").find(".pic_width").html();
				gall_popup(h,w,src,descr);
			});
	 }

 function shops(){
	 	$(".shop_list .shop .prev img").click(function(){
				src = $(this).parents(".shop").find(".detail_pic_src").html();
				descr = $(this).parents(".shop").find(".detail_text").html();				
				name = $(this).parents(".shop").find(".detail_name").html();
				h = $(this).parents(".shop").find(".detail_pic_height").html();
				w = $(this).parents(".shop").find(".detail_pic_width").html();
				gall_popup_shops(h,w,src,descr,name);
			});
	 }
	 
 function gall_popup(h,w,src,descr){
	 	$(".layer .popup .photo").html("<img height='"+h+"' width='"+w+"' src='"+src+"' alt='"+descr+"' title='"+descr+"' />");
				$(".layer .popup .label").html(descr);
			if(w>300) $(".layer .popup").css("width",w+"px");	
			popup2();
		 }
		 
 function text_popup(text){
	 	//$(".layer .popup .photo").html("<img height='"+h+"' width='"+w+"' src='"+src+"' alt='"+descr+"' title='"+descr+"' />");
			$(".layer .popup .photo").css("display","none");
                        $(".layer .popup .label").html(text);
			$(".layer .popup").css("width","800px");	
			popup2();
		 }		 
		 
 function gall_popup_shops(h,w,src,descr,name){
	 	$(".layer .popup .photo").html("<img height='"+h+"' width='"+w+"' src='"+src+"' alt='"+name+"' title='"+name+"' />");
				$(".layer .popup .label").html(descr);
			if(w>300) $(".layer .popup").css("width",w+"px");	
			popup2();
		 }		 

 function popup2(){
			w = $(window).width();
			if(w<$(".main").width()) w = $(".main").width();
			h = $(document).height();
			$(".layer").css("height",h+"px");
			$(".layer").css("width",w+"px");			
			if($.browser.msie&&$.browser.version==6) $(".layer").css("display","block");			
			else $(".layer").fadeIn("2000");
		 	t = ($(window).height()-$(".popup").height())/2+$(window).scrollTop();
			if(h<($(".popup").height()+80)) { h=$(".popup").height()+80; $(".layer").css("height",h+"px"); }
			if(t<0) t = 40;						
			$(".popup").css("margin-top",t+"px");			
	 }

 function rightcol(){
		if($(".main .content .rightcol .nopics").length>0) {
				$(".main .content").toggleClass("c2cols");
			}
			else $(".main .content").removeClass("c2cols");
	 }
	 
 function popup(){	
		$(".popup .close img").click(function(){					
				if($.browser.msie&&$.browser.version==6) { $(".layer").css("display","none"); $(".layer .popup .photo").css("display","block");}
				else $(".layer").fadeOut("1000",function(){$(".layer .popup .photo").css("display","block");});
				});
	 } 
  
