var slideList = function(list, size, view, idx, dir, auto) {
	var dir = (dir == "vertical") ? 0 : 1 || 1;
	var wrap = $(list).parent().parent();
	var totalCnt = $(list).find("li").length;
	$.slideListCount = new Array(idx);
	for(var i = 0; i < $.slideListCount.length; ++i ) { $.slideListCount[i] = 0; }
	
	if (view >= totalCnt) { wrap.find("> a").hide(); }
	
	var setMove='';
	var t=true;
	var move = function(obj) {
		if ($(obj).hasClass("prev") || t == false) {
			if ($.slideListCount[idx - 1] > 0) {
				--$.slideListCount[idx - 1];
				if (dir) {
					$(list).animate({left : "+=" + size + "px"}, 250);
					$(obj).find("a.next").css({"background-position":"-491px -142px","cursor":"pointer"})
					if ($.slideListCount[idx - 1] == 0) {
						$(obj).parent().find(".prev").css({"background-position":"-481px -203px", "cursor":"default"});
					}
				} else {
					$(list).animate({top : "+=" + size + "px"}, 250);
						$(obj).find("a.next").css("background-position", "-501px -216px")
					if ($.slideListCount[idx - 1] == 0) {
						$(obj).css({"background-position":"-524px -204px", "cursor":"default"});
					}
				} 
			}else {
				if(String(obj).indexOf("#") == -1) {
					t=true;
					clearInterval(setMove);
					setMove = setInterval(move, 1500);
					$(obj).find("a.prev").css({"background-position":"-481px -204px","cursor":"default"})
					$(obj).find("a.next").css({"background-position":"-491px -142px","cursor":"pointer"})
				}else {clearInterval(setMove);}
			} 
		}else {
			if (view + $.slideListCount[idx - 1] < totalCnt) {
				++$.slideListCount[idx - 1];
				if (dir) {
					$(list).animate({left : "-=" + size + "px"}, 250);
					$(obj).find("a.prev").css({"background-position":"-481px -142px","cursor":"pointer"})
					if (view + $.slideListCount[idx - 1] == totalCnt) {
						$(obj).parent().find(".next").css({"background-position":"-491px -203px", "cursor":"default"});
					}
				} else { 
					$(list).animate({top : "-=" + size + "px"}, 250);
					$(obj).find("a.prev").css({"background-position":"-501px -204px","cursor":"pointer"})
					if (view + $.slideListCount[idx - 1] == totalCnt) {
						$(obj).css({"background-position":"-524px -216px", "cursor":"default"});
					}
				}
			}else {
				if(String(obj).indexOf("#") == -1) {
					t=false;
					clearInterval(setMove);
					setMove = setInterval(move, 1500);
					$(obj).find("a.prev").css({"background-position":"-481px -142px","cursor":"pointer"})
					$(obj).find("a.next").css({"background-position":"-491px -204px","cursor":"default"})
				}else {clearInterval(setMove);}
			}
		}
	}
	
	wrap.find("> a").click(function() {
		move(this);
		return false;
	});
	
	if(auto != "false") { 
		setMove = setInterval(move, 1500); 
		
		wrap.find("> a").mouseover(function() {
			clearInterval(setMove);
		});
		wrap.find("> a").mouseout(function() {
			setMove = setInterval(move, 1500);
		});
		$(list).mouseover(function() {
			clearInterval(setMove);
		});
		$(list).mouseout(function() {
			setMove = setInterval(move, 1500);
		});
	}
};

var makeComma = function(num) {
	var cNum = num.toString().split(",").join(""); 
	var cArr = cNum.split("."); 
	var cInt = parseInt(cArr[0]).toString(); 
	var cFloat = cArr[1]; 
	var cCom = ""; 
	for (var i = 0; i < cInt.length; ++i) {
		if (i > 0 && i % 3 == 0) { cCom = "," + cCom; }
		cCom = cInt.charAt(cInt.length - i - 1) + cCom; 
	}
	if (typeof cFloat == "string") { cCom += "." + cFloat; }
	return cCom; 
};

var buyTicket = function(url) {
	window.open(url, 'settlement', 'width=790, height=560 ,left=0 ,top=0 ,scrollbars=1');
	return false;
};

function openDaumCash(url) {
    var winFeat = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=275";
    newWin = window.open(url, "bill", winFeat);
    newWin.focus();
}


jQuery(function($) {
	$("#searchForm").submit(function() {
		if ($.trim($("#searchQuery").val()).length > 0){
			return true;
		} else {
			alert('검색어를 입력해주세요.');
			$("#searchQuery")[0].focus();
			return false;
		}
	});
	
	$("#BestAndUpdate > div:first a").click(function() {
		switch ($(this).attr("class")) {
			case "best" : {
				$("#BestAndUpdate div.title").css("background-position", "0 -166px");
				$("#BestAndUpdate ul.update").hide();
				$("#BestAndUpdate div.best").show();
				break;
			}
			case "update" : {
				$("#BestAndUpdate div.title").css("background-position", "0 -193px");
				$("#BestAndUpdate div.best").hide();
				$("#BestAndUpdate ul.update").show();
				break;
			}
		}
		return false;
	});
	$('h1#pointerSett').bind('click',function(){
		opener.location='/notice/view?id=66';
	});
	$('h1#pointerSett').css('cursor','pointer');
});

/// png파일
function setPng24(obj) { 
  obj.width=obj.height=1; 
  obj.className=obj.className.replace(/\bpng24\b/i,''); 
  obj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ obj.src +"',sizingMethod='image');" 
  obj.src='';  
  return ''; 
}
