function resizeframe(frame,w,h,maxw,maxh)
{
    if (arguments.length == 5) {
	w = w > maxw ? maxw : w;
	h = h > maxh ? maxh : h;
    }
    var fr=document.getElementById(frame);
    fr.style.width=w + "px";
    fr.style.height=h + "px";
    fr.style.display='block';
    fr.setAttribute('width',w);
    fr.setAttribute('height',h);
}

function pix_on()
{
	var content_table;

	content_table=document.getElementById("content_table");

	var results;
	var trs;

	trs=content_table.getElementsByTagName("tr");


	var i;
	for (i=0; i<trs.length; i++)
	{
		var foo=trs[i];

		var attr_id=foo.getAttribute("id");

		if (attr_id == "content_table_hdr")
		{
			if (foo.childNodes.length == 0 || foo.childNodes[0].getAttribute("id") != "pix_hdr")
			{
				var hdr=document.createElement("th");
				hdr.setAttribute("width","65");
				hdr.setAttribute("class","btn3");
				hdr.setAttribute("id","pix_hdr");
				// MSIE needs the following 3 lines ...
				hdr.style.color="white";
			//	hdr.style.fontFamily=foo.childNodes[1].style.fontFamily;
				hdr.style.fontSize="11px";
				hdr.appendChild(document.createTextNode("Bild"));
				foo.insertBefore(hdr,foo.childNodes[0]);
			}
			continue;
		}

		var re=/art_(\d+)(x)?/;

		try { results = re.exec(attr_id) } catch (e) { };


		if (results)
		{
		
			var neuTDcontents;
			var results;
		
			var id=results[1];
			
			var fc=foo.firstChild;
			var neuTD;
			if (fc.getAttribute("id") == "pix_"+id)
			{
				neuTD=fc;
			}
			else
			{
				neuTD=document.createElement("td");
				neuTD.setAttribute("id","pix_"+id);
				neuTD.setAttribute("align","center");
				neuTD.setAttribute("bgcolor","white");
				neuTD.setAttribute("width","65");
				if (results[2] != "x")
				{
					neuTDcontents=document.createElement("a");
					neuTDcontents.setAttribute("href","a"+id+".html");
					var img;
					img=document.createElement("img");
					img.setAttribute("src","http://s.gzhls.at/"+id+".jpg");
					img.setAttribute("border","0");
					neuTDcontents.appendChild(img);
					neuTD.appendChild(neuTDcontents);
				}
		
				foo.insertBefore(neuTD, foo.childNodes[0]);
	
			}
		}
		else if (foo.className == "trc")
		{
			//alert(foo.firstChild.getAttribute("colspan"));
			foo.firstChild.colSpan=foo.firstChild.colSpan+1;

			// next version works only in Firefox ... Boo, MSIE.
			//foo.firstChild.setAttribute("colspan",foo.firstChild.getAttribute("colspan")+1);
		}

	}
}

function pix_off()
{
	var content_table=document.getElementById("content_table");
	var trs=content_table.getElementsByTagName("tr");
	var results;
	var i;

	for (i=0; i<trs.length; i++)
	{
		var foo=trs[i];
		var fc=foo.firstChild;

		if (fc.getAttribute("id") == "pix_hdr")
		{	
			foo.removeChild(fc);
			continue;
		}

		var re=/art_(\d+)/;   // stupid MSIE doesn't support /.../() syntax
	
		try { results = re.exec(foo.getAttribute("id")) } catch (e) {};

		if (results)
		{
			var id=results[1];

			if (fc.getAttribute("id") == "pix_"+id)
			{
				foo.removeChild(fc);	
			}
		
		}
	}

	content_table.setAttribute("width","100%");

}

function set10ycookie (name,value)
{
	var date = new Date();
	date.setTime (date.getTime()-1000*86400);
	// delete old versions 
	document.cookie = name+"="+escape(value)+"; expires="+date.toGMTString();
	// set new version with path=/
	date.setTime (date.getTime()+1000*86400*365*10);
	document.cookie = name+"="+escape(value)+"; expires="+date.toGMTString()+"; path=/";
}

function getcookie (name)
{
	if (document.cookie.length == 0) return "";
	var i=document.cookie.indexOf(name+"=");
	if (i>=0)
	{
		var end=document.cookie.indexOf(";",i+name.length+1);
		if (end == -1) end=document.cookie.length;
		return unescape(document.cookie.substring(i+name.length+1,end));
	}
	return "";
	
}

function btn_pix_on()
{
	pix_on();
	set10ycookie("vspix",1);
}

function btn_pix_off()
{
	pix_off();	
	set10ycookie("vspix",0);
}

function bl_lim()
{
	// stupid MSIE fails ... if the value is not set explicitly, it
	// returns nothing
	var a=document.getElementById("bl1_id").value;
	set10ycookie("blaettern",a);
	document.forms["filterbox"].submit();
}

function vs_buttons()
{
	var v=getcookie("vspix");
	document.getElementById("pixonoff").style.display='inline';
	if (v == 1) document.forms["filterbox"].pixonoff[1].checked=true;
	else document.forms["filterbox"].pixonoff[0].checked=true;
}

