//函数区
//作用：算出他们在页面中具体的布局
//box_lm:是ul_lm的父元素的类名，ul_ml是li_lm的父元素的类名，传入该元素的类名
	function seek_position(leiming1,leiming2,leiming3){//1-  最大的box   2- ul  3- li
			var wid_1=$("."+leiming1).width();
			var wid_2=$("."+leiming2).width();
			var wid_3=$("."+leiming3).width();
			var num=parseInt(wid_1/wid_3);
			switch (num) {
				case 1:
					One();
				
				break;
				case 2:
					Two();
				break;
				
				case 3:
					Three();
				break;

				case 4:
					Four();
				break;
				} 
			function Four(){
				var ul_wid=wid_3*num+80;
				$("."+leiming2).css("max-width",ul_wid);
				if($("."+leiming2).width() < ul_wid){
					num--;
					var ul_wid=wid_3*num+60;
					$("."+leiming2).css("max-width",ul_wid);
				}
			}
			function One(){
				var ul_wid=wid_3*num+20;
				$("."+leiming2).css("max-width",ul_wid);   
				if($("."+leiming2).width() < ul_wid){
					num--;
					var ul_wid=wid_3*num+20;
					$("."+leiming2).css("max-width",ul_wid);
				}
			}
			function Two(){
				var ul_wid=wid_3*num+40;
				$("."+leiming2).css("max-width",ul_wid);
				if($("."+leiming2).width() < ul_wid){
					num--;
					var ul_wid=wid_3*num+20;
					$("."+leiming2).css("max-width",ul_wid);
				}
			}
			function Three(){
				var ul_wid=wid_3*num+60;
				$("."+leiming2).css("max-width",ul_wid);
				if($("."+leiming2).width() < ul_wid){
					num--;
					var ul_wid=wid_3*num+40;
					$("."+leiming2).css("max-width",ul_wid);
				}
			} 		
	}
//函数区结束
$(function() {
	//模态框中的相关事件
	$(".ngsty-Iul img").on("click",function(){
		var a_2="<a class='am-icon-close ngjs-a2' href='javascript: void(0)'  onclick='$(this).prev().click();'></a>";
		$(".am-pureview-actions").append(a_2);
		$(".ngjs-a2").addClass("ngph-a1");
		$(".ngjs-a2").prev().addClass("ngph-a2");
	})
	// 图片自适应布局
		seek_position("ngjs-jh","ngjs-yo","ngjs-ms");
    $(window).resize(function() {
		seek_position("ngjs-jh","ngjs-yo","ngjs-ms");
    });


})