function backimg(name){ 
if(!fancy) return;

	if(!name)
		name = readCookie('pixback');
	
	if(!name)
		name = "back_saya.png";	

	var b = new Image();
	b.src = name;
	b.onload = function()
	{
		with(document.body.style){background="url("+name+")"; backgroundAttachment="fixed"; }
		align(null);
	}
	with(document.body.style){background="url("+name+")"; backgroundAttachment="fixed"; }

	createCookie("pixback",name,30);
//	alert(readCookie("pixback"));
} 

function align(pos){

if(!fancy) return;

	if(!pos){
		pos=readCookie("pixbackpos");
		if(!pos) return;
	}
	var W = window.innerWidth ? window.innerWidth : document.body.clientWidth;
	var H = window.innerHeight ? window.innerHeight : document.body.clientHeight;
	var w = pos.substring(0, pos.indexOf(' '));
	var h = pos.substring(pos.indexOf(' ')+1);
	var b = new Image();//alert(parent.document.body.clientWidth+" "+parent.window.innerWidth); 
	var ImgW = 0;
	var ImgH = 0; 
	var img = readCookie("pixback"); 
	if(!img || img.indexOf('.')<0) img = "back_saya.png";
	b.src = img;
	ImgW = parseInt(w<1 && w>0 ? b.width : 0);
	ImgH = parseInt(h<1 && h>0 ? b.height : 0); 
	b.onload = function(){
		ImgW = parseInt(w<1 && w>0 ? this.width : 0);
		ImgH = parseInt(h<1 && h>0 ? this.height : 0); 
	}
/*	if(!ImgW && (w*h) && (w*h)!=1){ 
		switch(b.src){ 
			case "back_saja.png": ImgW=1600; break;
			default: alert(b.src+" "+img);
		}
	}
	*/
//alert(b.src+" "+img+" "+ImgW+" "+b.width);

	W = Math.round((ImgW+W)*w);
	H = Math.round((ImgH+H)*h); 
	pos = W + "px " + H + "px"; 
	document.body.style.backgroundPosition = pos; 
	createCookie("pixbackpos", w+" "+h , 30);
}

function param(name){ return param2(name, window.location.href);}

function param2(name, str)
{
	var left = str.indexOf(name+"=") + 1;
	if(!left) return "";
	left += name.length;
	var right = str.indexOf("&",left);
	if(right<0) right = str.length;
	return str.substring(left, right);
}


function createCookie(name,value,days) {
var expire = "";
if(days){
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
}
document.cookie = name+"="+escape(value)+expires;//+"; path=/";
}

function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length,c.length));
}
return null;
}

function eraseCookie(name) {
createCookie(name,"",-1);
}

/**
var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = getMouseXY;

if (!IE) document.captureEvents(Event.CLICK);
document.onclick = hide;

var tempX = 0
var tempY = 0
var myW = 550
var myH = 0
var hider = 0, shower = 0;

function getMouseXY(e) {

  if (IE) { 
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {      
    tempX = e.clientX
    tempY = e.clientY
  }
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  return true
}

function ButtonClick(no)
{   
    if(hider){ clearTimeout(hider)}

    var pwin = document.getElementById("popupwin");
    if(!no) return true;    
    if(pwin)
    {
	pwin.src = "pixmicat.php?no="+no;
        pwin.style.width = (myW=Math.max(600,myW)) + "px";
        pwin.style.left = (tempX>screen.width/2 ? tempX-myW : tempX) + "px"; //alert(pwin.style.left);
	pwin.style.top = (tempY>screen.height/2 ? tempY-myH : tempY) + "px";
        return true;
    }
    return false;
}
function hide(e)
{
    if(document.getElementById("popupwin"))
       hider = setTimeout('document.getElementById(\"popupwin\").style.display=\"none\"',e?0:500);
}

function ResizeIframe() 
{
    var i = document.getElementById("popupwin");
    if(!i.src) return false;

    clearTimeout(hider);
    i.style.display = "";

    var b = i.contentWindow.document.body;    
    myW = b.scrollWidth;
    myH = b.scrollHeight;
    i.style.height = myH + (IE?0:20) +"px";
    i.style.width = myW + "px";
    return true;
}
**/
var listed = false;
var fader = null;
var frame = null;//document.getElementById("LatestThreadList");
function fold(){ listed = false; }
function unfold(){ listed = true; }
function refocus()
{
	if(frame && frame.style.display != "none") display();
}
function display()
{
	//alert(frame.style.display+"\n"+frame.style.MozOpacity);
	if(frame)
	{
		if(frame.filters) frame.filters.alpha.opacity = 100; else frame.style.MozOpacity = 1.0;
		frame.style.display = "block";
		if(fader) clearTimeout(fader);
		//fader = setTimeout("fade();",5000);
	}
}
function fade(forced)
{
	if(!forced && listed) return;
	if(!frame) return;

	listed = false;

	if(frame.style.MozOpacity>0) frame.style.MozOpacity -= 0.1;
	else
	if(frame.filters && frame.filters.alpha.opacity>0) frame.filters.alpha.opacity -= 10;
	else
	{
		if(frame.style.MozOpacity) frame.style.MozOpacity = 0;
		if(frame.filters && frame.filters.alpha.opacity) frame.filters.alpha.opacity = 0;
		frame.style.display = "none";
//		alert(frame.style.display);
		return;
	}
	fader = setTimeout("fade();",50);
	listed = false;
}


		function set_icon(url){ 
			//if(url) window.location.href=url;
			return;
			if(!isList) return;
			var icon = parent.document.getElementById('icon'); 
			if(!icon) return;
			if(url){ icon.src=url; }else{ icon.src='style/rina.jpg'; }
		}
		function reload(){ 
			var p = window.frames['LatestThreadListFrame']; 
			if(p){	p.window.location.reload(true);	 }	
			if(!p){
				p = document.getElementById('LatestThreadListFrame'); 
				if(p) p.src = p.src; 
			}
		}
