function setMenu(url)
{
	toframe();
	//alert(parent.frames[0].location.href);
	parent.Select.setMenu(url);
	resizeBodyImage();
	self.focus();
}

function toframe()
{
	if (this.document == top.document)
	{
		top.location.href = base+"index.html";
		return;
	}
	if(top.Main)
	{
	}
	else if(opener)
	{
		CacheObj = opener.top.Main.Cache;
	}
	else
	{
		CacheObj = parent.opener.top.Main.Cache;
	}
		CacheObj = top.Main.Cache;
}

function resizeBodyImage()
{
	if (img = document.getElementById('image_body_absolute'))
	{
		iw = img.width;
		ih = img.height;
		w = 900; // Framebreite fix
		h = self.innerHeight;
		if(!h) h = document.documentElement.clientHeight;
		scale = Math.max(w / iw, h / ih);
		nw = Math.floor(scale * iw);
		nh = Math.floor(scale * ih);
//	alert(w +  " " + nw +  " " + h +  " " + nh);
		img.style.width = nw + "px";
		img.style.height = nh + "px";
		ytop = 0; ybot = h;
		if(nh > h)
		{
			ytop = Math.ceil((nh - h) * 0.6);
		}
		ybot = ytop + h;
		bh = ybot-ytop;
//		alert(nh + " " + h + " " + ytop + " " + ybot + " " + bh);
		img.style.clip = "rect(" + ytop + "px " + w + "px " + ybot + "px 0px)";
		img.style.top = "-" + ytop + "px";
	}
}


//---------------------------------------------------------------------------------------------- 
function mOverPic(elem)
{
	cell = elem.parentNode;
	pic = "url(../../images/imgbuttons/" + cell.id + "_on.jpg)";
	cell.style.backgroundImage = pic;
	cell.style.cursor = "n-resize";
}

function mOutPic(elem)
{
	cell = elem.parentNode;
	pic = "url(../../images/imgbuttons/" + cell.id + "_off.jpg)";
	cell.style.backgroundImage = pic;
	cell.style.cursor = "auto";
}

function imgbutton_click(img)
{
	lnk = img.parentNode.parentNode;
	location.href=lnk.getAttribute('href');
}

