
	// 주문하기
function go_product_order(menu_id, order_type) {
  $.ajax({
		async: "false",
		type: "POST",
		url: CON_URL_ORDER+"/order/cart/auth_cart_proc.asp",
		contentType:"application/x-www-form-urlencoded",
		data: {
      "menu_id": menu_id,
      "order_type": order_type
    },
		dataType: "jsonp",
		success: function(data) {
			if (data.result != "SUCCESS") {
				//alert(data.result);
			}

      XLayerLoad('/auth/order_layer.asp?order_type='+order_type,'','',{bgClickClose: false,ltype:"order"});
		},
		error: function(request, error) {
//			alert(request.statusText);
//			alert(request.responseText);
		}
	}); // ajax
}


  var bannerState = "MOVE";
  var noticeState = "MOVE";
  var eventState  = "MOVE";
  $(function(){
     //마이크로 레이어
     //$.lhDialog.Hide();
     //XLayerLoad('/micro.asp');
    //메인이미지 클릭액션
//    $(".mainwrap .mainwp1").hide();
    $(".mainwrap .mainwp2").hide();
    $(".mainwrap .mainwp3").hide();
    $(".mainwrap .mainwp1 .inbt a").eq(0).click(function(){$(".mainwrap .mainwp1").animate({left: '+=100%'},{easing:'easeInOutBack',duration: 1000}).fadeOut(1000);$(".mainwrap .mainwp3").animate({left: '+=100%'},{easing:'easeInOutBack',duration: 1000}).fadeIn(1000);});
    $(".mainwrap .mainwp1 .inbt2 a").eq(0).click(function(){$(".mainwrap .mainwp1").animate({left: '+=100%'},{easing:'easeInOutBack',duration: 1000}).fadeOut(1000);$(".mainwrap .mainwp3").animate({left: '+=100%'},{easing:'easeInOutBack',duration: 1000}).fadeIn(1000);});
    $(".mainwrap .mainwp1 .inbt a").eq(1).click(function(){$(".mainwrap .mainwp1").animate({left: '-=100%'},{easing:'easeInOutBack',duration: 1000}).fadeOut(1000);$(".mainwrap .mainwp2").animate({right: '+=100%'},{easing:'easeInOutBack',duration: 1000}).fadeIn(1000);});

    $(".mainwrap .mainwp2 .inbt a").eq(0).click(function(){$(".mainwrap .mainwp2").animate({right: '-=100%'},{easing:'easeInOutBack',duration: 1000}).fadeOut(1000);$(".mainwrap .mainwp1").animate({left: '+=100%'},{easing:'easeInOutBack',duration: 1000}).fadeIn(1000);});
    $(".mainwrap .mainwp2 .inbt a").eq(1).click(function(){$(".mainwrap .mainwp2").animate({right: '-=100%'},{easing:'easeInOutBack',duration: 1000}).fadeOut(1000);$(".mainwrap .mainwp3").animate({left: '+=100%'},{easing:'easeInOutBack',duration: 1000}).fadeIn(1000);$(".mainwrap .mainwp1").animate({left: '+=200%'},{easing:'easeInOutBack',duration: 1000}).fadeOut(1000);});
    $(".mainwrap .mainwp2 .inbt2 a").eq(0).click(function(){$(".mainwrap .mainwp2").animate({right: '-=100%'},{easing:'easeInOutBack',duration: 1000}).fadeOut(1000);$(".mainwrap .mainwp3").animate({left: '+=100%'},{easing:'easeInOutBack',duration: 1000}).fadeIn(1000);$(".mainwrap .mainwp1").animate({left: '+=200%'},{easing:'easeInOutBack',duration: 1000}).fadeOut(1000);});


    $(".mainwrap .mainwp3 .inbt a").eq(0).click(function(){$(".mainwrap .mainwp3").animate({left: '-=100%'},{easing:'easeInOutBack',duration: 1000}).fadeOut(1000);$(".mainwrap .mainwp2").animate({right: '+=100%'},{easing:'easeInOutBack',duration: 1000}).fadeIn(1000);$(".mainwrap .mainwp1").animate({left: '-=200%'},{easing:'easeInOutBack',duration: 1000}).fadeOut(1000);});
    $(".mainwrap .mainwp3 .inbt a").eq(1).click(function(){$(".mainwrap .mainwp3").animate({left: '-=100%'},{easing:'easeInOutBack',duration: 1000}).fadeOut(1000);$(".mainwrap .mainwp1").animate({left: '-=100%'},{easing:'easeInOutBack',duration: 1000}).fadeIn(1000);});


    $(".mainwrap .mainwp2 .ricte .matabmn a").eq(0).click(function(){  $(".mainwrap .mainwp2 .ricte .twiwp").each(function(){$(this).hide();});$(".mainwrap .mainwp2 .ricte .twiwp").eq(0).show();});
    $(".mainwrap .mainwp2 .ricte .matabmn a").eq(1).click(function(){  $(".mainwrap .mainwp2 .ricte .twiwp").each(function(){$(this).hide();});$(".mainwrap .mainwp2 .ricte .twiwp").eq(1).show();});

    //배너 작동
    var bCnt = $(".mabanwp1 .mactn1").eq(0).find("p a").length;
    var nCnt = 1;
    if(bCnt%2 == 1){
      var mLeft = "161"; //배너가 홀수일때
    }
    else{
      var mLeft = "322"; //배너가 짝수일때
    }
    if (bCnt>2){
      $(".mabanwp1 .mactn1").eq(0).find("a").eq(0).click(
        function(){
          slideBanner(0,bCnt, mLeft);
          $(".mabanwp1 .mactn1").eq(0).find("p").animate({left:"+="+mLeft+"px"},300);

        }
      );
      $(".mabanwp1 .mactn1").eq(0).find("a").eq(1).click(
        function(){
        //오른쪽에서 왼쪽으로 슬라이드
            $(".mabanwp1 .mactn1").eq(0).find("p").animate({left:"-="+mLeft+"px"},300);
            setTimeout("slideBanner(1,"+bCnt+","+mLeft+")",300);
        }
      );
    }
    //배너 자동롤링 & 오버시 정지
    setTimeout("autoRotation()",3000);
    $(".mabanwp1 .mactn1").eq(0).find("a").mouseover(function(){bannerState="STOP";}).mouseleave(function(){bannerState="MOVE";});
    $(".mabanwp1 .mactn1").eq(0).find("p.roll").mouseover(function(){bannerState="STOP";}).mouseleave(function(){bannerState="MOVE";});

    //공지사항&이벤트 로테이션
    setTimeout("viewMainText('noticeData',0)",3000);
    setTimeout("viewMainText('eventData',1)",3000);
    $(".manotevwp dd").eq(0).find("a").attr("href",$("input[name=noticeData]").eq($("input[name=noticeDataCnt]").val()).attr("link"));
    $(".manotevwp dd").eq(0).fadeOut(function(){$(".manotevwp dd").eq(0).find("a").text($("input[name=noticeData]").eq(0).val());}).fadeIn();
    $(".manotevwp dd").eq(0).mouseenter(function(){noticeState="STOP"}).mouseleave(function(){noticeState="MOVE";});
    $(".manotevwp dd").eq(1).find("a").attr("href",$("input[name=eventData]").eq($("input[name=eventDataCnt]").val()).attr("link"));
    $(".manotevwp dd").eq(1).fadeOut(function(){$(".manotevwp dd").eq(1).find("a").text($("input[name=eventData]").eq(0).val());}).fadeIn();
    $(".manotevwp dd").eq(1).mouseenter(function(){eventState="STOP"}).mouseleave(function(){eventState="MOVE";});



    //메인 피자 애니메이션
    $(".mainwp1 .mapizza.mapizzabg p.mpmimg").hide().first().show();
    $(".mainwp1 .mapizza dl dt").hide().first().show();
    setTimeout("mainAnimate(0)",2000);

    //이벤트 애니매이션
    $(".mainwp3 li img").click(
      function(){
        if($(".mainwp3 li img").length==2)
        {
          ebMinWidth = "150px";
          ebMaxWidth = "576px";
          ebHeight = "337px";
        }
        else if($(".mainwp3 li img").length==3)
        {
          ebMinWidth = "157px";
          ebMaxWidth = "420px";
          ebHeight = "338px";
        }

        if($(this).css("width")==ebMaxWidth){
        }
        else{
          $(".mainwp3 ul li img").each(function(){if($(this).attr("src").indexOf("_on.jpg")!=-1){
              $(this).animate({width:ebMinWidth,height:ebHeight},250).replaceImage("_on.jpg","_off.jpg");
              $(this).attr("usemap","");
              $(this).css({"cursor":"pointer"});
          }});
					//$(this).replaceImage("_off.jpg","_on.jpg").animate({width:ebMaxWidth,height:ebHeight},250);
          $(this).animate({width:ebMaxWidth,height:ebHeight},250).replaceImage("_off.jpg","_on.jpg");
          $(this).attr("usemap","#mevt2_"+($(".mainwp3 ul li img").index($(this))+1)+"_on");
          $(this).css({"cursor":""});
        }
      }
    );
		
		//닫기버튼 이벤트
		$("area#eventClose1").click(function(){
			$(".mainwp3 li img").eq(1).click();
		});

		$("area#eventClose2").click(function(){
			$(".mainwp3 li img").eq(2).click();
		});

		$("area#eventClose3").click(function(){
			$(".mainwp3 li img").eq(0).click();
		});
  });


  function autoRotation(){
    if(bannerState=="MOVE"){
      $(".mabanwp1 .mactn1").eq(0).find("a").eq(1).click();
    }
    setTimeout("autoRotation()",3000);
  }
  function imgOnOff(This) {
    $("." + This.className).each(function() { $(this).attr("src", $(this).attr("src").replace("on.gif", ".gif")); });
    $(This).attr("src", $(This).attr("src").replace(".gif", "on.gif"));
  }
  function slideBanner(val, bCnt,mLeft){
    if (val){
      //오른쪽에서 왼쪽으로 슬라이드
      bTag = "<span>"+$(".mabanwp1 .mactn1").eq(0).find("p span").eq(0).html()+"</span>";
      if(bCnt%2==0){bTag += "<span>"+$(".mabanwp1 .mactn1").eq(0).find("p span").eq(1).html()+"</span>";}
      $(".mabanwp1 .mactn1").eq(0).find("p").append(bTag);
      $(".mabanwp1 .mactn1").eq(0).find("p span").eq(0).remove();
      if(bCnt%2==0){$(".mabanwp1 .mactn1").eq(0).find("p span").eq(0).remove();}
      $(".mabanwp1 .mactn1").eq(0).find("p").animate({left:"+="+mLeft+"px"},0);
    }
    else{
      bTag = "<span>"+$(".mabanwp1 .mactn1").eq(0).find("p span").eq(bCnt-1).html()+"</span>";;
      if(bCnt%2==0){bTag = "<span>"+$(".mabanwp1 .mactn1").eq(0).find("p span").eq(bCnt-2).html()+"</span>" + bTag;}
      $(".mabanwp1 .mactn1").eq(0).find("p span").eq(0).before(bTag);
      $(".mabanwp1 .mactn1").eq(0).find("p span").eq(bCnt).remove();
      if(bCnt%2==0){$(".mabanwp1 .mactn1").eq(0).find("p span").eq(bCnt).remove();}
      $(".mabanwp1 .mactn1").eq(0).find("p").animate({left:"-="+mLeft+"px"},0);
    //메인 피자 애니메이션
    $(".mainwp1 .mapizza.mapizzabg p.mpmimg").hide().first().show();
    $(".mainwp1 .mapizza dl dt").hide().first().show();
    }

  }

