var xLayerNo=0;
var myBrowser;
var staticMenu;

function xLayer(newLayer, x, y) 
{
	if(x==null)x=0; 
	if(y==null)y=0; 
 	if(document.layers) 
	{
		if(typeof newLayer == "string")
		{
			this.layer=new Layer(100); 
			this.layer.document.open(); 
			this.layer.document.write(newLayer); 
			this.layer.document.close(); 
		}
		else
			this.layer=newLayer;

		this.layer.moveTo(x,y); 
		this.images=this.layer.document.images; 
 	} 
	else 
	if(document.all) 
	{
		var Xname;
		if(typeof newLayer == "string")
		{
			xName="xLayer" + xLayerNo++; 
 			var txt =   "<DIV ID='" + xName 
				+ "' STYLE=\"position:absolute;" 
				+ "left:"  + x + ";" 
				+ "top:"   + y + ";" 
				+ "visibility:hidden\">" 
				+ newLayer 
 				+ "</DIV>"; 

			document.body.insertAdjacentHTML("BeforeEnd",txt); 
		}
		else
			xName=newLayer.id;

		this.content = document.all[xName]; 
		this.layer   = document.all[xName].style; 
		this.images  = document.images; 
	} 
	else 
	if (document.getElementById)
	{
		
		var newDiv;

		if(typeof newLayer == "string")
		{
			var xName="xLayer" + xLayerNo++;

			var txt = ""
				+ "position:absolute;"
				+ "left:"  + x + "px;"
				+ "top:"   + y + "px;"
				+ "visibility:hidden";

			var newRange   = document.createRange();

			newDiv = document.createElement("DIV");
			newDiv.setAttribute("style",txt);
			newDiv.setAttribute("id", xName);

			document.body.appendChild(newDiv);

			newRange.setStartBefore(newDiv);
			strFrag = newRange.createContextualFragment(newLayer);	
			newDiv.appendChild(strFrag);
		}
		else
			newDiv = newLayer;

		this.content = newDiv;	
		this.layer   = newDiv.style;
		this.images  = document.images;
	}

	return(this); 
} 

function xLayerFromObj(theObj)
{
	if(document.layers)
		return(new xLayer(document.layers[theObj]));
	else 
	if(document.all)
		return(new xLayer(document.all[theObj]));
	else 
	if(document.getElementById)
		return(new xLayer(document.getElementById(theObj)));
}

