//var root="http://localhost/aish/";
var root='file://D:/Daten/WWW/aish/';
if(location.href.substr(0,4) == 'http')
{
	root='http://www.aish.de/';
}
else
{
//	alert(root);
}
//---------------------------------------------------------------------------------------------- 
function setMenue()
{
	if(this.document == top.document)
	{
		url = this.location.href;
		url = url.substr(root.length);
//		alert(url); return;
		window.location.href = root + 'index.php?url=' + url;
	}
	setTimeout('top.Select.setMenue();', 300);
}
//function closesub(){if(top.opener.closed==true){top.location.href="../index.html"}else{top.close();}}
//---------------------------------------------------------------------------------------------- 
function toframe()
{
	if(window.location.href.indexOf("aish")<0){window.location.href = root; return true;}
	if(this.document == top.document) window.location.href = root;
}
//---------------------------------------------------------------------------------------------- 
function search()
{
	val=document.Formular.Suchbegriff.value;
	if(val == "")
	{
		document.Formular.action="../cgi-bin/firmen.pl";
		return true;
	}
	else
	{
		i=val.indexOf("  ");
		while(i>=0)
		{
			val=val.substr(0,i)+val.substr(i+1);
			i=val.indexOf("  ");
		}
		if(val.substr(0,1)==" ") val=val.substr(1);
		if(val.substr(val.length-1)==" ") val=val.substr(0,val.length-1);
		if(val.length < 2)
		{
			alert ("Es müssen mindestens zwei Zeichen eingegeben werden!");
			return false;
		}
		else
		{
			val=html_mask(val);
			document.Formular.action="../cgi-bin/firmen.pl?"+val;
			return true;
		}
	}
}
//---------------------------------------------------------------------------------------------- 
winopen = false;
function gof(hpage)
{
var hdir=hpage.substr(0,1);
if(winopen) firm.close();
firm = window.open("about:blank",hpage,'toolbar=yes, status=no,location=no,directories=no,scrollbars=yes,resizable=yes');
with (firm.document)
	{
//	clear();
	open('text/html','replace');
	write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">");
	write("<html><head><TITLE>AISH - Ausbildungs-Initiative Schleswig-Holstein</TITLE></head>");
	write("<FRAMESET rows=\"70,*\" marginwidth=\"0\" marginheigth=\"0\" frameborder=\"0\" border=\"0\" framespacing=\"0\">");
	write("	<FRAME src=\""+root+"/cgi-bin/select_firma.pl?"+hpage+"\" name=\"Selection\" noresize scrolling=\"no\">");
	write("	<FRAME src=\""+root+"/firmen/"+hdir+"/"+hpage+"/firma.htm\" name=\"Content\">");
	write("</FRAMESET><body></body></html>");
	close();
	}
	winopen = true;
	firm.focus();
//return;
}
//---------------------------------------------------------------------------------------------- 
function html_mask(s)
{
	s=s.replace(/Ä/g,"&Auml;");
	s=s.replace(/Ö/g,"&Ouml;");
	s=s.replace(/Ü/g,"&Uuml;");
	s=s.replace(/ä/g,"&auml;");
	s=s.replace(/ö/g,"&ouml;");
	s=s.replace(/ü/g,"&uuml;");
	s=s.replace(/ß/g,"&szlig;");
	return s;
}
//---------------------------------------------------------------------------------------------- 
function ShowImage(URL,Title,h,w)
{
	var scrollbars='no';
	if(h>screen.availHeight)
	{
		h=screen.availHeight*0.9;
		scrollbars='yes';
	}
	if(w>screen.availWidth)
	{
		w=screen.availWidth*0.9;
		scrollbars='yes';
	}
	options="status=no,location=no,menubar=no,directories=no,scrollbars="+scrollbars+",height="+h+",width="+w;
	Imag=window.open("","WIN",options);
	Imag.moveTo(10,10);
	Imag.document.open("text/html");
	Imag.document.write("<html><head><title>" + Title + "</title></head>"
	+ "<link href='/aish.css' rel=stylesheet type=text/css>"
	+ "<body style='margin-left: 0px; margin-top: 0px;'>"
	+ "<center><a href='JavaScript:window.close()'><img src=" + URL + " border=0 alt='close window'></a>"
	+ "</center></body></html>");
	Imag.document.close;
	Imag.focus();
	return;
}
//---------------------------------------------------------------------------------------------- 
function NewWin(URL,Title,h,w)
{
	var scrollbars='no';
	if(h>screen.availHeight)
	{
		h=screen.availHeight*0.9;
		scrollbars='yes';
	}
	if(w>screen.availWidth)
	{
		w=screen.availWidth*0.9;
		scrollbars='yes';
	}
	options="status=no,location=no,menubar=no,directories=no,scrollbars="+scrollbars+",height="+h+",width="+w;
	Imag=window.open("","WIN",options);
	Imag.moveTo(10,10);
	Imag.document.open("text/html");
	Imag.document.write("<html><head><title>" + Title + "</title></head>"
	+ "<link href='/aish.css' rel=stylesheet type=text/css>"
	+ "<body><center><table cellpadding=0 cellspacing=0><tr><td><img src=/images/empty.gif height="+ h +" width=1></td><td valign='middle'>"
	+ "<center><a href='JavaScript:window.close()'><img src=" + URL + " border=0 alt='close window'><br><br>Fenster schlie&szlig;en</a>"
	+ "</td><td><img src=/images/empty.gif height="+ h +" width=1></td></tr></table></center></body></html>");
	Imag.document.close;
	Imag.focus();
	return;
}
//---------------------------------------------------------------------------------------------- 
win_popup = new Array();
popup_counter = 0;
function openPopUp(URL,TITLE,WIDTH,HEIGHT,SB)
{
	if(win_popup[TITLE])
	{
		if(!win_popup[TITLE].closed)
		{
			win_popup[TITLE].focus();
			return;
		}
		win_popup[TITLE].close();
		popup_counter--;
	}
	popup_counter++;
	if (!SB) SB="yes";
	if (!HEIGHT) HEIGHT=400;
	if (!WIDTH) WIDTH=600;
	OPT="height="+HEIGHT+", width="+WIDTH+", scrollbars="+SB;
	win_popup[TITLE] = window.open("about:blank", TITLE, OPT);
	win_popup[TITLE].document.open("text/html");
	win_popup[TITLE].document.write('<html><head><title>'+ TITLE +'</title></head>'
	+ '<frameset name="'+ TITLE +'" rows="*,1,30" frameborder="0" framespacing="0" border="0">'
	+ '<frame name="Content" src="' + URL + '" marginwidth="1" marginheight="1" scrolling="' + SB + '" frameborder="0">'
	+ '<frame src="'+ root +'emptyborder.html" marginwidth="0" marginheight="1" scrolling="no" frameborder="0" noresize>'
	+ '<frame src="'+ root +'popup_close.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>'
	+ '</frameset><body></body></html>');
	win_popup[TITLE].document.close();
	win_popup[TITLE].focus();
}
//---------------------------------------------------------------------------------------------- 
function setFirmSelect()
{
if(parent.Selection.document.forms.length>0){
	for (i=0;i<parent.Selection.document.Formular.Berufe.length;i++)
	if(this.location.href.indexOf(parent.Selection.document.Formular.Berufe.options[i].value+".htm")>0){
		parent.Selection.document.Formular.Berufe.options[i].selected=true;
		return true;
		}
	parent.Selection.document.Formular.Berufe.options[0].selected=true;
	}
}
//---------------------------------------------------------------------------------------------- 
//Bewerbungsformular fuer die Firmenseiten
function bewerbung()
{
i=document.location.href.indexOf("firmen/")+9;
j=document.location.href.lastIndexOf("firma")-1;
file=document.location.href.substr(i,j-i);
URL="../../../cgi-bin/bewerbung.pl?"+file;
NAME="bewerbung";
popup(URL,NAME);
}