var PopupArray = Array();
//---------------------------------------------------------------------------------------------- 
function openPopUp(URL,LANG,WIN,WIDTH,HEIGHT,SB,ACTION)
{
	var j = -1;
	if (!SB) SB="yes";
	if(window.outerHeight)
	{
		x = self.outerWidth;
		y = self.outerHeight;
	}
	else
	{
		x = (screen.availWidth - 200);
		y = (screen.availHeight - 100);
	}
	if (!HEIGHT) HEIGHT = y;
	if (!WIDTH) WIDTH = x;
	OPT="scrollbars=no,toolbar=no,status=no,menubar=no,location=no,height="+HEIGHT+", width="+WIDTH;
//alert(base);
	for(i=0;i<PopupArray.length;i++)
	{
		//alert(PopupArray[i].name);
		if(PopupArray[i].closed == true)
		{
			PopupArray.splice(i, 1);
			i -= 1;
		}
		else if(PopupArray[i].name == WIN)
		{
			j = i;
			break;
		}
	}
	if(j > -1)
	{
		//if(ContentArray[j].Content.href != URL)
		//alert(PopupArray[j].Content.location.href);
		PopupArray[j].focus();
		//return;
		PopupArray[j].close();
		PopupArray.splice(j, 1);
	}
	else
	{
		j = i;
	}
//	alert(PopupArray[j] + WIN);
	PopupArray[j] = window.open("about:blank", WIN, OPT);
	PopupArray[j].document.open();
	PopupArray[j].document.write("<html><head><title>" + gl_title + "</title></head>"
	+ '<frameset rows="*,1,30" frameborder="0" framespacing="0" border="0" onload="' + ACTION + '">'
	+ '<frame name="Content" src="' + URL + '" marginwidth="1" marginheight="1" scrolling="' + SB + '" frameborder="0">'
	+ '<frame src="'+ base +'emptyborder.html" marginwidth="0" marginheight="1" scrolling="no" frameborder="0" noresize>'
	+ '<frame name="Select" src="'+ base +'htmdocs/'+ LANG +'/popup_close.html" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" noresize>'
	+ '</frameset><body></body></html>');
	PopupArray[j].document.close();
	PopupArray[j].setTimeout('focus()',600);
}
//---------------------------------------------------------------------------------------------- 
function NewWin(URL,NAME,h,w)
{
	if(h<screen.availHeight && w<screen.availWidth)
	{
		options="status=no,location=no,menubar=no,directories=no,scrollbars=no,height="+h+",width="+w;
	}else{
		options="status=no,location=no,menubar=no,directories=no,scrollbars=yes,height="+h+",width="+w;
	}
	F=window.open(URL,NAME,options);
	F.focus();
}
//---------------------------------------------------------------------------------------------- 
var ImagesArray = Array();
function ShowPicture(pic, size_abbr)
{
	if(size_abbr == undefined) size_abbr = "_xl";
	picpath = pic.substr(0, pic.lastIndexOf("/")+1);
	picname = pic.substr(pic.lastIndexOf("/")+1);
	ext = picname.substr(picname.lastIndexOf("."));
	picname = picname.substr(0, picname.lastIndexOf("."));
	i = picname.lastIndexOf("_");
	if(i > 0) picname = picname.substr(0, i);
	pic=picpath+picname+size_abbr+ext;
	//alert(pic);return;
	CacheObj.document.getElementById("CacheImage").src = pic;
	URL = base + "image.html";
	WIN = picname.replace(/-/g, "_");
//	WIN = "Imag";
	CacheObj.openPopUp(URL,lang,WIN,400,250,'no');
	return;
}
//---------------------------------------------------------------------------------------------- 
function loadImage()
{
	//titel = document.getElementsByTagName("title")[0];
//	titel.text = titel.text + " - " + opener.parent.Select.document.getElementById("CacheTitle").value;
	pic = document.ShowImage;
	pic.src = CacheObj.document.getElementById("CacheImage").src;
	setTimeout('resizeToImage()',60);
}

function resizeToImage()
{
	pic = document.ShowImage;
//	pic.style.visibility = "hidden";
	h = pic.height;
	w = pic.width;
	if(w < 100)
	{
//	alert(pic.src);alert("resie" + w);
		setTimeout('resizeToImage()',60);
	}
	else
	{
		selectHeight = 20;
		if(parent.Select.innerHeight) selectHeight = parent.Select.innerHeight;
		max_nw = screen.availWidth - 30;
		max_nh = screen.availHeight - 80 - selectHeight;
		scale = 1;
		if(w > max_nw) scale = max_nw / w;
		if(h > max_nh) scale = Math.min(scale, max_nh / h);
		w = w * scale;
		h = h * scale;
		pic.style.visibility = "visible";
		pic.style.width = w;
		pic.style.height = h;
		h += selectHeight;
		parent.resizeTo(w,h);
		if(parent.innerHeight)
		{
			nw = w;
			nh = h;
			nw = 2 * w - parent.innerWidth;
			nh = 2 * h - parent.innerHeight;
			parent.resizeTo(nw,nh);
//		alert(parent.innerHeight);
		}
		else
		{
			h += 30;
			w += 10;
			parent.resizeTo(w,h);
		}
		var x = (screen.availWidth - w) / 3;
		var y = (screen.availHeight - h - 50) / 3;
		if(x < 0) x=0;
		if(y < 0) y=3;
		parent.moveTo(x,y);
		parent.focus();
	}
//	alert(document.getElementsByTagName("title")[0].text);
}
//---------------------------------------------------------------------------------------------- 
function OpenArchiv(URL)
{
	URL="album/"+URL+".html";
	h=screen.availHeight-50;
	w=750;
	options="status=no,location=no,menubar=no,directories=no,scrollbars=yes,height="+h+",width="+w;
	win=window.open(URL,'Archiv',options);
	win.moveTo(10,10);
	win.focus();
}

function ArchivPicture(PicTitle,pic)
{
	var base="../../";
	imgbase="../../images/album/";
	ShowPic(PicTitle,pic);
}

