var cleared = false;

function clearQuickFindField() {
	if (cleared == false) {
		document.forms.quick_find.search.value='';
		cleared = true;
	}
}

function stoperror(){ 
//	return false; 
}
 
function removeTitle(link, title) {
	if (link.title)
		link.title = title;
	return false;
}

function removeTitleAlt(link, alt) {
	if (link.alt)
		link.alt = alt;
	if (link.title)
		link.title = alt;
	return false;
}

function gotoAnchor(id) {
	var i, anchor_id;
	var doc_url;
	// Parse alle Anker auf der Seite durch... Wird gemacht, da Mozilla und Netscape die IDs auf andere Weise verwalten
	anchor_id = 0;
	for (i=0; i<this.document.anchors.length; i++) {
	 	// Sollte der gesuchte Anker gefunden sein, übergebe dessen ID und springe aus der Schleife
	 	if (this.document.anchors[i].name == id) {
	 		anchor_id = i;
	 		break;
	 	}
	}
	// URL des Dokuments auslesen
	doc_url = this.document.URL;
	id = String(id);
	 
	if (doc_url.lastIndexOf("#") >= 0) {
	 	doc_url = doc_url.substr(0,doc_url.lastIndexOf("#"))
	}
	// URL um Anker erweiteren und springen
	 
	self.location = doc_url+'#'+this.document.anchors[anchor_id].name;
	 
	return false;
}

// Gibt ein Objekt anhand dessen ID/Name zurück
function getObjectByTypeName(name) { 
   return getObject(name);
}  

// Gibt ein Objekt anhand dessen ID/Name zurück
function getObject(name) { 
   var ns4 = (document.layers) ? true : false; 
   var w3c = (document.getElementById) ? true : false; 
   var ie4 = (document.all) ? true : false; 

   if (ns4) return eval('document.' + name); 
   if (w3c) return document.getElementById(name); 
   if (ie4) return eval('document.all.' + name); 
   return false; 
}

function getParameters(querystring) {
  if(querystring == '') return;
  var wertestring = unescape(querystring);
  wertestring = wertestring.slice(1);
  var paare = wertestring.split("&");
  for (var i=0; i < paare.length; i++) {
    var name = paare[i].substring(0, paare[i].indexOf("="));
    var wert = paare[i].substring(paare[i].indexOf("=")+1, paare[i].length);
    this[name] = wert;
  }
}

// Sleep in JS
function Pause(duration, busy){
  this.duration= duration * 1000;
  this.busywork = null; // function to call while waiting.
  this.runner = 0;

  if (arguments.length == 2) {
     this.busywork = busy;
  }

  this.pause(this.duration);
}

Pause.prototype.pause = function(duration){
  if ( (duration == null) || (duration < 0)) {return;}

  var later = (new Date()).getTime() + duration;

  while(true){
     if ((new Date()).getTime() > later) {
        break;
     }
     this.runner++;
     if (this.busywork != null) {
        this.busywork(this.runner);
     }
  }
}

function popupWindow(url) {
	window.open(url,'popupWindow','toolbar=no,location=no,directories=no status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=450,screenX=150,screenY=150,top=150,left=150')
}

function popupWindowSized(url, xWidth, yWidth) {
	window.open(url,'popupWindow','toolbar=no,location=no,directories=no status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+xWidth+',height='+yWidth+',screenX=150,screenY=150,top=150,left=150')
}

function getY() {
	var x,y;
	if (self.pageYOffset) // all except Explorer
	{
		x = self.pageXOffset;
		y = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
	// Explorer 6 Strict
	{
		x = document.documentElement.scrollLeft;
		y = document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}
	return y;
}


window.onerror=stoperror;