function openwin(URL){window.open(URL,'fenster','status=no,location=no,directories=no,scrollbars=yes');}
function popup(URL,NAME)
{
	window.open(URL,NAME,'status=no,location=no,directories=no,scrollbars=yes');
}
//---------------------------------------------------------------------------------------------- 
// Bild aufrufen , Bild des Links mit src und title
function ShowPicture(anc)
{
	home_dir=root;
	pic=anc.firstChild.src;
	PicTitle=anc.firstChild.title;
	if(pic.indexOf('_s.jpg') > 0)
	{
		pic=pic.substr(0,pic.length-6) + '.jpg';
	}
	else
	{
		pic=pic.substr(0,pic.length-4) + '_xl.jpg';
	}
	self.document.CacheImage.src = pic;
	//alert(document.CacheImage.height);
	htm = home_dir+"image.html";
	h = 40;
	w = 500;
	var opts = "scrollbars=no,toolbar=no,status=no,menubar=no,location=no,rezisable=yes,width="+w+",height="+h;
	Imag = window.open(htm, "Imag", opts);
	var x = (screen.availWidth - 800);
	var y = (screen.availHeight - 600);
	if(x < 0) x=0;
	if(y < 0) y=0;
	Imag.moveTo(x,y);
//	titel = Imag.document.getElementsByTagName("title")[0];
//	titel.text = titel.text + " - " + PicTitle;

}
//---------------------------------------------------------------------------------------------- 
// Bild laden
function loadImage()
{
//alert(self.name);
//	titel = document.getElementsByTagName("title")[0];
//	titel.text = titel.text + " - " + opener.parent.Select.document.getElementById("CacheTitle").value;
	pic = document.ShowImage;
	pic.src = opener.document.CacheImage.src;
	setTimeout('resizeToImage()',60);
}
//---------------------------------------------------------------------------------------------- 
function resizeToImage()
{
	pic = document.ShowImage;
	pic.style.visibility = "hidden";
	h = pic.height;
	w = pic.width;
	if(w < 100)
	{
		setTimeout('resizeToImage()',600);
	}
	else
	{
		pic.style.visibility = "visible";
		self.resizeTo(w,h);
		if(window.innerHeight)
		{
			nh = h;
			nw = w;
			if(self.innerHeight < h) nh = nh + 50;
			if(self.innerWidth < w) nw = nw + 30;
			self.resizeTo(nw,nh);
			self.innerHeight = h+5;
			self.innerWidth = w+5;
//		alert(self.innerHeight);
		}
		else
		{
			h += 30;
			w += 12;
			self.resizeTo(w,h);
		}
		var x = (screen.availWidth - w - 150) / 3;
		var y = (screen.availHeight - h - 30) / 3;
		if(x < 0) x=0;
		if(y < 0) y=0;
		self.moveTo(x,y);
		self.focus();
	}
//	alert(document.getElementsByTagName("title")[0].text);
}
//---------------------------------------------------------------------------------------------- 