if(navigator.appName.indexOf("Netscape") != -1 && !document.getElementById)
{
var eventmasks = {
      onabort:Event.ABORT, onblur:Event.BLUR, onchange:Event.CHANGE,
      onclick:Event.CLICK, ondblclick:Event.DBLCLICK, 
      ondragdrop:Event.DRAGDROP, onerror:Event.ERROR, 
      onfocus:Event.FOCUS, onkeydown:Event.KEYDOWN,
      onkeypress:Event.KEYPRESS, onkeyup:Event.KEYUP, onload:Event.LOAD,
      onmousedown:Event.MOUSEDOWN, onmousemove:Event.MOUSEMOVE, 
      onmouseout:Event.MOUSEOUT, onmouseover:Event.MOUSEOVER, 
      onmouseup:Event.MOUSEUP, onmove:Event.MOVE, onreset:Event.RESET,
      onresize:Event.RESIZE, onselect:Event.SELECT, onsubmit:Event.SUBMIT,
      onunload:Event.UNLOAD
};


xLayer.prototype.moveTo 	= function(x,y) 	{ this.layer.moveTo(x,y); }
xLayer.prototype.moveBy 	= function(x,y) 	{ this.layer.moveBy(x,y); }
xLayer.prototype.show		= function() 	{ this.layer.visibility = "show"; }
xLayer.prototype.hide 		= function() 	{ this.layer.visibility = "hide"; }
xLayer.prototype.setzIndex	= function(z)	{ this.layer.zIndex = z; }
xLayer.prototype.setBgColor 	= function(color) { this.layer.bgColor = color; if(color==null)this.layer.background.src=null;}
xLayer.prototype.setBgImage 	= function(image) { this.layer.background.src = image; }
xLayer.prototype.getX 		= function() 	{ return this.layer.left; }
xLayer.prototype.getY 		= function() 	{ return this.layer.top; }
xLayer.prototype.getWidth 	= function() 	{ return this.layer.width; }
xLayer.prototype.getHeight 	= function() 	{ return this.layer.height; }
xLayer.prototype.getzIndex	= function()	{ return this.layer.zIndex; }
xLayer.prototype.isVisible 	= function() 	{ return this.layer.visibility == "show"; }
xLayer.prototype.setContent   = function(xHtml)
{
	this.layer.document.open();
	this.layer.document.write(xHtml);
	this.layer.document.close();
}

xLayer.prototype.clip = function(x1,y1, x2,y2)
{
	this.layer.clip.top	=y1;
	this.layer.clip.left	=x1;
	this.layer.clip.bottom	=y2;
	this.layer.clip.right	=x2;
}
xLayer.prototype.addEventHandler = function(eventname, handler) 
{
        this.layer.captureEvents(eventmasks[eventname]);
        var xl = this;
        this.layer[eventname] = function(event) { 
		event.clientX	= event.pageX;
		event.clientY	= event.pageY;
		event.button	= event.which;
		event.keyCode	= event.which;
		event.altKey	=((event.modifiers & Event.ALT_MASK) != 0);
		event.ctrlKey	=((event.modifiers & Event.CONTROL_MASK) != 0);
		event.shiftKey	=((event.modifiers & Event.SHIFT_MASK) != 0);
            return handler(xl, event);
        }
}
xLayer.prototype.removeEventHandler = function(eventName) 
{
	this.layer.releaseEvents(eventmasks[eventName]);
	delete this.layer[eventName];
}


} 
else if(document.all) 
{ 

xLayer.prototype.moveTo = function(x,y) 
{ 
	this.layer.pixelLeft = x; 
	this.layer.pixelTop = y; 
} 
xLayer.prototype.moveBy = function(x,y) 
{ 
	this.layer.pixelLeft += x; 
	this.layer.pixelTop += y; 
} 
xLayer.prototype.show		= function() 	{ this.layer.visibility = "visible"; } 
xLayer.prototype.hide		= function() 	{ this.layer.visibility = "hidden"; } 
xLayer.prototype.setzIndex	= function(z)	{ this.layer.zIndex = z; } 
xLayer.prototype.setBgColor	= function(color) { this.layer.backgroundColor = color==null?'transparent':color; } 
xLayer.prototype.setBgImage	= function(image) { this.layer.backgroundImage = "url("+image+")"; } 
xLayer.prototype.setContent   = function(xHtml)	{ this.content.innerHTML=xHtml; } 
xLayer.prototype.getX		= function() 	{ return this.layer.pixelLeft; } 
xLayer.prototype.getY		= function() 	{ return this.layer.pixelTop; } 
xLayer.prototype.getWidth	= function() 	{ return this.layer.pixelWidth; } 
xLayer.prototype.getHeight	= function() 	{ return this.layer.pixelHeight; } 
xLayer.prototype.getzIndex	= function()	{ return this.layer.zIndex; } 
xLayer.prototype.isVisible	= function()	{ return this.layer.visibility == "visible"; } 
xLayer.prototype.clip		= function(x1,y1, x2,y2) 
{ 
	this.layer.clip="rect("+y1+" "+x2+" "+y2+" "+x1+")"; 
	this.layer.pixelWidth=x2; 
	this.layer.pixelHeight=y2; 
	this.layer.overflow="hidden"; 
}
xLayer.prototype.addEventHandler = function(eventName, handler) 
{
	var xl = this;
	this.content[eventName] = function() 
	{ 
            var e = window.event;
		e.layerX = e.offsetX;
		e.layerY = e.offsetY;
            e.cancelBubble = true;
            return handler(xl, e); 
	}
}
xLayer.prototype.removeEventHandler = function(eventName) 
{
	this.content[eventName] = null;
}
 
} 
else if (document.getElementById) 
{

xLayer.prototype.moveTo = function(x,y)
{
	this.layer.left = x+"px";
	this.layer.top = y+"px";
}
xLayer.prototype.moveBy 	= function(x,y) 	{ this.moveTo(this.getX()+x, this.getY()+y); } 
xLayer.prototype.show		= function() 	{ this.layer.visibility = "visible"; }
xLayer.prototype.hide		= function() 	{ this.layer.visibility = "hidden"; }
xLayer.prototype.setzIndex	= function(z)	{ this.layer.zIndex = z; }
xLayer.prototype.setBgColor	= function(color) { this.layer.backgroundColor = color==null?'transparent':color; }
xLayer.prototype.setBgImage	= function(image) { this.layer.backgroundImage = "url("+image+")"; }
xLayer.prototype.getX		= function() 	{ return parseInt(this.layer.left); }
xLayer.prototype.getY		= function() 	{ return parseInt(this.layer.top); }
xLayer.prototype.getWidth	= function() 	{ return parseInt(this.layer.width); }
xLayer.prototype.getHeight	= function() 	{ return parseInt(this.layer.height); }
xLayer.prototype.getzIndex	= function()	{ return this.layer.zIndex; }
xLayer.prototype.isVisible	= function()	{ return this.layer.visibility == "visible"; }
xLayer.prototype.clip		= function(x1,y1, x2,y2)
{
	this.layer.clip="rect("+y1+" "+x2+" "+y2+" "+x1+")";
	this.layer.width=x2 + "px";
	this.layer.height=y2+ "px";
	this.layer.overflow="hidden";
}
xLayer.prototype.addEventHandler = function(eventName, handler) 
{
	var xl = this;
	this.content[eventName] = function(e) 
	{ 
            e.cancelBubble = true;
            return handler(xl, e);
	}
}
xLayer.prototype.removeEventHandler = function(eventName) 
{
	delete this.content[eventName];
}
xLayer.prototype.setContent   = function(xHtml)
{
	var newRange   = document.createRange();
	newRange.setStartBefore(this.content);

	while (this.content.hasChildNodes())
		this.content.removeChild(this.content.lastChild);

	var strFrag    = newRange.createContextualFragment(xHtml);	
	this.content.appendChild(strFrag);
}

} else
{
xLayer.prototype.moveTo 	= function(x,y) 	{  }
xLayer.prototype.moveBy 	= function(x,y) 	{  }
xLayer.prototype.show 		= function() 	{  }
xLayer.prototype.hide 		= function() 	{  }
xLayer.prototype.setzIndex	= function(z) {  }
xLayer.prototype.setBgColor 	= function(color) {  }
xLayer.prototype.setBgImage 	= function(image) {  }
xLayer.prototype.getX 		= function() 	{ return 0; }
xLayer.prototype.getY 		= function() 	{ return 0; }
xLayer.prototype.getWidth 	= function() 	{ return 0; }
xLayer.prototype.getHeight 	= function() 	{ return 0; }
xLayer.prototype.getzIndex	= function()	{ return 0; }
xLayer.prototype.isVisible 	= function() 	{ return false; }
xlayer.prototype.setContent   = function(xHtml) { }
}

