var server="img1";
var md='/online_manga/';
var mangadir='/online_manga/';
var maxwidth=750;
var maxheight=1800;
var orginalwidth=0;
var orginalheight=0;
var acivestyle="1px solid #6699ff"

function cview(id,ch)
{
document.location.href=mangadir+id+"-"+ch+".html";
}
function cv(id,ch)
{
document.location.href=mangadir+id+"-"+ch+".html";
}
function bbimg(o){
	var zoom=parseInt(o.style.zoom, 10)||100;zoom+=event.wheelDelta/12;if (zoom>0) o.style.zoom=zoom+'%';
	return false;
}

function zoomb(o){
var zoom=parseInt(document.getElementById("TheImg").style.zoom, 10)||100;
zoom+=20;
if (zoom>0&&zoom<=400) 
{
if(document.all)	document.getElementById("TheImg").style.zoom=zoom+'%';
else {document.getElementById("TheImg").style.zoom=2}
}

}
if(document.location.href.toLowerCase().indexOf('8comic.com')>=0 && !getCookie("CKVP") && document.location.href.toLowerCase().indexOf('/photo/')<0 ){document.location.href="/";}

function zoombb(o){
	var zoom=parseInt(document.getElementById("TheImg").style.zoom, 10)||100;
	if (zoom>0&&zoom<=400) zoom+=20;
	zoomb(o)
	writecookie(zoom);
	SetActive(o);
}

function zooms(o){
	var zoom=parseInt(document.getElementById("TheImg").style.zoom, 10)||100;
	zoom-=20;if (zoom>=20) document.getElementById("TheImg").style.zoom=zoom+'%';
}
function zoomss(o){
	var zoom=parseInt(document.getElementById("TheImg").style.zoom, 10)||100;
	if (zoom>=20) zoom-=20;
	zooms(o)
	writecookie(zoom);
	SetActive(o);
}

function zoomf(o){
		
//alert(screen.width+" "+document.body.scrollWidth+" "+maxwidth)
//var zoom=100;
//if(document.body.scrollWidth>screen.width) {maxwidth=screen.width-50; }
//Else {maxwidth=document.body.scrollWidth-50;}
//if(document.getElementById("TheImg").width>document.getElementById("TheImg").height*maxwidth/maxheight) zoom=maxwidth/document.getElementById("TheImg").width;
//Else zoom=maxheight/document.getElementById("TheImg").height;
//if(zoom>4) z=1;
//document.getElementById("TheImg").style.zoom=zoom*100+'%';
//if(document.getElementById("TheTable").style.width>screen.width*0.9)

//document.getElementById("TheTable").style.width=screen.width*0.95;
document.getElementById("TheImg").style.width=screen.width*0.89;


}
//if(document.location.href.toLowerCase().indexOf('2comic.com')>=0 && !getCookie("CKVP") && document.location.href.toLowerCase().indexOf('v.aspx')<0 ){document.location.href="http://www.2comic.com";}
function zoomff(o){
    var zoom=0;
	writecookie(zoom);
	zoomf(o)
	SetActive(o);	
}


function zooma(o){
//document.getElementById("TheImg").style.zoom='100%';
//document.getElementById("TheTable").style.width='';
document.getElementById("TheImg").style.width='';
}

function zoomaa(o){
	var zoom=100;
	writecookie(zoom);
	zooma(o)
	SetActive(o);	
}



function SetActive(o){
	//document.getElementById("zb").style.border="";
	//document.getElementById("zs").style.border="";
	document.getElementById("za").style.border="";
	document.getElementById("zf").style.border="";			

	o.style.border=acivestyle;
	
}



function shakeimg(o){

}

function resetmaxsize()
{
if(document.body.scrollWidth>screen.width) {maxwidth=screen.width-50; }
		else {maxwidth=document.body.scrollWidth-50;}
}
//window.onresize=resetmaxsize;
//window.onload=resetmaxsize;


var scrollcount=0;
var dragy;
var dragx;

function initdrag() {
scrollcount=1;
dragy=event.clientY;
dragx=event.clientX;
//document.body.setCapture();
//document.body.style.cursor='move';
//window.status='x:'+dragx+' y:'+dragy;
}

function startdrag() {
if (scrollcount==1) {
window.scrollBy((dragx-event.clientX)*2,(dragy-event.clientY)*2);
dragy=event.clientY;
dragx=event.clientX;
}
}

function enddrag() {
//document.body.style.cursor='';
scrollcount=0;
//document.body.releaseCapture();
}



//window.event for firefox Dot Not Delete/////////////////////////////
if(window.addEventListener) {FixPrototypeForGecko();}
function FixPrototypeForGecko(){HTMLElement.prototype.__defineGetter__("runtimeStyle",element_prototype_get_runtimeStyle);window.constructor.prototype.__defineGetter__("event",window_prototype_get_event);Event.prototype.__defineGetter__("srcElement",event_prototype_get_srcElement);}
function element_prototype_get_runtimeStyle(){return this.style;}
function window_prototype_get_event(){	return SearchEvent();}
function event_prototype_get_srcElement(){	return this.target;}
function SearchEvent(){if(document.all) return window.event;func=SearchEvent.caller;while(func!=null){var arg0=func.arguments[0];if(arg0){if(arg0.constructor==Event)return arg0;}func=func.caller;}	return null;}
//window.event for firefox End /////////////////////////////


