/****************************************************************************
* functions.js
* Common JavaScript functions: win-opener, image-swap, NN4-resize-bugfix,
* Layer An / Aus
* author: oh@vsn-munich.de | date: 2002-08-08
*
* produced by VSN VISUAL SOLUTIONS NETWORK GBR
* http://www.vsn-munich.de
*
* Version: 1.1    Datum: 2002-08-08
***************************************************************************/

//______________________________________________________________________
// framset nachladen
function buildFrameset() {
	if(self == top) location.href = "/index.php";
}


//______________________________________________________________________
// banner laden
function loadBanners(path1,path2) {
	if(path2 == "praxis") { path1 = path2; }
	window.parent.frames[1].location.href = "/banner.php?bannerTag="+path1;
}

//______________________________________________________________________
// allgemeine Funktionen - cross-browser
function getImage(bildName,layerID)
{
	return (document.all||document.getElementById?window.document.images[bildName]:layerID?document.layers[layerID].document.images[bildName]:window.document.images[bildName]);
}

function getLayer(layerID)
{
	return (document.getElementById?document.getElementById(layerID).style:document.all?document.all[layerID].style:document.layers[layerID]);
}


//______________________________________________________________________
// Bildwechsel mit Vorlader
var aktivBild = "";
var aktivLayer = "";

var Bilder=new Array();					
function vorLader(bildName,src1,src2)
{
	Bilder[bildName]=new Array();
	Bilder[bildName]["aus"]=new Image();
	Bilder[bildName]["aus"].src=src1;
	Bilder[bildName]["an"]=new Image();
	Bilder[bildName]["an"].src=src2;
}

function bildAn(bildName,layerID)
{
	getImage(bildName,layerID).src=Bilder[bildName]["an"].src;
}
	
function bildAus(bildName,layerID)
{
	getImage(bildName,layerID).src=Bilder[bildName]["aus"].src;
}

function bildFest(bildName,layerID)
{
	if(aktivBild != "" && aktivBild != bildName)
		getImage(aktivBild,aktivLayer).src = Bilder[aktivBild]["aus"].src;
		
	aktivBild = bildName;
	aktivLayer = layerID;
}

//______________________________________________________________________
// Layer ein- / ausschalten
function layerAn()
{
	for(i=0;i<arguments.length;i++) { getLayer(arguments[i]).visibility="visible"; }
}
 	
function layerAus()
{
	for(i=0;i<arguments.length;i++) { getLayer(arguments[i]).visibility="hidden"; }
}


//______________________________________________________________________
// new window opener
function openViewer(url,name,width,height)
{
	var xpos = (screen.availWidth-width)/2;
	var ypos = (screen.availHeight-height)/2;
	popUp = window.open(url,name,"toolbar=no,location=no,status=no,menubar=no,scrollbars=no,width="+width+",height="+height+",resizable=no,left="+xpos+",top="+ypos);
}

function openArt(url,name,width,height)
{
	var xpos = (screen.availWidth-width)/2;
	var ypos = (screen.availHeight-height)/2;
	popUp = window.open(url,name,"toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,width="+width+",height="+height+",resizable=yes,left="+xpos+",top="+ypos);
}


//______________________________________________________________________
// select form
function menu(type,item)
{
	var external;
	var Suche;
	
	if (item=="nix")
	{
		document.formular.reset();
		document.formular.liste.blur();
		return;
	}
	else if (type=="link")
	{
		document.location.href="#"+item;
	}
		document.formular.reset();
		document.formular.filter.blur();
}

//______________________________________________________________________
// Fix NetscapeNavigator4.5 resize bug

function reDo() {
	if (innerWidth != origWidth || innerHeight != origHeight) {
		history.go(0);		
	}
}
if (document.layers) {
    origWidth = innerWidth;
    origHeight = innerHeight;		
    onresize = reDo;
}


/**
* Methode versendet das Suchformular im Template
*
* @access 	public
* @param	object	searchForm 		Referenz auf das Suchformular
* @param	string	formActionNormal 	Action des Formulares, wenn es die nicht auf Online Werke eingeschraengt ist
* @param	string	formActionOnlineWerke 	Action des Formulares, nur bei Online-Werken
*
* @return 	boolean
*/
function checkSearchAction(searchForm, formActionNormal, formActionOnlineWerke) {
	if(!searchForm || !document.getElementById("searchfield") || !formActionNormal || !formActionOnlineWerke){
		return false;	
	}
	with (searchForm) {
		if (document.getElementById("searchfield").name == "query") {	// Cache-Problem bei einigen Browsern -> Daten wewrden bei Back-Button nicht zurückgesetzt
			action = formActionNormal;
			target = "_self";
			method = "post";
			document.getElementById("searchfield").name = "qs";
		}
		if (elements["searchfield"].value == "") {
			return false;
		} else {
			selField = elements["selectKategorie"];
			if (selField.options[selField.selectedIndex].value.indexOf("1322034") != -1) {
				action = formActionOnlineWerke;
				target = "_blank";
				method = "post";
				document.getElementById("searchfield").name = "query";
				return true;
			}else { 
				return true; 
			}
		}
	}
}