function xBrowser(){	if(navigator.appName.indexOf("Netscape") != -1)
	{
		this.getCanvasWidth	= function() {return innerWidth;}
		this.getCanvasHeight	= function() {return innerHeight;}
		this.getWindowWidth 	= function() {return outerWidth;}
		this.getWindowHeight	= function() {return outerHeight;}
		this.getScreenWidth 	= function() {return screen.width;}
		this.getScreenHeight	= function() {return screen.height;}
		this.getMinX		= function() {return(pageXOffset);}
		this.getMinY		= function() {return(pageYOffset);}
		this.getMaxX		= function() {return(pageXOffset+innerWidth);}
		this.getMaxY		= function() {return(pageYOffset+innerHeight);}

	}	else	if(document.all)	{
		this.getCanvasWidth	= function() {return document.body.clientWidth;}
		this.getCanvasHeight	= function() {return document.body.clientHeight;}
		this.getScreenWidth	= function() {return screen.width;}
		this.getScreenHeight	= function() {return screen.height;}
		this.getMinX		= function() {return(document.body.scrollLeft);}
		this.getMinY		= function() {return(document.body.scrollTop);}
		this.getMaxX		= function() {
			return(document.body.scrollLeft
				+document.body.clientWidth);
		}
		this.getMaxY		= function() {
				return(document.body.scrollTop
					+document.body.clientHeight);
		}
	}	return(this);}

function CreateStaticMenu(theObj, x, y)
{
	myBrowser = new xBrowser();
	staticMenu = new xLayerFromObj(theObj);
	staticMenu.baseX = x;
	staticMenu.baseY = y;
	staticMenu.x = x;
	staticMenu.y = y;
	staticMenu.moveTo(x,y);
	staticMenu.show();
	setInterval("ani()", 5);
}

function ani()
{
	var b = staticMenu;
	var targetX = myBrowser.getMinX() + b.baseX;
	var targetY = myBrowser.getMinY() + b.baseY;
	var dx = (targetX - b.x)/8;
	var dy = (targetY - b.y)/8;
	b.x += dx;
	b.y += dy;
	b.moveTo(b.x, b.y);
}


// <config>

startColor = "#FFFFFF"; 	// initial link color
endColor = "#cee3bc";  		// final link color

stepIn = 20; 				// delay when fading in
stepOut = 30; 				// delay when fading out

autoFade = true;			//set to true or false; true will cause all links to fade automatically
 
// </config>

hexa = new makearray(16);
for(var i = 0; i < 10; i++)
    hexa[i] = i;
hexa[10]="a"; hexa[11]="b"; hexa[12]="c";
hexa[13]="d"; hexa[14]="e"; hexa[15]="f";

