/*
 * runOnLoad(function() { var seefest = getCookie('seefest'); if (seefest == '') { setCookie('seefest', 'seen', null,
 * '/'); Ext.MessageBox.maxWidth = 800; var box = Ext.MessageBox.show({ title: 'Seefest', msg: '<img
 * src="/images/gd/seefest.jpg" alt="" style="width:640px;height:457px;">', animEl: 'head', width: 640, height: 457,
 * modal: false, fn: function(){ Ext.MessageBox.hide(); } }); }; });
 */
var changeDet = function(el) {
	var mPic = Ext.get('mPic');
	if (mPic) {
		var url = el.src.replace(/\/thm\//, '/media/');
		if (url == mPic.dom.src) {
			return;
		};
		mPic.removeAllListeners();
		mPic.on('load', function() {
			mPic.fadeIn();
		});
		mPic.shift({
			opacity : 0,
			callback : function() {
				mPic.dom.src = url;
			}
		});
	}
};
var initMap = function() {
	if (!this.maps.gmap_anfgmap) {
		window.setTimeout(initMap.createDelegate(this), 100);
		return;
	};
	this.maps.gmap_anfgmap.map.setZoom(8);
	this.maps.gmap_anfgmap.mapMarkers['default'][0].openInfoWindowTabsHtml([
		new google.maps.InfoWindowTab('Adresse', this.config.points[0].customtext), new google.maps.InfoWindowTab('Route', this.directionsTxt(this.config.points[0].point, this.config.id, this.config.points[0].loc_street + ',' + this.config.points[0].loc_ort))
	]);
};
var gkey = 'ABQIAAAAy-MfgKvKUTrUdcDeLLAi0RRKNy4wrhSDNjLKDT2VZ_DXvrBHQBQMwQ8jsMV0JSCV6Mm-POY183FAgw';
runOnLoad(function() {
	var t = Ext.get('gmap_anfgmap');
	if (t) {
		LazyLoad.js('/_/scripts/libs/src/gmapfe.js', function() {
			var mconfig = {
				id : 'gmap_anfgmap',
				mt : '',
				lat : '9.64910',
				lon : '50.10115',
				zl : '6',
				pl : '',
				points : []
			};
			mconfig.points.push({
				"customtext" : "<div style='font-weight:bold;'>Gut D&uuml;rnhof</div><div>Burgsinner Stra&szlig;e 3</div><div>D-97794 Rieneck</div><div>(0 93 54) 10 01 </div><div><a href='mailto:info@gut-duernhof.de'>info@gut-duernhof.de</a></div><div><a href='http://www.gut-duernhof.de' target='_blank'>http://www.gut-duernhof.de</a></div>",
				"lat" : "50.10115",
				"lng" : "9.64910",
				"loc_land" : "Deutschland",
				"loc_plz" : "97794",
				"loc_ort" : "Rieneck",
				"loc_street" : "Burgsinner Str. 3",
				"loc_street_alt" : ""
			});
			gMap.create = gMap.create.createSequence(initMap, gMap);
			initGMap(mconfig);
		});
	};
	Ext.ux.Lightbox.overlayOpacity = 0.7;
	Ext.ux.Lightbox.labelImage = 'Bild';
	Ext.ux.Lightbox.labelOf = 'von';
	Ext.ux.Lightbox.register('a.lightbox', true);
	Ext.select('a.dirs21').each(function(l) {
		l.dom.onclick = function() {
			return (false);
		};
		l.on('click', function(e, o) {
			var html = '<iframe frameborder="no" scrolling="auto" src="' + o.href + '" style="width:780px; height: 740px;"></iframe>';
			Ext.Msg.maxWidth = 800;
			Ext.Msg.show({
				title : 'Verf&uuml;gbarkeit pr&uuml;fen',
				msg : html,
				buttons : null,
				animEl : o
			});
		});
	});
	Ext.select('.angebotlink').each(function(a) {
		a.up('div.angebotcnt').setOpacity(.8);
		a.on('mouseover', function(e, el) {
			Ext.get(el).up('div.angebotcnt').shift({
				opacity : 1
			});
		});
		a.on('mouseout', function(e, el) {
			Ext.get(el).up('div.angebotcnt').shift({
				opacity : .8
			});
		});
	});
	Ext.select('div.detpicmini img').each(function(a) {
		a.shift({
			opacity : .8
		});
		a.on('mouseover', function(e, el) {
			Ext.get(el).shift({
				opacity : 1
			});
		});
		a.on('mouseout', function(e, el) {
			Ext.get(el).shift({
				opacity : .8
			});
		});
	});
	var bsl = Ext.select('div.startpicmaxi');
	var ids = [];
	bsl.each(function(img) {
		ids.push(img.dom.id);
	});
	var count = 1;
	var dur = 3;
	var slide = function() {
		var pic = Ext.get(ids[count]);
		if (pic) {
			pic.fadeIn({
				duration : dur,
				callback : function() {
					count++;
					if (count == ids.length) {
						count = 1;
						bsl.setDisplayed(false);
						bsl.first().setDisplayed(true);
					};
					window.setTimeout(slide, dur * 1000);
				}
			});
		}
	};
	if (ids.length > 0) {
		window.setTimeout(slide, dur * 1000);
	}
});
var loading = new Image();
loading.src = basepath + '_/pics/formwait.gif';
window.onbeforeunload = function(oEvent) {
	if (!oEvent) {
		oEvent = window.event;
	};
	var db = Ext.get('container');
	if (db) {
		db.mask('<img src="' + basepath + '_/pics/formwait.gif" style="margin:0 5px 0 0; vertical-align:middle;">Loading...');
	}
};
