var webtype = "";	
var uid = "";
var order = "";
var page = "";
var order_min = 0;
var order_max = 0;
var widJump = 0;
var writer = "";
var cartoon_img_path = "http://isplus.joins.com/enter/cartoon/org_cartoon";

var cid = "";
var idx = "";

function getValue() {
	var currenturl = unescape(location.href);
	var parameters = (currenturl.slice(currenturl.indexOf('?')+1,currenturl.length)).split('&');

	for (var i = 0 ; i<parameters.length ; i++) {
		var varName = parameters[i].split('=')[0].toLowerCase();
		var val = parameters[i].split('=')[1];
		if (varName=="webtype") webtype = parseInt(val);
		else if (varName=="uid") uid = parseInt(val);		
		else if (varName=="order") order = parseInt(val);
		else if (varName=="page") page = parseInt(val);
		else if (varName=="writer") writer = parseInt(val);
		else if (varName=="cid") cid = parseInt(val);
		else if (varName=="idx") idx = parseInt(val);
	} 

	if (page=="") page = 1;
	//alert("webtype=" + webtype + ", order=" + order + ", page=" + page);
}

function chkLogin() {
	if (tmp_login_userID==null) {
		alert("·Î±×ÀÎÀÌ ÇÊ¿äÇÕ´Ï´Ù.");
		top.location.href="http://login.joins.com/login_isplus.asp?TargetURL=" + escape(top.document.location.toString());
	}
}


function delComments(idx) {
	var f = document.fCom;

	f.mode.value = "DEL";
	f.idx.value = idx;
	f.submit();
}


function goQuotes(mode, idx) {
	var f = document.fQuo;

	f.mode.value = mode;
	f.idx.value = idx;
	f.submit();
}


function goIndex() {
	top.document.location.href = "cartoon_xml.asp?idx=" + cid;
}


function goPrev(type) {
	if (page==1) alert("Ã¹ÆäÀÌÁö ÀÔ´Ï´Ù.");
	else {
		page = parseInt(page) - 2;	
		if (type=="pop") document.location.href = "cartoon_viewer_xml_popup.asp?page=" + page + "&idx=" + idx + "&cid=" + cid;
		else {
			//document.location.href = "cartoon_viewer_xml.asp?page=" + (page-1) + "&idx=" + idx + "&cid=" + cid;
			document.getElementById("viewer_image").src = "cartoon_viewer_image.asp?title=" + title + "&cid=" + cid + "&idx=" + idx + "&page=" + page;
		}
	}
}


function goNext(type) {	
	if (document.getElementById("leftImg").src == document.getElementById("rightImg").src) {
		if (idx<seq) {
			var ans = confirm("¸¶Áö¸·ÆäÀÌÁö ÀÔ´Ï´Ù.\n´ÙÀ½È¸Â÷·Î ÀÌµ¿ÇÏ½Ã°Ú½À´Ï±î?");
			if (ans) {
				idx++;
				if (type=="pop") document.location.href = "cartoon_viewer_xml_popup.asp?idx=" + idx + "&cid=" + cid;
				else document.location.href = "cartoon_viewer_xml.asp?idx=" + idx + "&cid=" + cid;
			}
		} else {
			alert("¸¶Áö¸·È¸Â÷ ÀÔ´Ï´Ù.");
		}
	} else {
		page = parseInt(page) + 2;
		if (type=="pop") document.location.href = "cartoon_viewer_xml_popup.asp?page=" + page + "&idx=" + idx + "&cid=" + cid;
		else {
			//document.location.href = "cartoon_viewer_xml.asp?page=" + (page+1) + "&idx=" + idx + "&cid=" + cid;
			
			url = "cartoon_viewer_image.asp?title=" + title + "&cid=" + cid + "&idx=" + idx + "&page=" + page;
			document.getElementById("viewer_image").src = url;
		}
	}
}


function freePage(type, n1) {
	if ((n1 % 2)==0) n1 = n1 - 1;
	page = n1;	

	if (type=="pop") {
		document.location.href = "cartoon_viewer_xml_popup.asp?page=" + n1 + "&idx=" + idx + "&cid=" + cid;
		return false;				
	}
	else {
		//document.location.href = "cartoon_viewer_xml.asp?page=" + n1 + "&idx=" + idx + "&cid=" + cid;
		document.getElementById("viewer_image").src = "cartoon_viewer_image.asp?title=" + title + "&cid=" + cid + "&idx=" + idx + "&page=" + n1;
		return false;
	}
}

function freeVolume(type, n1) {
	if (type=="pop") document.location.href = "cartoon_viewer_xml_popup.asp?idx=" + n1 + "&cid=" + cid;
	else {
		document.location.href = "cartoon_viewer_xml.asp?idx=" + n1 + "&cid=" + cid;
	}
}


function nextNo(type, n1) {
	if (n1!='') {
		if (type=="pop") document.location.href = "cartoon_viewer_xml_popup.asp?idx=" + n1 + "&cid=" + cid;
		else document.location.href = "cartoon_viewer_xml.asp?idx=" + n1 + "&cid=" + cid;
	}
}


function viewPopup() {
	window.open("cartoon_viewer_xml_popup.asp?page=" + page + "&idx=" + idx + "&cid=" + cid, "popup_viewer", "width=980,height=730").focus();
}

function errorcheck(mode) {
	var dPage = "http://enportsimg.joins.com/cartoon/template_bin.gif";
	if (mode=="L") document.getElementById("leftImg").src = dPage;
	else document.getElementById("rightImg").src = dPage;
}

// ¸¸È­¸Þ´º
function changeTbody(no) {
	var mbody = "ÀÏÀÏ¿¬Àç,¹«·á¸¸È­,¾Ö´ÏÅ÷".split(",");
	var cls = "";
	var str = "";
	//alert(mbody[0]);

	for (i=1; i<=3; i++) {
		if (i==1) cls = "lfi";
		else cls = "";
		if (i==no) str += '<li class="' + cls + ' lo">' + mbody[i - 1] + '</li>\n';
		else str += '<li class="' + cls + '"><a href="javascript:changeTbody(' + i + ');">' + mbody[i - 1] + '</a></li>\n';
	}
	//alert(str);
	document.getElementById("ttap").innerHTML = str;
	changeLayer('tbody', 3, no);
}

function goJump(no) {
	//alert("no : " + no);
	for (i=0; i<no; i++)	{
		doScrollerIE('down','view_order', 132.5);
	}	
}