var auto_view;
function imgGet(comic_idx,volume_idx,PageNo,pageview) {
var totalpage = $("#totalpage").val();
if(parseInt(totalpage) >= parseInt(PageNo)){
$.ajax({
type : "post",
url : "img_get_prev.asp",
data : {"comic_idx":comic_idx,"volume_idx":volume_idx,"pageNo":PageNo,"pageview":pageview},
dataType : "json",
success : function(oResult){
if (oResult.RESULT =="Y"){
imgShow(oResult);
}else{
alert("다시 접속해 주세요");
location.replace('/comic/detailview_comic.asp?comic_idx='+comic_idx);
}
}
});
}
}
function imgShow(oResult) {
var size = oResult.IMGSET.length;
var pageview = $("#pageview").val();
var PageNo = $("#PageNo").val();
var viewtype = $("#viewtype").val();
if(parseInt(pageview) < 2) {
$("#vtd").addClass("vtd_cls");
$("#imgViewer_"+pageview+"_1").attr("src",oResult.IMGSET[0].VIEWIMG).css('max-height', '830px');
//$("#pageViewer_"+pageview+"_1").text(PageNo);
}else {
$("#vtd").removeClass("vtd_cls");
for (var i = 0; i < size; i++) {
var j = i + 1;
$("#imgViewer_"+viewtype+"_"+j).attr("src",oResult.IMGSET[i].VIEWIMG).css('max-height', '830px');
//$("#pageViewer_"+pageview+"_"+j).text(parseInt(PageNo)+i);
}
}
}
function GoToNext() {
var pageview = $("#pageview").val();
var totalpage = $("#totalpage").val();
var autopvt = $("#autopvt").val();
var PageNo = $("#PageNo").val();
var freetype = $("#freetype").val();
if (PageNo == ""){
alert('페이지 숫자를 입력해 주세요.');
return false;
}
PageNo =parseInt(PageNo);
var next_PageNo;
if(parseInt(pageview) == 1) {
next_PageNo = PageNo + 1;
}else {
next_PageNo = PageNo + 2;
}
if(next_PageNo > totalpage) {
if (freetype == "more"){
if (confirm("맛보기가 끝났습니다.\n계속 보시겠습니까?")){
var comic_idx=$("#comic_idx").val();
location.replace("/viewer2/freecomic.asp?comic_idx="+comic_idx+"&PageNo="+(parseInt(totalpage)+1));
}else{
comic_page_view(totalpage);
}
}else{
$("#divHidden").show();
$("#layer_pop").show();
}
}else {
comic_page_view(next_PageNo);
if(autopvt >0) {
AutoPage();
}
}
}
function GoToPrev() {
var pageview = parseInt($("#pageview").val());
var PageNo = $("#PageNo").val();
if (PageNo == ""){
alert('페이지 숫자를 입력해 주세요.');
return false;
}
PageNo =parseInt(PageNo);
var prev_PageNo;
if(pageview == 1) {
prev_PageNo = PageNo - 1;
} else {
prev_PageNo = PageNo - 2;
}
if(PageNo < 2 ){
alert('첫 페이지 입니다.');
}else{
comic_page_view(prev_PageNo);
}
}
function comic_page_view(PageNo) {
var comic_idx = $("#comic_idx").val();
var totalpage = $("#totalpage").val();
var pageview = $("#pageview").val();
var volume_idx = $("#volume_idx").val();
//var volume_idx = $("#volume_idx option:selected").val();
if (parseInt(PageNo) > parseInt(totalpage)){
PageNo=totalpage;
}
if (parseInt(PageNo) == 0){
PageNo=1;
}
if ((pageview != "1") && (parseInt(PageNo)%2 ==0)){
PageNo = parseInt(PageNo)-1;
}
imgGet(comic_idx,volume_idx,PageNo,pageview);
$("#PageNo").val(PageNo);
}
function AutoPage() {
var autopvt = parseInt($("#autopvt").val()) * 1000;
var tmp = $("#tmp").val();
var totalPage = $("#totalpage").val();
if (totalPage == tmp) { tmp++; }
if (totalPage > tmp) {
if (autopvt > 0) {
clearTimeout(auto_view);
auto_view = setTimeout("GoToNext()", autopvt);
}
}
}
function page_view_num(){
var PageNo = $("#PageNo").val();
var ori_pv = $("#oripageview").val();
var pageview = $("#pageview").val();
var viewtype = $("#viewtype").val();
var width=WINDOW_WH("w");
var height=WINDOW_WH("h");
$("#vtab2").toggle();
$("#vtab1").toggle();
$("#vtit").toggle();
if(parseInt(pageview) > 1) {
var s_width = screen.width;
if(s_width-50 >= width ){
resizeBy(-(width/2), 0);
}
$("#tdsize").css("width","97px");
}else{
resizeBy(width, 0);
$("#tdsize").css("width","290px");
}
$("#div_viewer_1").toggle();
if (parseInt(ori_pv) == 2 && viewtype=="R"){
$("#div_viewer_R").toggle();
}else if(parseInt(ori_pv) == 2 && viewtype=="L"){
$("#div_viewer_L").toggle();
}
if(parseInt(pageview) > 1) {
$("#pageview").val("1");
}else{
$("#pageview").val(ori_pv);
}
comic_page_view(PageNo);
return;
}
function Gosubmit(){
var fm=document.viewer;
fm.PageNo.value="1";
fm.action=pageAction;
fm.submit();
}
function closelayer(){
$("#divHidden").hide();
$("#layer_pop").hide();
}
function BookMark(){
alert("맛보기에서는 책갈피가 지원되지 않습니다.");
}
function fullscr(){
var winLeft = window.screenLeft ? window.screenLeft : window.screenX;
var winTop = window.screenTop ? window.screenTop : window.screenY;
moveTo(0, 0);
var width = screen.width;
var height = screen.height;
var w_width=WINDOW_WH("w");
var w_height=WINDOW_WH("h");
resizeTo(width, height);
$("#full_original").html("
원본보기");
if(parseInt(pageview) > 1) {
$("#onefull_original").html("
");
}else{
$("#onefull_original").html("
");
}
}
function original(w,h,l,t){
var w_width=WINDOW_WH("w");
var w_height=WINDOW_WH("h");
resizeBy(-(w_width-w),-(w_height-h));
moveTo(l,t);
$("#full_original").html("
전체보기");
$("#onefull_original").html("
");
}
function onefullscr(){
var winLeft = window.screenLeft ? window.screenLeft : window.screenX;
var winTop = window.screenTop ? window.screenTop : window.screenY;
var width = screen.width;
var height = screen.height;
var w_width=WINDOW_WH("w");
var w_height=WINDOW_WH("h");
moveTo(0, 0);
resizeTo(width, height);
if(parseInt(pageview) > 1) {
$("#full_original").html("
원본보기");
}else{
$("#full_original").html("
원본보기");
}
$("#onefull_original").html("
");
}
function oneoriginal(w,h,l,t){
var w_width=WINDOW_WH("w");
var w_height=WINDOW_WH("h");
resizeBy(-(w_width-w),-(w_height-h));
moveTo(l,t);
$("#full_original").html("
전체보기");
$("#onefull_original").html("
");
}
function WINDOW_WH(wh){
var w_width=window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var w_height= window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
if(wh =="w"){
return w_width;
}else{
return w_height;
}
}
function two_original(){
resizeTo(900, 750);
}
$(window).resize(function(){
var w_height=WINDOW_WH("h");
$("#imgViewer_1_1").css("height",w_height-100);
$("#imgViewer_R_1").css("height",w_height-100);
$("#imgViewer_R_2").css("height",w_height-100);
$("#imgViewer_L_1").css("height",w_height-100);
$("#imgViewer_L_2").css("height",w_height-100);
}).resize();
$(document).on('touchstart touchend touchmove click', '#divHidden', function(e) {
if(e.type == 'touchmove' || e.type == 'click') {
closelayer();
}
});