<!--
Main = {
	noticeSe: 0,
	snsSe : 0,
	Load : function() {

		//메인 비주얼 슬라이더
		$("#scrollable").jQBanner({
			nWidth:1200,
			nHeight:596,
			nCount: $('#scrollable .main_visual div').length,
			isActType:"left",
			nOrderNo:1,
			isStartAct:"N",
			isStartDelay:"Y",
			nDelay:5000,
			isBtnType:"img",
			isBtnAct : "click"
		});

		//NEWS&NOTICE 이벤트
		var noticeTimer = null;
		$(".layer_news").hover(function() {
			$(this).children(".layer_close").children(".list01").hide();
			$(this).children(".layer_close").children(".layer_open").show(0, function() {
				$(this).children(".news_list").slideDown(100).hover(function() {
					NoticeShow(this);
				}, function() {
					NoticeHide(this);
				});
						
			})
		}, function() {

		}).css({"cursor":"pointer"});

		function NoticeShow(ts) {
			clearTimeout(noticeTimer);
			noticeTimer = null;
		};

		function NoticeHide(ts) {
			if($(ts).css("display") != "none") {
				if(noticeTimer == null) {
					noticeTimer = setTimeout(function() {
						$(ts).slideUp(100, function() {
							$(ts).parent().hide();
							$(ts).parent().parent().children(".list01").show();
							NoticeShow(ts);
						})
					},1000);
				}
			}
		};


		

		//NEWS&NOTICE 이전 다음 버튼 이벤트 
		$(".layer_news .pre_next a").eq(0).click(function() {
			Main.noticeSe = ( (Main.noticeSe ) > 0) ? Main.noticeSe-1 : 0;
			Main.Notice(noticeTimer);
			return false;
		});
		$(".layer_news .pre_next a").eq(1).click(function() {
			var noticeCnt = $(".news_list li").length;
			Main.noticeSe = ( (Main.noticeSe + 1) < noticeCnt) ? Main.noticeSe+1 : Main.noticeSe;
			Main.Notice(noticeTimer);
			return false;		
		});


		
		//하단 쇼룸 보이기/감추기
		var showroomTimer = null;
		$(".layer_showroom").mouseover(function() {
		
			var layer_close = $(this).children(".layer_close");
			if($(layer_close).children(".layer_open").css("display") != 'block') { 
				$(layer_close).children("div").eq(1).slideUp(100);
				$(layer_close).children(".layer_open").slideDown(300, function() {
					
					$(this).hover(function() {
						ShowRoomShow();
					}, function() {
						ShowRoomHide();
					});
								
				});
			}
		}).css("overflow", "hidden");

		$(".layer_showroom ul li a img").hover(function() {
			$(this).attr("src", $(this).attr("src").replace(/_off/g, "_on"));
		}, function() {
			$(this).attr("src", $(this).attr("src").replace(/_on/g, "_off"));
		});		

		function ShowRoomHide() {
			var layer_close = $(".layer_showroom .layer_close");
			if($(layer_close).children("layer_open").css("display") != "none") {
				if(showroomTimer == null) {
					showroomTimer = setTimeout(function() {
						$(layer_close).children(".layer_open").slideUp(100, function() {
							$(layer_close).children("div").eq(1).slideDown(100);
							ShowRoomShow(layer_close); 
						});
					}, 1000);
				}
			}
		
		};

		function ShowRoomShow(ts) {
			clearTimeout(showroomTimer); 
			showroomTimer = null
		};
		

		//SNS TOTYTA
		$("#main_bottom .sns_toyota .btn_area li a").eq(0).click(function() {
			Main.snsSe = ( (Main.snsSe ) > 0) ? Main.snsSe-1 : 0;
			Main.SNS();
			return false;
		});
		$("#main_bottom .sns_toyota .btn_area li a").eq(1).click(function() {
			var snsCnt = $("#main_bottom .sns_toyota .sns_list li").length;
			Main.snsSe = ( (Main.snsSe + 1) < snsCnt) ? Main.snsSe+1 : Main.snsSe;
			Main.SNS();
			return false;
		});
		

	},

	//NEWS&NOTICE 이전, 다움
	Notice: function(noticeTimer) {
		if(noticeTimer !== null) {
			clearTimeout(noticeTimer); 
			noticeTimer = null
		}
		$(".news_list li").hide(0, function() {
			$(".news_list li").eq(Main.noticeSe).show();
		});
	},

	//배너롤링
	Banner : function(dely, n) {
		var len = $(".left_banner a").length;
		n = (n >= (len - 1)) ? 0 : n + 1 ;
		//배너롤링
		var bannerTimer = setTimeout(function() {
			$(".left_banner a").hide();
			$(".left_banner a").eq(n).show();
			Main.Banner(dely, n);
		}, dely);
	},

	//SNS TOTYTA 이전, 다움
	SNS: function() {
		$("#main_bottom .sns_toyota .sns_list li").hide(0, function() {
			$("#main_bottom .sns_toyota .sns_list li").eq(Main.snsSe).show();
		});
	},
	
	OpenCenter: function(winNM, parm, width, height, scroll, popname, left, top ) {
        var sw = screen.availWidth;
        var sh = screen.availHeight;

        //px = (sw - width) / 2;
        if (left == "right" ) {
			px = (sw - width)
		}
		else {
			px = left;
		}
		//py = (sh - height) / 2;
		py = top;

        var setting = 'top=' + py + ',left=' + px;
        setting += ',width=' + width + ',height=' + height + ',toolbar=0,resizable=no,status=0,scrollbars='+scroll;
        winNM = (parm == '' || parm == null) ? winNM : winNM + '?' + parm;
        var popNM = popname + "_win";
        popNM = window.open(winNM, popname, setting);
        popNM.focus();
    }
}

$(window).load(function() {
	Main.Load();
	Main.Banner(3000, 0);
	cookie_pop = document.cookie;

	/*if (cookie_pop.indexOf("popup=no") < 0){
		Main.OpenCenter("/pop_event_201201.html", "", "437", "700", "yes", "Pop", "0" ,"0")
	}
	
	if (cookie_pop.indexOf("popup2=no") < 0){
		Main.OpenCenter("/pop_event_201112_2.html", "", "420", "730", "no", "Pop2" ,"447" ,"0")
	}*/

	if (cookie_pop.indexOf("popup=no") < 0){
		Main.OpenCenter("/pop_event_20120221_1.html", "", "437", "680", "yes", "Pop", "0" ,"0")
	}
	
	site = Math.round(Math.random()*2);
	
	//alert(site);

	if (site == 1) {
		if (cookie_pop.indexOf("popup3=no") < 0){
			Main.OpenCenter("/pop_event_20120221_2.html", "", "600", "485", "no", "Pop3" ,"right" ,"0")
		}
		else {
			if (cookie_pop.indexOf("popup2=no") < 0){
				Main.OpenCenter("/pop_event_20120220.html", "", "381", "600", "no", "Pop2" ,"right" ,"0")
			}
		}
	}
	else {
		if (cookie_pop.indexOf("popup2=no") < 0){
			Main.OpenCenter("/pop_event_20120220.html", "", "381", "600", "no", "Pop2" ,"right" ,"0")
		}
		else {
			if (cookie_pop.indexOf("popup3=no") < 0){
				Main.OpenCenter("/pop_event_20120221_2.html", "", "600", "485", "no", "Pop3" ,"right" ,"0")
			}
		}
	}

	
	/*if (cookie_pop.indexOf("popup2=no") < 0){
		Main.OpenCenter("/pop_event_20120220.html", "", "381", "600", "no", "Pop2" ,"447" ,"0")
	}*/

});
//-->