//공지사항 이벤트 뷰
  function viewMainText(iname,v){
    var viewMainState;
    if(v==0){viewMainState=noticeState;}else if(v==1){viewMainState=eventState;}
    if(viewMainState=="MOVE"){
      $("input[name="+iname+"Cnt]").val(parseInt($("input[name="+iname+"Cnt]").val())+1);
      $(".manotevwp dd").eq(v).fadeOut(function(){$(".manotevwp dd").eq(v).find("a").text($("input[name="+iname+"]").eq($("input[name="+iname+"Cnt]").val()).val());}).fadeIn();
      $(".manotevwp dd").eq(v).find("a").attr("href",$("input[name="+iname+"]").eq($("input[name="+iname+"Cnt]").val()).attr("link"));
      if($("input[name="+iname+"]").length == $("input[name="+iname+"Cnt]").val() ){ $("input[name="+iname+"Cnt]").val(0);}
    }
    setTimeout("viewMainText('"+iname+"',"+v+")",3000);
  }

  //피자 링크 코드
  var pizzaLinkCode = [];
  pizzaLinkCode[0] = "/menu/premium_view.asp?menu=premium&menu_id=0101010500";
  pizzaLinkCode[1] = "/menu/new.asp";
  //메인 피자 애니매이션
  function mainAnimate(val){
    var pimgCnt = $(".mapizza.mapizzabg p.mpmimg").length;
    var ptimgCnt = $(".mapizza.mapizzabg dl dt").length;
    if(pimgCnt>val+1){
      $(".mainwp1 .mapizza.mapizzabg p.mpmimg").eq(val).fadeOut(500,function(){$(".mainwp1 .mapizza.mapizzabg p.mpmimg").next().fadeIn(500);});
      $(".mainwp1 .mapizza dl dt").eq(val).fadeOut(500,function(){$(".mainwp1 .mapizza dl dt").next().fadeIn(500);});
      $(".mapizza.mapizzabg dl dd.ct2 a").each(function(){$(this).attr("href",$(this).attr("href").replace(pizzaLinkCode[val],pizzaLinkCode[val+1]));});

//      $(".mapizza.mapizzabg dl dd.ct2 a").attr("href",$(this).attr("href").replace(pizzaLinkCode[val],pizzaLinkCode[val+1]));
//      $(".mapizza.mapizzabg dl dd.ct2 a").attr("href",$(".mapizza.mapizzabg dl dd.ct2 a").attr("href").replace(pizzaLinkCode[val],pizzaLinkCode[val+1]));
//      $(".mapizza.mapizzabg dl dd.ct2").next().find("a").attr("href",$(".mapizza.mapizzabg dl dd.ct2").next().find("a").attr("href").replace(pizzaLinkCode[val],pizzaLinkCode[val+1]));

      val = val + 1;
    }else{
      $(".mainwp1 .mapizza.mapizzabg p.mpmimg").eq(val).fadeOut(500,function(){$(".mainwp1 .mapizza.mapizzabg p.mpmimg").first().fadeIn(500);});
      $(".mainwp1 .mapizza dl dt").eq(val).fadeOut(500,function(){$(".mainwp1 .mapizza dl dt").first().fadeIn(500);});
      $(".mapizza.mapizzabg dl dd.ct2 a").each(function(){$(this).attr("href",$(this).attr("href").replace(pizzaLinkCode[val],pizzaLinkCode[0]));});
//      $(".mapizza.mapizzabg dl dd.ct2 a").attr("href",$(this).attr("href").replace(pizzaLinkCode[val],pizzaLinkCode[0]));
//      $(".mapizza.mapizzabg dl dd.ct2 a").attr("href",$(".mapizza.mapizzabg dl dd.ct2 a").attr("href").replace(pizzaLinkCode[val],pizzaLinkCode[0]));
//      $(".mapizza.mapizzabg dl dd.ct2").next().find("a").attr("href",$(".mapizza.mapizzabg dl dd.ct2").next().find("a").attr("href").replace(pizzaLinkCode[val],pizzaLinkCode[0]));

      val = 0;
    }

    setTimeout("mainAnimate("+val+")",4000);
  }