function ShowPic(PicTitle,pic)
{
var width=screen.availWidth*0.9;
if(width > 750) width=750;
var height=screen.availHeight;
if(height > 750) height=750;
var opts = "Scrollbars=no,toolbar=no,status=no,menubar=no,location=no,rezisable=no,width="+width+",height="+height;
pic=pic+"_xl.jpg";
height-=20;
Imag=window.open("","Img",opts);
Imag.moveTo(10,10);
Imag.document.open("text/html");
Imag.document.write("<html><head><title>" +PicTitle + "</title></head>"
+ "<link href='"+ base +"format.css' rel=stylesheet type=text/css>"
+ "<body class='ImgWindow'><center><table cellpadding=0 cellspacing=0><tr><td><img src=" + imgbase + "empty.gif height="+ height +" width=1></td><td valign='middle'>"
+ "<a href='JavaScript:window.close()'><img src=" + imgbase + pic + " border=1 alt='close window'></a>"
+ "</td><td><img src=" + imgbase + "empty.gif height="+ height +" width=1></td></tr></table></center></body></html>");
Imag.document.close;
Imag.focus();
return;
}


function printout()
{
	show("Printbutton",0);
	show("Closebutton",0);
	self.print();
	show("Printbutton",1);
	show("Closebutton",1);
	return;
}

vis = new Array("hidden","visible");
function show(which,mod)
{
	if (document.all)
	{
	eval("document.all."+which+".style.visibility='"+vis[mod]+"'");
	}else{
	eval("document."+which+".visibility='"+vis[mod]+"'");
	}
return;
}

//---------------------------------------------------------------------------------------------- 
function ShowBoat(img)
{
	i = 0;
//	alert(anc.nodeName);
	htm=img.parentNode.href;
	if(parent.Show.location.href != htm) parent.Show.location.href = htm;
}

//---------------------------------------------------------------------------------------------- 
function load_boat()
{
//	titel = document.getElementsByTagName("title")[0];
//	titel.text = titel.text + " - " + opener.parent.Select.document.getElementById("CacheTitle").value;
	cacheId = "CacheImage";
	pic = document.getElementById(cacheId);
//	alert(parent.frames[1].name);return;
	img = parent.Cache.document.getElementById(cacheId);
//	tag = parent.Select.document.childNodes[1].childNodes[1];
//	alert(tag.tagName + " " + tag.nodeValue);return;
//	alert(img.src);return;
	pic.src = img.src;
	imgsrc = img.src;
//	pic.style.visibility = "hidden";
	h = pic.height;
	w = pic.width;
	if(h < w)
	{
		img = document.getElementById("ShowImageLandscape");
		boat = document.getElementById("ShowBoatLandscape").firstChild;
		text = document.getElementById("ShowTextLandscape").firstChild;
		tabl = document.getElementById("tableLandscape");
	}
	else
	{
		img = document.getElementById("ShowImagePortrait");
		boat = document.getElementById("ShowBoatPortrait").firstChild;
		text = document.getElementById("ShowTextPortrait").firstChild;
		tabl = document.getElementById("tablePortrait");
	}
	img.src = pic.src;
	img.setAttribute("heigth", h);
	img.setAttribute("width", w);
	boat.nodeValue = parent.Cache.document.getElementById("CacheBoat").firstChild.nodeValue;
	text.nodeValue = parent.Cache.document.getElementById("CacheText").firstChild.nodeValue;
	tabl.setAttribute("style", "visibility:visible;");
	return;
	Imag = self;
	//imgbase = '';
	Imag.document.open("text/html");
	Imag.document.write("<html><head><title>Bootsbau Yacht Werft Dick Kiel</title>"
	+ "<link href='"+ base +"format.css' rel=stylesheet type='text/css'></head>"
	+ "<body><center><table cellpadding=0 cellspacing=0 width=100% height=100%><tr><td>"
	+ "<img src=\"" + imgsrc + "\" border=1 alt=''>"
	+ "</td></tr></table></center></body></html>");
	Imag.document.close;
}
//---------------------------------------------------------------------------------------------- 