function getCanvasInfo()
{
var myWidth = 0, myHeight = 0;
var scrOfX = 0, scrOfY = 0;

  if( typeof( window.innerWidth ) == "number" ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && 
	( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
    //IE 6+ in "standards compliant mode"
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  if( typeof( window.pageYOffset ) == "number" ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return {scrollX:scrOfX, scrollY:scrOfY, innerW:myWidth, innerH:myHeight };
}


//var IE = document.all?true:false;
//if (!IE) document.captureEvents(Event.MOUSEMOVE);
//document.onmousemove = getMouseXY;
//if (!IE) document.captureEvents(Event.CLICK);

var IE = (document.all?true:false);
var tempX = 0
var tempY = 0
var hider = 0, shower = 0;
var xhider = 0, shower = 0;
var myW = 450;
var myH = 0;

function getMouseXY(e) 
{
  if (IE) { 
    tempX = event.clientX;
    tempY = event.clientY;
  } else {      
    tempX = e.clientX;
    tempY = e.clientY;
  }
  return true;
}

if (!IE) document.captureEvents(Event.MOUSEMOVE);
if (!IE) document.captureEvents(Event.CLICK);

document.onclick = xHideComm;
document.onmousemove = getMouseXY;

//alert(IE);
function xShowComm(no,thumb)
{   

	if(xhider){ clearTimeout(xhider)}
	if(!no) return true; 

	var pwin = document.getElementById("xpopupwin");
	if(pwin)
	{	
		$.post("pixmicat.php?no="+no,{},
		function(comment)
		{
			if(!comment)
				comment = "本文なし";
			else
				comment = comment.replace(/<iframe[^>]*>/,'');
			if(thumb)
			{	comment = "<img style='float:left; width:expression(this.width>100?100:true);max-width:100px;height:auto; margin:0px 30px 10px 0px' src='"+thumb+"' /></td><td>"+comment+"</td></tr></table>";
				//+ comment;
			}			
			pwin.innerHTML = comment;
			
			pwin.style.top = "-10000px";
			pwin.style.display = ""; //so as to get a nonzero pwin.offsetWidth
			var c = getCanvasInfo();
			var LEFT = (1?c.scrollX:0) + tempX - (tempX>c.innerW/2 ? pwin.offsetWidth+5 : -5) + "px";
			var TOP  = (1?c.scrollY:0) + tempY - (tempY>c.innerH/2 ? pwin.offsetHeight+5 : -5) + "px";
			pwin.style.display = "none";
			pwin.style.left = LEFT;
			pwin.style.top = TOP;
			//pwin.style.backgroundImage = document.body.style.backgroundImage;
			//pwin.style.backgroundPosition = document.body.style.backgroundPosition;
			$(pwin).fadeIn('fast');

			//if(IE) pwin.style.width = "expression(this.width>400?400:true)";
			//alert(c.scrollX+"\n"+c.scrollY+"\n"+c.innerW+"\n"+c.innerH+"\n"+tempX+"\n"+tempY);
		 });
	}
	return true;
}
function xHideComm(e)
{
	if(document.getElementById("xpopupwin"))
		xhider = setTimeout("$('#xpopupwin').fadeOut('fast')", e?0:500);
	return true;
}

var _parent = null;
var _html = "";
var editButtonHTML = "";

