var popupContainer = function(c){
	var cont = document.createElement("div");
	cont.style.position = "absolute";
	cont.style.padding = "30px";
	cont.style.textAlign = "center";
	var back = document.createElement("div");
	back.className = "rest_popup_back";
	cont.appendChild(back);
	if(c)cont.appendChild(c);
	return cont;
}

var popup = function(c){
	window.scrollTo(0,0);
	var bdy = document.body;
	bdy.style.overflow = "hidden";
	var layer = document.createElement("div");
	layer.className = "rest_overlay";
	layer.style.background = "url("+sushi.root+"img/spacer.gif)";
	layer.onclick = function(ev){
		if(!ev)ev = window.event;
		if(sushi.browser.gecko){
			var target = ev.relatedTarget;
			var from   = ev.target;
		}
		else{
			var target = ev.toElement;
			var from   = ev.srcElement;	
		}
		if(from == c || sushi.isChildOf(from,c))return;
		bdy.removeChild(layer);
		bdy.style.overflow = "visible";
	}
	bdy.appendChild(layer);

	var cont = popupContainer(c);
	cont.style.color = "white";
	layer.appendChild(cont);

	//	position
	var w  = cont.offsetWidth;
	var bw = bdy.offsetWidth;
	cont.style.left = (bw-w)/2 + "px";
	cont.style.top  = "150px";

	//	close
	var close = document.createElement("span");
	close.innerHTML = "<b>(x)schließen</b>";
	close.style.position = "absolute";
	close.style.top = close.style.left = "8px";
	close.style.fontSize = "12px";
	close.style.cursor = "pointer";
	cont.appendChild(close);
	return cont;
}

var sushiPlaces = {
	box : "http://maps.google.de/maps?f=q&source=s_q&hl=de&geocode=&q=Boxhagener+Stra%C3%9Fe+44,+Berlin&sll=51.151786,10.415039&sspn=25.370884,67.675781&ie=UTF8&ll=52.510109,13.464003&spn=0.018283,0.036478&z=14&output=embed",
	bln : "http://maps.google.de/maps?f=q&source=s_q&hl=de&geocode=&q=Berlin,+Berliner+Str.+1-3+&sll=51.151786,10.415039&sspn=25.370884,67.675781&ie=UTF8&ll=52.442252,13.265219&spn=0.018312,0.036478&z=14&iwloc=A&output=embed",
	trp : "http://maps.google.de/maps?f=q&source=s_q&hl=de&geocode=&q=Wilhelminenhofstra%C3%9Fe+48,+Berlin&sll=52.460082,13.516585&sspn=0.005799,0.016512&ie=UTF8&hq=&hnear=Wilhelminenhofstra%C3%9Fe+48,+Berlin+12459+Berlin&z=14&ll=52.45962,13.52433&output=embed",
	pan : "http://maps.google.de/maps?f=q&source=s_q&hl=de&geocode=&q=Wollankstr.+13+berlin&sll=52.56654,13.39604&sspn=0.01123,0.012252&ie=UTF8&hq=&hnear=Wollankstra%C3%9Fe+13,+Berlin+13187+Berlin&z=14&ll=52.56654,13.39604&output=embed",
	hoh : "http://maps.google.de/maps?f=q&source=s_q&hl=de&geocode=&q=rotkamp+2+berlin&aq=&sll=51.151786,10.415039&sspn=24.033931,67.631836&ie=UTF8&hq=&hnear=Rotkamp+2,+Berlin+13053+Berlin&ll=52.56092,13.50878&spn=0.011335,0.033023&z=14&output=embed",
	tmp : "http://maps.google.de/maps?f=q&source=s_q&hl=de&geocode=&q=Tempelhofer+Damm+128,+Berlin&aq=0&sll=51.151786,10.415039&sspn=24.033931,67.631836&ie=UTF8&hq=&hnear=Tempelhofer+Damm+128,+Berlin+12099+Berlin&ll=52.468508,13.385296&spn=0.00915,0.018239&z=15&iwloc=A&output=embed"
};
var sushiImages = {
	box : [
		sushi.root+"img/restaurant/galerie/innenfoto.jpg",
		sushi.root+"img/restaurant/galerie/aussen_nachts.jpg"
	],
	bln : [
		sushi.root+"img/restaurant/galerie/innenfoto.jpg",
		sushi.root+"img/restaurant/galerie/aussen_nachts.jpg"
	]
};

//	Map
var sushiMap = function(place){
	var iframe = document.createElement("iframe");
	iframe.scrolling = "no";
	iframe.marginheight = iframe.marginwidth = iframe.frameborder = "0";
	iframe.style.height = iframe.style.width = "500px";
	iframe.style.border = "2px solid #bb0000";
	iframe.src = sushiPlaces[place];
	var cont = popup(iframe);
	if(sushi.browser.ie == 6){
		iframe.style.position = "relative";
		iframe.style.left = "-25px";
		cont.style.width  = "560px";
		cont.style.height = "500px";
	}
}

