
var ww=0;
var aktiv;
var editor;

function regexptest()
{

if(document.myform.regexp) {if (document.myform.regexp.value != ' Stichwort') sortTable(document.myform.regexp.value)};
}

function refresh()
	{
	var theurl=""+document.URL+"&action=refresh";
	document.location.href=theurl
	}
	
function reset()
	{
	var theurl=""+document.URL.replace(/&action=refresh/,"")+"&action=reset";
	document.location.href=theurl
	}
	
function editpage()
	{
	var theurl=document.URL.replace(/static\//,"cgi-bin/parse.pl?file=");
	var theurl2=theurl.replace(/\.html/,"");
	document.location.href=theurl2
	}

function closetest()
	{
	if(editor.closed == true){location.reload(); window.clearInterval(aktiv);};
	}

function edit(feld)
	{
	if(feld.search(/:/) < 0){
	splitUrl = document.URL.split("&");
	var theurl=""+splitUrl[0].substr(0,splitUrl[0].length-2)+":"+feld;}
	else{
	var theurl=document.URL.replace(/=.+/,"="+feld)};
	var theurl2 = theurl.replace(/parse.pl/,"edit.pl")
	if(document.URL.search(/parse/) > 0) editor = window.open(theurl2,'sowjeteditor','resizable=yes,scrollbars=yes'); aktiv = window.setInterval("closetest()",1000); //self.focus(); parent.Editor.location.href=theurl2; //
	}
	
function restricted(feld)
	{
	var theurl2 = document.URL.replace(/static/,"restricted")
	parent.document.location.href=theurl2;
	}
	
function opn(src)
	{ window.open(src,'','width=400,height=400') }

var cookieValue="";

function SetCookie(name, value, expires, path, domain)
{ document.cookie = name + "=" + escape(value) +
  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
  ((path == null)    ? "" : "; path=" + path) +
  ((domain == null)  ? "" : "; domain=" + domain);
}

function AddItem(name,val)
{
	splitUrl = val.split("=");
	val = splitUrl[1];
	var cname = name + "=";
  var dc = document.cookie;
  if (dc.length > 0)
  { begin = dc.indexOf(cname);
    if (begin != -1)
    { begin += cname.length;
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
      cookieValue = unescape(dc.substring(begin, end));
    }
  }
  SetCookie(name, val, null, '/');
}

function suchen()
{
	name = 'Architekturbild';
	var cname = name + "=";
  var dc = document.cookie;
  if (dc.length > 0)
  { begin = dc.indexOf(cname);
    if (begin != -1)
    { begin += cname.length;
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
      cookieValue = unescape(dc.substring(begin, end));
    }
  }
  if (cookieValue.length == 0){cookieValue="%22Alle+Objekte%22"};
  parent.location.href='http://architekturbild.ch/cgi-bin/search/search.pl?Terms='+cookieValue;
}

 function email(adr)
{
  	var emailadr="mailto:" + adr + "@" + "architekturbild.ch" ;
  	location.href = emailadr ;
}

function sortTable(expr)
	{
	expr=expr.toLowerCase();
	var tblEl = document.getElementById('offTblBdy');
	var oldDsply = tblEl.style.display;
  	tblEl.style.display = "none";

  	var tmpEl;
  	var i, j;
  	var siz = tblEl.rows.length;
  	j=0;

  	for (i = 0; i < siz; i++)
  		{
    	c=siz-1-i+j;
 		tblEl.rows[c].className="nosel";
		if(
		getTextValue(tblEl.rows[c].cells[0]).toLowerCase().indexOf(expr)!=-1 ||
		getTextValue(tblEl.rows[c].cells[1]).toLowerCase().indexOf(expr)!=-1 ||
		getTextValue(tblEl.rows[c].cells[2]).toLowerCase().indexOf(expr)!=-1 
		)
			{
			tmpEl = tblEl.removeChild(tblEl.rows[c]);
			tblEl.insertBefore(tmpEl, tblEl.rows[0]);
			tblEl.rows[0].className="sel";
			j=j+1;
			}
  		}

  tblEl.style.display = oldDsply;
  return false;
}

if (document.ELEMENT_NODE == null) {
  document.ELEMENT_NODE = 1;
  document.TEXT_NODE = 3;
}

function getTextValue(el)
	{

  var i;
  var s;

  s = "";
  for (i = 0; i < el.childNodes.length; i++)
    if (el.childNodes[i].nodeType == document.TEXT_NODE)
      s += el.childNodes[i].nodeValue;
    else if (el.childNodes[i].nodeType == document.ELEMENT_NODE &&
             el.childNodes[i].tagName == "BR")
      s += " ";
    else
      s += getTextValue(el.childNodes[i]);

  return normalizeString(s);
	}

var whtSpEnds = new RegExp("^\\s*|\\s*$", "g");
var whtSpMult = new RegExp("\\s\\s+", "g");

function normalizeString(s)
	{
  	s = s.replace(whtSpMult, " ");  // Collapse any multiple whites space.
  	s = s.replace(whtSpEnds, "");   // Remove leading or trailing white space.
  	return s;
	}