linki=document.getElementsByTagName("a");
oldonmouseover = new makearray(linki.length);
oldonmouseout = new makearray(linki.length);
function init() {
if (!document.getElementsByTagName || !autoFade) return;
for (var i=0; i <linki.length; i++) {
	oldonmouseover[i]=linki[i].onmouseover;
	oldonmouseout[i]=linki[i].onmouseout;
	linki[i].onmouseover=domouseover(i);
	linki[i].onmouseout=domouseout(i);
	if (!linki[i].id) linki[i].id="fade_id"+(i+1);
	}
}
startColor = dehexize(startColor.toLowerCase());
endColor = dehexize(endColor.toLowerCase());

var fadeId = new Array();

function dehexize(Color){
	var colorArr = new makearray(3);
	for (i=1; i<7; i++){
		for (j=0; j<16; j++){
			if (Color.charAt(i) == hexa[j]){
				if (i%2 !=0)
					colorArr[Math.floor((i-1)/2)]=eval(j)*16;
				else
					colorArr[Math.floor((i-1)/2)]+=eval(j);
			}
		}
	}
	return colorArr;
}

function domouseover(i) {
	var i;
	if (oldonmouseover[i]) {return new Function ("oldonmouseover["+i+"](); fade(startColor,endColor,this.id,stepIn);");}
	else {return new Function ("fade(startColor,endColor,this.id,stepIn);");}
	}

function domouseout(i) {
	var i;
	if (oldonmouseout[i]) {return new Function ("oldonmouseout["+i+"](); fade(endColor,startColor,this.id,stepIn);");}
	else {return new Function ("fade(endColor,startColor,this.id,stepIn);");}
	}

function makearray(n) {
    this.length = n;
    for(var i = 1; i <= n; i++)
        this[i] = 0;
    return this;
}

function hex(i) {
    if (i < 0)
        return "00";
    else if (i > 255)
        return "ff";
    else
       return "" + hexa[Math.floor(i/16)] + hexa[i%16];
}

function setColor(r, g, b, element) {
      var hr = hex(r); var hg = hex(g); var hb = hex(b);
      element.style.color = "#"+hr+hg+hb;
}

function fade(s,e,element,step){
	var sr = s[0]; var sg = s[1]; var sb = s[2];
	var er = e[0]; var eg = e[1]; var eb = e[2];
	if (fadeId[0] != null && fade[0] != element){
		setColor(sr,sg,sb,eval("document.getElementById(\""+fadeId[0]+"\")"));
		var i = 1;
		while(i < fadeId.length){
			clearTimeout(fadeId[i]);
			i++;
			}
		}
	for(var i = 0; i <= step; i++) {
		fadeId[i+1] = setTimeout("setColor(Math.floor(" +sr+ " *(( " +step+ " - " +i+ " )/ " +step+ " ) + " +er+ " * (" +i+ "/" +
step+ ")),Math.floor(" +sg+ " * (( " +step+ " - " +i+ " )/ " +step+ " ) + " +eg+ " * (" +i+ "/" +step+
")),Math.floor(" +sb+ " * ((" +step+ "-" +i+ ")/" +step+ ") + " +eb+ " * (" +i+ "/" +step+ ")),document.getElementById(\""+element+"\"));",i*step);
	}
	fadeId[0] = element;
}

function go(){
  if (document.jumpto.pids.options[document.jumpto.pids.selectedIndex].value != "none") {
	location = document.jumpto.pids.options[document.jumpto.pids.selectedIndex].value;
  }
}

function confirmAlbum(stuffid)
{
    var is_confirmed = confirm("Are you sure you want to DELETE this album? (id: " + stuffid + ") \n\nWARNING: All the pictures and comments in this album will \nalso be deleted!");
    if (is_confirmed) {
        // Do nothing...
    }
    return is_confirmed;
} 

function confirmPicture(stuffid)
{
    var is_confirmed = confirm("Are you sure you want to DELETE this picture? (id: " + stuffid + ") \nComments will also be deleted.");
    if (is_confirmed) {
        // Do nothing...
    }
    return is_confirmed;
} 

function confirmComment(stuffid)
{
    var is_confirmed = confirm("Are you sure you want to DELETE this comment? (id: " + stuffid + ")");
    if (is_confirmed) {
        // Do nothing...
    }

    return is_confirmed;
} 

//Funkcja adujca obrazki do cache przegldarki
function preload(imgObj,imgSrc) {
	if (document.images) {
		eval(imgObj+' = new Image()')
		eval(imgObj+'.src = "'+imgSrc+'"')
	}
}

//Funkcja zmieniajca obrazki
function changeImage(layer,imgName,imgObj) {
	if (document.images) {
		if (document.layers && layer!=null) eval('document.'+layer+'.document.images["'+imgName+'"].src = '+imgObj+'.src')
		else document.images[imgName].src = eval(imgObj+".src")
}
}