function bl_ui()
{
	var a=getcookie("blaettern");
	document.getElementById("bl1_b").style.display='inline';
	if (a == -1) document.getElementById("blall").selected=true;
	else if (a == 0 || a == 100) document.getElementById("bl100").selected=true;
	else if (a == 30) document.getElementById("bl30").selected=true;
	else if (a == 300) document.getElementById("bl300").selected=true;
}

function blabla()
{
var found=0;
imgs=document.getElementsByTagName("img"); var i;
for (i=0; i<imgs.length; i++) {
if (imgs[i].getAttribute("src").match(/false/)) {
found=1;
}}

if (!found) {parent.resizeframe(
document.location.href.substring(
document.location.href.lastIndexOf("/")+1),0,0); }

}

function quote_text() {
    if (window.getSelection) {
        var str = window.getSelection() + "";
    } else if (document.getSelection) {
        var str = document.getSelection() + "";
    } else if (document.selection) {
        var str = document.selection.createRange().text + "";
    } else {
        var str = "";
    }

    if (0 == str.length) {
        var parentBody = document.getElementById("parentBody");
        for (var child = parentBody.firstChild; child != null; child = child.nextSibling) {
            if (3 == child.nodeType) {
                str += child.nodeValue;
            }
        }
    }
    //str = str.replace(/(.{1,78})( |$|\r?\n)/g, "> $1\n");
    str = "<blockquote><em> "+ str.replace(/(.{1,78})( |$|\r?\n)/g, "$1\n")+"</em></blockquote>";
    document.getElementById("rf_body").value += str;
}


function ch_img(id) {
    if (id >= 0 && id <= images.length - 1) {
        if (id == 0) {
            document.getElementById("p_img2").style.visibility = "hidden";
            document.getElementById("n_img2").style.visibility = "visible";
        } else if(id == images.length - 1) {
            document.getElementById("p_img2").style.visibility = "visible";
            document.getElementById("n_img2").style.visibility = "hidden";
        } else {
            document.getElementById("p_img2").style.visibility = "visible";
            document.getElementById("n_img2").style.visibility = "visible";
        }
        var match = /(?:bepixelung\.org\/)(\d+)/.exec(images[id]['c']);
        if (match != undefined && RegExp.$1 >= 0 && show_bp > 0) { // bp image
            document.getElementById('img_container').innerHTML = '<div id=ghpic> <table cellpadding=0 cellspacing=0 align=center border=0> <tr valign=top id="bp_t"><td class=ecke><img src=http://b.gzhls.at/lo.gif width=12 height=12></td><td class="border-top"><img src=http://b.gzhls.at/blanky.gif height=12 width=12></td><td class=ecke><img src=http://b.gzhls.at/ro.gif width=12 height=12></td></tr> <tr><td class="border-left"><img src=http://b.gzhls.at/blanky.gif height=12 width=12></td><td valign=top align=center> <a href="http://bepixelung.org/'+RegExp.$1+'" target=_blank title="Bild '+RegExp.$1+' auf bepixelung.org"> <img src="http://p.gzhls.at/'+images[id]['i']+'" width='+images[id]['w']+' height='+images[id]['h']+' alt="'+images[id]['c']+'" border=0 id="prod_img"> </a> <div class=links> <a href="http://bepixelung.org/?rm=search&from_bild='+RegExp.$1+'" target=_blank>Alle Bilder anzeigen</a> <a href="http://bepixelung.org/?rm=upload_form&from_bild='+RegExp.$1+'" target=_blank>Bild hochladen</a> <a href="http://bepixelung.org/'+RegExp.$1+'#license" target=_blank title="Hinweise zu den Bildrechten f&uuml;r dieses Bild / Copyright information">Usage information</a> </div> <div class="clr"></div> </div> </td> <td class="border-right"> <img src=http://b.gzhls.at/blanky.gif height=12 width=12> </td> </tr> <tr class=borderonly valign=bottom height=24> <td class=ecke2> <img src=http://b.gzhls.at/lu.gif width=12 height=24> </td> <td class="border-bot"> <a href=http://bepixelung.org target=_blank> <img src=http://b.gzhls.at/blanky.gif height=24 width=200 alt="bepixelung.org" title="bepixelung.org"></a> </td> <td class=ecke2> <img src=http://b.gzhls.at/ru.gif width=12 height=24> </td> </tr> </table> </div>';
            document.getElementById('mapnot').style.display = "none";
        } else {
            document.getElementById('img_container').innerHTML = '<img height="'+images[id]['h']+'" width="'+images[id]['w']+'" border="0" alt="'+images[id]['c']+'" src="http://p.gzhls.at/'+images[id]['i']+'"/><br><span>'+images[id]['c']+'</span>';
            document.getElementById('mapnot').style.display = "inline";
        }
        document.getElementById("mofn").innerHTML = (id + 1) + " / " + images.length;

        document.getElementById("p_img2").onclick=function(){ch_img((id-1)*1)};
        document.getElementById("n_img2").onclick=function(){ch_img((id+1)*1)};
    }
}

var ti, triadx, triady, triadinter;