//	Galerie
var sushiGalerieIndex = 0;
var sushiGalerieImage = null;
var imagePrev = function(place){
	var p = sushiImages[place];
	sushiGalerieIndex--;
	if(sushiGalerieIndex < 0)sushiGalerieIndex = p.length - 1;
	if(sushiGalerieImage)sushiGalerieImage.src = p[sushiGalerieIndex];
}
var imageNext = function(place){
	var p = sushiImages[place];
	sushiGalerieIndex++;
	if(sushiGalerieIndex > (p.length - 1))sushiGalerieIndex = 0;
	if(sushiGalerieImage)sushiGalerieImage.src = p[sushiGalerieIndex];
}
var sushiGalerie = function(place){
	var imgs = sushiImages[place];
	var image = sushiGalerieImage = new Image();
	image.src = imgs[sushiGalerieIndex];
	image.width  = 500;
	image.height = 350;
	image.className = "rest_galerie_image";
	var ic = document.createElement("div");
	ic.style.position = "relative";
	ic.style.width = "500px";
	ic.style.marginBottom = "5px";
	ic.appendChild(image)
	var cont = popup(ic);

	//	Description
	var desc = document.createElement("span");
	desc.innerHTML = "Klicken Sie auf die linke oder rechte Seite des Bildes um,<br/>das nächste Bild zu sehen."
	desc.style.fontSize = "12px";
	desc.style.color = "white";
	cont.appendChild(desc);

	//	Overlays
	var lOv = document.createElement("div");
	lOv.innerHTML = "<div id=\"rest_galerie_go_left\">das vorherige Bild</div>"
	lOv.className = "rest_galerie_left";
	lOv.style.background = "url("+sushi.root+"img/spacer.gif)"
	ic.appendChild(lOv);
	lOv.onmouseover = function(){ lOv.firstChild.style.display = "block";};
	lOv.onmouseout = function(){ lOv.firstChild.style.display = "none";};
	lOv.onclick = function(){imagePrev(place);}

	var rOv = document.createElement("div");
	rOv.innerHTML = "<div id=\"rest_galerie_go_right\">das nächste Bild</div>"
	rOv.style.background = "url("+sushi.root+"img/spacer.gif)"
	rOv.className = "rest_galerie_right";
	ic.appendChild(rOv);
	rOv.onmouseover = function(){ rOv.firstChild.style.display = "block";};
	rOv.onmouseout = function(){ rOv.firstChild.style.display = "none";};
	rOv.onclick = function(){imageNext(place);}

	if(sushi.browser.ie == 6 || sushi.browser.ie == 7){
		ic.style.width = "500px";
		desc.style.position = "relative";
		if(sushi.browser.ie == 6){
			ic.style.left = "-25px";
			desc.style.left = "-25px";
		}
		cont.style.width  = (sushi.browser.ie == 6) ?  "560px" : "500px";
		cont.style.height = (sushi.browser.ie == 6) ?  "370px" : "440px";
	}
	else cont.style.paddingBottom = "5px";
}

//	Reservierung
var sushiReservierung = function(){
	var desc = document.createElement("div");
	desc.style.fontSize  = "12px";
	desc.style.textAlign = "left";
	desc.innerHTML = "<b>Ihre Firmen- oder<br/>Geburtstagsfeier<br/>im Happy Sushi Restaurant!</b><br/><br/>\
	<ul>\
		<li style=\"margin-top:5px;\">Reservieren Sie unsere Partytische<br/>für 4-12 Personen.</li>\
		<li style=\"margin-top:5px;\">Lassen Sie sich in stilvollem<br/>Ambiente verwöhnen.</li>\
		<li style=\"margin-top:5px;\">Wählen Sie à la Carte oder unsere<br/>fantastischen Partyplatten.</li>\
	</ul><br/>\
	<b>Reservierungshotline</b><br/>\
	Tel 030 - 42 02 02 66<br/>\
	Fax 030 - 25 76 83 14<br/><br/>\
	<a href=\"mailto:info@happy-sushi.de\" class=\"rest_link\">info@happy-sushi.de</a><br/>\
	Ansprechpartner: Hr. Grove"

	var cont = popup(desc);
	var back = cont.firstChild;
	cont.style.color = "#660000";
	back.style.background = "url("+sushi.root+"img/restaurant/reserv_back.jpg)";
	if(sushi.browser.ie == 6 || sushi.browser.ie == 7){
		cont.style.width  = "230px";
		cont.style.height = "280px";
		if(sushi.browser.ie)cont.style.paddingBottom = "320px";
	}
}
