
/////// Open a specify size window
function openw(url,w,h)
{
window.open(url,"","width="+w+",height="+h+",left="+(screen.width/2-w/2)+",top="+(screen.height/2-h/2));	
}

function opens(url,w,h)
{
window.open(url,"","scrollbars=yes,status=no,width="+w+",height="+h+",left="+(screen.width/2-w/2)+",top="+(screen.height/2-h/2));	
}

/////// Open a fixed size window
function openwin(url)
{
window.open(url,"","width="+480+",status=no,height="+320+",left="+(screen.width/2-240)+",top="+(screen.height/2-160));	
}

/////// Open a fixed size window
function play(id)
{
window.open("/member/pop.aspx?id="+id,"","width="+480+",status=no,height="+320+",left="+(screen.width/2-240)+",top="+(screen.height/2-200));	
}
function music(id)
{
window.open("/member/popmusic.aspx?m=1&id="+id,"","width="+480+",status=no,height="+320+",left="+(screen.width/2-240)+",top="+(screen.height/2-200));	
}
function play2(id,num)
{
window.open("/member/play.aspx?id="+id+"&num="+num,"","width="+490+",status=no,height="+400+",left="+(screen.width/2-245)+",top="+(screen.height/2-200));	
}

function move(x,y)
{
window.resizeTo(x,y);
window.moveTo((screen.width-x)/2,(screen.height-y)/2);
}

function reloadwin()
{
var newurl=opener.document.location.href;if(newurl.indexOf('#')==newurl.length-1) newurl=newurl.substring(0,newurl.length-1);opener.document.location.href=newurl;
}


function setCookie(n, v)	{
var expiredays=365;
var expire_date = new Date();
expire_date.setDate(expire_date.getDate() + expiredays );
document.cookie = n + "=" + escape( v ) + "; expires=" + expire_date.toGMTString() + "; path=/";
}





function addfavorite()
{

if(document.location.href.toLowerCase().indexOf("boxmanga.com")>0) window.external.addFavorite('http://boxmanga.com','BoxManga.com - enjoy manga!');
else if(document.location.href.toLowerCase().indexOf("8manga.com")>0) window.external.addFavorite('http://8manga.com','8Manga.com - enjoy manga!');	
}	
	
	
function getCookie(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 addhistory(id,name,thumb)
{
	
	var c=getCookie("itemhistory");
	var s="";
	if(c!=null && c!="")
	{
	var a=c.split(",");
	var f=0;
	var i=0;
	for(i=0;i<a.length&&i<9;i++)
	{
		if(a[i].indexOf(id+"|")<0)
		{
			s+=","+a[i];			
		}
	}
	
	}
	//if(s=="") s=id+"|"+escape(name)
	//else 
	s=id+"|"+escape(name)+"|"+thumb+s;
	setCookie("itemhistory",s);
	
	
}
function clearhistory()
{
	setCookie("itemhistory","");
	setCookie("clearhistory","1");
	var newurl=document.location.href;if(newurl.indexOf('#')==newurl.length-1) newurl=newurl.substring(0,newurl.length-1);
	
	document.location.href=newurl;
	
}
function sethistory()
{
	setCookie("itemhistory","");
	setCookie("clearhistory","");
	var newurl=document.location.href;if(newurl.indexOf('#')==newurl.length-1) newurl=newurl.substring(0,newurl.length-1);

	document.location.href=newurl;
	
}


function showhistory()
{
	var c=getCookie("itemhistory");
	var cc=getCookie("clearhistory");
	if(c!=null && c!="")
	{
	var a=c.split(",");
	document.write("<table width=100% border=0 cellpadding=0><tr><td height=2 background=/images/line.gif></td></tr><tr><td align=center height=25 nowrap><img src=/images/bb.gif hspace=4 border=0 align=absmiddle /><font color=#0066CC><b>Browse History</b></font>");
	if(cc==null || cc=="") 
	{
		document.write("<font style='font-family:arial;font-size:9px' >[<a href=# onclick=clearhistory();>clear</a>]</font></td></tr>");
		for(i=0;i<a.length;i++)
		{
			document.write("<tr><td height=20 >");
			document.write("<img src=../images/a.gif border=0 align=absmiddle> <a href=/manga/"+a[i].split("|")[0]+".html class=cyan onmouseover='showthumb("+a[i].split("|")[0]+",\""+a[i].split("|")[2]+"\",this);' onmouseout='hidethumb();'>"+unescape(a[i].split("|")[1])+"</a>");
			document.write("</td></tr>");
			//document.write("<tr><td height=1 background=../images/dots.gif></td></tr>");
		}



	}
	else 	document.write("<font style='font-family:arial;font-size:9px' ><a href=# onclick=sethistory();>set</a>]</font><br><img src=../images/spacer.gif width=120 height=1></td></tr>");
	document.write("</table>");
	}
	//alert(c);
	
}

function request(queryStringName)
{var returnValue="";
var URLString=new String(document.location);
var serachLocation=-1;
var queryStringLength=queryStringName.length;
do{serachLocation=URLString.indexOf(queryStringName+"\=");
if (serachLocation!=-1){if ((URLString.charAt(serachLocation-1)=='?') || (URLString.charAt(serachLocation-1)=='&'))
{URLString=URLString.substr(serachLocation);break;}URLString=URLString.substr(serachLocation+queryStringLength+1);}}
while (serachLocation!=-1)
if (serachLocation!=-1)
{var seperatorLocation=URLString.indexOf("&");
if (seperatorLocation==-1){returnValue=URLString.substr(queryStringLength+1);}
else{returnValue=URLString.substring(queryStringLength+1,seperatorLocation);} }
return returnValue;}



function checkall(form)
{
for (var i=0;i<form.elements.length;i++){
var e=form.elements[i];
if (e.type=="checkbox"&&e.id.indexOf("cb")>=0)
{e.checked=form.ids.checked; 
form.ids.value += document.getElementById(e.id).value +",";
if(!form.ids.checked)form.ids.value = "";
}
}
}
 
function getx(obj) {
var curleft = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curleft += obj.offsetLeft;
obj = obj.offsetParent;
}
}
else if (obj.x) {
curleft += obj.x;
}
return curleft;
}

function gety(obj) {
var curtop = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curtop += obj.offsetTop;
obj = obj.offsetParent;
}
}
else if (obj.y)
curtop += obj.y;
return curtop;
}


function showthumb(img,thumb,setpos)
{
var v='<table width="80" height="100" border="0" cellspacing="0" cellpadding="2" bgcolor="#FFFFFF"><tr><td align=center>';
v+='<img src="'+thumb+'" border="0">';
v+='</td><tr></table>';
document.getElementById('thumbfloat').innerHTML=v;
document.getElementById('thumbfloat').style.top=gety(setpos)-110;
document.getElementById('thumbfloat').style.left=getx(setpos);

}

function hidethumb()
{
document.getElementById('thumbfloat').innerHTML="";
}

function contact()
{
openw('/data/msg.aspx?title=Bugs%20Report&content='+document.location.href,500,300);
}
