/*var pop = null;
var popnew = null;
function popup(obj, width, height) {
  var refreshPop = false;
  if(obj.nodeName == 'A') {
  	url = obj.href;
  	isNewSearch = false;  	
  }
  else if (obj.nodeName == 'FORM') {
  	url = obj.action + '?q=' + escape(obj.q.value)
  	isNewSearch = true; 
  }
  else {
  	return false;
  }
  
  if(pop && !pop.closed && !isNewSearch) {
  	pop.focus();
  	return false;
  }
  var url = url;
  if (!url) return true;
  var args = 'width='+width+',height='+height+',resizable, scrollbars';
  pop = window.open(url,'search',args);
  pop.opener = self;
  pop.title = 'search';
  pop.focus();
  return (pop) ? false : true;
}*/
/*
function checkSearchExists() {
  elem = document.getElementById('searchLink');
  if((!pop || pop.closed) && !window.isLoading ) {
  	elem.childNodes[0].nodeValue = 'Suche';
  }
  else {
  	elem.childNodes[0].nodeValue = 'Suchfenster anzeigen';
  }
}
*/
function changeSearchLinkText(obj) {
  obj.childNodes[0].nodeValue = 'Suchfenster anzeigen';
  window.isLoading = true;
}
/*
function form()
		{
		Bestellformular=window.open("index.php?module=catalog","Bestellformular","width=290,height=95")
		
		Bestellformular.focus();
		}

function fenster() {
	NeuesFenster=window.open("templates/thomax/content/bestellen.html","bestellen","width=500,height=250")
	NeuesFenster.focus();
	return false;
}
*/
// Array mit den geoeffneten Popups
var openPopups = new Array();

function popitup(obj, name, width, height, scrollbar) {
	 if (scrollbar == null) {
       scrollbar = 'no';
     }
     else if( scrollbar == 'yes' ) {
       scrollbar = 'yes';
     }
     else {
       scrollbar = 'no';
     }
     var newwindow = null;
     var url = null;
     var isForm = false;

     if(obj.nodeName == 'FORM') {
       isForm = true;
     }

     // Gibts das Popup bereits im Array?
     // Falls vorhanden, dann zuweisen.
     if(openPopups[name]) {
       newwindow = openPopups[name];
     }
 
     // URL entweder vom href oder action Attribut holen.
     // Weitere Quellen fuer URLS hier hinzufuegen.
     // Wenn keins gefunden wird Abbruch.
     if(obj.href) {
       url = obj.href;
     }
     else if (obj.action) {
       url = obj.action + '?q=' + escape(obj.q.value);
     }
     else return false;

     var args = 'width='+width+',height='+height+',scrollbars=' + scrollbar+',title=' + name;

     // Fokus, wenn das Popup offen ist und wenn die Anfrage, nicht aus einem
     // Form gekommen ist.
     // Bei einem Form soll ein refresh durchgefuehrt werden.
	if (newwindow && !newwindow.closed && !isForm) {
		newwindow.focus();
   	    return false;
	}
	else {
		newwindow=window.open(url,name, args);
        newwindow.title = name;
		openPopups[name] = newwindow;
		if (!newwindow.opener) newwindow.opener = self;
	}
	if (window.focus) {newwindow.focus()}
	return false;
}


function sprung(form){
	var zielseite=form.zielwahl.selectedIndex
	if (form.zielwahl.options[zielseite].value != "0") {
		location=form.zielwahl.options[zielseite].value;
	}
}
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function openCatalogue () {
	opener.location.href = this.href;
    return false;
}

function extendLinks () {
	if(!opener) {
		return false;
	}
	var links = getElementsByClass('articleLink', document, 'a');
	YAHOO.util.Event.addListener(links, "click", openCatalogue );
}
function resetOpener() {
  if(opener) {
  	opener.isLoading = false;
  }
}
