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

	if(!name){
		name = readCookie('pixback');
	}
	if(name){
		with(document.body.style){background="url("+name+")"; backgroundAttachment="fixed"; }
	}else
		name = "back_saya.png";	
	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 createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+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 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; 
			}
		}
**/