var hm=0;
document.onkeydown=onkeydown;
function onkeydown()
{

	switch(window.event.keyCode)
		{
			
//			case 27 : window.close(); break;
//			case 17 : jumpnext(); break;   //Ctrl
//			case 37 : jumpnext(); break;
			case 32 : if(hm==0) {window.scrollBy(1000,0);hm=1;return false;} else {window.scrollBy(-1000,0);hm=0;return false;} break;			
//			case 38 : document.location.href=document.getElementById("prev").href; break;
//			case 16 : jumpprev(); break;   //Shift
//			case 18 : jumpnext(); break;   //Alt

//			case 39 : jumpprev(); break;
			case 90	: zoomff(o); break;
			case 122: zoomff(o); break;
			case 65	: zoomaa(o); break;
			case 97 : zoomaa(o); break;
//			case 40 : document.location.href=document.getElementById("next").href; break;

//		window.event.keyCode = 0;
//		window.event.returnValue= false;
		}
}
			
			
function writecookie(zoom){
setCookie("zoom",zoom,30)
}

function readcookie(){
if(getCookie_1DIM("zoom")) initzoom=getCookie_1DIM("zoom")
else initzoom="100";
return initzoom;
}

function getCookie_1DIM(Name) {
  var search = Name + "="
  if (document.cookie.length > 0) { 
    offset = document.cookie.indexOf(search)
    if (offset != -1) { 
      offset += search.length

      end = document.cookie.indexOf(";", offset)

      if (end == -1)
        end = document.cookie.length
      return unescape(document.cookie.substring(offset, end))
    }
  }
}

function setCookie(name, value, expiredays)	{
	var expire_date = new Date();
	expire_date.setDate(expire_date.getDate() + expiredays );
	document.cookie = name + "=" + escape( value ) + "; expires=" + expire_date.toGMTString() + "; path=/";
 }

function initzoom()
{
var initzoom="100";
initzoom=readcookie();
//if(initzoom>400) initzoom=400;
if(initzoom!="0" && initzoom!=0 && document.getElementById("TheImg")) {
	document.getElementById("TheImg").style.zoom=initzoom+'%';
	//if(initzoom>100) document.getElementById("zb").style.border=acivestyle;
	//if(initzoom<100) document.getElementById("zs").style.border=acivestyle; 
	if(initzoom==100) document.getElementById("za").style.border=acivestyle; 

	
	}
else {zoomf();document.getElementById("zf").style.border=acivestyle;}


}

function initpage(totalstr,indexstr,elename)
{
var ele=document.getElementById(elename);
var total=parseInt(totalstr);
var iedx=parseInt(indexstr);

	//	o = document.createElement("OPTION");
	//	o.text='Cover';
	//	o.value=0;
	//	if(document.all) ele.add(o);else ele.add(o,null);
	for(var i=1;i<=total;i++)
	{
		o = document.createElement("OPTION");
		o.text='Page: '+i+'';
		o.value=i;
		if(document.all) ele.add(o);else ele.add(o,null);

	}
	ele.selectedIndex=iedx-1;
	
}

function initnav(totalstr,indexstr,elename)
{
var ele=document.getElementById(elename);
var total=parseInt(totalstr);
var iedx=parseInt(indexstr);
var addnum=5;
var percent=parseInt(iedx*100/total);
var leftpercent=100-percent;
var cell=(parseInt(1000/total))/10;
var text='Page: '+iedx+'/'+total+'';
var str="<table  cellPadding=1 cellSpacing=1 bgcolor=#cccccc width=220 height=10 id='tnav'  style='position:absolute;left:100px' ><tr><td bgcolor=#ffffff >"
str+="<table cellSpacing=0 cellSpacing=0 width=100% height=12><tr>"
str+="<td style='cursor:hand' onclick='jump(basep,1)' bgcolor=#cccccc   width=1%><font style='font-family:webdings;font:8px;line-height:8px' >7</font></td>";
str+="<td style='cursor:hand' bgcolor=#d8e8ff width="+percent+"% ></td>"
str+="<td style='cursor:hand' bgcolor=#ffffff width="+leftpercent+"% ></td>"
str+="<td style='cursor:hand' onclick='jump(basep,"+total+")' bgcolor=#cccccc width=1%><font  style='font-family:webdings;font:8px;line-height:8px' >8</font></td>";
str+="</tr></table>";
str+="</td></tr></table>";	

ele.innerHTML=str;

}

function replaceurl(keyname,keyvalue,uu)
{
var u=document.location.href.toLowerCase();
if(uu!=null && uu!="") u=uu;
if(u.indexOf("#")>0) u=u.substring(0,u.indexOf("#"));
var key=request(keyname).toLowerCase();
if(u.indexOf("&"+keyname+"="+key)>0 ) u=u.replace("&"+keyname+"="+key,"&"+keyname+"="+keyvalue);
else if(u.indexOf("?"+keyname+"="+key)>0 ) u=u.replace("?"+keyname+"="+key,"?"+keyname+"="+keyvalue);
else if(u.indexOf("?"+keyname+"=?")>0 ) 	u=u.replace("?"+keyname+"=?","");
else if(u.indexOf("?")>0) u=u+"&"+keyname+"="+keyvalue;
else u=u+"?"+keyname+"="+keyvalue;
return u;
}