/**
 * mplus_mobile_index
 */
var mplus_mobile_index = function(){
	//상속
	mplus_mobile.call(this);
	//super
	var self = this;
	
	//변수
	var $swiperWrapper = $( ".swiper-wrapper" );
	var div = $('<div></div>');
	var a = $('<a></a>');
	
	//index.jsp에 정의한 메뉴 정보를 담은 리스트를 초기화에서 생성자로 사용
	var menuList = menulist;
	var menuContainer = $('.menu-container');
	// test
	/**
	 * 초기화
	 */
	this.init = function(){
		initMenuList();
		initSwipe();
		addEvent();
	};
	/**
	 * 이벤트 등록
	 */
	var addEvent = function(){

	};
	
	// 메뉴 배치
	var initMenuList = function(){
		/*for( var i = 0; i < menulist.length; i++){
			var menu = div.clone().addClass('menu col-xs-6 col-sm-6 col-md-6 pd0');
			var link = a.clone().attr('href', contextPath + menulist[i].accessUriAddr+'?menuId='+menulist[i].menuId)
								.addClass('menu' + menulist[i].menuOrder).text(menulist[i].menuName);
			menu.append(link);
			menuContainer.append(menu);
		}*/
		
		for( var i = 0; i < menuList.length; i++ ){
			 var item = menuList[i];
			
			 var position = div.clone().addClass('menu col-xs-6 col-sm-6 col-sm-2 pd0'),
				 menuLink = a.clone().attr('href', contextPath + menulist[i].accessUriAddr+'?menuId='+menulist[i].menuId)
					/*.addClass('menu' + menulist[i].menuOrder).text(menulist[i].menuName);*/
				 .addClass('menu_' + menulist[i].menuId).text(menulist[i].menuName);

			 position.html( menuLink );
			 //현재 마지막으로 붙어 있는 slide에 메뉴를 붙인다
			 $swiperWrapper.append( position );
		};
	};
	
	/**
	 * swipe 초기화
	 */
	var initSwipe = function(){
		var hash = sessionStorage.getItem("nowMenu");
		if( hash === "" || hash === null || hash === undefined ){
			hash = 0;
		} else {
			hash = parseInt( hash.replace("#menu","") );
		}
		var option = {
				  dots: true,
				  infinite: true,
				  speed: 300,
				  arrows:false,
				  slidesPerRow: 2,
			      slidesToShow: 1,
			      slidesToScroll: 1,
			      initialSlide:hash,
				  rows:3,
				  responsive: [
				    {
				      breakpoint: 1024,
				      settings: {
				    	  rows:2,
				    	  slidesPerRow:2,
					      slidesToShow: 1,
					      slidesToScroll: 1
				      }
				    },
				    {
				      breakpoint: 801,
				      settings: {
						  rows:2,
						slidesPerRow:2,
				        slidesToShow: 1,
				        slidesToScroll: 1
				      }
				    },
				    {
				      breakpoint: 481,
				      settings: {
						rows:2,
						slidesPerRow:2,
				        slidesToShow: 1,
				        slidesToScroll: 1
				      }
				    }
				  ]
			};
		self.swipe( $swiperWrapper, option );
	};
};