var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion)
|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
for (var i=0;i<data.length;i++) {
var dataString = data[i].string;
var dataProp = data[i].prop;
this.versionSearchString = data[i].versionSearch || data[i].identity;
if (dataString) {
if (dataString.indexOf(data[i].subString) != -1)
return data[i].identity;
}
else if (dataProp)
return data[i].identity;
}
},
searchVersion: function (dataString) {
var index = dataString.indexOf(this.versionSearchString);
if (index == -1) return;
return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
},
dataBrowser: [
{   string: navigator.userAgent,
subString: "OmniWeb",
versionSearch: "OmniWeb/",
identity: "OmniWeb"
},
{
string: navigator.vendor,
subString: "Apple",
identity: "Safari"
},
{
prop: window.opera,
identity: "Opera"
},
{
string: navigator.vendor,
subString: "iCab",
identity: "iCab"
},
{
string: navigator.vendor,
subString: "KDE",
identity: "Konqueror"
},
{
string: navigator.userAgent,
subString: "Firefox",
identity: "Firefox"
},
{
string: navigator.vendor,
subString: "Camino",
identity: "Camino"
},
{   // for newer Netscapes (6+)
string: navigator.userAgent,
subString: "Netscape",
identity: "Netscape"
},
{
string: navigator.userAgent,
subString: "MSIE",
identity: "Explorer",
versionSearch: "MSIE"
},
{
string: navigator.userAgent,
subString: "Gecko",
identity: "Mozilla",
versionSearch: "rv"
},
{     // for older Netscapes (4-)
string: navigator.userAgent,
subString: "Mozilla",
identity: "Netscape",
versionSearch: "Mozilla"
}
],
dataOS : [
{
string: navigator.platform,
subString: "Win",
identity: "Windows"
},
{
string: navigator.platform,
subString: "Mac",
identity: "Mac"
},
{
string: navigator.platform,
subString: "Linux",
identity: "Linux"
}
]
};
BrowserDetect.init();
var IE = BrowserDetect.browser == 'Explorer' ? true : false;
var IE7 = IE && BrowserDetect.version == '7' ? true : false;
function set_cookie(name,value,expires,path) {
if(!path) path = '/';
//document.cookie = name+'='+value; expires="+ablauf.toGMTString();
var c = name+'='+value+'; path='+path+'';
document.cookie = c;
}
function get_cookie(name) {
var c = document.cookie.split(/; /); // space is important!!
for(var i=0;i<c.length;i++) {
var cookie = c[i].split(/=/);
if(cookie[0] == name) {
return cookie[1];
}
}
return '';
}
function clear_cookie(name) {
document.cookie = name+'=""; expires:0';
}
var onload_stack = new Array();
function add_onload(fnc) {
onload_stack.push(fnc);
}
function run_onload() {
n = onload_stack.length;
for(var i=0;i<n;i++) {
fnc = onload_stack.pop();
fnc();
}
}
function InfoBubbleToggle(buttonId,elemId,posX,posY) {
var b = $(buttonId);
var e = $(elemId);
var bubbles = $$('.info-bubble');
for(var i=0;i<bubbles.length;i++) {
if(!bubbles[i].className.match(/info\-bubble/)) {
bubbles[i].display = 'none';
}
}
if(e.className.match(/info\-bubble/)) { 	
Position.absolutize(b);
Position.absolutize(e);
Position.clone(b,e);
e.style.top = '0px';
e.style.left = '0px';
e.style.width = '200px';
e.style.height = 'auto';
e.style.zIndex = 300;
/* 
e.style.position = 'absolute';
e.style.top  = parseInt(posY)+'px';
e.style.left = parseInt(posX)+'px';
*/
if(e.style.display == 'none') {
Effect.Appear(e, {duration:0.2});
} else {
Effect.Fade(e, {duration:0.2});
}
}
}
function AjaxFormCollect(formId) {
var values = '';
var inputs = $(formId).getElementsByTagName('input');
for(var i=0;i<inputs.length;i++) {
switch(inputs[i].type) {
case 'text':
case 'hidden': 
case 'password':
values += inputs[i].name+'='+encodeURIComponent(inputs[i].value)+'&';
break;
case 'radio':
case 'checkbox':
if(inputs[i].checked == true) {
values += inputs[i].name+'='+encodeURIComponent(inputs[i].value)+'&';
}
break;
}
}
var textareas = $(formId).getElementsByTagName('textarea');
for(var i=0;i<textareas.length;i++) {
if(textareas[i].className.match(/mceEditorEnabled/)) {
values += textareas[i].name+'='+encodeURIComponent(tinyMCE.getContent(textareas[i].id))+'&';
} else {
values += textareas[i].name+'='+encodeURIComponent(textareas[i].value)+'&';
}
}
var selects = $(formId).getElementsByTagName('select');
for(var i=0;i<selects.length;i++) {
switch(selects[i].multiple) {
case true:
for(var j=0;j<selects[i].options.length;j++) {
if(selects[i].options[j].selected == true) {
values += selects[i].name+'[]='+encodeURIComponent(selects[i].options[j].value)+'&';
}
}
break;
case false:
values += selects[i].name+'='+encodeURIComponent(selects[i].options[selects[i].selectedIndex].value)+'&';
break;
}
}
return values;
}
function StdAjax(url,vars) {
if(!vars.onFailure) {
vars.onFailure = function() {
//alert('Connectivity error!');
}
}
if(!vars.onSuccess) {
vars.onSuccess = function() { }
}
if(!vars.onError) {
vars.onError = function() { }
}
// onWhatever gets called on EVERY ajax call, as long as
// the server responded (AFTER onSuccess/onError)
if(!vars.onWhatever) {
vars.onWhatever = function() { }
}
if(!vars.parameters) {
vars.parameters = '';
}
// detect ssl in URL and adapt if necessary
if (window.location.protocol == 'https:' && url.indexOf('http') != 0)
{
url = 'https://'+window.location.hostname+url;
}
new Ajax.Request(
url,
{
method: 'post',
parameters: vars.parameters,
onSuccess: function(result) {
try
{
if (result.responseText == '')
{
vars.onFailure();
return;
}
eval('var res = '+result.responseText+'');
if (res.success)
{
if(document.getElementById('no_ajaxactions') == null) ajax_action(res.result);
vars.onSuccess(res.result);
}
else
{
vars.onError(res.result, res.errors);
}
vars.onWhatever(res.result);
}
catch (e)
{
// turn me off after developing
//console.log(e);
}
},
onFailure: vars.onFailure
}
);
}
function sFetchInlineScripts(node,targetNode) {
var scripts = $(node).getElementsByTagName('script');
var script = '';
for(var i=0;i<scripts.length;i++) {
if(scripts[i].innerHTML.match(/tinyMCE\.init/)) continue;
script += scripts[i].innerHTML;
}
return script;
}
function ajax_action( oAjaxResult ){
if( oAjaxResult.actions != null ){
var nHtmlContentCount = 0;
for( var loop = 0 ; loop < oAjaxResult.actions.length ; loop++ ){
var sActionString = oAjaxResult.actions[ loop ];
var sSeparator = sActionString.charAt( 0 );
var aParts = sActionString.split( sSeparator );
var sCommand = "";
try{
switch( aParts[ 1 ] ){
case 'func':
sCommand = aParts[ 2 ] + '(' + aParts[ 3 ] + ')';
eval( sCommand );
break;
case 'style':
document.getElementById( aParts[ 2 ] ).style[ aParts[ 3 ] ] = aParts[ 4 ];
break;
case 'class':
document.getElementById( aParts[ 2 ] ).className = aParts[ 3 ];
break;
case 'html':
document.getElementById( aParts[ 2 ] ).innerHTML = oAjaxResult.html_action_contents[ nHtmlContentCount ];
nHtmlContentCount++;
break;
case 'value':
document.getElementById( aParts[ 2 ] ).value = aParts[ 3 ];
break;
case 'redirect':
document.location.href = aParts[ 2 ];
break;
case 'imagesrc':
document.getElementById( aParts[ 2 ] ).src = aParts[ 3 ];
break;
}
}catch( exception ){
//alert( 'command: "' + sActionString + '" failed!\n' + exception );
}
}
}
}
AjaxOnCreateHook = function(oRequest)
{
oRequest.options.requestHeaders = { 'X-CT-AjaxRequest' : '1' }
/*oRequest.oTimeout = window.setTimeout('vShowLoading', 1000);*/
vShowLoading();
}
AjaxOnCompleteHook = function(oRequest)
{
if (oRequest.oTimeout)
window.clearTimeout(oRequest.oTimeout);
vHideLoading();
}
Ajax.Responders.register(
{
onCreate: AjaxOnCreateHook
,onComplete: AjaxOnCompleteHook
});
function vShowLoading()
{
if ($('MBLoader1'))
{
$('MBLoader1').show();
}
}
function vHideLoading()
{
if ($('MBLoader1'))
{
$('MBLoader1').hide();
}
}
function oDateToObject(sDate) {
var aDateTime = sDate.split(' ');
var aDate = aDateTime[0].split('-');
var aTime = aDateTime[1].split(':');
return {
year:lz(aDate[0]), month:lz(aDate[1]), day:lz(aDate[2]), hour:lz(aTime[0]), minute:lz(aTime[1]), second:lz(aTime[2])
};
}
function oDateToday() {
oDate = new Date();
return {
year:lz(oDate.getFullYear()), month:lz(oDate.getMonth()+1), day:lz(oDate.getDate()), hour:lz(oDate.getHours()), minute:lz(oDate.getMinutes()), second:lz(0)
};
}
function lz(num) { // leading zero
var str = ''+num+'';
if(str.length == 1) {
return '0'+str;
}
return num;
}
function sDateToday() {
oDate = new Date();
var sDate = lz(oDate.getFullYear())+'-'+lz(oDate.getMonth()+1)+'-'+lz(oDate.getDate())+' '+lz(oDate.getHours())+':'+lz(oDate.getMinutes())+':'+lz(0);
return sDate;
}
function vFocus(sField)
{
if ($(sField))
$(sField).focus();
}
function UpdateRegions(poSelector, piCountryId)
{
StdAjax(
'/registrierung',
{
parameters: { iCountryId: piCountryId, command: 'getRegions' },
onSuccess: function(result) 
{
poSelector.innerHTML = '';
var o = document.createElement('option');
o.value = 0;
o.appendChild(document.createTextNode('Auswahl'));
poSelector.appendChild(o);
$H(result).each(function(e)
{
var o = document.createElement('option');
o.value = e.key;
o.appendChild(document.createTextNode(e.value));
poSelector.appendChild(o);
});
},
onError: function(result, errors) {}
}
);
}
function ExchangeHint(oField)
{
if (!oField.sOldValue)
{
oField.sOldValue = oField.value;
}
if (oField.sOldValue == oField.value)
{
$(oField).removeClassName('Hint');
oField.value = '';
return;
}
if (!oField.value.length)
{
$(oField).addClassName('Hint');
oField.value = oField.sOldValue;
}
}
var InlineHelp = Class.create();
InlineHelp.prototype = {
oTrigger: null,
oHelp: null,
initialize: function(poTrigger, psText)
{
if (poTrigger.oHelp)
{
return;
}
poTrigger.oHelp = document.createElement('div');
poTrigger.oHelp.innerHTML = psText;
poTrigger.oHelp.style.display = 'none';
poTrigger.oHelp.className = 'InlineHelp';
poTrigger.parentNode.insertBefore(poTrigger.oHelp, poTrigger);
poTrigger.style.cursor = 'help';
poTrigger.style.verticalAlign = 'middle';
poTrigger.oHelp.style.cursor = 'help';
$(poTrigger.oHelp).clonePosition
(
poTrigger,
{ setWidth: false, 
setHeight: false, 
offsetLeft: Math.round(poTrigger.offsetWidth / 2),
offsetTop: Math.round(poTrigger.offsetHeight / 2)
}
);
Event.observe(poTrigger, 'mouseover', this._vShowHelp);
Event.observe(poTrigger, 'mouseout', this._vHideHelp);
Event.observe(poTrigger.oHelp, 'mouseover', function(e) { $(Event.element(e)).show(); });
Event.observe(poTrigger.oHelp, 'mouseout', function(e) { $(Event.element(e)).hide(); });
},
_vShowHelp: function(e)
{
if (!Event.element(e).oHelp)
{
return;
}
$(Event.element(e).oHelp).show();
},
_vHideHelp: function(e)
{
if (!Event.element(e).oHelp)
{
return;
}
$(Event.element(e).oHelp).hide();
}
}
//******* Aufklappmenue (mainnav) *******************************/
startList = function(navRoot) {
if (!navRoot || !navRoot.hasChildNodes())
{
return;
}
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
if ($(node.getElementsByTagName('A')[0]).hasClassName('active'))
{
$(node).addClassName('over');
}
node.onmouseover=function() {
var nds = this.parentNode.getElementsByTagName('li');
for (k=0; k<nds.length; k++)
$(nds[k]).removeClassName('over');
$(this).addClassName('over');
var sublist = this.getElementsByTagName('UL')[0];
if (sublist){
for (j=0; j<sublist.childNodes.length; j++){
subNode = sublist.childNodes[j];
if (subNode.nodeName!='LI') {
continue;
}
subNode.onmouseover=function() {
var nds = this.parentNode.getElementsByTagName('li');
for (k=0; k<nds.length; k++)
$(nds[k]).removeClassName('over');
$(this).addClassName('over');
}
subNode.onmouseout=function() {
}   
}
}
}
node.onmouseout=function() {
}
}
}
}
add_onload(function () { startList($$('.lvl1')[0]);  } );
add_onload(function () { startList($$('.lvl0')[0]);  } );
var Debug = Class.create();
Debug.prototype = {
oMsgWindow: null,
initialize: function()
{
if (!this.oMsgWindow)
{
var _this = this;
this.oMsgWindow = document.createElement('div');
this.oMsgWindow.oHeader = document.createElement('h1');
this.oMsgWindow.oHeader.appendChild(document.createTextNode('DEBUG'));
this.oMsgWindow.oTools = document.createElement('form');
this.oMsgWindow.oTools.innerHTML = 'AdKeys: <input type="text" id="NewAdKeys" /><input type="button" value="Reload Ads" onclick="vUpdateAds($(\'NewAdKeys\').value); ReloadBoxes($(\'NewAdKeys\').value); return false" />';
this.oMsgWindow.oContent = document.createElement('div');
this.oMsgWindow.oContent.style.display = 'none';
this.oMsgWindow.id = 'JSDebug';
this.oMsgWindow.appendChild(this.oMsgWindow.oHeader);
this.oMsgWindow.appendChild(this.oMsgWindow.oTools);
this.oMsgWindow.appendChild(this.oMsgWindow.oContent);
document.body.appendChild(this.oMsgWindow);
Event.observe(this.oMsgWindow.oHeader, 'click', function() { $(_this.oMsgWindow.oContent).toggle(); });
}
return this;
},
Clear: function()
{
this.oMsgWindow.oContent.innerHTML = '';
},
Show: function(psValue)
{
this.oMsgWindow.oContent.innerHTML += '<p>'+psValue+'</p>';
}
}
var oDebug = null;
function debug(psValue)
{
if (!window.bIsLoaded)
{
add_onload(function() { debug(psValue); });
return;
}
if (typeof __DEBUG == 'undefined')
{
return;
}
if (!oDebug)
{
oDebug = new Debug();
}
if (!psValue || psValue.length == 0)
{
oDebug.Clear();
return;
}
oDebug.Show(psValue);
}
var IVW = Class.create();
IVW.prototype = {
sIVWCode: null,
initialize: function()
{
return this;
},
// parameter IVWCode, update AddServer, load AGOF [true/false], 
// parameter reload_agf is depricated
Change: function(psIVWCode, no_update, no_agf, reload_agf)
{
var sIVWCode = psIVWCode;
if (!sIVWCode)
{
sIVWCode = typeof __ivw != 'undefined' ? __ivw : null;
}
if (!sIVWCode)
{
return;
} 
var no_update = no_update; 
no_update = typeof no_update != 'undefined' ? no_update : null;
// depricated variable reload_agf: if no_agf is null AGOF is reloaded
// var reload_agf = reload_agf;
// reload_agf = typeof reload_agf != 'undefined' ? reload_agf : null;
var no_agf = no_agf; 
no_agf = typeof no_agf != 'undefined' ? no_agf : null; 
if(typeof __DEBUG != 'undefined')
{
debug('IVW:' + sIVWCode);
if(no_agf == null)
{
debug('agof_reload'); 
}
}
else if($('ivw_img') && IVWURL)
{
$('ivw_img').style.display = 'block'; 
$('ivw_img').src=IVWURL+ sIVWCode+";comment?r="+escape(document.referrer)+"&d="+(Math.random()*100000); 
}
/* reload agof i-frame */
if((no_agf==null) && $('agofscript') && AGOFURL)
{ 
agofcode = sIVWCode; 
if(typeof($('agofscript').src) != 'undefined') {
$('agofscript').src = "/agof.php?agofcode="+agofcode;
}
if(typeof($('agofscript').location) != 'undefined') {
$('agofscript').location.href = "/agof.php?agofcode="+agofcode
}
// $('agofscript').contentWindow.location.reload();
}
if(no_update == null)
{
vUpdateAds();  
}
}
}
var oIVW = new IVW;
function ft_sendInfo(clickName,id,link){
if(typeof id != "undefined" && id)
{
clickName = clickName + "." + id; 
// var action = action.substr(7);
// var action = action.split("/",2);
// if(typeof action[1] != "undefined")
// { 
//  clickName = clickName + "." + action[1];
//} 
}
clickName = clickName + ".klick"; 
if (typeof(wt_sendinfo) != 'undefined') {
wt_sendinfo(clickName, link);
}
}
/* ads */
var Ads = Class.create();
Ads.prototype = {
_aTargets: [],
initialize: function()
{
this._aTargets = $$('.AdTarget');
return this;
},
_sCleanKeys: function(psKeys)
{
psKeys = psKeys.toLowerCase();
psKeys = psKeys.replace(/ä/g, 'ae');
psKeys = psKeys.replace(/ö/g, 'oe');
psKeys = psKeys.replace(/ü/g, 'ue');
psKeys = psKeys.replace(/ß/g, 'ss');
psKeys = psKeys.replace(/[^a-z0-9_\+]/g, '_');
psKeys = psKeys.replace(/_+/g, '_');
return psKeys;
},
/**
* 
* @param {string} psTarget - The id of the ad target element
* @param {string} psKeys - The keys for the ads
* @param {string} poSubKeys - New for Premium POI ads. This property contains 3 keys which contain the current category, city and country.
*                             This is only set if we reload a Premium POI ad.
*/
_vUpdate: function(psTarget, psKeys, poSubKeys)
{
var oTarget = $(psTarget);
var bIsIFrame = oTarget.tagName.toLowerCase() == 'iframe';
if (psKeys)
{
psKeys = this._sCleanKeys(psKeys);
}
debug('<b>New keys received for '+psTarget+': </b>'+psKeys);
if (!oTarget) return;
var oTmp;
if(bIsIFrame){
oTmp = oTarget;
}
else{
oTmp = oTarget.getElementsByTagName('script')[0];
}
if (!oTmp) return;
var sUrl = oTmp.src;
if(bIsIFrame){
sUrl = sUrl.replace(location.href.replace(location.pathname, ''), '');
}		
if (psKeys && psKeys.length > 0)
{
sUrl = sUrl.replace(/^(.*;key=)(.*)(;misc=)([0-9]+)(.*)$/, '$1'+psKeys+'$3'+(Math.floor(new Date().getTime() / 1000))+'$5')
}
if(poSubKeys){
// prevent passing 'null/undefined' to sub1
if(!poSubKeys.sActCategory){ poSubKeys.sActCategory = ''; }
var sSubKeys = ';sub1=' + poSubKeys.sActCategory + ';sub2=' + poSubKeys.sActCity + ';sub3=' + poSubKeys.sActCountry + ';';
sUrl = sUrl.replace(/;sub1=.*;sub2=.*;sub3=.*;/, sSubKeys);
this._vTriggerUpdate(oTarget, sUrl, true);
}
else {
this._vTriggerUpdate(oTarget, sUrl);
}
},
_vUpdateAll: function(psKeys)
{
var _this = this;
$A(this._aTargets).each(function(oTarget)
{
// in case we receive a premium poi ad we have to handle the key / sub key substitution in 
// a different way.
if(oTarget.hasClassName('Premium-POI')){
if(window.TORR && window.TORR.oPremiumPOI){
_this._vUpdate(oTarget.id, psKeys, window.TORR.oPremiumPOI.oGetData());
}
}
else{
_this._vUpdate(oTarget.id, psKeys);
}
});
},
/**
* 
* @param {Object} poTarget
* @param {String} psUrl
* @param {Boolean} pbForceReload - forces reloading for IEs. used to reload premium poi ad.
*/
_vTriggerUpdate: function(poTarget, psUrl, pbForceReload)
{
var bIsIFrame = poTarget.tagName.toLowerCase() == 'iframe';
var oTarget = $(poTarget);
if (!oTarget) return;
var oFrame;
if(!bIsIFrame){
var oFrame = $('f_'+oTarget.id);
if (!oFrame) return;
}
else {
oFrame = oTarget;
}
var isIE6 = IE && !IE7;
if(!isIE6 || bIsIFrame || pbForceReload){
debug('<b>Reloading Ad: '+oTarget.id+'</b><br />'+psUrl);
oFrame.src = (bIsIFrame) ? psUrl : '/_ad_iframe.php?target='+oTarget.id+'&url='+psUrl;
}
},
_vReloadAd: function(psTarget, psInnerHTML)
{
if (!$(psTarget)) return;
debug('<b>Moving Ad: </b>'+psTarget);
$(psTarget).innerHTML = psInnerHTML;
}
}
function vUpdateAds(psKeys)
{
if (!oAds)
{
return;
}
oAds._vUpdateAll(psKeys);
}
function vUpdateAd(psTarget, psKeys)
{
if (!oAds)
{
return;
}
oAds._vUpdate(psTarget, psKeys);
}
function vReloadAd(psTarget, psInnerHTML)
{
if (!oAds)
{
return;
}
oAds._vReloadAd(psTarget, psInnerHTML);
}
function vBounceAd(poTarget, psUrl)
{
if (!oAds)
{
return;
}
oAds._vTriggerUpdate(poTarget, psUrl);
}
function vResizeAdFrame(poTarget, piHeight)
{
$(poTarget).setStyle({ height: piHeight + 'px' });
}
var oAds = null;
add_onload(function() { oAds = new Ads; } );
window.onload = function()
{
window.bIsLoaded = true;
run_onload();
}
function clearHints(env) {
if (env) {
var e = $(env).select('.Hint');
} else {
var e = $$('.Hint');
}
for(i=0;i<e.length;i++) {
if(e[i].tagName == 'INPUT' && e[i].type == 'text') {
e[i].value = '';
}
}
}
function openPic(url,winName,winParams) {
var theWindow = window.open(url,winName,winParams);
if (theWindow)  {
theWindow.focus();  
}
}
/*
function webtrekk_id(url) {
var domain = '';
var path = '';
var curr_path = window.location.href.substr(0,window.location.href.lastIndexOf('/'));
curr_path = curr_path.substr(curr_path.indexOf('://')+3);
curr_path.substr(curr_path.indexOf('/')+1);
// full qualified, doesn't work yet !!
if(url.indexOf('://')>-1) {
url = url.substr(url.indexOf('://')+3);
url_parts = url.split('/');
domain = url[0];
path = url.substr(url.indexOf('/')+1);
// relative path
} else if(url.substr(0,1) != '/') {
path = curr_path+'/'+url;
// absolute path
} else {
path = url;
}
trekk_id = path.replace(/\./,'_');
if(domain) {
trekk_id = domain.replace(/\./,'_')+'.'+trekk_id;
}
trekk_id = trekk_id.replace(/\//,'.');
if(trekk_id.indexOf('.') == 0) {
trekk_id = trekk_id.substr(1);
}
alert("domain: "+domain+"\npath: "+path+"\ntrekk_id: "+trekk_id);
}
*/
/*
webtrekk_id('http://www.marcopolo.de/foo/bar');
webtrekk_id('http://www.marcopolo.de/foo/bar.html');
webtrekk_id('http://www.marcopolo.de/foo_bar.html');
webtrekk_id('/bla/foo_bar.html');
webtrekk_id('bla/foo_bar.html');
webtrekk_id('/foo_bar.html');
webtrekk_id('foo_bar.html');
*/
function ReloadBoxes(psTags)
{
if (!window.bIsLoaded)
{
add_onload(function() { ReloadBoxes(psTags); });
return;
}
$A($$('.Reloadable')).each(function(oBox)
{
var sId = $w(oBox.className)[0];
new Ajax.Request('/__containers__/'+sId,
{
method: 'post',
asynchronous: false,
parameters: { sContainerType: sId, sTags: psTags, sReferrer: window.location.pathname },
onSuccess: function(oResult) 
{
if (oResult.responseText.length == 0)
{
return;
}
var oTmp = document.createElement('div');
oTmp.innerHTML = oResult.responseText;
var aReloadables = $(oTmp).select('.Reloadable');
if (aReloadables.length == 0)
{
return;
}
var sNewContent = aReloadables[0].innerHTML;
oBox.innerHTML = sNewContent;
// boxcontrollers
$A($(oBox).select('.TabbedNav')).each(function(oBC)
{
Object.extend($(oBC), TabController);
$(oBC).initialize();
});
}
});
});
}
/* SWFObject v2 compatibility wrapper */
var SWFObject = Class.create();
SWFObject.prototype = {
swf: '',
id: '',
width: 0,
height: 0,
height: 7,
params: { menu: false, bgcolor: '#ffffff' },
variables: {},
attributes: {},
initialize: function(swf, id, width, height, version, bgcolor)
{
this.swf = swf;
this.width = width;
this.height = height;
this.version = version;
this.params.bgcolor = bgcolor;
return this;
},
write: function(id)
{
this.id = id;
var _this = this;
swfobject.embedSWF(this.swf, this.id, this.width, this.height, this.version, null, this.variables, this.params, this.attributes);
swfobject.addLoadEvent(function() { _this.forceRedraw(); });
},
forceRedraw: function()
{
var target = document.getElementById(SWFObject.id);
if (!target)
{
return;
}
target.style.display = 'block';
},
addParam: function(key, value)
{
this.params[key] = value;
},
addVariable: function(key, value)
{
this.variables[key] = value;
}
}
/**
* gettext.js ( http://code.google.com/p/gettext-js/ )
*
* @author     Maxime Haineault, 2007 (max@centdessin.com)
* @version    0.1.0
* @licence    M.I.T
* @example:
*
*   Gettext.lang = 'de';
*   Gettext.gettext('hello %s','world');
*   _('hello %s','world');
*
*/
var jsGettext = Class.create();
jsGettext.prototype = {
initialize: function(lang) {
this.lang         = lang || 'en';
this.debug        = true;
this.LCmessages   = {};
this.links        = [];
this.linksPointer = 0;
this.currentFetch = false;
var _this = this;
$$('link').each(function(link)
{
if (link.rel == 'gettext' && link.href && link.lang) 
{
_this.links.push([link.lang, link.href]);
}
});
new PeriodicalExecuter(function(pe) {
if (Gettext.linksPointer == Gettext.links.length) pe.stop();
else {
Gettext.include.apply(Gettext, Gettext.links[Gettext.linksPointer])
Gettext.linksPointer++;
}
}, 0.5);
},
log: function() {
if (typeof console != 'undefined' && console.log && this.debug) {
console.log.apply(this,arguments);
}
},
include: function(lang, href) {
if (!lang) return;
if (arguments[1].substring(0,7) == 'http://') {
onCompleteCallback = this.include_complete.bind(this);
this.currentFetch  = lang;
new Ajax.Request(arguments[1], {
onComplete: onCompleteCallback,
asynchronous: false
});
}
else {
this.LCmessages[lang] = new jsGettext.Parse(str);
Gettext.log('Loading language: ', lang.toUpperCase(), ' (',str,')');
}
this.log('Loading language: ', lang.toUpperCase(), ' (',href,')');
},
include_complete: function (t) {
this.log('Fetched language: ', this.currentFetch.toUpperCase(), ' ('+ t.responseText.length +' bytes)');
this.LCmessages[this.currentFetch] = this.parse(t.responseText);
this.log(_('Parsed: %d msgids, %d msgids-plurals, %d msgstrs, %d obsoletes, %d contexts, %d references %d flags, %d previous untranslateds, %d previous untranslated-plurals',[
this.LCmessages[this.currentFetch].msgid.length,
this.LCmessages[this.currentFetch].msgidplurals.length,
this.LCmessages[this.currentFetch].msgstr.length,
this.LCmessages[this.currentFetch].obsoletes.length,
this.LCmessages[this.currentFetch].contexts.length,
this.LCmessages[this.currentFetch].references.length,
this.LCmessages[this.currentFetch].flags.length,
this.LCmessages[this.currentFetch].previousUntranslateds.length,
this.LCmessages[this.currentFetch].previousUntranslatedsPlurals.length]));
this.currentFetch = false;
},
// This function based on public domain code. Feel free to take a look the original function at http://jan.moesen.nu/
// ---
// Changes made by Maxime Haineault (2007):
// - The function is now extended to Strings instead (using prototype)
// - The function now accept arrays as arguments, much easier to handle (using prototype)
// - The function throw error if argument lenght doesn't equal matches count (as specified in gettex file format documentation)	
// - Translations lookups
// Reference: http://www.gnu.org/software/gettext/manual/gettext.html#PO-Files
gettext: function() {
if (!arguments || arguments.length < 1 || !RegExp) return;
var str      = arguments[0];
arguments[0] = null;
arguments    = $A(arguments).compact();
if (arguments.length == 1 && typeof arguments[0] == 'object') {
arguments = $A(arguments[0]);
}
hasTokens = str.match('%','g');
if (hasTokens && hasTokens.length != arguments.length) {
Gettext.log('Gettext error: Arguments count ('+ arguments.length +') does not match replacement token count ('+ str.match('%','g').length +').');
return;
}
// Try to find translated string
if (Gettext.LCmessages[Gettext.lang] && Gettext.LCmessages[Gettext.lang].msgid.indexOf(str) != -1) {
str = Gettext.LCmessages[Gettext.lang].msgstr[Gettext.LCmessages[Gettext.lang].msgid.indexOf(str)];
}
var re  = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/; //'
var a   = b = [], i = 0, numMatches = 0;		
while (a = re.exec(str)) {
var leftpart   = a[1], pPad  = a[2], pJustify  = a[3], pMinLength = a[4];
var pPrecision = a[5], pType = a[6], rightPart = a[7];
numMatches++;
if (pType == '%') subst = '%';
else {
var param = arguments[i];
var pad   = '';
if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1);
else if (pPad) pad = pPad;
var justifyRight = true;
if (pJustify && pJustify === "-") justifyRight = false;
var minLength = -1;
if (pMinLength) minLength = parseInt(pMinLength);
var precision = -1;
if (pPrecision && pType == 'f') precision = parseInt(pPrecision.substring(1));
var subst = param;
if (pType == 'b')      subst = parseInt(param).toString(2);
else if (pType == 'c') subst = String.fromCharCode(parseInt(param));
else if (pType == 'd') subst = parseInt(param) ? parseInt(param) : 0;
else if (pType == 'u') subst = Math.abs(param);
else if (pType == 'f') subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision): parseFloat(param);
else if (pType == 'o') subst = parseInt(param).toString(8);
else if (pType == 's') subst = param;
else if (pType == 'x') subst = ('' + parseInt(param).toString(16)).toLowerCase();
else if (pType == 'X') subst = ('' + parseInt(param).toString(16)).toUpperCase();
}
str = leftpart + subst + rightPart;
i++;
}
return str;
},
parse: function(str) {
// #  translator-comments
// #. extracted-comments
// #: reference...
// #, flag...
// #| msgid previous-untranslated-string
// msgid untranslated-string
// msgstr translated-string
rgx_msg   = new RegExp(/((^#[\:\.,~|\s]\s?)?|(msgid\s"|msgstr\s")?)?("$)?/g);
function clean(str) {
return str.replace(rgx_msg,'').replace(/\\"/g,'"');
}
po        = str.split("\n");
head      = [];
msgids    = [];
strings   = [];
obs       = [];
tpls      = [];
curMsgid  = -1;
output    = { header: [], contexts: [], msgid: [], msgidplurals: [], references: [], flags: [], msgstr: [], obsoletes: [], previousUntranslateds: [], previousUntranslatedsPlurals: [] };
for(x=0, cnt=po.length; x<cnt; ++x) {
if (po[x].substring(0,1) == '#') {
switch (po[x].substring(1,2)) {
// translator-comments
case ' ':
// top comments
if (curMsgid == 0) output.header.push(po[x]);
break;
// references
case ':':
if(typeof output.references[curMsgid] == 'undefined') output.references[curMsgid] = [];
output.references[curMsgid].push(clean(po[x]));
break;
// msgid previous-untranslated-string
case '|':
if(typeof output.previousUntranslateds[curMsgid] == 'undefined') output.previousUntranslateds[curMsgid] = [];
// previous-untranslated-string-plural
if (po[x].substring(3,15) == 'msgid_plural') {
output.previousUntranslateds[curMsgid].push(clean(po[x]));
}
else {
output.previousUntranslatedsPlurals[curMsgid].push(clean(po[x]));
}
break;
// flags
case ',':
if(typeof output.flags[curMsgid] == 'undefined') output.flags[curMsgid] = [];
output.flags[curMsgid].push(clean(po[x]));
break;
// obsoletes
case '~':
if (po[x].substring(3,9) == 'msgid ') {
curMsgid++;
if(typeof output.msgid[curMsgid] == 'undefined') output.msgid[curMsgid] = [];
output.msgid[curMsgid].push(clean(po[x]));
output.obsoletes.push(curMsgid);
}
else if (po[x].substring(3,10) == 'msgstr ') {
if(typeof output.msgstr[curMsgid] == 'undefined')    output.msgstr[curMsgid] = [];
output.msgstr[curMsgid].push(clean(po[x]));
}
break;
}
}
else {
// untranslated-string
if (po[x].substring(0,6) == 'msgid ') {
if (po[x].substring(6,8) != '""')  {
curMsgid++;
// if(typeof output.msgid[curMsgid] != 'object') output.msgid[curMsgid] = [];
// output.msgid[curMsgid].push(clean(po[x]));
output.msgid[curMsgid] = clean(po[x]);
}
}
// untranslated-string-plural
if (po[x].substring(0,13) == 'msgid_plural ') {
if (!output.msgidplurals[curMsgid]) output.msgidplurals[curMsgid] = [];
output.msgidplurals[curMsgid].push(clean(po[x]));
}
// translated-string
if (po[x].substring(0,6) == 'msgstr') {
if (po[x].substring(8,10) != '""')  {
// translated-string-case-n
if (po[x].substring(6,7) == '[') {}
else {
// if (!output.msgstr[curMsgid]) output.msgstr[curMsgid] = [];
// output.msgstr[curMsgid].push(clean(po[x]));
output.msgstr[curMsgid] = clean(po[x]);
}
}
}
// context
if (po[x].substring(0,7) == 'msgctxt ') {
if (!output.contexts[curMsgid]) output.contexts[curMsgid] = [];
output.contexts[curMsgid].push(clean(po[x]));
}
}
}
return output;
}
}
/*
Gettext = new jsGettext();
Gettext.debug = false;
function _() { return Gettext.gettext.apply(this,arguments); }
*/
function _() { return arguments[0]; }
/* Copyright (c) 2007 Google Inc.
* 
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. 
*
* Version: 1.0
* Author: Doug Ricket, others
* 
* Marker manager is an interface between the map and the user, designed
* to manage adding and removing many points when the viewport changes.
*
*
* Algorithm: The MM places its markers onto a grid, similar to the map tiles.
* When the user moves the viewport, the MM computes which grid cells have
* entered or left the viewport, and shows or hides all the markers in those
* cells.
* (If the users scrolls the viewport beyond the markers that are loaded,
* no markers will be visible until the EVENT_moveend triggers an update.)
*
* In practical consequences, this allows 10,000 markers to be distributed over
* a large area, and as long as only 100-200 are visible in any given viewport,
* the user will see good performance corresponding to the 100 visible markers,
* rather than poor performance corresponding to the total 10,000 markers.
*
* Note that some code is optimized for speed over space,
* with the goal of accommodating thousands of markers.
*
*/
/**
* Creates a new MarkerManager that will show/hide markers on a map.
*
* @constructor
* @param {Map} map The map to manage.
* @param {Object} opt_opts A container for optional arguments:
*   {Number} maxZoom The maximum zoom level for which to create tiles.
*   {Number} borderPadding The width in pixels beyond the map border,
*                   where markers should be display.
*   {Boolean} trackMarkers Whether or not this manager should track marker
*                   movements.
*/
function MarkerManager(map, opt_opts) {
var me = this;
me.map_ = map;
me.mapZoom_ = map.getZoom();
me.projection_ = map.getCurrentMapType().getProjection();
opt_opts = opt_opts || {};
me.tileSize_ = MarkerManager.DEFAULT_TILE_SIZE_;
var maxZoom = MarkerManager.DEFAULT_MAX_ZOOM_;
if(opt_opts.maxZoom != undefined) {
maxZoom = opt_opts.maxZoom;
}
me.maxZoom_ = maxZoom;
me.trackMarkers_ = opt_opts.trackMarkers;
var padding;
if (typeof opt_opts.borderPadding == "number") {
padding = opt_opts.borderPadding;
} else {
padding = MarkerManager.DEFAULT_BORDER_PADDING_;
}
// The padding in pixels beyond the viewport, where we will pre-load markers.
me.swPadding_ = new GSize(-padding, padding);
me.nePadding_ = new GSize(padding, -padding);
me.borderPadding_ = padding;
me.gridWidth_ = [];
me.grid_ = [];
me.grid_[maxZoom] = [];
me.numMarkers_ = [];
me.numMarkers_[maxZoom] = 0;
GEvent.bind(map, "moveend", me, me.onMapMoveEnd_);
// NOTE: These two closures provide easy access to the map.
// They are used as callbacks, not as methods.
me.removeOverlay_ = function(marker) {
if (!marker.isInfoWindowOpened) {
map.removeOverlay(marker);
me.shownMarkers_--;
}
};
//ADDED: hideMe handling to keep markers hidden on zoom (robertsc)
me.addOverlay_ = function(marker) {
if( !marker.hideMe && !marker.isInfoWindowOpened ){
marker.isInfoWindowOpened = false;
map.addOverlay( marker );
me.shownMarkers_++;
}
};
me.resetManager_();
me.shownMarkers_ = 0;
me.shownBounds_ = me.getMapGridBounds_();
};
// Static constants:
MarkerManager.DEFAULT_TILE_SIZE_ = 1024;
MarkerManager.DEFAULT_MAX_ZOOM_ = 17;
MarkerManager.DEFAULT_BORDER_PADDING_ = 100;
MarkerManager.MERCATOR_ZOOM_LEVEL_ZERO_RANGE = 256;
/**
* Initializes MarkerManager arrays for all zoom levels
* Called by constructor and by clearAllMarkers
*/ 
MarkerManager.prototype.resetManager_ = function() {
var me = this;
var mapWidth = MarkerManager.MERCATOR_ZOOM_LEVEL_ZERO_RANGE;
for (var zoom = 0; zoom <= me.maxZoom_; ++zoom) {
me.grid_[zoom] = [];
me.numMarkers_[zoom] = 0;
me.gridWidth_[zoom] = Math.ceil(mapWidth/me.tileSize_);
mapWidth <<= 1;
}
};
/**
* Removes all currently displayed markers
* and calls resetManager to clear arrays
*/
MarkerManager.prototype.clearMarkers = function() {
var me = this;
me.processAll_(me.shownBounds_, me.removeOverlay_);
me.resetManager_();
};
/**
* Gets the tile coordinate for a given latlng point.
*
* @param {LatLng} latlng The geographical point.
* @param {Number} zoom The zoom level.
* @param {GSize} padding The padding used to shift the pixel coordinate.
*               Used for expanding a bounds to include an extra padding
*               of pixels surrounding the bounds.
* @return {GPoint} The point in tile coordinates.
*
*/
MarkerManager.prototype.getTilePoint_ = function(latlng, zoom, padding) {
var pixelPoint = this.projection_.fromLatLngToPixel(latlng, zoom);
return new GPoint(
Math.floor((pixelPoint.x + padding.width) / this.tileSize_),
Math.floor((pixelPoint.y + padding.height) / this.tileSize_));
};
/**
* Finds the appropriate place to add the marker to the grid.
* Optimized for speed; does not actually add the marker to the map.
* Designed for batch-processing thousands of markers.
*
* @param {Marker} marker The marker to add.
* @param {Number} minZoom The minimum zoom for displaying the marker.
* @param {Number} maxZoom The maximum zoom for displaying the marker.
*/
MarkerManager.prototype.addMarkerBatch_ = function(marker, minZoom, maxZoom) {
var mPoint = marker.getPoint();
// Tracking markers is expensive, so we do this only if the
// user explicitly requested it when creating marker manager.
if (this.trackMarkers_) {
GEvent.bind(marker, "changed", this, this.onMarkerMoved_);
}
GEvent.addListener(marker, "infowindowopen", function() {
marker.isInfoWindowOpened = true;
});
GEvent.addListener(marker, "infowindowclose", function() {
marker.isInfoWindowOpened = false;
});
var gridPoint = this.getTilePoint_(mPoint, maxZoom, GSize.ZERO);
for (var zoom = maxZoom; zoom >= minZoom; zoom--) {
var cell = this.getGridCellCreate_(gridPoint.x, gridPoint.y, zoom);
cell.push(marker);
gridPoint.x = gridPoint.x >> 1;
gridPoint.y = gridPoint.y >> 1;
}
};
/**
* Returns whether or not the given point is visible in the shown bounds. This
* is a helper method that takes care of the corner case, when shownBounds have
* negative minX value.
*
* @param {Point} point a point on a grid.
* @return {Boolean} Whether or not the given point is visible in the currently
* shown bounds.
*/
MarkerManager.prototype.isGridPointVisible_ = function(point) {
var me = this;
var vertical = me.shownBounds_.minY <= point.y &&
point.y <= me.shownBounds_.maxY;
var minX = me.shownBounds_.minX;
var horizontal = minX <= point.x && point.x <= me.shownBounds_.maxX;
if (!horizontal && minX < 0) {
// Shifts the negative part of the rectangle. As point.x is always less
// than grid width, only test shifted minX .. 0 part of the shown bounds.
var width = me.gridWidth_[me.shownBounds_.z];
horizontal = minX + width <= point.x && point.x <= width - 1;
}
return vertical && horizontal;
}
/**
* Reacts to a notification from a marker that it has moved to a new location.
* It scans the grid all all zoom levels and moves the marker from the old grid
* location to a new grid location.
*
* @param {Marker} marker The marker that moved.
* @param {LatLng} oldPoint The old position of the marker.
* @param {LatLng} newPoint The new position of the marker.
*/
MarkerManager.prototype.onMarkerMoved_ = function(marker, oldPoint, newPoint) {
// NOTE: We do not know the minimum or maximum zoom the marker was
// added at, so we start at the absolute maximum. Whenever we successfully
// remove a marker at a given zoom, we add it at the new grid coordinates.
var me = this;
var zoom = me.maxZoom_;
var changed = false;
var oldGrid = me.getTilePoint_(oldPoint, zoom, GSize.ZERO);
var newGrid = me.getTilePoint_(newPoint, zoom, GSize.ZERO);
while (zoom >= 0 && (oldGrid.x != newGrid.x || oldGrid.y != newGrid.y)) {
var cell = me.getGridCellNoCreate_(oldGrid.x, oldGrid.y, zoom);
if (cell) {
if (me.removeFromArray(cell, marker)) {
me.getGridCellCreate_(newGrid.x, newGrid.y, zoom).push(marker);
}
}
// For the current zoom we also need to update the map. Markers that no
// longer are visible are removed from the map. Markers that moved into
// the shown bounds are added to the map. This also lets us keep the count
// of visible markers up to date.
if (zoom == me.mapZoom_) {
if (me.isGridPointVisible_(oldGrid)) {
if (!me.isGridPointVisible_(newGrid)) {
me.removeOverlay_(marker);
changed = true;
}
} else {
if (me.isGridPointVisible_(newGrid)) {
me.addOverlay_(marker);
changed = true;
}
}
}
oldGrid.x = oldGrid.x >> 1;
oldGrid.y = oldGrid.y >> 1;
newGrid.x = newGrid.x >> 1;
newGrid.y = newGrid.y >> 1;
--zoom;
}
if (changed) {
me.notifyListeners_();
}
};
/**
* Searches at every zoom level to find grid cell
* that marker would be in, removes from that array if found.
* Also removes marker with removeOverlay if visible.
* @param {GMarker} marker The marker to delete.
*/
MarkerManager.prototype.removeMarker = function(marker) {
var me = this;
var zoom = me.maxZoom_;
var changed = false;
var point = marker.getPoint();
var grid = me.getTilePoint_(point, zoom, GSize.ZERO);
while (zoom >= 0) {
var cell = me.getGridCellNoCreate_(grid.x, grid.y, zoom);
if (cell) {
me.removeFromArray(cell, marker);
}
// For the current zoom we also need to update the map. Markers that no
// longer are visible are removed from the map. This also lets us keep the count
// of visible markers up to date.
if (zoom == me.mapZoom_) {
if (me.isGridPointVisible_(grid)) {
me.removeOverlay_(marker);
changed = true;
} 
}
grid.x = grid.x >> 1;
grid.y = grid.y >> 1;
--zoom;
}
if (changed) {
me.notifyListeners_();
}
};
/**
* Add many markers at once.
* Does not actually update the map, just the internal grid.
*
* @param {Array of Marker} markers The markers to add.
* @param {Number} minZoom The minimum zoom level to display the markers.
* @param {Number} opt_maxZoom The maximum zoom level to display the markers.
*/
MarkerManager.prototype.addMarkers = function(markers, minZoom, opt_maxZoom) {
var maxZoom = this.getOptMaxZoom_(opt_maxZoom);
for (var i = markers.length - 1; i >= 0; i--) {
this.addMarkerBatch_(markers[i], minZoom, maxZoom);
}
this.numMarkers_[minZoom] += markers.length;
};
/**
* Returns the value of the optional maximum zoom. This method is defined so
* that we have just one place where optional maximum zoom is calculated.
*
* @param {Number} opt_maxZoom The optinal maximum zoom.
* @return The maximum zoom.
*/
MarkerManager.prototype.getOptMaxZoom_ = function(opt_maxZoom) {
return opt_maxZoom != undefined ? opt_maxZoom : this.maxZoom_;
}
/**
* Calculates the total number of markers potentially visible at a given
* zoom level.
*
* @param {Number} zoom The zoom level to check.
*/
MarkerManager.prototype.getMarkerCount = function(zoom) {
var total = 0;
for (var z = 0; z <= zoom; z++) {
total += this.numMarkers_[z];
}
return total;
};
/**
* Add a single marker to the map.
*
* @param {Marker} marker The marker to add.
* @param {Number} minZoom The minimum zoom level to display the marker.
* @param {Number} opt_maxZoom The maximum zoom level to display the marker.
*/
MarkerManager.prototype.addMarker = function(marker, minZoom, opt_maxZoom) {
var me = this;
var maxZoom = this.getOptMaxZoom_(opt_maxZoom);
me.addMarkerBatch_(marker, minZoom, maxZoom);
var gridPoint = me.getTilePoint_(marker.getPoint(), me.mapZoom_, GSize.ZERO);
if(me.isGridPointVisible_(gridPoint) && 
minZoom <= me.shownBounds_.z &&
me.shownBounds_.z <= maxZoom ) {
me.addOverlay_(marker);
me.notifyListeners_();
}
this.numMarkers_[minZoom]++;
};
/**
* Returns true if this bounds (inclusively) contains the given point.
* @param {Point} point  The point to test.
* @return {Boolean} This Bounds contains the given Point.
*/
GBounds.prototype.containsPoint = function(point) {
var outer = this;
return (outer.minX <= point.x &&
outer.maxX >= point.x &&
outer.minY <= point.y &&
outer.maxY >= point.y);
}
/**
* Get a cell in the grid, creating it first if necessary.
*
* Optimization candidate
*
* @param {Number} x The x coordinate of the cell.
* @param {Number} y The y coordinate of the cell.
* @param {Number} z The z coordinate of the cell.
* @return {Array} The cell in the array.
*/
MarkerManager.prototype.getGridCellCreate_ = function(x, y, z) {
var grid = this.grid_[z];
if (x < 0) {
x += this.gridWidth_[z];
}
var gridCol = grid[x];
if (!gridCol) {
gridCol = grid[x] = [];
return gridCol[y] = [];
}
var gridCell = gridCol[y];
if (!gridCell) {
return gridCol[y] = [];
}
return gridCell;
};
/**
* Get a cell in the grid, returning undefined if it does not exist.
*
* NOTE: Optimized for speed -- otherwise could combine with getGridCellCreate_.
*
* @param {Number} x The x coordinate of the cell.
* @param {Number} y The y coordinate of the cell.
* @param {Number} z The z coordinate of the cell.
* @return {Array} The cell in the array.
*/
MarkerManager.prototype.getGridCellNoCreate_ = function(x, y, z) {
var grid = this.grid_[z];
if (x < 0) {
x += this.gridWidth_[z];
}
var gridCol = grid[x];
return gridCol ? gridCol[y] : undefined;
};
/**
* Turns at geographical bounds into a grid-space bounds.
*
* @param {LatLngBounds} bounds The geographical bounds.
* @param {Number} zoom The zoom level of the bounds.
* @param {GSize} swPadding The padding in pixels to extend beyond the
* given bounds.
* @param {GSize} nePadding The padding in pixels to extend beyond the
* given bounds.
* @return {GBounds} The bounds in grid space.
*/
MarkerManager.prototype.getGridBounds_ = function(bounds, zoom, swPadding,
nePadding) {
zoom = Math.min(zoom, this.maxZoom_);
var bl = bounds.getSouthWest();
var tr = bounds.getNorthEast();
var sw = this.getTilePoint_(bl, zoom, swPadding);
var ne = this.getTilePoint_(tr, zoom, nePadding);
var gw = this.gridWidth_[zoom];
// Crossing the prime meridian requires correction of bounds.
if (tr.lng() < bl.lng() || ne.x < sw.x) {
sw.x -= gw;
}
if (ne.x - sw.x  + 1 >= gw) {
// Computed grid bounds are larger than the world; truncate.
sw.x = 0;
ne.x = gw - 1;
}
var gridBounds = new GBounds([sw, ne]);
gridBounds.z = zoom;
return gridBounds;
};
/**
* Gets the grid-space bounds for the current map viewport.
*
* @return {Bounds} The bounds in grid space.
*/
MarkerManager.prototype.getMapGridBounds_ = function() {
var me = this;
return me.getGridBounds_(me.map_.getBounds(), me.mapZoom_,
me.swPadding_, me.nePadding_);
};
/**
* Event listener for map:movend.
* NOTE: Use a timeout so that the user is not blocked
* from moving the map.
*
*/
MarkerManager.prototype.onMapMoveEnd_ = function() {
var me = this;
me.objectSetTimeout_(this, this.updateMarkers_, 0);
};
/**
* Call a function or evaluate an expression after a specified number of
* milliseconds.
*
* Equivalent to the standard window.setTimeout function, but the given
* function executes as a method of this instance. So the function passed to
* objectSetTimeout can contain references to this.
*    objectSetTimeout(this, function() { alert(this.x) }, 1000);
*
* @param {Object} object  The target object.
* @param {Function} command  The command to run.
* @param {Number} milliseconds  The delay.
* @return {Boolean}  Success.
*/
MarkerManager.prototype.objectSetTimeout_ = function(object, command, milliseconds) {
return window.setTimeout(function() {
command.call(object);
}, milliseconds);
};
/**
* Refresh forces the marker-manager into a good state.
* <ol>
*   <li>If never before initialized, shows all the markers.</li>
*   <li>If previously initialized, removes and re-adds all markers.</li>
* </ol>
*/
MarkerManager.prototype.refresh = function() {
var me = this;
if (me.shownMarkers_ > 0) {
me.processAll_(me.shownBounds_, me.removeOverlay_);
}
me.processAll_(me.shownBounds_, me.addOverlay_);
me.notifyListeners_();
};
/**
* After the viewport may have changed, add or remove markers as needed.
*/
MarkerManager.prototype.updateMarkers_ = function() {
var me = this;
me.mapZoom_ = this.map_.getZoom();
var newBounds = me.getMapGridBounds_();
// If the move does not include new grid sections,
// we have no work to do:
if (newBounds.equals(me.shownBounds_) && newBounds.z == me.shownBounds_.z) {
return;
}
if (newBounds.z != me.shownBounds_.z) {
me.processAll_(me.shownBounds_, me.removeOverlay_);
me.processAll_(newBounds, me.addOverlay_);
} else {
// Remove markers:
me.rectangleDiff_(me.shownBounds_, newBounds, me.removeCellMarkers_);
// Add markers:
me.rectangleDiff_(newBounds, me.shownBounds_, me.addCellMarkers_);
}
me.shownBounds_ = newBounds;
me.notifyListeners_();
};
/**
* Notify listeners when the state of what is displayed changes.
*/
MarkerManager.prototype.notifyListeners_ = function() {
GEvent.trigger(this, "changed", this.shownBounds_, this.shownMarkers_);
};
/**
* Process all markers in the bounds provided, using a callback.
*
* @param {Bounds} bounds The bounds in grid space.
* @param {Function} callback The function to call for each marker.
*/
MarkerManager.prototype.processAll_ = function(bounds, callback) {
for (var x = bounds.minX; x <= bounds.maxX; x++) {
for (var y = bounds.minY; y <= bounds.maxY; y++) {
this.processCellMarkers_(x, y,  bounds.z, callback);
}
}
};
/**
* Process all markers in the grid cell, using a callback.
*
* @param {Number} x The x coordinate of the cell.
* @param {Number} y The y coordinate of the cell.
* @param {Number} z The z coordinate of the cell.
* @param {Function} callback The function to call for each marker.
*/
MarkerManager.prototype.processCellMarkers_ = function(x, y, z, callback) {
var cell = this.getGridCellNoCreate_(x, y, z);
if (cell) {
for (var i = cell.length - 1; i >= 0; i--) {
callback(cell[i]);
}
}
};
/**
* Remove all markers in a grid cell.
*
* @param {Number} x The x coordinate of the cell.
* @param {Number} y The y coordinate of the cell.
* @param {Number} z The z coordinate of the cell.
*/
MarkerManager.prototype.removeCellMarkers_ = function(x, y, z) {
this.processCellMarkers_(x, y, z, this.removeOverlay_);
};
/**
* Add all markers in a grid cell.
*
* @param {Number} x The x coordinate of the cell.
* @param {Number} y The y coordinate of the cell.
* @param {Number} z The z coordinate of the cell.
*/
MarkerManager.prototype.addCellMarkers_ = function(x, y, z) {
this.processCellMarkers_(x, y, z, this.addOverlay_);
};
/**
* Use the rectangleDiffCoords function to process all grid cells
* that are in bounds1 but not bounds2, using a callback, and using
* the current MarkerManager object as the instance.
*
* Pass the z parameter to the callback in addition to x and y.
*
* @param {Bounds} bounds1 The bounds of all points we may process.
* @param {Bounds} bounds2 The bounds of points to exclude.
* @param {Function} callback The callback function to call
*                   for each grid coordinate (x, y, z).
*/
MarkerManager.prototype.rectangleDiff_ = function(bounds1, bounds2, callback) {
var me = this;
me.rectangleDiffCoords(bounds1, bounds2, function(x, y) {
callback.apply(me, [x, y, bounds1.z]);
});
};
/**
* Calls the function for all points in bounds1, not in bounds2
*
* @param {Bounds} bounds1 The bounds of all points we may process.
* @param {Bounds} bounds2 The bounds of points to exclude.
* @param {Function} callback The callback function to call
*                   for each grid coordinate.
*/
MarkerManager.prototype.rectangleDiffCoords = function(bounds1, bounds2, callback) {
var minX1 = bounds1.minX;
var minY1 = bounds1.minY;
var maxX1 = bounds1.maxX;
var maxY1 = bounds1.maxY;
var minX2 = bounds2.minX;
var minY2 = bounds2.minY;
var maxX2 = bounds2.maxX;
var maxY2 = bounds2.maxY;
for (var x = minX1; x <= maxX1; x++) {  // All x in R1
// All above:
for (var y = minY1; y <= maxY1 && y < minY2; y++) {  // y in R1 above R2
callback(x, y);
}
// All below:
for (var y = Math.max(maxY2 + 1, minY1);  // y in R1 below R2
y <= maxY1; y++) {
callback(x, y);
}
}
for (var y = Math.max(minY1, minY2);
y <= Math.min(maxY1, maxY2); y++) {  // All y in R2 and in R1
// Strictly left:
for (var x = Math.min(maxX1 + 1, minX2) - 1;
x >= minX1; x--) {  // x in R1 left of R2
callback(x, y);
}
// Strictly right:
for (var x = Math.max(minX1, maxX2 + 1);  // x in R1 right of R2
x <= maxX1; x++) {
callback(x, y);
}
}
};
/**
* Removes value from array. O(N).
*
* @param {Array} array  The array to modify.
* @param {any} value  The value to remove.
* @param {Boolean} opt_notype  Flag to disable type checking in equality.
* @return {Number}  The number of instances of value that were removed.
*/
MarkerManager.prototype.removeFromArray = function(array, value, opt_notype) {
var shift = 0;
for (var i = 0; i < array.length; ++i) {
if (array[i] === value || (opt_notype && array[i] == value)) {
array.splice(i--, 1);
shift++;
}
}
return shift;
};
MarkerManager.prototype.addMarkersBatched = function( paMarkers, pnBatchSize, pnInterval, pnZoomMin, pnZoomMax ){
var nPresentBatch = 0;
var _this = this;
var batch = window.setInterval( 
function(){
var len = paMarkers.length;
var nStart = nPresentBatch * pnBatchSize;
var nEnd = Math.min( nStart + pnBatchSize, len );
for( var loop = nStart; loop < nEnd ; ++loop ){
var oMarker = paMarkers[ loop ];
_this.addMarker( oMarker, pnZoomMin, pnZoomMax );
if( oMarker.isHiddenMarker == true ){
oMarker.hide();
oMarker.hideMe = true;
}
}
if( nEnd == len ){
clearInterval( batch );
}
nPresentBatch++;
}, pnInterval );
}
GmapsVolume = Class.create();
GmapsVolume.prototype = {
initialize: function( psMap, pnFedZoomLevel, pnMpotgZoomLevel, poFilter, pfCloseFilter, psIvwCode ){
this.sMap = psMap;
this.oMap = new GMap2( document.getElementById( this.sMap ) );
this.oMap.bPan = false;
this.sMapSession = null;
this.initMap();
this.oMap.addControl( new GScaleControl() );
this.oMap.addControl( new GOverviewMapControl() );
this.oMap.addControl( new GSmallMapControl() );
this.oMap.addControl( new GMapTypeControl() );
this.oMap.addControl( new DragZoomControl() );
this.oMap.addMapType( G_PHYSICAL_MAP );
this.oMap.addControl( new GmapsOptionenControl( poFilter ) );
this.nBatchSize = 50;
this.nPauseBetweenBatches = 10;
this.nPageMovementDivisor = 3;
this.oMoveStartCenter = null;
this.nFedPoiZoomLevel = pnFedZoomLevel;
this.nMpotgPoiZoomLevel = pnMpotgZoomLevel;
this.aFedPoiMarkers = $H();
this.aFedPoiViewState = $H();
this.aFedPoiCategories = $H();
this.aFedPoiSearchMarkers = $H();
this.aFedIcons = $H();
this.aMpotgIcons = $H();
this.setFedPoiFilterZoomLevel( this.oMap, pnFedZoomLevel, poFilter, pfCloseFilter );
this.sIvwCode = psIvwCode;
this.bDeactivateMoveend = false;
this.bDeactivateZoomend = false;
},
initMap: function(){
var _this = this;
StdAjax(
'/gmaps/volume/init',
{
onSuccess: function(result) 
{
_this.sMapSession = result.data.sMapSession;
},
onError: function(result, errors) 
{
}
}
);
},
setView: function( psBand, prVolumesFunction ){
var _this = this;
StdAjax(
'/gmaps/volume/setview',
{
parameters: "view=" + encodeURIComponent(psBand),
onSuccess: function(result) 
{ 
var co = result.data.view;
var nZoomLevel = _this.oMap.getBoundsZoomLevel( new GLatLngBounds( new GLatLng( co.Y1, co.X1 ), new GLatLng( co.Y2, co.X2 ) ) );
_this.oMap.setCenter( new GLatLng( co.Y, co.X ), nZoomLevel );
//_this.oMap.setMapType( G_PHYSICAL_MAP );
_this.bMpotgPoiTeasersShown = false;
_this.setMpotgPoiMarkers( _this );
//add volume markers
var aVolumeMarkers = new Array();
var aVolumes = result.data.volumes;
var oVolumesMarkerManager = new MarkerManager( _this.oMap );
var oVolumeIcon = new GIcon( G_DEFAULT_ICON, '/images/gmaps/marker_band.png' );
oVolumeIcon.shadow = null;
oVolumeIcon.iconSize = new GSize( 24, 26 );
oVolumeIcon.iconAnchor = new GPoint( 0, 25 );
for( loop = 0, len = aVolumes.length ; loop < len ; ++loop ){
var volume = aVolumes[ loop ];
marker = new GMarker( new GLatLng( volume[ 3 ], volume[ 2 ] ), { title:volume[ 0 ], icon:oVolumeIcon } );
aVolumeMarkers[ loop ] = marker;
_this.addVolumeMarkerListener( marker, volume[ 1 ] );
}
oVolumesMarkerManager.addMarkersBatched( aVolumeMarkers, _this.nBatchSize, _this.nPauseBetweenBatches, 2, null );           
_this.setPageMarkers( _this );
_this.addMoveEndListener( _this );
_this.addZoomEndListener( _this );
_this.addMoveStartListener( _this );
GEvent.addListener( _this.oMap, "maptypechanged", function(){ oIVW.Change( _this.sIvwCode ); } );
prVolumesFunction( result.data );
},
onError: function(result, errors) 
{
}
}
);
},
setCenter: function( pnX, pnY, pnZoom ){
this.oMap.setCenter( new GLatLng( pnY, pnX ), pnZoom );
},
setSearch: function( psSearchPhrase, pfVolumesFunction, pfResultsFunction, pfShowResults, pfAds, sContentContainerId ){
var _this = this;
StdAjax(
'/gmaps/search/go',
{
parameters: "searchphrase=" + encodeURIComponent(psSearchPhrase),
onSuccess: function(result) 
{ 
if( typeof result.data.html != 'undefined' ){
$(sContentContainerId).innerHTML = result.data.html;
}
var aMarkers = result.data.markers;
var aBounds = result.data.bounds;
if( ( typeof aMarkers == 'undefined' || aMarkers.length == 0 ) && result.data.volumes.length == 0 ){
$('geo_results').style.display = 'none';
}else{          
if( aBounds != null ){
var nZoomLevel = _this.oMap.getBoundsZoomLevel( new GLatLngBounds( new GLatLng( aBounds.Y1, aBounds.X1 ), new GLatLng( aBounds.Y2 == '' ? aBounds.Y1 : aBounds.Y2, aBounds.X2 == '' ? aBounds.X1 : aBounds.X2 ) ) );
_this.oMap.setCenter( new GLatLng( aBounds.Y, aBounds.X ), nZoomLevel );
//_this.oMap.setMapType( G_PHYSICAL_MAP );
}else{
_this.oMap.setCenter( new GLatLng( 0, 0 ), 2 );  
}
if( typeof aMarkers != 'undefined' ){        
var oSearchMarkerManager = new MarkerManager( _this.oMap );
for( loop = 0, len = aMarkers.length; loop < len ; ++loop ){
var aData = aMarkers[ loop ];
switch( aData[ 0 ] ){
case 'fp':
oMarker = new GMarker( new GLatLng( aData[ 2 ], aData[ 1 ] ), { title:aData[ 3 ], icon:_this.getFedPoiIcon( aData[ 4 ], _this ) } );
_this.addFedMarkerListener( _this.oMap, oMarker, aData[ 5 ], aData[ 4 ] );
_this.aFedPoiSearchMarkers.set( aData[ 5 ], oMarker );
break;
case 'mp':
oMarker = new GMarker( new GLatLng( aData[ 2 ], aData[ 1 ] ), { title:aData[ 3 ], icon:_this.getMpotgPoiIcon( 'default', _this ) } );
_this.addMpotgMarkerListener( oMarker, aData[ 4 ] );
break;
default:
oMarker = new GMarker( new GLatLng( aData[ 2 ], aData[ 1 ] ), { title:aData[ 3 ] } );
} 
oSearchMarkerManager.addMarker( oMarker, 1 ); 
}
}
var oVolumesMarkerManager = new MarkerManager( _this.oMap );
if( typeof result.data.volume_markers != 'undefined' ){
var aVolumes = result.data.volume_markers;
var aVolumeMarkers = new Array();
var oVolumeIcon = new GIcon( G_DEFAULT_ICON, '/images/gmaps/marker_band.png' );
oVolumeIcon.shadow = null;
oVolumeIcon.iconSize = new GSize( 24, 26 );
oVolumeIcon.iconAnchor = new GPoint( 0, 25 );
for( loop = 0, len = aVolumes.length ; loop < len ; ++loop ){
var volume = aVolumes[ loop ];
marker = new GMarker( new GLatLng( volume[ 3 ], volume[ 2 ] ), { title:volume[ 0 ], icon:oVolumeIcon } );
aVolumeMarkers[ loop ] = marker;
_this.addVolumeMarkerListener( marker, volume[ 1 ] );
}
oVolumesMarkerManager.addMarkersBatched( aVolumeMarkers, _this.nBatchSize, _this.nPauseBetweenBatches, 2, null );               
}
_this.addMoveStartListener( _this );
_this.addMoveEndListener( _this );
_this.addZoomEndListener( _this );
GEvent.addListener( _this.oMap, "maptypechanged", function(){ oIVW.Change( _this.sIvwCode ); } );
}
pfVolumesFunction( result.data.volumes, result.teaser );
pfResultsFunction( result.data.results_html );         
pfShowResults();
pfAds( result.data.infos );
Object.extend($('poi_teaser_boxcontroller'), TabController);
$('poi_teaser_boxcontroller').initialize();
$('poi_teaser_boxcontroller').sActiveTab = '#top5';
$('poi_teaser_boxcontroller').vAddSwitchAction(function(){
if(!window.oIVW && typeof(IVW) != 'string'){
window.oIVW = new IVW();
}
if(window.oIVW){
window.oIVW.Change('1rf_map');
}
});
for(var sPoiId in result.data.fed_pois)
{
oRating.vAddRatingRequest('fed_poi_rate' + sPoiId + '_' + result.data.fed_pois[sPoiId].sCategory[0], "fed_poi", sPoiId);
}
if(result.data.top_fed_pois){
for(var i=0, len=result.data.top_fed_pois.length; i<len; i++){
var iFedPoiID = result.data.top_fed_pois[i].FED_POI_ID;
oRating.vAddRatingRequest('fed_poi_rate' + iFedPoiID , "fed_poi", iFedPoiID);
}
}
oRating.vSubmitRatingQueue();
// reinitialize the watchlist links
var TORR = window.TORR || {};
if(TORR.oWatchlist){
TORR.oWatchlist.vRefreshWatchLinks();
}
else {
TORR.oWatchlist = new Watchlist();
}
},
onError: function(result, errors) 
{
}
}
);
},  
setMpotgPoiMarkers: function( _this ){
var load_all = 1;
var nX1 = null;
var nX2 = null;
var nX3 = null;
var nX4 = null;
if( this.oMap.getZoom() < this.nMpotgPoiZoomLevel ){
if( !this.bMpotgPoiTeasersShown ){ 
nX1 = this.oMap.getBounds().getSouthWest().lng() + ( this.oMap.getBounds().toSpan().lng() / 5 );
nY1 = this.oMap.getBounds().getSouthWest().lat() + ( this.oMap.getBounds().toSpan().lat() / 5 );
nX2 = this.oMap.getBounds().getNorthEast().lng() - ( this.oMap.getBounds().toSpan().lng() / 5 );
nY2 = this.oMap.getBounds().getNorthEast().lat() - ( this.oMap.getBounds().toSpan().lat() / 5 );
load_all = 0;
this.bMpotgPoiTeasersShown = true;
}else{
return;
}
}else{
nX1 = this.oMap.getBounds().getSouthWest().lng() - ( this.oMap.getBounds().toSpan().lng() / this.nPageMovementDivisor );
nY1 = this.oMap.getBounds().getSouthWest().lat() - ( this.oMap.getBounds().toSpan().lat() / this.nPageMovementDivisor );
nX2 = this.oMap.getBounds().getNorthEast().lng() + ( this.oMap.getBounds().toSpan().lng() / this.nPageMovementDivisor );
nY2 = this.oMap.getBounds().getNorthEast().lat() + ( this.oMap.getBounds().toSpan().lat() / this.nPageMovementDivisor );  
}
StdAjax(
'/gmaps/volume/getmpotgpoimarkers',
{
parameters: { "x1" : nX1,
"y1" : nY1,
"x2" : nX2,
"y2" : nY2,
"mapsession" : this.sMapSession,
"load_all" : load_all },
onSuccess: function(result) 
{ 
var poiMarkerManager = new MarkerManager( _this.oMap );
var markers = result.data;
var marker = null;
var aMarkers = new Array();
var oMpotgIcon = _this.getMpotgPoiIcon( 'default', _this );
for( loop = 0, len = markers.length ; loop < len ; ++loop ){
var data = markers[ loop ];
marker = new GMarker( new GLatLng( data[ 2 ], data[ 1 ] ), { title:data[ 0 ], icon:oMpotgIcon } );
aMarkers[ loop ] = marker;
_this.addMpotgMarkerListener( marker, data[ 3 ] );
}
poiMarkerManager.addMarkersBatched( aMarkers, _this.nBatchSize, _this.nPauseBetweenBatches, 2, null );
},
onError: function(result, errors) 
{
}
}
);    
},
setPageMarkers: function( _this ){
StdAjax(
'/gmaps/volume/getpagemarkers',
{
parameters: { "x1" : _this.oMap.getBounds().getSouthWest().lng() - ( _this.oMap.getBounds().toSpan().lng() / _this.nPageMovementDivisor ),
"y1" : _this.oMap.getBounds().getSouthWest().lat() - ( _this.oMap.getBounds().toSpan().lat() / _this.nPageMovementDivisor ),
"x2" : _this.oMap.getBounds().getNorthEast().lng() + ( _this.oMap.getBounds().toSpan().lng() / _this.nPageMovementDivisor ),
"y2" : _this.oMap.getBounds().getNorthEast().lat() + ( _this.oMap.getBounds().toSpan().lat() / _this.nPageMovementDivisor ),
"mapsession" : this.sMapSession },
onSuccess: function(result) 
{ 
var pageMarkerManager = new MarkerManager( _this.oMap );
var markers = result.data;
var marker = null;
var aMarkers = new Array();
var oPageIcon = new GIcon( G_DEFAULT_ICON, '/images/gmaps/marker_artikel.png' );
oPageIcon.shadow = null;
oPageIcon.iconSize = new GSize( 24, 26 );
oPageIcon.iconAnchor = new GPoint( 0, 25 );
var oPodcastIcon = new GIcon( G_DEFAULT_ICON, '/images/gmaps/marker_podcast.png' );
oPodcastIcon.shadow = null;
oPodcastIcon.iconSize = new GSize( 24, 26 );
oPodcastIcon.iconAnchor = new GPoint( 0, 25 );
for( loop = 0, len = markers.length ; loop < len ; ++loop ){
var data = markers[ loop ];
marker = new GMarker( new GLatLng( data[ 2 ], data[ 1 ] ), { title:data[ 0 ], icon:data[4]?oPodcastIcon:oPageIcon } );
aMarkers[ loop ] = marker;
_this.addPageMarkerListener( marker, data[ 3 ] );
}
pageMarkerManager.addMarkersBatched( aMarkers, _this.nBatchSize, _this.nPauseBetweenBatches, 2, null );
},
onError: function(result, errors) 
{
}
}
);    
},  
setFedPoiMarkers: function( psInput ){    
var _this = this;        
if( this.oFedMarkerManager == null ){
this.oFedMarkerManager = new MarkerManager( this.oMap );
}
if( !psInput.load ){ 
var sValue = new String( psInput.value );
sValue.scan( /\w+/, function( match ){
var sCat = match[ 0 ];
if( !psInput.checked ){
var aMarkersToRemove = _this.aFedPoiMarkers.get( sCat );
if( aMarkersToRemove != null ){
aMarkersToRemove.each( function( oPair ){
aMarkersToRemove.get( oPair.key ).hide();                             
aMarkersToRemove.get( oPair.key ).hideMe = true;                             
} );
_this.aFedPoiViewState.set( sCat, 'hidden' );
_this.aFedPoiCategories.unset( sCat );
}
return;
}
if( _this.aFedPoiMarkers.get( sCat ) != null ){
var aMarkersToAdd = _this.aFedPoiMarkers.get( sCat );
aMarkersToAdd.each( function( oPair ){
aMarkersToAdd.get( oPair.key ).show();
aMarkersToAdd.get( oPair.key ).hideMe = false;
} );
_this.aFedPoiViewState.set( sCat, 'visible' );
_this.aFedPoiCategories.set( sCat, true );
} 
_this.aFedPoiCategories.set( sCat, true );
} );
}
var sAllCategories = '';
this.aFedPoiCategories.each( function( oPair ){
sAllCategories += oPair.key + ',';
} );
if( sAllCategories == '' ) return;
StdAjax(
'/gmaps/volume/getfedpoimarkers',
{
parameters: { "cat" : sAllCategories,
"x1" : this.oMap.getBounds().getSouthWest().lng() - ( this.oMap.getBounds().toSpan().lng() / this.nPageMovementDivisor ),
"y1" : this.oMap.getBounds().getSouthWest().lat() - ( this.oMap.getBounds().toSpan().lat() / this.nPageMovementDivisor ),
"x2" : this.oMap.getBounds().getNorthEast().lng() + ( this.oMap.getBounds().toSpan().lng() / this.nPageMovementDivisor ),
"y2" : this.oMap.getBounds().getNorthEast().lat() + ( this.oMap.getBounds().toSpan().lat() / this.nPageMovementDivisor ),
"mapsession" : this.sMapSession },
onSuccess: function(result) 
{ 
var aAllMarkers = $H( result.data );
var aMarkers = new Array();
var aIcons = $H();
aAllMarkers.each( function( oPair ){
var markers = oPair.value;
var marker = null;
var sCat = oPair.key;
if( _this.aFedPoiMarkers.get( sCat ) == null ){
_this.aFedPoiMarkers.set( sCat, $H() );
}
for( loop = 0, len = markers.length ; loop < len ; ++loop ){
var data = markers[ loop ];
marker = new GMarker( new GLatLng( data[ 2 ], data[ 1 ] ), { title:data[ 0 ], icon:_this.getFedPoiIcon( sCat, _this ) } );
_this.addFedMarkerListener( _this.oMap, marker, data[ 3 ], sCat );
if( _this.aFedPoiMarkers.get( sCat ).get( data[ 3 ] ) == null ){
if( _this.aFedPoiViewState.get( sCat ) == 'hidden' ){
marker.isHiddenMarker = true;
}
aMarkers.push( marker );
_this.aFedPoiMarkers.get( sCat ).set( data[ 3 ], marker );
}
}
} );
_this.oFedMarkerManager.addMarkersBatched( aMarkers, _this.nBatchSize, _this.nPauseBetweenBatches, _this.nFedPoiZoomLevel, null ); 
},
onError: function(result, errors) 
{
}
}
);
},
getFedPoiIcon: function( psCat, _this ){
if( _this.aFedIcons.get( psCat ) == null ){
var oIcon = new GIcon( G_DEFAULT_ICON, '/images/gmaps/' + psCat + '.png' );
oIcon.shadow = null;
if( psCat == 'event' ){
oIcon.iconAnchor = new GPoint( 0, 23 );
oIcon.iconSize = new GSize( 24, 26 );
}else{
oIcon.iconAnchor = new GPoint( 0, 20 );
oIcon.iconSize = new GSize( 21, 21 );
}
_this.aFedIcons.set( psCat, oIcon );
}
return _this.aFedIcons.get( psCat );
},
getMpotgPoiIcon: function( psType, _this ){
if( _this.aMpotgIcons.get( psType ) == null ){
var oMpotgIcon = new GIcon( G_DEFAULT_ICON, '/images/gmaps/marker_mpotg.png' );
oMpotgIcon.shadow = null;
oMpotgIcon.iconAnchor = new GPoint( 0, 25 );
oMpotgIcon.iconSize = new GSize( 24, 26 );
_this.aMpotgIcons.set( psType, oMpotgIcon );
}
return _this.aMpotgIcons.get( psType );
},
setFedPoiFilterZoomLevel: function( poMap, pnZoomLevel, poFilter, pfCloseFilter ){
GEvent.addListener( poMap,
"zoomend",
function(){
if( poMap.getZoom() >= pnZoomLevel ){
/*poFilter.style.display = 'block';
poFilter.style.visibility = 'visible';*/
poFilter.down().style.display = 'block';
poFilter.down().next().style.display = 'none';
}else{
//poFilter.style.display = 'none';
//poFilter.style.visibility = 'hidden';
poFilter.down().style.display = 'none';
poFilter.down().next().style.display = 'block';
pfCloseFilter();
}
} );
},
addFedMarkerListener: function( poMap, poMarker, pnFedPoiId, psCat ){
var _this = this;
GEvent.addListener( poMarker,
"click",
function(){ 
if( psCat == 'event' ){
document.location.href = '/reise_und_freizeit/veranstaltungen/veranstaltung-' + pnFedPoiId.split('').reverse().join('') + '.html';
return;
}
StdAjax(	'/gmaps/volume/getfedpoidescription',
{
parameters: "id=" + pnFedPoiId,
onSuccess: function(result) 
{               
if(typeof(_this.sIvwCode != 'undefined') && _this.sIvwCode)
{                 
oIVW.Change( _this.sIvwCode );
}                                
poMarker.openExtInfoWindow( poMap, 'fed_marker_window', '<div class="fedpoidescription"><ul id="fed_boxcontroller"><li class="firstChild"><a href="#fedinfo" class="active">Information</a></li><li><a href="#fedproducts">Produkte</a></li></ul>' + result.html + '</div>', { paddingX : 15, paddingY : 0 } );
oRating.vEmbeddRating( "fed_poi_rating", "fed_poi", pnFedPoiId );
oRating.vEmbeddRating( "fed_poi_rating_modal", "fed_poi", pnFedPoiId );
TORR.oWatchlist.vAddWatchLink('#watchlist-container-poi-' + pnFedPoiId);
Object.extend($('fed_boxcontroller'), TabController);
$('fed_boxcontroller').initialize();
Object.extend($('fed_boxcontroller'), TabController);
$('fed_boxcontroller').initialize();
},
onError: function(result, errors) 
{
}
}
)
} );                    
},
addMpotgMarkerListener: function( poMarker, pnMpotgPoiId ){
var _this = this;
GEvent.addListener( poMarker,
"click",
function(){ 
StdAjax(	'/gmaps/volume/getmpotgpoiurl',
{
parameters: "id=" + pnMpotgPoiId,
onSuccess: function(result) 
{ 
window.location.href = result.data
},
onError: function(result, errors) 
{
}
}
)
} );  
},
addPageMarkerListener: function( poMarker, pnPageId ){
var _this = this;
GEvent.addListener( poMarker,
"click",
function(){ 
StdAjax(	'/gmaps/volume/getpageurl',
{
parameters: "id=" + pnPageId,
onSuccess: function(result) 
{ 
window.location.href = result.data
},
onError: function(result, errors) 
{
}
}
)
} );  
},  
addVolumeMarkerListener: function( poMarker, psUrl ){
GEvent.addListener( poMarker,
"click",
function(){ window.location.href = psUrl }
);   
},
addMoveEndListener: function( _this ){
var nPreviousLat = _this.oMap.getCenter().lat();
var nPreviousLng = _this.oMap.getCenter().lng();
GEvent.addListener( _this.oMap,
"moveend",
function(){ 
var oCenter = _this.oMap.getCenter();
if(
( Math.abs( nPreviousLat - oCenter.lat() ) > _this.oMap.getBounds().toSpan().lat() / _this.nPageMovementDivisor
||
Math.abs( nPreviousLng - oCenter.lng() ) > _this.oMap.getBounds().toSpan().lng() / _this.nPageMovementDivisor )
){
if( _this.oMap.getZoom() >= _this.nFedPoiZoomLevel ){
_this.setFedPoiMarkers( { load : true } );  
}
_this.setMpotgPoiMarkers( _this );
nPreviousLat = oCenter.lat();
nPreviousLng = oCenter.lng(); 
}
_this.oMoveStartCenter = null;
if(  _this.nMoveStartCenterX != null ){
if( _this.nMoveStartZoom != _this.oMap.getZoom() ){
return;
}
var nPresentX = _this.oMap.getCurrentMapType().getProjection().fromLatLngToPixel( _this.oMap.getCenter(), _this.oMap.getZoom() ).x;
var nPresentY = _this.oMap.getCurrentMapType().getProjection().fromLatLngToPixel( _this.oMap.getCenter(), _this.oMap.getZoom() ).y;
var nDeltaX = Math.abs( _this.nMoveStartCenterX - nPresentX );
var nDeltaY = Math.abs( _this.nMoveStartCenterY - nPresentY );
if( nDeltaX >= 10 || nDeltaY >= 10 ){
_this.nMoveStartCenterX = nPresentX;
_this.nMoveStartCenterY = nPresentY;
if( !_this.bDeactivateMoveend && !_this.oMap.bPan ){
oIVW.Change( _this.sIvwCode );
}
_this.bDeactivateMoveend = false; 
_this.oMap.bPan = false; 
}
}
} );     
},
addZoomEndListener: function( _this ){
var nPreviousLat = _this.oMap.getCenter().lat();
var nPreviousLng = _this.oMap.getCenter().lng();
GEvent.addListener( _this.oMap,
"zoomend",
function(){ 
var oCenter = _this.oMap.getCenter();
if( !_this.bDeactivateZoomend ){
oIVW.Change( _this.sIvwCode );
}
_this.bDeactivateZoomend = false; 
if( _this.oMap.getZoom() >= _this.nFedPoiZoomLevel ){
var aFedPoiCategories = $$( '#fed_poi_filters input' );
for( loop = 0 ; loop < aFedPoiCategories.length ; loop++ ){
var sCategory = aFedPoiCategories[ loop ].value;                              
if( _this.aFedPoiCategories.get( sCategory ) == null && aFedPoiCategories[ loop ].checked ){
_this.aFedPoiCategories.set( sCategory, 1 );
}
}
_this.setFedPoiMarkers( { load : true } );  
}
_this.setMpotgPoiMarkers( _this );
} );     
},
addMoveStartListener: function( _this ){
GEvent.addListener( _this.oMap,
"movestart",
function(){
_this.nMoveStartCenterX = _this.oMap.getCurrentMapType().getProjection().fromLatLngToPixel( _this.oMap.getCenter(), _this.oMap.getZoom() ).x;
_this.nMoveStartCenterY = _this.oMap.getCurrentMapType().getProjection().fromLatLngToPixel( _this.oMap.getCenter(), _this.oMap.getZoom() ).y;
_this.nMoveStartZoom = _this.oMap.getZoom();
} );
}
}
//used for fed filter  
function checkIfAllUnchecked( poInput ){
var oDiv = poInput.up().up();  //each category div
var bChecked = false;
oDiv.up().down(0).checked = true; 
if( oDiv.up().down(0).checked ){ //headline input fields
$A( oDiv.getElementsByTagName( 'input' ) ).each( 
function( poInput )
{ 
if( poInput.checked )
{ 
bChecked = true;
} 
} );
oDiv.up().down(0).checked = bChecked;
} else {
bChecked = true;
$A( oDiv.getElementsByTagName( 'input' ) ).each( 
function( poInput )
{ 
if( !poInput.checked )
{ 
bChecked = false;
} 
} );
oDiv.up().down(0).checked = bChecked;
} 
}                                            
VolumeSelector = Class.create();
VolumeSelector.prototype = {
initialize: function( poContinentSelect, poCountrySelect, poVolumeSelect ){
this.oContinentSelect = poContinentSelect;
this.oCountrySelect = poCountrySelect;
this.oVolumeSelect = poVolumeSelect;
this.sVolumeUrl = '/reise_und_freizeit/';
this.sContinentWaehlenText = poContinentSelect.options[ 0 ].innerHTML;
this.sCountryWaehlenText = poCountrySelect.options[ 0 ].innerHTML;
this.sVolumeWaehlenText = poVolumeSelect[ 0 ].innerHTML;
},
getContinents: function(){
var _this = this;
StdAjax( '/gmaps/volume/getcontinents',
{
onSuccess: function( result ){
_this.oContinentSelect.innerHTML = '';
_this.addEmptyOption( _this.oContinentSelect, _this.sContinentWaehlenText );
$H( result.data ).each(
function( oPair ){
var oOption = document.createElement( 'option' );
oOption.value = oPair.key;
oOption.appendChild( document.createTextNode( oPair.value ) );
_this.oContinentSelect.appendChild( oOption );
} );
_this.oContinentSelect.onchange = function(){ _this.getCountries( _this.oContinentSelect.options[ _this.oContinentSelect.selectedIndex ].value );
_this.getVolumes( null, _this.oContinentSelect.options[ _this.oContinentSelect.selectedIndex ].value );
}; 
},
onError: function(result){}
} );
},
getCountries: function( psContinent ){
var _this = this;
StdAjax( '/gmaps/volume/getcountries',
{
parameters: { continent:psContinent },
onSuccess: function( result ){
_this.oCountrySelect.innerHTML = '';
_this.addEmptyOption( _this.oCountrySelect, _this.sCountryWaehlenText );
$H( result.data ).each(
function( oPair ){
var oOption = document.createElement( 'option' );
oOption.value = oPair.key;
oOption.appendChild( document.createTextNode( oPair.value ) );
_this.oCountrySelect.appendChild( oOption );
} );
_this.oCountrySelect.onchange = function(){ _this.getVolumes( _this.oCountrySelect.options[ _this.oCountrySelect.selectedIndex].value, null ) }; 
},
onError: function(result){}
} );
},
getVolumes: function( psCountry, psContinent ){
var _this = this;
StdAjax( '/gmaps/volume/getvolumes',
{
parameters: { country:psCountry, continent:psContinent },
onSuccess: function( result ){
_this.oVolumeSelect.innerHTML = '';
_this.addEmptyOption( _this.oVolumeSelect, _this.sVolumeWaehlenText );
$H( result.data ).each(
function( oPair ){
var oOption = document.createElement( 'option' );
oOption.value = oPair.key;
oOption.appendChild( document.createTextNode( oPair.value ) );
_this.oVolumeSelect.appendChild( oOption );
} );
_this.oVolumeSelect.onchange = function(){ window.location.href = _this.sVolumeUrl + _this.oVolumeSelect.options[ _this.oVolumeSelect.selectedIndex].value };
},
onError: function(result){}
} );
},
addEmptyOption: function( poSelect, psText ){
var oOption = document.createElement( 'option' );
oOption.value = '';
oOption.appendChild( document.createTextNode( psText ) );
poSelect.appendChild( oOption );
}
}
/*
* ExtInfoWindow Class, v1.0 
*  Copyright (c) 2007, Joe Monahan (http://www.seejoecode.com)
* 
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 
*       http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This class lets you add an info window to the map which mimics GInfoWindow
* and allows for users to skin it via CSS.  Additionally it has options to
* pull in HTML content from an ajax request, triggered when a user clicks on
* the associated marker.
*/
/**
* Creates a new ExtInfoWindow that will initialize by reading styles from css
*
* @constructor
* @param {GMarker} marker The marker associated with the info window
* @param {String} windowId The DOM Id we will use to reference the info window
* @param {String} html The HTML contents
* @param {Object} opt_opts A contianer for optional arguments:
*    {String} ajaxUrl The Url to hit on the server to request some contents 
*    {Number} paddingX The padding size in pixels that the info window will leave on 
*                    the left and right sides of the map when panning is involved.
*    {Number} paddingY The padding size in pixels that the info window will leave on 
*                    the top and bottom sides of the map when panning is involved.
*    {Number} beakOffset The repositioning offset for when aligning the beak element. 
*                    This is used to make sure the beak lines up correcting if the 
*                    info window styling containers a border.
*/
function ExtInfoWindow(marker, windowId, html, opt_opts) {
this.html_ = html;
this.marker_ = marker;
this.infoWindowId_ = windowId;
this.options_ = opt_opts == null ? {} : opt_opts;
this.ajaxUrl_ = this.options_.ajaxUrl == null ? null : this.options_.ajaxUrl;
this.callback_ = this.options_.ajaxCallback == null ? null : this.options_.ajaxCallback;
this.borderSize_ = this.options_.beakOffset == null ? 0 : this.options_.beakOffset;
this.paddingX_ = this.options_.paddingX == null ? 0 + this.borderSize_ : this.options_.paddingX + this.borderSize_;
this.paddingY_ = this.options_.paddingY == null ? 0 + this.borderSize_ : this.options_.paddingY + this.borderSize_;
this.map_ = null;
this.container_ = document.createElement('div');
this.container_.style.position = 'relative';
this.container_.style.display = 'none';
this.contentDiv_ = document.createElement('div');
this.contentDiv_.id = this.infoWindowId_ + '_contents';
this.contentDiv_.innerHTML = this.html_;
this.contentDiv_.style.display = 'block';
this.contentDiv_.style.visibility = 'hidden';
this.wrapperDiv_ = document.createElement('div');
};
//use the GOverlay class
ExtInfoWindow.prototype = new GOverlay();
/**
* Called by GMap2's addOverlay method.  Creates the wrapping div for our info window and adds
* it to the relevant map pane.  Also binds mousedown event to a private function so that they
* are not passed to the underlying map.  Finally, performs ajax request if set up to use ajax
* in the constructor.
* @param {GMap2} map The map that has had this extInfoWindow is added to it.
*/
ExtInfoWindow.prototype.initialize = function(map) {
this.map_ = map;
this.defaultStyles = {
containerWidth: this.map_.getSize().width / 2,
borderSize: 1
};
this.wrapperParts = {
tl:{t:0, l:0, w:0, h:0, domElement: null},
t:{t:0, l:0, w:0, h:0, domElement: null},
tr:{t:0, l:0, w:0, h:0, domElement: null},
l:{t:0, l:0, w:0, h:0, domElement: null},
r:{t:0, l:0, w:0, h:0, domElement: null},
bl:{t:0, l:0, w:0, h:0, domElement: null},
b:{t:0, l:0, w:0, h:0, domElement: null},
br:{t:0, l:0, w:0, h:0, domElement: null},
beak:{t:0, l:0, w:0, h:0, domElement: null},
close:{t:0, l:0, w:0, h:0, domElement: null}
};
for (var i in this.wrapperParts ) {
var tempElement = document.createElement('div');
tempElement.id = this.infoWindowId_ + '_' + i;
tempElement.style.visibility = 'hidden';
document.body.appendChild(tempElement);
tempElement = document.getElementById(this.infoWindowId_ + '_' + i);
var tempWrapperPart = eval('this.wrapperParts.' + i);    
tempWrapperPart.w = parseInt(this.getStyle_(tempElement, 'width'));
tempWrapperPart.h = parseInt(this.getStyle_(tempElement, 'height'));
document.body.removeChild(tempElement);
}
for (var i in this.wrapperParts) {
if (i == 'close' ) {
//first append the content so the close button is layered above it
this.wrapperDiv_.appendChild(this.contentDiv_);
}
var wrapperPartsDiv = null;
if (this.wrapperParts[i].domElement == null) {
wrapperPartsDiv = document.createElement('div');
this.wrapperDiv_.appendChild(wrapperPartsDiv);
} else {
wrapperPartsDiv = this.wrapperParts[i].domElement;
}
wrapperPartsDiv.id = this.infoWindowId_ + '_' + i;
wrapperPartsDiv.style.position = 'absolute';
wrapperPartsDiv.style.width = this.wrapperParts[i].w + 'px';
wrapperPartsDiv.style.height = this.wrapperParts[i].h + 'px';
wrapperPartsDiv.style.top = this.wrapperParts[i].t + 'px';
wrapperPartsDiv.style.left = this.wrapperParts[i].l + 'px';
this.wrapperParts[i].domElement = wrapperPartsDiv;
}
this.map_.getPane(G_MAP_FLOAT_PANE).appendChild(this.container_);
this.container_.id = this.infoWindowId_;
var containerWidth  = this.getStyle_(document.getElementById(this.infoWindowId_), 'width');
this.container_.style.width = (containerWidth == null ? this.defaultStyles.containerWidth : containerWidth);
this.map_.getContainer().appendChild(this.contentDiv_);
this.contentWidth = this.getDimensions_(this.container_).width;
this.contentDiv_.style.width = this.contentWidth + 'px';
this.contentDiv_.style.position = 'absolute';
this.container_.appendChild(this.wrapperDiv_);
GEvent.bindDom(this.container_, 'mousedown', this,this.onClick_);
GEvent.trigger(this.map_, 'extinfowindowopen');
if (this.ajaxUrl_ != null ) {
this.ajaxRequest_(this.ajaxUrl_);
}
};
/**
* Private function to steal mouse click events to prevent it from returning to the map.
* Without this links in the ExtInfoWindow would not work, and you could click to zoom or drag 
* the map behind it.
* @private
* @param {MouseEvent} e The mouse event caught by this function
*/
ExtInfoWindow.prototype.onClick_ = function(e) {
if(navigator.userAgent.toLowerCase().indexOf('msie') != -1 && document.all) {
window.event.cancelBubble = true;
window.event.returnValue = false;
} else {
e.preventDefault();
e.stopPropagation();
}
};
/**
* Remove the extInfoWindow container from the map pane. 
*/
ExtInfoWindow.prototype.remove = function() {
if (this.map_.getExtInfoWindow() != null) {
GEvent.trigger(this.map_, 'extinfowindowbeforeclose');
GEvent.clearInstanceListeners(this.container_);
if (this.container_.outerHTML) {
this.container_.outerHTML = ''; //prevent pseudo-leak in IE
}
if (this.container_.parentNode) {
this.container_.parentNode.removeChild(this.container_);
}
this.container_ = null;
GEvent.trigger(this.map_, 'extinfowindowclose');
this.map_.setExtInfoWindow_(null);
}
};
/**
* Return a copy of this overlay, for the parent Map to duplicate itself in full. This
* is part of the Overlay interface and is used, for example, to copy everything in the 
* main view into the mini-map.
* @return {GOverlay}
*/
ExtInfoWindow.prototype.copy = function() {
return new ExtInfoWindow(this.marker_, this.infoWindowId_, this.html_, this.options_);
};
/**
* Draw extInfoWindow and wrapping decorators onto the map.  Resize and reposition
* the map as necessary. 
* @param {Boolean} force Will be true when pixel coordinates need to be recomputed.
*/
ExtInfoWindow.prototype.redraw = function(force) { 
if (!force || this.container_ == null) return;
//set the content section's height, needed so  browser font resizing does not affect the window's dimensions
var contentHeight = this.contentDiv_.offsetHeight;
this.contentDiv_.style.height = contentHeight + 'px';
//reposition contents depending on wrapper parts.
//this is necessary for content that is pulled in via ajax
this.contentDiv_.style.left = this.wrapperParts.l.w + 'px';
this.contentDiv_.style.top = this.wrapperParts.tl.h + 'px';
this.contentDiv_.style.visibility = 'visible';
//Finish configuring wrapper parts that were not set in initialization
this.wrapperParts.tl.t = 0;
this.wrapperParts.tl.l = 0;
this.wrapperParts.t.l = this.wrapperParts.tl.w;
this.wrapperParts.t.w = (this.wrapperParts.l.w + this.contentWidth + this.wrapperParts.r.w) - this.wrapperParts.tl.w - this.wrapperParts.tr.w;
this.wrapperParts.t.h = this.wrapperParts.tl.h;
this.wrapperParts.tr.l = this.wrapperParts.t.w + this.wrapperParts.tl.w;
this.wrapperParts.l.t = this.wrapperParts.tl.h;
this.wrapperParts.l.h = contentHeight;
this.wrapperParts.r.l = this.contentWidth + this.wrapperParts.l.w;
this.wrapperParts.r.t = this.wrapperParts.tr.h;
this.wrapperParts.r.h = contentHeight;
this.wrapperParts.bl.t = contentHeight + this.wrapperParts.tl.h;
this.wrapperParts.b.l = this.wrapperParts.bl.w;
this.wrapperParts.b.t = contentHeight + this.wrapperParts.tl.h;
this.wrapperParts.b.w = (this.wrapperParts.l.w + this.contentWidth + this.wrapperParts.r.w) - this.wrapperParts.bl.w - this.wrapperParts.br.w;
this.wrapperParts.b.h = this.wrapperParts.bl.h;
this.wrapperParts.br.l = this.wrapperParts.b.w + this.wrapperParts.bl.w;
this.wrapperParts.br.t = contentHeight + this.wrapperParts.tr.h;
this.wrapperParts.close.l = this.wrapperParts.tr.l +this.wrapperParts.tr.w - this.wrapperParts.close.w - this.borderSize_;
this.wrapperParts.close.t = this.borderSize_;
this.wrapperParts.beak.l = this.borderSize_ + (this.contentWidth / 2) - (this.wrapperParts.beak.w / 2);
this.wrapperParts.beak.t = this.wrapperParts.bl.t + this.wrapperParts.bl.h - this.borderSize_;
//create the decoration wrapper DOM objects
//append the styled info window to the container
for (var i in this.wrapperParts) {
if (i == 'close' ) {
//first append the content so the close button is layered above it
this.wrapperDiv_.insertBefore(this.contentDiv_, this.wrapperParts[i].domElement);
}
var wrapperPartsDiv = null;
if (this.wrapperParts[i].domElement == null) {
wrapperPartsDiv = document.createElement('div');
this.wrapperDiv_.appendChild(wrapperPartsDiv);
} else {
wrapperPartsDiv = this.wrapperParts[i].domElement;
}
wrapperPartsDiv.id = this.infoWindowId_ + '_' + i;
wrapperPartsDiv.style.position='absolute';
wrapperPartsDiv.style.width = this.wrapperParts[i].w + 'px';
wrapperPartsDiv.style.height = this.wrapperParts[i].h + 'px';
wrapperPartsDiv.style.top = this.wrapperParts[i].t + 'px';
wrapperPartsDiv.style.left = this.wrapperParts[i].l + 'px';
this.wrapperParts[i].domElement = wrapperPartsDiv;
}
//add event handler for the close box
var currentMarker = this.marker_;
var thisMap = this.map_;
GEvent.addDomListener(this.wrapperParts.close.domElement, 'click', 
function() {
thisMap.closeExtInfoWindow();
}
);
//position the container on the map, over the marker
var pixelLocation = this.map_.fromLatLngToDivPixel(this.marker_.getPoint());
this.container_.style.position = 'absolute';
var markerIcon = this.marker_.getIcon();
this.container_.style.left = (pixelLocation.x 
//- (this.contentWidth / 2) 
- markerIcon.iconAnchor.x 
+ markerIcon.infoWindowAnchor.x
) + 'px';
this.container_.style.top = (pixelLocation.y
- this.wrapperParts.bl.h
- contentHeight
- this.wrapperParts.tl.h
- this.wrapperParts.beak.h
- markerIcon.iconAnchor.y
+ markerIcon.infoWindowAnchor.y
+ this.borderSize_
) + 'px';
this.container_.style.display = 'block';
if(this.map_.getExtInfoWindow() != null) {
this.repositionMap_();
}
};
/**
* Determine the dimensions of the contents to recalculate and reposition the 
* wrapping decorator elements accordingly.
*/
ExtInfoWindow.prototype.resize = function(){
//Create temporary DOM node for new contents to get new height
//This is done because if you manipulate this.contentDiv_ directly it causes visual errors in IE6
var tempElement = this.contentDiv_.cloneNode(true);
tempElement.id = this.infoWindowId_ + '_tempContents';
tempElement.style.visibility = 'hidden';	
tempElement.style.height = 'auto';
document.body.appendChild(tempElement);
tempElement = document.getElementById(this.infoWindowId_ + '_tempContents');
var contentHeight = tempElement.offsetHeight;
document.body.removeChild(tempElement);
//Set the new height to eliminate visual defects that can be caused by font resizing in browser
this.contentDiv_.style.height = contentHeight + 'px';
var contentWidth = this.contentDiv_.offsetWidth;
var pixelLocation = this.map_.fromLatLngToDivPixel(this.marker_.getPoint());
var oldWindowHeight = this.wrapperParts.t.domElement.offsetHeight + this.wrapperParts.l.domElement.offsetHeight + this.wrapperParts.b.domElement.offsetHeight;	
var oldWindowPosTop = this.wrapperParts.t.domElement.offsetTop;
//resize info window to look correct for new height
this.wrapperParts.l.domElement.style.height = contentHeight + 'px';
this.wrapperParts.r.domElement.style.height = contentHeight + 'px';
var newPosTop = this.wrapperParts.b.domElement.offsetTop - contentHeight;
this.wrapperParts.l.domElement.style.top = newPosTop + 'px';
this.wrapperParts.r.domElement.style.top = newPosTop + 'px';
this.contentDiv_.style.top = newPosTop + 'px';
windowTHeight = parseInt(this.wrapperParts.t.domElement.style.height);
newPosTop -= windowTHeight;
this.wrapperParts.close.domElement.style.top = newPosTop + this.borderSize_ + 'px';
this.wrapperParts.tl.domElement.style.top = newPosTop + 'px';
this.wrapperParts.t.domElement.style.top = newPosTop + 'px';
this.wrapperParts.tr.domElement.style.top = newPosTop + 'px';
this.repositionMap_();
};
/**
* Check to see if the displayed extInfoWindow is positioned off the viewable 
* map region and by how much.  Use that information to pan the map so that 
* the extInfoWindow is completely displayed.
* @private
*/
ExtInfoWindow.prototype.repositionMap_ = function(){
//pan if necessary so it shows on the screen
var mapNE = this.map_.fromLatLngToDivPixel(
this.map_.getBounds().getNorthEast()
);
var mapSW = this.map_.fromLatLngToDivPixel(
this.map_.getBounds().getSouthWest()
);
var markerPosition = this.map_.fromLatLngToDivPixel(
this.marker_.getPoint()
);
var panX = 0;
var panY = 0;
var paddingX = this.paddingX_;
var paddingY = this.paddingY_;
var infoWindowAnchor = this.marker_.getIcon().infoWindowAnchor;
var iconAnchor = this.marker_.getIcon().iconAnchor;
//test top of screen	
var windowT = this.wrapperParts.t.domElement;
var windowL = this.wrapperParts.l.domElement;
var windowB = this.wrapperParts.b.domElement;
var windowR = this.wrapperParts.r.domElement;
var windowBeak = this.wrapperParts.beak.domElement;
var offsetTop = markerPosition.y - ( -infoWindowAnchor.y + iconAnchor.y +  this.getDimensions_(windowBeak).height + this.getDimensions_(windowB).height + this.getDimensions_(windowL).height + this.getDimensions_(windowT).height + this.paddingY_);
if (offsetTop < mapNE.y) {
panY = mapNE.y - offsetTop;
} else {
//test bottom of screen
var offsetBottom = markerPosition.y + this.paddingY_;
if (offsetBottom >= mapSW.y) {
panY = -(offsetBottom - mapSW.y);
}
}
//test right of screen
var offsetRight = Math.round(markerPosition.x + this.getDimensions_(this.container_).width + this.getDimensions_(windowR).width + this.paddingX_ + infoWindowAnchor.x - iconAnchor.x);
if (offsetRight > mapNE.x) {
panX = -( offsetRight - mapNE.x);
} else {
//test left of screen
var offsetLeft = - (Math.round( (this.marker_.getIcon().iconSize.width/2) + this.getDimensions_(windowL).width + this.borderSize_ + this.paddingX_) - markerPosition.x - infoWindowAnchor.x + iconAnchor.x);
if( offsetLeft < mapSW.x) {
panX = mapSW.x - offsetLeft;
}
}
if (panX != 0 || panY != 0 && this.map_.getExtInfoWindow() != null ) {
this.map_.bPan = true; 
this.map_.panBy(new GSize(panX,panY));      
}
};
/**
* Private function that handles performing an ajax request to the server.  The response
* information is assumed to be HTML and is placed inside this extInfoWindow's contents region.
* Last, check to see if the height has changed, and resize the extInfoWindow accordingly.
* @private
* @param {String} url The Url of where to make the ajax request on the server
*/
ExtInfoWindow.prototype.ajaxRequest_ = function(url){
var thisMap = this.map_;
var thisCallback = this.callback_;
GDownloadUrl(url, function(response, status){
var infoWindow = document.getElementById(thisMap.getExtInfoWindow().infoWindowId_ + '_contents');
if (response == null || status == -1 ) {
infoWindow.innerHTML = '<span class="error">ERROR: The Ajax request failed to get HTML content from "' + url + '"</span>';
} else {
infoWindow.innerHTML = response;
}
if (thisCallback != null ) {
thisCallback();
}
thisMap.getExtInfoWindow().resize();
GEvent.trigger(thisMap, 'extinfowindowupdate');
});
};
/**
* Private function derived from Prototype.js to get a given element's
* height and width
* @private
* @param {Object} element The DOM element that will have height and 
*                    width will be calculated for it.
* @return {Object} Object with keys: width, height
*/
ExtInfoWindow.prototype.getDimensions_ = function(element) {
var display = this.getStyle_(element, 'display');
if (display != 'none' && display != null) { // Safari bug
return {width: element.offsetWidth, height: element.offsetHeight};
}
// All *Width and *Height properties give 0 on elements with display none,
// so enable the element temporarily
var els = element.style;
var originalVisibility = els.visibility;
var originalPosition = els.position;
var originalDisplay = els.display;
els.visibility = 'hidden';
els.position = 'absolute';
els.display = 'block';
var originalWidth = element.clientWidth;
var originalHeight = element.clientHeight;
els.display = originalDisplay;
els.position = originalPosition;
els.visibility = originalVisibility;
return {width: originalWidth, height: originalHeight};
};
/**
* Private function derived from Prototype.js to get a given element's
* value that is associated with the passed style
* @private
* @param {Object} element The DOM element that will be checked.
* @param {String} style The style name that will be have it's value returned.
* @return {Object}
*/
ExtInfoWindow.prototype.getStyle_ = function(element, style) {
var found = false;
style = this.camelize_(style);
var value = element.style[style];
if (!value) {
if (document.defaultView && document.defaultView.getComputedStyle) {
var css = document.defaultView.getComputedStyle(element, null);
value = css ? css[style] : null;
} else if (element.currentStyle) {
value = element.currentStyle[style];
}
}
if((value == 'auto') && (style == 'width' || style == 'height') && (this.getStyle_(element, 'display') != 'none')) {
if( style == 'width' ) {
value = element.offsetWidth;
}else {
value = element.offsetHeight;
}
}
if (window.opera && ['left', 'top', 'right', 'bottom'].include(style)) {
if (this.getStyle_(element, 'position') == 'static') value = 'auto';
} 
return (value == 'auto') ? null : value;
};
/**
* Private function pulled from Prototype.js that will change a hyphened
* style name into camel case.
* @private
* @param {String} element The string that will be parsed and made into camel case
* @return {String}
*/
ExtInfoWindow.prototype.camelize_ = function(element) {
var parts = element.split('-'), len = parts.length;
if (len == 1) return parts[0];
var camelized = element.charAt(0) == '-'
? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
: parts[0];
for (var i = 1; i < len; i++) {
camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);
}
return camelized;
};
GMap.prototype.ExtInfoWindowInstance_ = null;
GMap.prototype.ClickListener_ = null;
GMap.prototype.InfoWindowListener_ = null;
/**
* Creates a new instance of ExtInfoWindow for the GMarker.  Register the newly created 
* instance with the map, ensuring only one window is open at a time. If this is the first
* ExtInfoWindow ever opened, add event listeners to the map to close the ExtInfoWindow on 
* zoom and click, to mimic the default GInfoWindow behavior.
*
* @param {GMap} map The GMap2 object where the ExtInfoWindow will open
* @param {String} cssId The id we will use to reference the info window
* @param {String} html The HTML contents
* @param {Object} opt_opts A contianer for optional arguments:
*    {String} ajaxUrl The Url to hit on the server to request some contents 
*    {Number} paddingX The padding size in pixels that the info window will leave on 
*                    the left and right sides of the map when panning is involved.
*    {Number} paddingX The padding size in pixels that the info window will leave on 
*                    the top and bottom sides of the map when panning is involved.
*    {Number} beakOffset The repositioning offset for when aligning the beak element. 
*                    This is used to make sure the beak lines up correcting if the 
*                    info window styling containers a border.
*/
GMarker.prototype.openExtInfoWindow = function(map, cssId, html, opt_opts) {
if (map == null) {
throw 'Error in GMarker.openExtInfoWindow: map cannot be null';
return false;
}
if (cssId == null || cssId == '') {
throw 'Error in GMarker.openExtInfoWindow: must specify a cssId';
return false;
}
map.closeInfoWindow();
if (map.getExtInfoWindow() != null) {
map.closeExtInfoWindow();
}
if (map.getExtInfoWindow() == null) {
map.setExtInfoWindow_( new ExtInfoWindow(
this,
cssId,
html,
opt_opts
) );
if (map.ClickListener_ == null) {
//listen for map click, close ExtInfoWindow if open
map.ClickListener_ = GEvent.addListener(map, 'click',
function(event) {
if( !event && map.getExtInfoWindow() != null ){
map.closeExtInfoWindow();
}
}
);
}
if (map.InfoWindowListener_ == null) {
//listen for default info window open, close ExtInfoWindow if open
map.InfoWindowListener_ = GEvent.addListener(map, 'infowindowopen', 
function(event) {
if (map.getExtInfoWindow() != null) {
map.closeExtInfoWindow();
}
}
);
}
map.addOverlay(map.getExtInfoWindow());
}
};
/**
* Remove the ExtInfoWindow instance
* @param {GMap2} map The map where the GMarker and ExtInfoWindow exist
*/
GMarker.prototype.closeExtInfoWindow = function(map) {
map.closeExtInfoWindow();
};
/**
* Get the ExtInfoWindow instance from the map
*/
GMap2.prototype.getExtInfoWindow = function(){
return this.ExtInfoWindowInstance_;
};
/**
* Set the ExtInfoWindow instance for the map
* @private
*/
GMap2.prototype.setExtInfoWindow_ = function( extInfoWindow ){
this.ExtInfoWindowInstance_ = extInfoWindow;
}
/**
* Remove the ExtInfoWindow from the map
*/
GMap2.prototype.closeExtInfoWindow = function(){
this.ExtInfoWindowInstance_.remove();
};
function GmapsOptionenControl( poFilterButton ){
this.oFilterButton = poFilterButton;
}
GmapsOptionenControl.prototype = new GControl();
GmapsOptionenControl.prototype.initialize = function( poMap ){
var optionenButton = this.oFilterButton;
poMap.getContainer().appendChild( optionenButton );
return optionenButton;
}
GmapsOptionenControl.prototype.getDefaultPosition = function(){
return new GControlPosition( G_ANCHOR_TOP_LEFT, new GSize( 3, 150 ) ); 
}
var openFilter = null;
function toggleFilter(Container) {
$A($(Container).getElementsByTagName('h2')).each (
function (headline) {
Event.observe(headline, 'click', 
function (eHeadline) {
var div = $($(Event.element(eHeadline)).next());
if (openFilter && openFilter != div) {
$(openFilter).previousSiblings()[0].style.backgroundImage = 'url(/images/gmaps/ic_poiplus.gif)';
$(openFilter).hide();
}
if (div.style.display == 'none') {
div.show();
headline.style.backgroundImage = 'url(/images/gmaps/ic_poiminus.gif)';
openFilter = div;
} else {
div.hide();
headline.style.backgroundImage = 'url(/images/gmaps/ic_poiplus.gif)';
}
}
);
}
)
}
function markAll(id) {
var checkBox = $(id).next().next().getElementsByTagName('input');
var sCategories = '';
if($(id).checked == true){
//    $(id).style.backgroundImage = 'url(/images/gmaps/chk_selected.gif)';
for( i = 0 ; i < checkBox.length ; i++ ){
checkBox[i].checked = "checked";
sCategories += " " + checkBox[ i ].value;
}
showFedMarkers( { value:sCategories, checked:true, idVal: id } );
} else {
//    $(id).style.backgroundImage = 'url(/images/gmaps/chk_unselected.gif)';
for( i = 0 ; i < checkBox.length ; i++ ){
checkBox[i].checked = "";
sCategories += " " + checkBox[ i ].value;
}
showFedMarkers( { value:sCategories, checked:false, idVal: id } );
}
}
function demarkAll() {
var sCategories = '';
for( i = 0 ; i < $('fed_poi_filters').getElementsByTagName('input').length ; i++ ){
var oCheckBox = $('fed_poi_filters').getElementsByTagName('input')[i];
oCheckBox.checked = "";
sCategories += " " + oCheckBox.value;
}
showFedMarkers( { value:sCategories, checked:false } );
}
/*
* DragZoomControl Class v1.2 
*  Copyright (c) 2005-2007, Andre Lewis, andre@earthcode.com
*
* Back Button functionality
*  Copyright (c)  2007, Richard Garland, papabear.newyork@gmail.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 
*       http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This class lets you add a control to the map which will let the user
*  zoom by dragging a rectangle.
*  More info on original GZoom at http://earthcode.com
*
* Back Button functionality provides the user with a one click means to return the map state 
*  to its state prior to the DragZoom.  Sequential DragZooms are backed out in reverse order.
*/
/**
* Constructor for DragZoomControl, which takes 3 option hashes and
*  uses them to customize the control.
* @param {opts_boxStyle} Named optional arguments:
*   opts_boxStyle.opacity {Number} Opacity from 0-1
*   opts_boxStyle.fillColor {String} Hex value of fill color
*   opts_boxStyle.border {String} CSS-style declaration of border
* @param {opts_other} Named optional arguments:
*   opts_other.buttonHTML {String} The zoom button HTML in non-activated state
*   opts_other.buttonStartingStyle {Object} A hash of css styles for the 
*     zoom button which are common to both un-activated and activated state
*   opts_other.buttonStyle {Object} A hash of css styles for the zoom button 
*     which will be applied when the button is in un-activated state.
*   opts_other.buttonZoomingHTML {String} HTML which is placed in the 
*     zoom button when the button is activated. 
*   opts_other.buttonZoomingStyle {Object} A hash of css styles for the 
*    zoom button which will be applied when the button is activated.
*   opts_other.overlayRemoveTime {Number} The number of milliseconds to wait before
*     removing the rectangle indicating the zoomed-in area after the zoom has happened.
*   opts_other.stickyZoomEnabled {Boolean} Whether or not the control stays in 
*     "zoom mode" until turned off. When true, the user can zoom repeatedly, 
*     until clicking on the zoom button again to turn zoom mode off.
*   opts_other.backButtonEnabled {Boolean} enables Back Button functionality
*   opts_other.backButtonHTML {String} The back button HTML
*   opts_other.backButtonStyle {Object} A hash of css styles for the back button
*     which will be applied when the button is created.	
* @param {opts_callbacks} Named optional arguments:
*   opts_callbacks.buttonclick {Function} Called when the DragZoom is activated 
*     by clicking on the "zoom" button. 
*   opts_callbacks.dragstart {Function} Called when user starts to drag a rectangle.
*     Callback args are x,y -- the PIXEL values, relative to the upper-left-hand 
*     corner of the map, where the user began dragging.
*   opts_callbacks.dragging {Function} Called repeatedly while the user is dragging.
*     Callback args are startX,startY, currentX,currentY -- the PIXEL values of the 
*     start of the drag, and the current drag point, respectively.
*   opts_callbacks.dragend {Function} Called when the user releases the mouse button 
*     after dragging the rectangle. Callback args are: NW {GLatLng}, NE {GLatLng}, 
*     SE {GLatLng}, SW {GLatLng}, NW {GPoint}, NE {GPoint}, SE {GPoint}, SW {GPoint}.
*     The first 4 are the latitudes/longitudes; the last 4 are the pixel coords on the map.
*   opts_callbacks.backbuttonclick {Function} Called when the back button is activated 
*     after the map context is restored. Callback args: methodCall (boolean) set true if
*     this backbuttonclick was to restore context set by the mathod call, else false.
* Method
*    this.saveMapContext(text) Call to push map context onto the backStack and set the button text 
*    this.initiateZoom() Call to simulate clicking the dragZoom button
*    this.initiateZoomBack() Call to simulate clicking the dragZoom back button
**/
/**
*  Versions
*  1.0 original version (v 189) 5/24/2007
*  1.1 backbutton functionality added  (v 211) 7/30/2007
*  1.2 bug fixes and 2 new methods 9/6/2007
*    fix text selection conflict in IE
*    fix align-text:center inheritance problem in IE
*    create methods initiateZoom and initiateZoomBack which call buttonclick_() and backbuttonclick_()
**/
function DragZoomControl(opts_boxStyle, opts_other, opts_callbacks) {
// Holds all information needed globally
// Not all globals are initialized here
this.globals = {
draggingOn: false,
cornerTopDiv: null,
cornerRightDiv: null,
cornerBottomDiv: null,
cornerLeftDiv: null,
mapPosition: null,
outlineDiv: null,
mapWidth: 0,
mapHeight: 0,
mapRatio: 0,
startX: 0,
startY: 0,
borderCorrection: 0
};
//box style options
this.globals.style = {
opacity: .2,
fillColor: "#000",
border: "2px solid blue"
};
var style = this.globals.style;
for (var s in opts_boxStyle) {
style[s]=opts_boxStyle[s];
}
var borderStyleArray = style.border.split(' ');
style.outlineWidth = parseInt(borderStyleArray[0].replace(/\D/g,''));
style.outlineColor = borderStyleArray[2];
style.alphaIE = 'alpha(opacity=' + (style.opacity * 100) + ')';
// map context stack for back button
this.globals.backStack = [];
// Other options
this.globals.options={
buttonHTML: '<img src="/images/google_zoom.gif" alt="Zoom" />',
buttonStartingStyle: {},
buttonStyle: {},
backButtonHTML: '<img src="/images/google_zoom.gif" alt="Zoom" />',
backButtonStyle: {background: '#FFF', display: 'none'},
buttonZoomingHTML: '<p style="background: #f1dfd7; border: 1px solid #000; padding: 3px; width: 100px;">Ziehen Sie ein Rechteck in der Karte auf.</p>',
buttonZoomingStyle: { background: 'transparent' },
overlayRemoveTime: 6000,
backButtonEnabled: false,
stickyZoomEnabled: false
};
for (var s in opts_other) {
this.globals.options[s] = opts_other[s]
}
// callbacks: buttonclick, dragstart, dragging, dragend, backbuttonclick 
if (opts_callbacks == null) {
opts_callbacks = {}
}
this.globals.callbacks = opts_callbacks;
}
DragZoomControl.prototype = new GControl();
/**
* Methods
*/
/**
* Method called to save the map context before the zoom.
* Back Button functionality:	
* @param {text} text string for the back button
*/
DragZoomControl.prototype.saveMapContext = function(text) {
if (this.globals.options.backButtonEnabled) {
this.saveBackContext_(text,true);
this.globals.backButtonDiv.style.display = 'block';
}	
};
/**
* Method called to initiate a dragZoom as if the user had clicked the dragZoom button.
*/
DragZoomControl.prototype.initiateZoom = function() {this.buttonclick_()};
/**
* Method called to initiate a dragZoom back operation as if the user had clicked the dragZoom back button.
* Back Button functionality:	
*/
DragZoomControl.prototype.initiateZoomBack = function() {if (this.globals.options.backButtonEnabled) this.backbuttonclick_()};	
/**
* Creates a new button to control gzoom and appends to the button container div.
* @param {DOM Node} buttonContainerDiv created in main .initialize code
*/
DragZoomControl.prototype.initButton_ = function(buttonContainerDiv) {
var G = this.globals;
var buttonDiv = document.createElement('div');
buttonDiv.innerHTML = G.options.buttonHTML;
buttonDiv.id = 'gzoom-control';
DragZoomUtil.style([buttonDiv], {cursor: 'pointer', zIndex:200});
DragZoomUtil.style([buttonDiv], G.options.buttonStartingStyle);
DragZoomUtil.style([buttonDiv], G.options.buttonStyle);
buttonContainerDiv.appendChild(buttonDiv);
return buttonDiv;
};
/**												
* Creates a second new button to control backup zoom and appends to the button container div.
* @param {DOM Node} buttonContainerDiv created in main .initialize code
*/
DragZoomControl.prototype.initBackButton_ = function(buttonContainerDiv) {
var G = this.globals;
var backButtonDiv = document.createElement('div');
backButtonDiv.innerHTML = G.options.backButtonHTML;
backButtonDiv.id = 'gzoom-back';
DragZoomUtil.style([backButtonDiv], {cursor: 'pointer', zIndex:200});
DragZoomUtil.style([backButtonDiv], G.options.buttonStartingStyle);
DragZoomUtil.style([backButtonDiv], G.options.backButtonStyle);
buttonContainerDiv.appendChild(backButtonDiv);
return backButtonDiv;
};
/**
* Sets button mode to zooming or otherwise, changes CSS & HTML.
* @param {String} mode Either "zooming" or not.
*/
DragZoomControl.prototype.setButtonMode_ = function(mode){
var G = this.globals;
if (mode == 'zooming') {
G.buttonDiv.innerHTML = G.options.buttonZoomingHTML;
DragZoomUtil.style([G.buttonDiv], G.options.buttonStartingStyle);
DragZoomUtil.style([G.buttonDiv], G.options.buttonZoomingStyle);
} else {
G.buttonDiv.innerHTML = G.options.buttonHTML;
DragZoomUtil.style([G.buttonDiv], G.options.buttonStartingStyle);
DragZoomUtil.style([G.buttonDiv], G.options.buttonStyle);
}
};
/**
* Is called by GMap2's addOverlay method. Creates the zoom control
* divs and appends to the map div.
* @param {GMap2} map The map that has had this DragZoomControl added to it.
* @return {DOM Object} Div that holds the gzoomcontrol button
*/ 
DragZoomControl.prototype.initialize = function(map) {
var G = this.globals;
var me = this;
var mapDiv = map.getContainer();
// Create div for both buttons	
var buttonContainerDiv = document.createElement("div");	
DragZoomUtil.style([buttonContainerDiv], {cursor: 'pointer', zIndex: 150});
// create and init the zoom button
//DOM:button
var buttonDiv = this.initButton_(buttonContainerDiv);
// create and init the back button				
//DOM:button
var backButtonDiv = this.initBackButton_(buttonContainerDiv);
// Add the two buttons to the map 					
mapDiv.appendChild(buttonContainerDiv);
//DOM:map covers
var zoomDiv = document.createElement("div");
zoomDiv.id ='gzoom-map-cover';
zoomDiv.innerHTML ='<div id="gzoom-outline" style="position:absolute;display:none;"></div><div id="gzoom-cornerTopDiv" style="position:absolute;display:none;"></div><div id="gzoom-cornerLeftDiv" style="position:absolute;display:none;"></div><div id="gzoom-cornerRightDiv" style="position:absolute;display:none;"></div><div id="gzoom-cornerBottomDiv" style="position:absolute;display:none;"></div>';
DragZoomUtil.style([zoomDiv], {position: 'absolute', display: 'none', overflow: 'hidden', cursor: 'crosshair', zIndex: 101});
mapDiv.appendChild(zoomDiv);
// add event listeners
GEvent.addDomListener(buttonDiv, 'click', function(e) {
me.buttonclick_(e);
});
GEvent.addDomListener(backButtonDiv, 'click', function(e) {
me.backbuttonclick_(e);
});
GEvent.addDomListener(zoomDiv, 'mousedown', function(e) {
me.coverMousedown_(e);
});
GEvent.addDomListener(document, 'mousemove', function(e) {
me.drag_(e);
});
GEvent.addDomListener(document, 'mouseup', function(e) {
me.mouseup_(e);
});
// get globals
G.mapPosition = DragZoomUtil.getElementPosition(mapDiv);
G.outlineDiv = DragZoomUtil.gE("gzoom-outline");	
G.buttonDiv = DragZoomUtil.gE("gzoom-control");
G.backButtonDiv = DragZoomUtil.gE("gzoom-back");
G.mapCover = DragZoomUtil.gE("gzoom-map-cover");
G.cornerTopDiv = DragZoomUtil.gE("gzoom-cornerTopDiv");
G.cornerRightDiv = DragZoomUtil.gE("gzoom-cornerRightDiv");
G.cornerBottomDiv = DragZoomUtil.gE("gzoom-cornerBottomDiv");
G.cornerLeftDiv = DragZoomUtil.gE("gzoom-cornerLeftDiv");
G.map = map;
G.borderCorrection = G.style.outlineWidth * 2;	
this.setDimensions_();
//styles
this.initStyles_();
// disable text selection on map cover
G.mapCover.onselectstart = function() {return false}; 
return buttonContainerDiv;
};
/**
* Required by GMaps API for controls. 
* @return {GControlPosition} Default location for control
*/
DragZoomControl.prototype.getDefaultPosition = function() {
return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(3, 120));
};
/**
* Function called when mousedown event is captured.
* @param {Object} e 
*/
DragZoomControl.prototype.coverMousedown_ = function(e){
var G = this.globals;
var pos = this.getRelPos_(e);
G.startX = pos.left;
G.startY = pos.top;
DragZoomUtil.style([G.mapCover], {background: 'transparent', opacity: 1, filter: 'alpha(opacity=100)'});
DragZoomUtil.style([G.outlineDiv], {left: G.startX + 'px', top: G.startY + 'px', display: 'block', width: '1px', height: '1px'});
G.draggingOn = true;
G.cornerTopDiv.style.top = (G.startY - G.mapHeight) + 'px';
G.cornerTopDiv.style.display ='block';
G.cornerLeftDiv.style.left = (G.startX - G.mapWidth) +'px';
G.cornerLeftDiv.style.top = G.startY + 'px';
G.cornerLeftDiv.style.display = 'block';
G.cornerRightDiv.style.left = G.startX + 'px';
G.cornerRightDiv.style.top = G.startY + 'px';
G.cornerRightDiv.style.display = 'block';
G.cornerBottomDiv.style.left = G.startX + 'px';
G.cornerBottomDiv.style.top = G.startY + 'px';
G.cornerBottomDiv.style.width = '0px';
G.cornerBottomDiv.style.display = 'block';
// invoke the callback if provided
if (G.callbacks.dragstart != null) {
G.callbacks.dragstart(G.startX, G.startY);
}
return false;
};
/**
* Function called when drag event is captured
* @param {Object} e 
*/
DragZoomControl.prototype.drag_ = function(e){
var G = this.globals;
if(G.draggingOn) {
var pos = this.getRelPos_(e);
rect = this.getRectangle_(G.startX, G.startY, pos, G.mapRatio);
if (rect.left) {
addX = -rect.width;			
} else { 
addX = 0;
}
if (rect.top) {
addY = -rect.height;
} else {
addY = 0;
}
DragZoomUtil.style([G.outlineDiv], {left: G.startX + addX + 'px', top: G.startY + addY + 'px', display: 'block', width: '1px', height: '1px'});	
G.outlineDiv.style.width = rect.width + "px";
G.outlineDiv.style.height = rect.height + "px";
G.cornerTopDiv.style.height = ((G.startY + addY) - (G.startY - G.mapHeight)) + 'px';
G.cornerLeftDiv.style.top = (G.startY + addY) + 'px';
G.cornerLeftDiv.style.width = ((G.startX + addX) - (G.startX - G.mapWidth)) + 'px';
G.cornerRightDiv.style.top = G.cornerLeftDiv.style.top;
G.cornerRightDiv.style.left = (G.startX + addX + rect.width + G.borderCorrection) + 'px';
G.cornerBottomDiv.style.top = (G.startY + addY + rect.height + G.borderCorrection) + 'px';
G.cornerBottomDiv.style.left = (G.startX - G.mapWidth + ((G.startX + addX) - (G.startX - G.mapWidth))) + 'px';
G.cornerBottomDiv.style.width = (rect.width + G.borderCorrection) + 'px';
// invoke callback if provided
if (G.callbacks.dragging != null) {
G.callbacks.dragging(G.startX, G.startY, rect.endX, rect.endY)
}
return false;
}  
};
/** 
* Function called when mouseup event is captured
* @param {Event} e
*/
DragZoomControl.prototype.mouseup_ = function(e){
var G = this.globals;
if (G.draggingOn) {
var pos = this.getRelPos_(e);
G.draggingOn = false;
var rect = this.getRectangle_(G.startX, G.startY, pos, G.mapRatio);
if (rect.left) rect.endX = rect.startX - rect.width;
if (rect.top) rect.endY = rect.startY - rect.height;
this.resetDragZoom_();
var nwpx = new GPoint(rect.startX, rect.startY);
var nepx = new GPoint(rect.endX, rect.startY);
var sepx = new GPoint(rect.endX, rect.endY);
var swpx = new GPoint(rect.startX, rect.endY);
var nw = G.map.fromContainerPixelToLatLng(nwpx); 
var ne = G.map.fromContainerPixelToLatLng(nepx); 
var se = G.map.fromContainerPixelToLatLng(sepx); 
var sw = G.map.fromContainerPixelToLatLng(swpx); 
var zoomAreaPoly = new GPolyline([nw, ne, se, sw, nw], G.style.outlineColor, G.style.outlineWidth + 1,.4);
try{
G.map.addOverlay(zoomAreaPoly);
setTimeout (function() {G.map.removeOverlay(zoomAreaPoly)}, G.options.overlayRemoveTime);  
}catch(e) {}
polyBounds = zoomAreaPoly.getBounds();
var ne = polyBounds.getNorthEast();
var sw = polyBounds.getSouthWest();
var se = new GLatLng(sw.lat(), ne.lng());
var nw = new GLatLng(ne.lat(), sw.lng());
zoomLevel = G.map.getBoundsZoomLevel(polyBounds);
center = polyBounds.getCenter();
G.map.setCenter(center, zoomLevel);
// invoke callback if provided
if (G.callbacks.dragend != null) {
G.callbacks.dragend(nw, ne, se, sw, nwpx, nepx, sepx, swpx);
}
//re-init if sticky
if (G.options.stickyZoomEnabled) {
//GLog.write("stickyZoomEnabled, re-initting");
this.initCover_();
if (G.options.backButtonEnabled) this.saveBackContext_(G.options.backButtonHTML,false); // save the map context for back button
G.backButtonDiv.style.display='none';
}
}
};
/**
* Set the cover sizes according to the size of the map
*/
DragZoomControl.prototype.setDimensions_ = function() {
var G = this.globals;
var mapSize = G.map.getSize();
G.mapWidth  = mapSize.width;
G.mapHeight = mapSize.height;
G.mapRatio  = G.mapHeight / G.mapWidth;
// set left:0px in next <div>s in case we inherit text-align:center from map <div> in IE.
DragZoomUtil.style([G.mapCover, G.cornerTopDiv, G.cornerRightDiv, G.cornerBottomDiv, G.cornerLeftDiv], 
{left: '0px',width: G.mapWidth + 'px', height: G.mapHeight +'px'});
};
/**
* Initializes styles based on global parameters
*/
DragZoomControl.prototype.initStyles_ = function(){
var G = this.globals;
DragZoomUtil.style([G.mapCover, G.cornerTopDiv, G.cornerRightDiv, G.cornerBottomDiv, G.cornerLeftDiv], 
{filter: G.style.alphaIE, opacity: G.style.opacity, background:G.style.fillColor});
G.outlineDiv.style.border = G.style.border;  
};
/**
* Function called when the zoom button's click event is captured.
*/
DragZoomControl.prototype.buttonclick_ = function(){
var G = this.globals;	
G.backButtonDiv.style.display='none';
if (G.mapCover.style.display == 'block') { // reset if clicked before dragging 
this.resetDragZoom_();
if (G.options.backButtonEnabled) {  
this.restoreBackContext_();  // pop the backStack on a button reset
if (G.backStack.length==0) G.backButtonDiv.style.display='none';
}
} else {
this.initCover_();
if ( G.options.backButtonEnabled ) this.saveBackContext_(G.options.backButtonHTML,false); // save the map context for back button
}
};
/**
* Back Button functionality:	
* Function called when the back button's click event is captured.
* calls the function to set the map context back to where it was before the zoom.
*/
DragZoomControl.prototype.backbuttonclick_ = function(){
var G = this.globals;	
if (G.options.backButtonEnabled && G.backStack.length > 0) {
this.restoreBackContext_();
// invoke the callback if provided
if (G.callbacks['backbuttonclick'] != null) {
G.callbacks.backbuttonclick(G.methodCall);
}
}
};
/** 
* Back Button functionality:	
* Saves the map context and pushes it on the backStack for later use by the back button
*/
DragZoomControl.prototype.saveBackContext_ = function(text,methodCall) {
var G = this.globals;
var backFrame = {};
backFrame["center"] = G.map.getCenter();
backFrame["zoom"] = G.map.getZoom();
backFrame["maptype"] = G.map.getCurrentMapType();
backFrame["text"] = G.backButtonDiv.innerHTML; // this saves the previous button text
backFrame["methodCall"] = methodCall; //This determines if it was an internal or method call
G.backStack.push(backFrame);
G.backButtonDiv.innerHTML = text;
// Back Button is turned on in resetDragZoom_()
};
/** 
* Back Button functionality:	
* Pops the previous map context off of the backStack and restores the map to that context
*/
DragZoomControl.prototype.restoreBackContext_ = function() {
var G = this.globals;
var backFrame = G.backStack.pop();
G.map.setCenter(backFrame["center"],backFrame["zoom"],backFrame["maptype"]);
G.backButtonDiv.innerHTML = backFrame["text"];
G.methodCall = backFrame["methodCall"];
if (G.backStack.length==0) G.backButtonDiv.style.display = 'none'; // if we're at the top of the stack, hide the back botton
};
/**
* Shows the cover over the map
*/
DragZoomControl.prototype.initCover_ = function(){
var G = this.globals;
G.mapPosition = DragZoomUtil.getElementPosition(G.map.getContainer());
this.setDimensions_();
this.setButtonMode_('zooming');
DragZoomUtil.style([G.mapCover], {display: 'block', background: G.style.fillColor});
DragZoomUtil.style([G.outlineDiv], {width: '0px', height: '0px'});
//invoke callback if provided
if(G.callbacks['buttonclick'] != null){
G.callbacks.buttonclick();
}
};
/**
* Gets position of the mouse relative to the map
* @param {Object} e
*/
DragZoomControl.prototype.getRelPos_ = function(e) {
var pos = DragZoomUtil.getMousePosition(e);
var G = this.globals;
return {top: (pos.top - G.mapPosition.top), 
left: (pos.left - G.mapPosition.left)};
};
/**
* Figures out the rectangle the user's trying to draw
* @param {Number} startX 
* @param {Number} startY
* @param {Object} pos
* @param {Number} ratio
* @return {Object} Describes the rectangle
*/
DragZoomControl.prototype.getRectangle_ = function(startX, startY, pos, ratio){
var left = false;
var top = false;
var dX = pos.left - startX;
var dY = pos.top - startY;	
if (dX < 0) {
dX = dX * -1;
left = true;
}
if (dY < 0) {
dY = dY * -1;
top = true;
}
delta = dX > dY ? dX : dY;
return {
startX: startX,
startY: startY,
endX: startX + delta,
endY: startY + parseInt(delta * ratio),
width: delta,
height: parseInt(delta * ratio),
left:left,
top:top
}
};
/** 
* Resets CSS and button display when drag zoom done
*/
DragZoomControl.prototype.resetDragZoom_ = function() {
var G = this.globals;
DragZoomUtil.style([G.mapCover, G.cornerTopDiv, G.cornerRightDiv, G.cornerBottomDiv, G.cornerLeftDiv], 
{display: 'none', opacity: G.style.opacity, filter: G.style.alphaIE});
G.outlineDiv.style.display = 'none';	
this.setButtonMode_('normal');
if (G.options.backButtonEnabled  && (G.backStack.length > 0)) G.backButtonDiv.style.display = 'block'; // show the back button
};
/* utility functions in DragZoomUtil.namespace */
var DragZoomUtil={};
/**
* Alias function for getting element by id
* @param {String} sId
* @return {Object} DOM object with sId id
*/
DragZoomUtil.gE = function(sId) {
return document.getElementById(sId);
}
/**
* A general-purpose function to get the absolute position
* of the mouse.
* @param {Object} e  Mouse event
* @return {Object} Describes position
*/
DragZoomUtil.getMousePosition = function(e) {
var posX = 0;
var posY = 0;
if (!e) var e = window.event;
if (e.pageX || e.pageY) {
posX = e.pageX;
posY = e.pageY;
} else if (e.clientX || e.clientY){
posX = e.clientX + 
(document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
posY = e.clientY + 
(document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
}	
return {left: posX, top: posY};  
};
/**
* Gets position of element
* @param {Object} element
* @return {Object} Describes position
*/
DragZoomUtil.getElementPosition = function(element) {
var leftPos = element.offsetLeft;          // initialize var to store calculations
var topPos = element.offsetTop;            // initialize var to store calculations
var parElement = element.offsetParent;     // identify first offset parent element  
while (parElement != null ) {                // move up through element hierarchy
leftPos += parElement.offsetLeft;      // appending left offset of each parent
topPos += parElement.offsetTop;  
parElement = parElement.offsetParent;  // until no more offset parents exist
}
return {left: leftPos, top: topPos};
};
/**
* Applies styles to DOM objects 
* @param {String/Object} elements Either comma-delimited list of ids 
*   or an array of DOM objects
* @param {Object} styles Hash of styles to be applied
*/
DragZoomUtil.style = function(elements, styles){
if (typeof(elements) == 'string') {
elements = DragZoomUtil.getManyElements(elements);
}
for (var i = 0; i < elements.length; i++){
for (var s in styles) { 
elements[i].style[s] = styles[s];
}
}
};
/**
* Gets DOM elements array according to list of IDs
* @param {String} elementsString Comma-delimited list of IDs
* @return {Array} Array of DOM elements corresponding to s
*/
DragZoomUtil.getManyElements = function(idsString){		
var idsArray = idsString.split(',');
var elements = [];
for (var i = 0; i < idsArray.length; i++){
elements[elements.length] = DragZoomUtil.gE(idsArray[i])
};
return elements;
};
/**
* @author Christian Knott <c.knott@21torr.com>
* Watchlist class
*/
var Watchlist = (function(){
/**
* This method adds a POI to a users watchlist.
* 
* @param {int} piPOIId - The id of the POI we want to add to the watchlist
*/
var vAddItem = function(piPOIId){
// show the confirmation in a modal box.
var oModal = new Modal(1, 500);
new Ajax.Request('/watchlist/additem/' + piPOIId, {
onSuccess: function(res){
if(res.responseJSON){
if(res.responseJSON.success == true){
oModal.AddButton('Zur Merkliste', null, null, null, res.responseJSON.result.watchlist_url);
oModal.ShowSuccess('Der Eintrag wurde erfolgreich zur Merkliste hinzugefügt!', res.responseJSON.result.html);
oIVW.Change('1co_merk');
}
else if(res.responseJSON.success == false){
oModal.ShowError('Fehler', res.responseJSON.errors.join('<br/>'));
}
}
}
});
}
/**
* This method initializes the event handler for all 'Merken' links
* 
* @param {string} psWatchlistContainer - Optional field indicating a specific watchlist link container
*                 Very handy when we dont want to parse the whole DOM for watch links (eg. POI bubble)
*/
var vInitWatchLinks = function(psWatchlistContainer){
var sWatchlistContainer = psWatchlistContainer || '';
// extend the selector
sWatchlistContainer += ' a.watchlist-watch-item';
// attach an event listener to all 'Merken' hyperlinks
$$(sWatchlistContainer).each(function(n){
$(n).observe('click', function(e){
Event.stop(e);
var oElem = Event.element(e);
// get the POI Id, stored in the hyperlinks href (eg '#232344')
var sElemHash = oElem.readAttribute('href').split('#')[1];
var iPOIId = sElemHash.replace(/\D/g,'') || '';
vAddItem(iPOIId);         
});
});
}
/**
* This method initializes an event handler on the watchlist container and 
* catches all up-bubbling events and dispatches them.
*/
var vWatchlistInit = function(){
// get all div.watchlist-container elements, although we should only receive one element
$$('div.watchlist-container').each(function(n){
$(n).observe('click', function(e){
var oElem = Event.element(e), sClassName = oElem.className;
if(oElem.tagName.toLowerCase() != 'a' && oElem.tagName.toLowerCase() != 'input'){ return; }
var bEventCaught = true;
// the elements classname indicates the action
switch(sClassName){
case 'show-in-map':
//center the selected POI in the mini map in the marginal column
var iPOIId = oElem.readAttribute('href').replace(/\D/, '');
gmapsTypo.centerOnMarker(iPOIId);
break;
case 'show-notice':
var oParentElement = oElem.up().up();
vShowNotice(oParentElement, oElem);
break;
case 'hide-notice':
var oParentElement = oElem.up().up();
vHideNotice(oParentElement, oElem);
break;
case 'save-notice':
var iWatchlistItemID = oElem.readAttribute('href').replace(/\D/, '');
var sNoticeText = oElem.up().getElementsBySelector('textarea')[0].value;
vAddNotice(iWatchlistItemID, sNoticeText);
break;
case 'delete-item':
var iWatchlistItemID = oElem.readAttribute('href').replace(/\D/, '');
vDeleteItem(iWatchlistItemID);
break;
case 'delete-all':
vDeleteAllItems();
break;
case 'show-infos':
//get the full info div container
Effect.BlindUp(oElem.up().up(), {
duration: 0.2,
afterFinish: function(){
var oFullInfo = oElem.up().up().up().select('.full-info')[0];
Effect.BlindDown(oFullInfo, {
duration: 0.4
});
}
});
break;
case 'hide-infos':
//get the full info div container
var oShortInfo = oElem.up().up().up().select('.short-info')[0];
Effect.BlindUp(oElem.up().up(), {
duration: 0.4,
afterFinish: function(){
Effect.BlindDown(oShortInfo, {
duration: 0.2
});
}
});
break;
case 'select-watchlist-url':
oElem.select();
break;
default:
bEventCaught = false;
break;
}
// if we caught an event, there was a javascript action so stop event bubbling/propagation
if(bEventCaught || oElem.readAttribute('href') == '#'){ Event.stop(e); }
});
});
}
var vAddNotice = function(piWatchlistItemID, psNoticeText){
new Ajax.Request('/watchlist/savenotice/' + piWatchlistItemID, {
parameters: {
'notice-text': psNoticeText
},
onSuccess: function(res){
var oModal = new Modal(1, 500);
if(res.responseJSON.success == true){
oModal.ShowSuccess('Notiz hinzugefügt', 'Die Notiz wurde erfolgreich gespeichert!');
oIVW.Change('1co_plan');
if(psNoticeText.replace(/\s*/g, '') == ''){
window.setTimeout(function(){
window.location.reload();
}, 2000);
}
}
else if(res.responseJSON == false){
oModal.ShowError('Fehler', 'Es trat ein Fehler beim Speichern der Notiz auf.<br/>Bitte versuchen sie es später noch einmal!');
}
}
});
}
var vHideNotice = function(poParentElement, poElem){
poParentElement.getElementsBySelector('.notice-input-container').each(function(n){
Effect.BlindUp(n, {
duration: 0.5,
afterFinish: function(){
poElem.removeClassName('hide-notice').addClassName('show-notice');
poElem.update('&raquo; Notiz anlegen');
poElem.setAttribute('title', 'Notiz anlegen');
oIVW.Change('1co_plan');
}
});
});
}
var vShowNotice = function(poParentElement, poElem){
poParentElement.getElementsBySelector('.notice-input-container').each(function(n){
Effect.BlindDown(n, {
duration: 0.5,
afterFinish: function(){
//switch classnames to remove the textarea with the next click on the link
poElem.removeClassName('show-notice').addClassName('hide-notice');
poElem.update('&raquo; Notizfeld ausblenden');
poElem.setAttribute('title', 'Notizfeld ausblenden');
oIVW.Change('1co_plan');
}
});
}); 	
}
var vDeleteItem = function(piWatchlistItemID){
var oModal = new Modal(1, 500);
oModal.AddButton('abort', function(){
oModal.Close();
});
oModal.ShowError('Entfernen des Ortes bestätigen', 'Diesen Ort wirklich von der Merkliste entfernen? Löschen bitte mit Klick auf \'OK\' bestätigen.', function(){
new Ajax.Request('/watchlist/deleteitem/' + piWatchlistItemID, {
onSuccess: function(res){
if(res.responseJSON.success){
oModal.Close();
window.setTimeout(function(){
window.location.reload();							
}, 1000);
}
}
});
});
}
var vDeleteAllItems = function(){
var oModal = new Modal(1, 500);
oModal.AddButton('abort', function(){
oModal.Close();
});
oModal.ShowError('Entfernen aller Orte bestätigen', 'Wirklich alle Orte von der Merkliste entfernen? Löschen bitte mit Klick auf \'OK\' bestätigen.', function(){
new Ajax.Request('/watchlist/deleteall/', {
onSuccess: function(res){
if(res.responseJSON.success){
oModal.Close();
window.setTimeout(function(){
window.location.reload();             
}, 1000);
}
}
});
});
}
// the constructor
var f = function(){
var that = this;
vInitWatchLinks();
vWatchlistInit();
}
/**
* add an event handler for focussing the url input field with the url to the users watchlist
*/
f.prototype.vAddInputListener = function(){
var oURLInput = $('watchlist-url-input');
if(oURLInput){
oURLInput.observe('focus', function(e){
Event.element(e).select();
});
}
}
/**
* Exposes the vInitWatchLinks method to be able to add watch links at runtime (eg. POI bubble).
* 
* @param {string} psWatchlistLinkContainer
*/
f.prototype.vAddWatchLink = function(psWatchlistLinkContainer){
// the css selector psWatchlistLinkContainer is mandatory
if(!psWatchlistLinkContainer){ return; }	 	 
vInitWatchLinks(psWatchlistLinkContainer);
}
// static members
return f;
})();
// create a Watchlist instance on window load.
Event.observe(window, 'load', function(){
// to prevent somebody overwriting our variables, create a namespace, if not created already, and store
// the variables within the namespace
var TORR = window.TORR || {};
TORR.oWatchlist = TORR.oWatchlist || new Watchlist();
});
var PremiumPOI = (function(){
var f = function(){
var that = this;
var oData = {
'sActCategory': null, 
'sActCity': null, 
'sActCountry': 'Deutschland'
};
this.oGetData = function(){
return {
'sActCategory': oData['sActCategory'],
'sActCity': oData['sActCity'],
'sActCountry': oData['sActCountry']
};
}
this.vSet = function(sProp, sValue){
if(!oData.hasOwnProperty(sProp)){ return; }
oData[sProp] = sValue.capitalize();
// enable chained calls by returning this (that)
return that;
} 
}
return f;
}());
Event.observe(window, 'load', function(){
window.TORR = window.TORR || {};
if(!window.TORR.oPremiumPOI){
window.TORR.oPremiumPOI = new PremiumPOI();
}
});
/*	SWFObject v2.2 <http://code.google.com/p/swfobject/> 
is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/
var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();
/**
* TabController
* 
* @author Ralf Barth / 21TORR AGENCY gmbh
*/
var TabController = {
// functions that get called when a tab is switched, handy for defining custom actions on some tab boxes (eg. IVW counting on gateway tab box)
aSwitchActions: [],
/**
* Constructor
* @param (object) poOptions - An object containing all possible options for the tabcontroller.
*                 Currently implemented options:
*                 - oExcludeTabs (object) - An array containing the tabs which should not load their content through AJAX.
*                   The tabs are identified by their href eg ('#top5').
*/
initialize: function(poOptions)
{
var that = this;
this.aSwitches = $A(this.getElementsByTagName('a'));
this.sInitialClass = this.className;
this.sActiveTab = '';
// Look for a tab-to-activate in cookie
//var sOldTab = get_cookie('TCActiveTab');
var sOldTab = "";
// Look for a tab to active in
if (sOldTab.length <= 2)
{
var sOldTab = window.location.href.split('#')[1];
}
var bRemembered = false;
for (var i = 0; i < this.aSwitches.length; i++)
{
var oSwitch = this.aSwitches[i];
oSwitch.sTab = this.aSwitches[i].href.split('#')[1];
oSwitch.oLayer = $(oSwitch.sTab);
if (sOldTab && sOldTab.length > 2)
{
if (oSwitch.sTab == sOldTab)
{
$(oSwitch).addClassName('active');
bRemembered = true;
}
else
{
$(oSwitch).removeClassName('active').addClassName('tab_inactive');
}
}
$(oSwitch).hasClassName('active') ? $(oSwitch.oLayer).show() : $(oSwitch.oLayer).hide();
oSwitch.oController = this;
oSwitch.toggleLayer = function()
{
if (this.bActive)
{ 
this.oLayer.show();
this.removeClassName('tab_inactive').addClassName('active');
$(this.oController).addClassName(this.sTab+'_IsActive');
if(that.aSwitchActions.length !== 0){
that.aSwitchActions.each(function(fSwitchAction){
if(typeof(fSwitchAction) != 'function'){ return; }
fSwitchAction.call();
});
}
}
else
{
this.oLayer.hide();
this.removeClassName('active').addClassName('tab_inactive');
}
}
Event.observe(oSwitch, 'click', function(e)
{
Event.stop(e);
var oThisSwitch = Event.element(e);
if (oThisSwitch.bActive){
return;
}
var sCategoryHref = oThisSwitch.getAttribute('href');
var sActiveLayer = sCategoryHref.split('#')[1];
if(typeof(PremiumPOI) != 'undefined'){
if(!window.TORR || !window.TORR.oPremiumPOI){
window.TORR = window.TORR || {};
window.TORR.oPremiumPOI = new PremiumPOI();
}
window.TORR.oPremiumPOI.vSet('sActCategory', oCategoryMap['#'+sActiveLayer] || '');
}
that.sActiveTab = '#' + sActiveLayer;
/*if(poOptions && poOptions.oExcludeTabs && !poOptions.oExcludeTabs[sCategoryHref] && !oThisSwitch.hasClassName('hasLoaded')){
StdAjax('/gmaps/volume/getpoisbycategory', {
parameters: {
sVolume : sVolume,
sMainCat: oCategoryMap[sCategoryHref],
aCats: sCat,
iPageId: 1
},
onSuccess: function(result){
oThisSwitch.addClassName('hasLoaded');
oThisSwitch.oLayer.innerHTML = result.html;
for(i=0; i<result.data.length;i++)
{
var oElem = $$('div#' + sActiveLayer + ' div#fed_poi_rate'+result.data[i].ID)[0];
oRating.vEmbeddRating(oElem, "fed_poi", result.data[i].ID);
} 
}						
});
}*/
var oController = oThisSwitch.oController;
$(oController).className = oController.sInitialClass;
oController.aSwitches.each(function(oSwitch)
{ 
oSwitch.bActive = oSwitch == oThisSwitch;
oSwitch.toggleLayer();
});
});
}
if (!bRemembered)
{
this.aSwitches[0].bActive = true;
this.aSwitches[0].toggleLayer();
}
},
vAddSwitchAction: function(pfAction){
if(typeof(pfAction) == 'function'){
this.aSwitchActions[this.aSwitchActions.length] = pfAction;
}
},
sGetActiveTab: function(){
return this.sActiveTab;
}
}
function jump(obj)
{
var sPath = obj.options[obj.selectedIndex].value;
if (sPath == '')
{
return false;
}
window.location.href = sPath;
}
function _vShowForumHint()
{
var oM = new Modal(2,400);
oM.Show('Bitte anmelden',
'Um Antworten zu können musst Du angemeldet sein. Falls Du noch kein Mitglied bist, kannst Du Dich <a href="/community/registrierung">hier registrieren</a>.'
);
oM.SetCancelButtonTitle('Schliessen');
}
EventsSelector = Class.create();
EventsSelector.prototype = {
initialize: function( poCountrySelect, poCitySelect, psSelectedState ){
var _this = this;
this.oCountrySelect = poCountrySelect;
this.oCitySelect = poCitySelect;
this.sSelectedState = typeof(psSelectedState) != 'undefined' ? psSelectedState : null; 
this.oCountrySelect.onchange = function(){ _this.getCities( _this.oCountrySelect.value ) };
this.nCityId = null;
this.fPostCityAction = null;
},
setCityId: function( pnCityId ){
this.nCityId = pnCityId;  
},
setPostCityAction: function( pfAction ){
this.fPostCityAction = pfAction;  
},
getCities: function( pnCountryId ){
if( pnCountryId == '' ) return;
var _this = this;
StdAjax( '/events/getcities',
{
parameters: { nCountryId: pnCountryId },
onSuccess: function( result ){
_this.oCitySelect.innerHTML = '';
$H( result.data ).each(
function( oPair ){
var oOption = document.createElement( 'option' );
/*
* bug # 6536: 
* all values that contain a number that is greater than 0 or not -1 are 
* allowed. -1 is reserved for any non relevant option data like the
* '-----' seperator.
*/
if(parseInt(oPair.key) >= 0 || parseInt(oPair.key) != -1)
{
oOption.value = oPair.key;
}
else
{
oOption.value = ""; 
}
if(oPair.value == _this.sSelectedState)
{
oOption.selected = true;
}
oOption.appendChild( document.createTextNode( oPair.value ) );
_this.oCitySelect.appendChild( oOption );
} );
if( _this.nCityId != null ){
_this.oCitySelect.value = _this.nCityId;
}
if( _this.fPostCityAction != null ){
_this.fPostCityAction();
}
},
onError: function(result){}
} );
}
}
var dateSelectInactive = false;
var periodSelectInactive = false;
var oOldSearch = null;
function inactivateDateSelect(){
if( dateSelectInactive ) return;
$('startdate[day]').disabled = 1;
$('startdate[month]').disabled = 1;
$('startdate[year]').disabled = 1;
$('enddate[day]').disabled = 1;
$('enddate[month]').disabled = 1;
$('enddate[year]').disabled = 1;
dateSelectInactive = true;
}
function inactivatePeriodSelect(){
if( periodSelectInactive ) return;
$('period_select').disabled = 1;
periodSelectInactive = true;
}
function changeSearch(){
$('search_events').style.visibility = 'visible';
$('search_events').style.display = 'block';
$('search_result').style.visibility = 'hidden';
$('search_result').style.display = 'none';
$('event_info').style.visibility = 'hidden';
$('event_info').style.display = 'none';
}
function sortBy( psSort ){
$('sortby').value = psSort;
if( typeof document.events_form != 'undefined' ){
document.events_form.Send();
}else if( typeof documents.rs_07_events_form != 'undefined' ){
document.rs_07_events_form.Send();
}
}
function showEvent( pnEventId ){
StdAjax( '/events/' + pnEventId,
{
onSuccess: function( result ){
$('event_info').innerHTML = result.html;
if( $('search_events') != null ){
$('search_events').style.visibility = 'hidden';
$('search_events').style.display = 'none';
}
$('search_result').style.visibility = 'hidden';
$('search_result').style.display = 'none';
$('event_info').style.visibility = 'visible';
$('event_info').style.display = 'block';
if( $('search_events') == null ){
$('change_search_info').style.visibility = 'hidden';
$('change_search_info').style.display = 'none';
}else{
$('search_events').style.visibility = 'hidden';
$('search_events').style.display = 'none';
}
if( $('search_result').innerHTML == '' ){
$('back_to_search').style.visibility = 'hidden';
}
window.location.hash= '!' + $('event_hash').readAttribute('href');
}
} );
sIVWCodeEvents = typeof sIVWCodeEvents != 'undefined' ? sIVWCodeEvents : null;
oIVW = typeof oIVW != 'undefined' ? oIVW : null;
if(sIVWCodeEvents && oIVW)
{
oIVW.Change(sIVWCodeEvents,null,null,true); 
}
}
function showResult(){
if( $('search_events') != null ){
$('search_events').style.visibility = 'hidden';
$('search_events').style.display = 'none';
}
$('search_result').style.visibility = 'visible';
$('search_result').style.display = 'block';
$('event_info').style.visibility = 'hidden';
$('event_info').style.display = 'none';  
}
function checkAll( psId, pbChecked ){
var aLinks = $$('#' + psId + ' li input');
for( loop = 0 ; loop < aLinks.length ; loop++ ){
if( !pbChecked && aLinks[ loop ].value != "" ){
aLinks[ loop ].checked = false;
}else if( aLinks[ loop ].value != "" ){
aLinks[ loop ].checked = true;
}
}
}
// the validator
var SmartForm = Class.create();
SmartForm.prototype = {
oForm: null,
oCache: {},
oFormDefinitions: {},	
oErrorMessages: {},	
oElements: {},
oOnSuccess: null,
bSendByAjax: false,
initialize: function(pmForm, poOptions)
{
try
{ 
if (!pmForm || !$(pmForm) || $(pmForm).tagName.toLowerCase() != 'form')
{
throw 'not a form object';
}
if (!poOptions.definitions)
{
throw 'no form definition';
}
if (!poOptions.errors)
{
throw 'no error messages';
}
this.oForm = $(pmForm);
this.oForm.oSmartForm = this;
this.oForm.Send = function() { this.oSmartForm.Send(); }
this.oFormDefinitions = poOptions.definitions;
this.oErrorMessages = poOptions.errors;
this.bSendByAjax = poOptions.ajax ? true : false;
this.oGlobalErrorMsg = poOptions.error_msg ? $(poOptions.error_msg) : null;
if (this.oGlobalErrorMsg)
{ 
this.oGlobalErrorMsg.bAppend = poOptions.append_errors ? true : false;
this.oGlobalErrorMsg.oCurrentErrorMessages = new Array(); 
this.oGlobalErrorMsg.sAppendToken = poOptions.append_token ? poOptions.append_token : '<br />';
this.oGlobalErrorMsg.Set = function(sText)
{
if (!this.bAppend)
{
this.innerHTML = sText;
return;
}
// prevent duplicate error messages 
if (this.oCurrentErrorMessages.indexOf(sText) == -1)
{
this.oCurrentErrorMessages.push(sText); 
if (this.tagName.toLowerCase() == 'ul' || this.tagName.toLowerCase() == 'ol')
{
this.innerHTML += '<li>' + sText + '</li>';
}
else
{
this.innerHTML += sText + this.sAppendToken;
}
}
}
}
this.oResult = poOptions.result ? poOptions.result : null;
this.oData = poOptions.data ? poOptions.data : null;
this.oOnSuccess = poOptions.onSuccess ? poOptions.onSuccess : null;
this.oOnError = poOptions.onError ? poOptions.onError : null;
Event.observe(this.oForm, 'submit', function(e) 
{ 
Event.stop(e);
var oForm = $(Event.element(e));
oForm.oSmartForm._vDoSend();
return false;
});
this._vEnhance();
this._vAddFeatures();
this._vHandleResult();
this._vTrackChanges();
return this;
}
catch (e)
{
return null;
}
},
Send: function()
{
this._vDoSend();
},
_vDoSend: function()
{
if (!this.bValidate()) 
{ 
return false; 
} 
$(this.oGlobalErrorMsg).style.display = 'none';
if(typeof sWebtrekkCode != 'undefined' && typeof wt_sendinfo != 'undefined') 
{ 
// alert(sWebtrekkCode+'text.delete.klick','click'); 
wt_sendinfo(sWebtrekkCode+'text.send.klick','click');
}
if (this.bSendByAjax)
{
var oData = this.oForm.serialize(true);
var _this = this;
StdAjax(this.oForm.getAttribute('action'), 
{
parameters: oData,
onSuccess: function(oResult) 
{ 
if (_this.oOnSuccess)
{
_this.oOnSuccess(oResult);
}
},
onError: function(oResult, aErrors) 
{ 
for (var i = 0; i < _this.oForm.elements.length; i++)
{
if (_this.oForm.elements[i].vUnmark)
{
_this.oForm.elements[i].vUnmark();
}
}
$H(aErrors).each(function(oError)
{
_this._vHandleError({ oField: $(oError.key), sError: oError.value });
});
if (aErrors.ERROR_CODE && _this.oGlobalErrorMsg && _this.oErrorMessages[aErrors.ERROR_CODE])
{
_this.oGlobalErrorMsg.Set(_this.oErrorMessages[aErrors.ERROR_CODE]);
}
if(_this.oOnError){
_this.oOnError(oResult, aErrors);
}
}
});
return false;
}
this.oForm.submit();
},
_vHandleResult: function()
{
var _this = this;
if (this.oData)
{
for (var i = 0; i < this.oForm.elements.length; i++)
{
var oField = this.oForm.elements[i];
if (!oField.name || !this.oData[oField.name])
{
continue;
}
switch (oField.type)
{
case 'text':
case 'hidden':
oField.value = this.oData[oField.name];
break;
case 'checkbox':
case 'radio':
oField.checked = oField.value == this.oData[oField.name];
break;
case 'select-one':
case 'select-multiple':
$A(oField.options).each(function(oOption)
{
if (oOption.value == _this.oData[oField.name])
{
oOption.selected = true;
}
})
break;
default:
continue;
}
}
}
if (this.oResult)
{
$H(this.oResult.errors).each(function(oError)
{
_this._vHandleError({ oField: $(oError.key), sError: oError.value });
});
if (this.oResult.errors.ERROR_CODE && this.oGlobalErrorMsg && this.oErrorMessages[this.oResult.errors.ERROR_CODE])
{
this.oGlobalErrorMsg.Set(this.oErrorMessages[this.oResult.errors.ERROR_CODE]);
}
}
},
_vTrackChanges: function()
{
for (var i = 0; i < this.oForm.elements.length; i++)
{
var oField = this.oForm.elements[i];
if (!oField.name)
{
continue;
}
switch (oField.type)
{
case 'text':
oField.mOldValue = oField.value;
oField.bHasChanged = function() { return this.mOldValue != this.value; };
break;
case 'textarea':
oField.mOldValue = oField.value;
oField.bHasChanged = function() { return this.mOldValue != this.value; };
break; 
case 'checkbox':
case 'radio':
oField.mOldValue = oField.checked;
oField.bHasChanged = function() { return this.mOldValue != this.checked; };
break;
case 'select-one':
oField.mOldValue = oField.selectedIndex > 0 ? oField.options[oField.selectedIndex].value : null;
oField.bHasChanged = function() { 
if(this.selectedIndex == 0)
{
return this.mOldValue && this.mOldValue != this.options[this.selectedIndex].value ? true : false;	
}
else
{
return this.selectedIndex > 0 ? this.mOldValue != this.options[this.selectedIndex].value : false; };
}
break;
case 'select-multiple':
oField.mOldValue = new Array();
$A(oField.options).each(function(oOption) {
if (oOption.selected)
{
oField.mOldValue.push(oOption.value);
}
});
var aCurrentValues = new Array();
oField.bHasChanged = function()
{ 
$A(this.options).each(function(oOption) 
{
if (oOption.selected)
{
aCurrentValues.push(oOption.value);
}
});
return (this.mOldValue.join('') != aCurrentValues.join('')); // simple hash comparison
}
break;
default:
continue;
}
}
},
bHasChanges: function()
{
for (var i = 0; i < this.oForm.elements.length; i++)
{
var oField = this.oForm.elements[i];
if (oField.bHasChanged && oField.bHasChanged())
{
return true;
}
}
return false;
},
_vAddFeatures: function()
{
var _this = this;
$H(this.oFormDefinitions).each(function(oFD)
{
if (oFD.value.sParent)
{
var oParent = $(_this.oElements[oFD.value.sParent]);
var oChild = $(_this.oElements[oFD.key]);
oParent.oChild = oChild;
if (
(oChild.value && _this._bEmpty(oChild.value))
||
(oChild.options && oChild.options.length == 0)
)
{
oChild.disabled = true;
}
Event.observe(oParent, 'change', function(e)
{
_this._vUpdateChild(Event.element(e));
});
}
});
},
_vUpdateChild: function(poParent)
{
var _this = this;
switch (poParent.type)
{
case 'select-one':
var mValue = poParent.options[poParent.selectedIndex].value;
if (this._bEmpty(mValue))
{
$(poParent.oChild).innerHTML = '';
$(poParent.oChild).disabled = true;
return;
}
break;
default: return;
}
if (!this.oCache[poParent.name] || !this.oCache[poParent.name][mValue])
{
StdAjax(this.oForm.getAttribute('action'), 
{
parameters: { command: 'aGetChildNodes', mParentValue: mValue, sParentName: poParent.name },
onSuccess: function(oResult) 
{
if (!_this.oCache[poParent.name])
{
_this.oCache[poParent.name] = {};
}
_this.oCache[poParent.name][mValue] = oResult;
_this._vUpdateChild(poParent);
},
onError: function(oResult, aErrors) 
{ 
}
});
return;
}
this._vFillChild(poParent.oChild, this.oCache[poParent.name][mValue]);
},
_vFillChild: function(poChild, poData)
{
switch (poChild.type)
{
case 'select-one':
$(poChild).innerHTML = '';
$H(poData).each(function(oPair)
{
if (poChild.disabled)
{
poChild.disabled = false;
}
var oOpt = document.createElement('option');
oOpt.value = oPair.key;
oOpt.appendChild(document.createTextNode(oPair.value));
poChild.appendChild(oOpt);
});
break;
}
},
_vEnhance: function()
{
var _this = this;
$A(this.oForm.getElementsByTagName('label')).each(function(oLabel)
{
oLabel.style.cursor = 'pointer';
var sId = oLabel.htmlFor;
var oField = $(sId);
if (oField)
{
_this.oElements[oField.name] = oField;
if (!_this.oGlobalErrorMsg)
{
oField.oErrorMsg = $('SFError_'+oField.name);
if (!oField.oErrorMsg)
{
oField.oErrorMsg = $('SFError_'+oField.name.replace(/\[\]/, ''));
}
if (!oField.oErrorMsg)
{
oField.oErrorMsg = document.createElement('span');
oField.parentNode.insertBefore(oField.oErrorMsg, oLabel);
oField.parentNode.insertBefore(document.createTextNode(' '), oLabel);
}
oField.oErrorMsg.oField = oField;
oField.oErrorMsg.className = 'SFError';
oField.oErrorMsg.style.display = 'none';
oField.oErrorMsg.Set = function(sText)
{
this.innerHTML = sText;
this.oField.title = sText;
this.oField.oLabel.title = sText;
}
}
oField.vMark = function()
{
var _this = this;
if (this.type == 'hidden') // fckeditor-mode
{
_this = $(this.id + '___Frame');
_this.oLabel = this.oLabel;
_this.oErrorMsg = this.oErrorMsg;
}
$(_this).addClassName('error');
if (_this.oLabel)
{
$(_this.oLabel).addClassName('error');
}
if (_this.oErrorMsg)
{
$(_this.oErrorMsg).show();
}
}
oField.vUnmark = function()
{
var _this = this;
if (this.type == 'hidden')
{
_this = $(this.id + '___Frame');
_this.oLabel = this.oLabel;
_this.oErrorMsg = this.oErrorMsg;
}
$(_this).removeClassName('error');
if (_this.oLabel)
{
$(_this.oLabel).removeClassName('error');
}
if (_this.oErrorMsg)
{
$(_this.oErrorMsg).hide();
}
}
Event.observe(oField, 'focus', function(e)
{
$(Event.element(e)).addClassName('active');
if( typeof( $(Event.element(e).oLabel) ) != 'undefined' ){
$(Event.element(e).oLabel).addClassName('active');
}
});
Event.observe(oField, 'blur', function(e)
{
$(Event.element(e)).removeClassName('active');
if( typeof( $(Event.element(e).oLabel) ) != 'undefined' ){
$(Event.element(e).oLabel).removeClassName('active');
}
});
oField.oLabel = oLabel;
var oDef = _this.oFormDefinitions[oField.name];
if (!oDef)
{
oDef = _this.oFormDefinitions[(oField.name.replace(/\[\]/, ''))];
}
if (oDef && oDef.bMandatory)
{
oLabel.innerHTML += '*';
}
}
});
},
SetInstantValidation: function()
{
var _this = this;
for (var i = 0; i < this.oForm.elements.length; i++)
{
var oField = this.oForm.elements[i];
if (!oField.name || !this.oFormDefinitions[oField.name])
{
continue;
}
Event.observe(oField, 'blur', function(e)
{
_this._bValidateField(Event.element(e), _this.oFormDefinitions[Event.element(e).name]);
});
}
},
bValidate: function()
{
// clear Error Messages Array
if (this.oGlobalErrorMsg && this.oGlobalErrorMsg.oCurrentErrorMessages)
{
this.oGlobalErrorMsg.oCurrentErrorMessages.clear();
} 
if (this.oGlobalErrorMsg)
{
this.oGlobalErrorMsg.innerHTML = '';
}
// Tell tinyMCE to update content
var bCheckTinyMCE = typeof tinyMCE != 'undefined';
if (bCheckTinyMCE)
{
tinyMCE.triggerSave();
}
var bHasErrors = false;
for (var i = 0; i < this.oForm.elements.length; i++)
{
var oField = this.oForm.elements[i];
if (!oField.name)
{
continue;
}
// check if FCKEditor is present
if (typeof FCKeditorAPI != 'undefined' && FCKeditorAPI.GetInstance(oField.name))
{
FCKeditorAPI.GetInstance(oField.name).UpdateLinkedField();
}
var oDef = this.oFormDefinitions[oField.name];
if (!oDef)
{
oDef = this.oFormDefinitions[(oField.name.replace(/\[\]/, ''))];
}
if (!oDef)
{
continue;
}
if (!this._bValidateField(oField, oDef))
{
bHasErrors = true;
}
}
return !bHasErrors;
},
_bValidateField: function(poField, poFieldAttributes)
{
try
{
poField.vUnmark();
switch (poField.type)
{
case 'text':
case 'textarea':
case 'hidden':
case 'password':
var aValue = [poField.value];
break;
case 'select-one':
case 'select-multiple':
var aValue = [];
for (var i = 0; i < poField.options.length; i++)
{
if (poField.options[i].selected)
{
aValue.push
(
poField.options[i].value == '0' || poField.options[i].value == '-'
? ''
: poField.options[i].value
);
}
}
if (!aValue.length)
{
aValue.push('');
}
break;
case 'checkbox':
case 'radio':
var aValue = [];
for (var i = 0; i < this.oForm.elements.length; i++)
{
var oField = this.oForm.elements[i];
if (oField.name == poField.name && oField.checked)
{
aValue.push(oField.value);
}
}
if (!aValue.length)
{
aValue.push('');
}
break;
default:
return true;
}
for (var i = 0; i < aValue.length; i++)
{
if (poFieldAttributes.sCondition && !this._bMatchCondition(poFieldAttributes.sCondition))
{
continue;
}
var sValue = aValue[i].strip();
var bIsNumeric = poFieldAttributes.sFormat && poFieldAttributes.sFormat == 'bNumeric';
if (poFieldAttributes.bMandatory && this._bEmpty(sValue, bIsNumeric))
{  
throw 'mandatory';
}
else if (!poFieldAttributes.bMandatory && this._bEmpty(sValue, bIsNumeric))
{
continue; /* skip empty non-mandatory fields */
}
if (poFieldAttributes.sLength && !this._bLength(sValue, poFieldAttributes.sLength))
{
throw 'length';
}
if (!this._bEmpty(sValue, bIsNumeric) && poFieldAttributes.sFormat && !this[poFieldAttributes.sFormat](sValue, poField.name))
{
throw 'format';
}
}
return true;	
}
catch (e)
{
this._vHandleError({ oField: poField, sError: e.toString() });
return false;
}
},
_vHandleError: function(poError)
{
if (!poError || !poError.oField || !poError.sError)
{
return;
}
$(poError.oField).vMark();
var oFieldErrors = this.oErrorMessages[poError.oField.name];
if (!oFieldErrors)
{
oFieldErrors = this.oErrorMessages[poError.oField.name.replace(/\[\]/, '')];
}
if (oFieldErrors && oFieldErrors[poError.sError])
{
var sErrorMsg = oFieldErrors[poError.sError];
}
else if (oFieldErrors && oFieldErrors['default'])
{
var sErrorMsg = oFieldErrors['default'];
}
else if (this.oErrorMessages['_global_'])
{
var sErrorMsg = this.oErrorMessages['_global_'];
}
else
{
return;
} 
var oErrorMsg = this.oGlobalErrorMsg
? this.oGlobalErrorMsg
: $(poError.oField).oErrorMsg;
oErrorMsg.Set(sErrorMsg);
},
_sTrim: function(psValue)
{
psValue = psValue.replace(/^\s+/g, '');
psValue = psValue.replace(/\s+$/g, '');
return psValue;
},
_bLength: function(psValue, psLength)
{
psValue = this._sTrim(psValue); 
if (psLength.indexOf("-") > -1) 
{
var aLength = psLength.split("-");
var iMin = aLength[0] ? parseInt(aLength[0]) : 0;
var iMax = aLength[1] ? parseInt(aLength[1]) : 0;
if (iMax > 0 && iMax < iMin)
{
return false;
}
if (psValue.length < iMin)
{
return false;
}
if (iMax > 0 && psValue.length > iMax) 
{
return false;
}
return true;
}
if (psValue.length == psLength)
{
return true;
}
return false;	
},
_bEmpty: function(psValue, bIsNumeric)
{
if (this._sTrim(psValue).length == 0 || (!bIsNumeric && psValue == 0) || psValue == '-')
{
return true;
}
return false;
},
_bMatchCondition: function(psCondition)
{
var aTmp = psCondition.split(':');
var oCondField = $(aTmp[0]);
if (!oCondField)
{
return true;
}
switch (aTmp[1])
{
case 'checked':
return oCondField.checked;
}
return true;
},
bAlphanumeric: function(psValue)
{
return psValue.match(/^[\sa-zöäüß0-9\.\-]+$/gi) ? true : false;
},
bStreetNumber: function(psValue)
{
return psValue.match(/^[\sa-z0-9\.\-\/]+$/gi) ? true : false;
},
bStrictAlphanumeric: function(psValue)
{
return psValue.match(/^[a-z0-9]+$/gi) ? true : false;
},
bUrlCompliant: function(psValue)
{
return psValue.match(/^[a-z0-9_\-]+$/gi) ? true : false;
},
bAlphanumericNoSpaces: function(psValue)
{
return psValue.match(/^[a-zöäüß0-9\.]+$/gi) ? true : false;
},
bAlphabetical: function(psValue)
{
return psValue.match(/^[\sa-zöäüß]+$/gi) ? true : false;
},
bNumeric: function(psValue)
{
return psValue.match(/^[0-9]+$/g) ? true : false;
},
bPhone: function(psValue)
{
return psValue.match(/^[\s\+\(\)\-\/0-9]+$/g) ? true : false;
},
bEmail: function(psValue)
{
return psValue.match(/^[a-z0-9_\-\.]+@[a-z0-9_\-\.]+\.[a-z]{2,6}$/gi) ? true : false;	
},
bGermanDate: function(psValue)
{
return psValue.match(/^[0-9]{2}\.[0-9]{2}\.[0-9]{4}$/gi) ? true : false;	
},
bIsoDate: function(psValue)
{
return psValue.match(/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/gi) ? true : false;	
},
bMatchField: function(psValue, psFieldName)
{
var oFieldToMatch = this.oElements[psFieldName.replace(/_match/, '')];
return (oFieldToMatch.value == psValue);
}
}
/**
* Part of the lightbox project
* http://www.huddletogether.com/projects/lightbox2/
* Licence: http://creativecommons.org/licenses/by/2.5/
*/
// -----------------------------------------------------------------------------------
//
//	Lightbox v2.03.3
//	by Lokesh Dhakar - http://www.huddletogether.com
//	5/21/06
//
//	For more information on this script, visit:
//	http://huddletogether.com/projects/lightbox2/
//
//	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
//
//	Credit also due to those who have helped, inspired, and made their code available to the public.
//	Including: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.com), Thomas Fuchs(mir.aculo.us), and others.
//
//
// -----------------------------------------------------------------------------------
//
//	Additional methods for Element added by SU, Couloir
//	- further additions by Lokesh Dhakar (huddletogether.com)
//
Object.extend(Element, {
getWidth: function(element) {
element = $(element);
return element.offsetWidth;
},
setWidth: function(element,w) {
element = $(element);
element.style.width = w +"px";
},
setHeight: function(element,h) {
element = $(element);
element.style.height = h +"px";
},
setTop: function(element,t) {
element = $(element);
element.style.top = t +"px";
},
setLeft: function(element,l) {
element = $(element);
element.style.left = l +"px";
},
setSrc: function(element,src) {
element = $(element);
element.src = src;
},
setHref: function(element,href) {
element = $(element);
element.href = href;
},
setInnerHTML: function(element,content) {
element = $(element);
element.innerHTML = content;
}
});
// -----------------------------------------------------------------------------------
//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.com
//
function getPageScroll(){
var xScroll, yScroll;
if (self.pageYOffset) {
yScroll = self.pageYOffset;
xScroll = self.pageXOffset;
} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
yScroll = document.documentElement.scrollTop;
xScroll = document.documentElement.scrollLeft;
} else if (document.body) {// all other Explorers
yScroll = document.body.scrollTop;
xScroll = document.body.scrollLeft;
}
arrayPageScroll = new Array(xScroll,yScroll)
return arrayPageScroll;
}
// -----------------------------------------------------------------------------------
//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.com
// Edit for Firefox by pHaez
//
function getPageSize(){
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = window.innerWidth + window.scrollMaxX;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth, windowHeight;
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);
if (self.innerHeight) {	// all except Explorer
if(document.documentElement.clientWidth){
windowWidth = document.documentElement.clientWidth;
} else {
windowWidth = self.innerWidth;
}
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)
// for small pages with total width less then width of the viewport
if(xScroll < windowWidth){
pageWidth = xScroll;
} else {
pageWidth = windowWidth;
}
//	console.log("pageWidth " + pageWidth)
arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;
}
// -----------------------------------------------------------------------------------
function showSelectBoxes(doc){
var selects = doc.getElementsByTagName("select");
for (i = 0; i != selects.length; i++) {
selects[i].style.visibility = "visible";
}
}
// ---------------------------------------------------
function hideSelectBoxes(doc){
var selects = doc.getElementsByTagName("select");
for (i = 0; i != selects.length; i++) {
selects[i].style.visibility = "hidden";
}
}
// ---------------------------------------------------
function showFlash(doc){
var flashObjects = doc.getElementsByTagName("object");
for (i = 0; i < flashObjects.length; i++) {
flashObjects[i].style.visibility = "visible";
}
var flashEmbeds = doc.getElementsByTagName("embed");
for (i = 0; i < flashEmbeds.length; i++) {
flashEmbeds[i].style.visibility = "visible";
}
}
// ---------------------------------------------------
function hideFlash(doc){
var flashObjects = doc.getElementsByTagName("object");
for (i = 0; i < flashObjects.length; i++) {
flashObjects[i].style.visibility = "hidden";
}
var flashEmbeds = doc.getElementsByTagName("embed");
for (i = 0; i < flashEmbeds.length; i++) {
flashEmbeds[i].style.visibility = "hidden";
}
}
/**
* Custom code (not part of lightbox)
*/
function blurPageCheckResize() {
var arrayPageSize = getPageSize();
Element.setWidth('overlay', arrayPageSize[0]);
Element.setHeight('overlay', arrayPageSize[1]);
}
function showInputfields(doc){
var inputs = doc.getElementsByTagName("input");
for (i = 0; i != inputs.length; i++) {
inputs[i].style.visibility = "visible";
}
}
function hideInputfields(doc){
var inputs = doc.getElementsByTagName("input");
for (i = 0; i != inputs.length; i++) {
inputs[i].style.visibility = "hidden";
}
}
function hideAllForOverlay(doc) {
hideSelectBoxes(doc);
hideInputfields(doc)
hideFlash(doc);
}
function showAllForOverlay(doc) {
showSelectBoxes(doc);
showInputfields(doc)
showFlash(doc);
}
function blurPage(afterFinish) {
var arrayPageSize = getPageSize();
var objBody = document.getElementsByTagName("body").item(0);
var objOverlay = document.createElement("div");
if(!afterFinish) afterFinish = function() {};
objOverlay.setAttribute('id','overlay');
objOverlay.style.display = 'none';
objBody.appendChild(objOverlay);
hideAllForOverlay(document);
window.oldonresize = window.onresize;
window.onresize = blurPageCheckResize;
Element.setWidth('overlay', arrayPageSize[0]);
Element.setHeight('overlay', arrayPageSize[1]);
Effect.Appear('overlay', { duration: 0.5, from: 0.0, to: 0.1, afterFinish:afterFinish});
}
function focusPage() {
var objBody = document.getElementsByTagName("body").item(0);
var objOverlay = $('overlay');
window.onresize = window.oldonresize;
Effect.Fade(objOverlay, { duration: 0.5, afterFinish: function() {
if(objOverlay) {
objBody.removeChild(objOverlay);
showAllForOverlay(document);
}}}
);
}
function modalBoxShow(level,width,height) {
alert('Bitte die neue ModalBox nutzen.');
var objBody = document.getElementsByTagName('body').item(0);
var layer = document.createElement('div');
var layer_inner = document.createElement('div');
var table = document.createElement('table');
var rows = new Array();
var cells = new Array();
var smallWidths = [ 0,2,3,5,6,8 ];
var smallHeight = [ 0,1,2,6,7,8 ];
var bigWidth = [ 1,4,7 ];
var bgAppendix = [ 'tl','tc','tr','cl','','cr','bl','bc','br' ];
objBody.appendChild(layer);
layer.id = 'modalbox_'+level;
layer.className = 'modal-box';
if(width) {
layer.style.width = width;
}
layer.style.top = '100px';
// IE error
try {
layer.style.left = window.innerWidth/2-(width/2)+'px';
} catch(e) {
layer.style.left = document.documentElement.clientWidth/2-(width/2)+'px';
}
//layer.style.display = 'none';
layer_inner.className='modal-inner';
table.id = 'modalbox_table_'+level;
layer.style.zIndex = 100+level;
table.setAttribute('border', 0);
table.setAttribute('cellpadding',0);
table.setAttribute('cellspacing',0);
table.setAttribute('cellmargin', 0);
var k = 0;
for(var i=0;i<3;i++) {
rows[i] = document.createElement('tr');
for(j=0;j<3;j++) {
cells[k] = document.createElement('td');
rows[i].appendChild(cells[k]);
k++;
}
table.appendChild(rows[i]);
}
for(var i=0;i<smallWidths.length;i++) {
cells[smallWidths[i]].style.width = '10px';
}
for(var i=0;i<smallHeight.length;i++) {
cells[smallHeight[i]].style.height = '10px';
}
if(width) {
for(var i=0;i<bigWidth.length;i++) {
cells[bigWidth[i]].style.width = width+'px';
}
}
for(var i=0;i<bgAppendix.length;i++) {
if(bgAppendix[i]) {
if(bgAppendix[i].indexOf('c')==0) {
cells[i].style.background = 'url(/images/modalshadow_'+bgAppendix[i]+'.png) top left repeat-y';
} else if(bgAppendix[i].indexOf('c')==1) {
cells[i].style.background = 'url(/images/modalshadow_'+bgAppendix[i]+'.png) top left repeat-x';
} else {
cells[i].style.background = 'url(/images/modalshadow_'+bgAppendix[i]+'.png) top left no-repeat';
}
}
}
if(height) {
var heightImage = document.createElement('img');
heightImage.src = '/ADMIN/images/s.gif';
heightImage.width = 1;
heightImage.height = height;
cells[3].appendChild(heightImage);
}
cells[4].style.width = (width-10)+'px';
cells[4].style.backgroundColor = '';
cells[4].valign = 'top';
cells[4].appendChild(layer_inner);
layer.appendChild(table);
layer_inner.style.border = '';
layer.style.display = '';
layer.style.border = "2px solid blue";
table.style.border = "2px dashed red";
layer.style.height = "200px";
centerBox(layer,width);
return layer_inner;
}
function modalBoxDestroy(level) {
var box = $('modalbox_'+level);
if(box) {
box.parentNode.removeChild(box);
}
}
function centerBox(boxId,width) {
var layer = $(boxId);
layer.style.top = '100px';
try {
layer.style.left = window.innerWidth/2-(width/2)+'px';
} catch(e) {
layer.style.left = document.documentElement.clientWidth/2-(width/2)+'px';
}
}
function showDialog(sType, sTitle, sText, oOnClick)
{
alert('-y-OLD-y-');
/*
var oDialog = $('GlobalDialog');
if (!oDialog)
return;
oDialog.addClassName(sType);
var oHeader = $('GlobalDialogHeader');
var oText = $('GlobalDialogText');
var oAction = $('GlobalDialogAction');
oHeader.innerHTML = sTitle;
oText.innerHTML = sText;
if(!oOnClick) {
oOnClick = function() {
closeDialog();
}
}
oAction.onclick = oOnClick;
oDialog.show();
*/
}
function showConfirmDialog(sType, sTitle, sText, oOnYes, oOnNo, oAppendToContent)
{
alert('-x-OLD-x-');
/*
var oDialog = $('GlobalConfirmDialog');
if (!oDialog)
return;
oDialog.addClassName(sType);
var oHeader = $('GlobalConfirmDialogHeader');
var oText = $('GlobalConfirmDialogText');
var oActionYes = $('GlobalConfirmDialogActionYes');
var oActionNo = $('GlobalConfirmDialogActionNo');
oHeader.innerHTML = sTitle;
oText.innerHTML = sText;
if (oAppendToContent)
oText.appendChild(oAppendToContent);
oActionYes.onclick = oOnYes;
oActionNo.onclick = oOnNo;
oDialog.show();
*/
}
function closeDialog() { $('GlobalDialog').hide(); }
function closeConfirmDialog() { $('GlobalConfirmDialog').hide(); }
/* New modal box */
var oMBBlurLayer = null;
var iNumModalBoxes = 0;
var Modal = Class.create();
Modal.prototype = {
iLevel: 100,
iWidth: 400,
iHeight: 300,
sTitle: '',
aPageSize: null,
oFrame: null,
oRoot: null,
oCloseFunction: null,
oDOMParent: null,
oDOMNextSibling: null,
bHasTopAd: false,
fAbortAction: function(){},
initialize: function(iLevel, iWidth, iHeight, poDragHandle)
{
iNumModalBoxes++;
this.iLevel = iLevel;
this.iWidth = iWidth;
this.iHeight = iHeight;
this.oDragHandle = poDragHandle;
this.aPageSize = getPageSize();
//this.oRoot = document.getElementsByTagName('body')[0];
/*
* fix disappearing elements in IE6, see bug #6147
* add the modal box to the content container element, instead of directly 
* inserting it into the body, fix for FF2, modalbox disappearing behind the header
*/
this.oRoot = ( $('container') ) ? $('container') : document.getElementsByTagName('body')[0];
this._vConstruct();
},
vAddAbortAction: function(pfAction){
if(typeof(pfAction) == 'function'){
this.fAbortAction = pfAction;
}
},
_vBlurPage: function()
{ 
var _this = this;
// Hide select boxes 
if (IE && !IE7)
{
hideSelectBoxes(document);
showSelectBoxes(this.oFrame);
}
oMBBlurLayer = $('MBBlurLayer');
if (!oMBBlurLayer)
{
oMBBlurLayer = document.createElement('div');
oMBBlurLayer.id = 'MBBlurLayer';
oMBBlurLayer.style.display = 'none';
this.oRoot.appendChild(oMBBlurLayer);
}
oMBBlurLayer.style.width = this.aPageSize[0] + 'px';
oMBBlurLayer.style.height = this.aPageSize[1] + 'px';
Effect.Appear(oMBBlurLayer,
{
from: 0.0,
to: 0.45,
duration: 0.5,
afterFinish: function() { 
oMBBlurLayer.bBlurred = true; 
_this._vShowFrame(); 
if(typeof(XMLHttpRequest) != undefined){
oMBBlurLayer.height = document.viewport.getHeight() + 'px';
if(document.all && typeof(XMLHttpRequest) == 'undefined'){
oMBBlurLayer.style.position = 'absolute';
}
else{
oMBBlurLayer.style.position = 'fixed';
}
} 
}
});
//oMBBlurLayer.style.opacity = '0.5';
//oMBBlurLayer.style.display = '';
//oMBBlurLayer.style.filter = 'alpha(opacity=50)';
oMBBlurLayer.bBlurred = true; _this._vShowFrame();
},
_vConstruct: function()
{
var that = this;
this.oFrame = document.createElement('div');
this.oFrame.className = 'MBFrame';
// For Safari
this.oFrame.style.position = 'absolute';
this.oFrame.style.width = this.iWidth + 'px';
this.oFrame.style.height = this.iHeight ? this.iHeight + 'px' : 'auto';
this.oFrame.style.display = 'none';
this.oFrame.style.zIndex = 100 + this.iLevel;
this.oFrame.style.left = (Math.round(this.aPageSize[0] / 2) - Math.round(this.iWidth / 2)) + 'px';
var iTopPosition = Math.round(this.aPageSize[3] / 2)
- (this.iHeight ? Math.round(this.iHeight / 2) : 300)
+ getPageScroll()[1];
this.oFrame.style.top = iTopPosition < 0 ? 0 : iTopPosition + 'px';
this.oFrame.oTopAd = document.createElement('div');
this.oFrame.oTopAd.className = 'MBTopAd';
this.oFrame.appendChild(this.oFrame.oTopAd);
this.oFrame.oHeader = document.createElement('h1');
this.oFrame.oHeader.appendChild(document.createTextNode(this.sTitle));
this.oFrame.appendChild(this.oFrame.oHeader);
this.oFrame.oErrorHint = document.createElement('p');
this.oFrame.oErrorHint.className = 'MBErrorHint';
this.oFrame.oErrorHint.style.display = 'none';
this.oFrame.appendChild(this.oFrame.oErrorHint);
this.oFrame.oNotifications = document.createElement('p');
this.oFrame.oNotifications.className = 'MBNotifications';
this.oFrame.oNotifications.style.display = 'none';
this.oFrame.oNotifications.style.width = this.iWidth - 60 + 'px';
this.oFrame.appendChild(this.oFrame.oNotifications);
this.oFrame.oContent = document.createElement('div');
this.oFrame.oContent.className = 'MBContent';
this.oFrame.appendChild(this.oFrame.oContent);
this.oFrame.oFooter = document.createElement('div');
this.oFrame.oFooter.className = 'MBFooter';
this.AddButton('Abbrechen', function(e) { Event.element(e).oController.Close(); that.fAbortAction.call(); }, this, 'MBCancel');
this.oFrame.appendChild(this.oFrame.oFooter);
this.oFrame.oClose = document.createElement('a');
this.oFrame.oClose.className = 'MBClose';
this.oFrame.oClose.appendChild(document.createTextNode('Close'));
this.oFrame.oClose.oModal = this;
Event.observe(this.oFrame.oClose, 'click', function(e) { Event.element(e).oModal.Close(); });
//this.oFrame.oHeader.appendChild(this.oFrame.oClose);
this.oFrame.appendChild(this.oFrame.oClose);
if (!$('MBLoader'+this.iLevel))
{
this.oFrame.oLoader = document.createElement('img');
this.oFrame.oLoader.src = '/images/modalbox.ajax_loader.gif';
this.oFrame.oLoader.id = 'MBLoader'+this.iLevel;
this.oFrame.oLoader.style.display = 'none';
this.oFrame.appendChild(this.oFrame.oLoader);
}
this.oRoot.appendChild(this.oFrame);
// Draggable-ize our modal box
this.SetDragHandle(this.oFrame.oHeader);
},
_vShowFrame: function()
{
// disabled blinddown due to screen glitches 
/*Effect.BlindDown(this.oFrame, { duration: 0.5 });*/
$(this.oFrame).show();
},
SetDragHandle: function(poDragHandle)
{
if (this.oFrame.oDraggable)
{
this.oFrame.oDraggable.destroy();
}
this.oFrame.oDraggable = new Draggable(this.oFrame,
{ handle: poDragHandle, starteffect: null, endeffect: null }
);
$(poDragHandle).style.cursor = 'move';
},
DefineCloseFunction: function(oFunction)
{
this.oCloseFunction = oFunction;
},
ReloadOnExit: function(psUrl)
{
if (psUrl)
{
this.DefineCloseFunction(function() { window.location.href = psUrl; });
}
else
{
this.DefineCloseFunction(function() { window.location.reload(); });
}
},
MoveDOMContent: function(oDOMObject)
{
this.oDOMObject = oDOMObject;
this.oDOMParent = this.oDOMObject.parentNode;
this.oDOMNextSibling = this.oDOMObject.nextSibling;
$(this.oDOMObject).toggle(); // Switch between visible and invisible state
this.oFrame.oContent.innerHTML = '';
this.oFrame.oContent.appendChild(this.oDOMObject);
// Finishing commands to restore e.g tinyMCE functionality
if (typeof tinyMCE != 'undefined')
{
$A(this.oDOMObject.getElementsByTagName('textarea')).each(
function(oTextarea)
{
if (oTextarea.id)
tinyMCE.execCommand('mceAddControl', false, oTextarea.id);
}
);
}
},
RestoreDOMContent: function()
{
// Finishing commands to restore e.g tinyMCE functionality
if (this.oDOMObject)
{
if (typeof tinyMCE != 'undefined')
$A(this.oDOMObject.getElementsByTagName('textarea')).each(
function(oTextarea)
{
if (oTextarea.id)
tinyMCE.execCommand('mceRemoveControl', false, oTextarea.id);
}
);
// Restore original position of inserted DOM objects
if (this.oDOMNextSibling)
this.oDOMParent.insertBefore(this.oDOMObject, this.oDOMNextSibling);
else
this.oDOMParent.appendChild(this.oDOMObject);
$(this.oDOMObject).toggle();
this.oDOMObject = null;
}
},
Show: function(sTitle, mContentHTML)
{
this.HideErrorHint();
this.HideNotification();
this.SetTitle(sTitle);
this.oFrame.className = 'MBFrame';
this.RestoreDOMContent();
if (mContentHTML)
{
if (typeof mContentHTML == 'object')
this.MoveDOMContent(mContentHTML);
else
this.oFrame.oContent.innerHTML = mContentHTML;
}
else
{
this.oFrame.oContent.innerHTML = '';
}
if (!oMBBlurLayer || !oMBBlurLayer.bBlurred)
{
this._vBlurPage();
}
else
{
if (this.oFrame.style.display == 'none')
{
this._vShowFrame();
}
this.RemoveButtons();
}
this.SetFocus();
},
SetTitle: function(sTitle)
{
if (sTitle.length)
{
this.oFrame.oHeader.firstChild.nodeValue = sTitle;
$(this.oFrame.oHeader).show();
}
else
{
$(this.oFrame.oHeader).hide();
}
},
AddContent: function(mContentHTML)
{
this.HideNotification();
if (typeof mContentHTML == 'object')
this.oFrame.oContent.appendChild(mContentHTML);
else
this.oFrame.oContent.innerHTML += mContentHTML;
},
SetTopAd: function(mContentHTML)
{
if (!this.oFrame.oTopAd)
{
return;
}
if (typeof mContentHTML == 'object')
{
this.oFrame.oTopAd.innerHTML = '';
this.oFrame.oTopAd.appendChild(mContentHTML);
}
else
{
this.oFrame.oTopAd.innerHTML = mContentHTML;
}
this.bHasTopAd = true;
$(this.oFrame.oTopAd).show();
},
HideTopAd: function()
{
if (!this.oFrame.oTopAd)
{
return;
}
$(this.oFrame.oTopAd).hide();
},
ShowSuccess: function(sTitle, sContentHTML, oOnClick, iTimeout)
{
iTimeout ? this.ShowAutoClose(sTitle, sContentHTML, iTimeout) : this.Show(sTitle, sContentHTML);
$(this.oFrame).addClassName('MBFSuccess');
this.RemoveCancelButton();
oOnClick ? this.AddButton('OK', oOnClick, this) : this.AddButton('OK', this.Close, this);
},
ShowError: function(sTitle, sContentHTML, oOnClick)
{
this.Show(sTitle, sContentHTML);
$(this.oFrame).addClassName('MBFError');
this.RemoveCancelButton();
oOnClick ? this.AddButton('OK', oOnClick, this) : this.AddButton('OK', this.Close, this);
},
ShowAutoClose: function(sTitle, sContentHTML, iTimeout, oOnClick)
{
this.Show(sTitle, sContentHTML);
$(this.oFrame).addClassName('MBFSuccess');
this.RemoveCancelButton();
var _this = this;
if (oOnClick)
{
this.pe = new PeriodicalExecuter(function(oPE) { oPE.stop(); oOnClick(); }, iTimeout ? iTimeout : 3);
}
else 
{
this.pe = new PeriodicalExecuter(function(oPE) { oPE.stop(); _this.Close(); }, iTimeout ? iTimeout : 3);
}
},
ShowErrorHint: function(sContent)
{
this.oFrame.oErrorHint.innerHTML = sContent;
$(this.oFrame.oErrorHint).show();
},
HideErrorHint: function()
{
$(this.oFrame.oErrorHint).hide();
},
ShowNotification: function(sContent)
{
this.oFrame.oNotifications.innerHTML = sContent;
$(this.oFrame.oNotifications).show();
},
HideNotification: function()
{
$(this.oFrame.oNotifications).hide();
},
SetFocus: function(sField)
{
if (!sField)
{
var aFields = this.oFrame.oContent.getElementsByTagName('input');
if (!aFields[0] || !aFields[0].id)
return;
sField = aFields[0].id;
}
if (!$(sField))
return;
window.setTimeout("MBFocus('"+sField+"')", 1000);
},
Close: function(e)
{
var oController = this;
if (e && Event.element(e) && Event.element(e).oController)
var oController = Event.element(e).oController;
if (oController.oCloseFunction)
{
oController.oCloseFunction(oController);
return;
}
oController.Destroy();
},
Destroy: function(oAfterFinish, bLeaveBlurred)
{
if (this.pe)
{
this.pe.stop();
}
var _this = this;
iNumModalBoxes--;
Effect.BlindUp(_this.oFrame,
{
duration: 0.5,
afterFinish: function()
{
// restore ad tags
if (_this.bHasTopAd)
{
_this.oFrame.oTopAd.firstChild.hide();
document.body.appendChild(_this.oFrame.oTopAd.firstChild);
_this.bHasTopAd = false;
}
_this.RestoreDOMContent();
_this.oFrame.oDraggable.destroy();
_this.RemoveButtons();
_this.RemoveCancelButton();
$(_this.oFrame).remove();
if (oAfterFinish)
oAfterFinish();
if (!bLeaveBlurred && iNumModalBoxes < 1)
{
Effect.Fade(oMBBlurLayer,
{
duration: 0.5,
afterFinish: function()
{
oMBBlurLayer.bBlurred = false;
_this.oRoot.removeChild(oMBBlurLayer);
// Re-show select boxes on IE < 7.x
if (IE && !IE7)
showSelectBoxes(document);
}
});
}
}
});
},
AddButton: function(sTitle, oAction, oController, sId, sHref)
{
var oButton = document.createElement('a');
if (oController)
oButton.oController = oController;
if (sId)
{
oButton.Identifier = sId;
oButton.id = sId;
}
oButton.appendChild(document.createTextNode("» "+sTitle));
//oButton.className = 'link-button MBBtn_'+sButton;
oButton.className = 'link-button MBBtn_'+this.sGenerateClassName(sTitle);
this.oFrame.oFooter.insertBefore(oButton, this.oFrame.oFooter.lastChild);
if(sHref){
oButton.href = sHref;
}
else{
oButton.href = 'javascript:void(0)';
Event.observe(oButton, 'click', oAction);
}
},
sGenerateClassName: function(sTitle) 
{
return sTitle.replace(/\W/g, '').toLowerCase(); // no specialchars and all lowercase
},
RemoveButton: function(iButtonIdx)
{
switch (iButtonIdx)
{
case 'all':
$A(this.oFrame.oFooter.getElementsByTagName('a')).each(
function(oButton)
{
if (oButton.Identifier == 'MBCancel') return;
$(oButton).remove();
});
break;
case 'cancel':
$A(this.oFrame.oFooter.getElementsByTagName('a')).each(
function(oButton)
{
if (oButton.Identifier == 'MBCancel') $(oButton).remove();
});
break;
default:
var oButton = this.oFrame.oFooter.getElementsByTagName('a')[iButtonIdx];
if (oButton)
$(oButton).remove();
}
},
RemoveButtons: function()
{
this.RemoveButton('all');
},
RemoveCancelButton: function()
{
this.RemoveButton('cancel');
},
SetCancelButtonTitle: function(sTitle)
{
this.oFrame.oFooter.lastChild.firstChild.nodeValue = sTitle;
this.oFrame.oFooter.lastChild.className = 'link-button MBBtn_'+this.sGenerateClassName(sTitle);
}
}
function MBFocus(sField)
{
try
{
document.getElementById(sField).focus();
}
catch(e)
{}
}
var Comments = Class.create();
Comments.prototype = {
initialize: function ()
{
},
SaveMediaComment: function(iMediaId, sComment, oCallback)
{
_this = this;
StdAjax('/comments',
{
parameters: { comment: sComment, media_id: iMediaId, command: 'saveMediaComment' },
onSuccess: function(result)
{
if (typeof oCallback != 'undefined')
{
oCallback(result.comments);
}
},
onError: function(result,errors)
{
}
}
);
},
SaveEventComment: function(iEventId, sComment, oCallback)
{
_this = this;
StdAjax('/comments',
{
parameters: { comment: sComment, event_id: iEventId, command: 'saveEventComment' },
onSuccess: function(result)
{
_this.oLastComment.USERNAME = result.USERNAME;
_this.oLastComment.DATE = result.DATE;
_this.oLastComment.COMMENT = result.COMMENT;
},
onError: function(result,errors)
{
}
}
);
},
SavePageComment: function(iPageId, sComment, oCallback)
{
_this = this;
StdAjax('/__modules__/comments',
{
parameters: { comment: sComment, page_id: iPageId, command: 'savePageComment' },
onSuccess: function(result)
{
if (typeof oCallback != 'undefined')
{
oCallback(result.comments);
}
},
onError: function(result,errors)
{
}
}
);
},
SaveMPOTGComment: function(iId, sComment, oCallback)
{
_this = this;
StdAjax('/comments',
{
parameters: { comment: sComment, mpotg_id: iId, command: 'saveMPOTGComment' },
onSuccess: function(result)
{
_this.oLastComment.USERNAME = result.USERNAME;
_this.oLastComment.DATE = result.DATE;
_this.oLastComment.COMMENT = result.COMMENT;
},
onError: function(result,errors)
{
}
}
);
},
SaveFedPoiComment: function(iId, sComment, oCallback)
{
_this = this;
StdAjax('/comments',
{
parameters: { comment: sComment, fed_poi_id: iId, command: 'saveFedPoiComment' },
onSuccess: function(result)
{
if (typeof oCallback != 'undefined')
{
oCallback(result.comments);
}
},
onError: function(result,errors)
{
}
}
);
},  
SaveUserComment: function(iId, sComment, oCallback)
{
_this = this;
StdAjax('/comments',
{
parameters: { comment: sComment, user_id: iId, command: 'saveUserComment' },
onSuccess: function(result)
{
_this.oLastComment.USERNAME = result.USERNAME;
_this.oLastComment.DATE = result.DATE;
_this.oLastComment.COMMENT = result.COMMENT;
},
onError: function(result,errors)
{
}
}
);
},
RedrawTo: function(psTarget, paComments)
{
var oTarget = $(psTarget);
var oNumComments = $('nbr_'+psTarget);
if (!paComments || paComments.length == 0 || !oTarget || !oNumComments)
{
return;
}
oTarget.innerHTML = '';
$A(paComments).each(function(oC)
{
var oneComment = document.createElement('div');
var img = document.createElement('img');
img.src = oC.AUTHOR_PORTRAIT_IMAGE_SRC;
oneComment.appendChild(img);
var h = document.createElement('h3');
var sAuthorName = oC.AUTHOR_USERNAME
? oC.AUTHOR_USERNAME
: oC.AUTHOR_FIRSTNAME + ' ' + oC.AUTHOR_LASTNAME; 
h.appendChild
(
document.createTextNode(sAuthorName + ' schrieb am ' + oC.DISPLAY_DATE)
);
oneComment.appendChild(h);
var p = document.createElement('p');
p.appendChild(document.createTextNode(oC.CONTENT));
oneComment.appendChild(p);
oTarget.appendChild(oneComment);
});
$(oTarget).show();
$(oNumComments).innerHTML = paComments.length;
}
}
var oComments = new Comments();
/**
* Rating request helper class.
*/
var RatingRequest = function(oOptions){
this.oRating = {
bUserRated: null,
iAverage: 0,
iRating: 0
};
this.oDomObj = oOptions.domObj;
this.sType = oOptions.type;
this.sObjectId  = oOptions.objectId;
this.oCallBack = oOptions.oCallBack || null;
};
RatingRequest.prototype.toString = function(){
return this.sObjectId + '|' + this.sType;
}
var Rating = Class.create();
Rating.prototype = {
oModal: null,
oCallback: null,
aRatingResults: {},
aRatingReqStack: [],
initialize: function()
{
return this;
},
// add a rating request to the stack
vAddRatingRequest: function(domObj, type, objectId, oCallBack){
this.aRatingReqStack.push(new RatingRequest({
domObj: domObj,
type: type,
objectId: objectId,
oCallBack: oCallBack
}));
},
vSubmitRatingQueue: function(){
var that = this;
var sRatingIDs = this.aRatingReqStack.join(',');
var sURL = '/__modules__/rating/getMultiple/' + sRatingIDs;
StdAjax(sURL, {
onSuccess: function(result){
for(var i=0, len=that.aRatingReqStack.length, oDomObj=null, rating=null, bUserRated=false; i<len; i++){
var oRatingReq = that.aRatingReqStack[i];
if(!result[oRatingReq.sObjectId]){ continue; }
if(Object.isElement(oRatingReq.oDomObj)){
oDomObj = oRatingReq.oDomObj;
}
else{
oDomObj = $(oRatingReq.oDomObj);
}
oDomObj.innerHTML = '';
rating = result[oRatingReq.sObjectId].avg_rate;
bUserRated = result[oRatingReq.sObjectId]['user_voted'] ? result[oRatingReq.sObjectId]['user_voted'] == 1 ? true : result[oRatingReq.sObjectId]['user_voted'] : false;
oDomObj.appendChild(that._oCreateRatingBar(bUserRated, result[oRatingReq.sObjectId].average, oRatingReq.sType, oRatingReq.sObjectId));
if (oRatingReq.oCallBack)
{
oRatingReq.oCallBack(result);
}
}
that.aRatingReqStack = [];
},
onError: function(res, error){
that.aRatingReqStack = [];
}
});
},
vEmbeddRating: function(domObj, type, objectId, oCallBack) 
{
var bUserRated = false;
var bCreate = true;
var _this = this;
var oDomObj;
if(Object.isElement(domObj)){
oDomObj = domObj;
}
else{
oDomObj = $(domObj);
}
oDomObj.innerHTML = '';
StdAjax('/__modules__/rating/get/'+type+'/'+objectId,
{
onSuccess: function(result) 
{
rating = result.avg_rate;
bUserRated = result['user_voted'] ? result['user_voted'] == 1 ? true : result['user_voted'] : false;
oDomObj.appendChild(_this._oCreateRatingBar(bUserRated, result.average, type, objectId));
if (oCallBack)
{
oCallBack(result);
}
},
onError: function(result, errors) 
{
}
});
},
_oCreateRatingBar: function(user_voted, rating, type, objectId) {
var oBar = document.createElement('ul');
var _this = this;
this._vSetRating(type, objectId, rating);
oBar.className = 'star-rating';
for (var i = 1; i <= 5; i++) {
var li = document.createElement('li');
var a = document.createElement('a');
var t = document.createTextNode(String(i)+' Stern(e)');
a.href = '#';
a.title = 'Mit '+String(i)+' von 5 Sternen bewerten';
if(rating>=i) {
li.className = 'rating_on';
} else {
li.className = 'rating_off';
}
a.stars = i;
a.iId = type+'_'+objectId;
if(!user_voted) {
li.onmouseover = function() {
oRating._vHighlight(oBar,this);
};
li.onmouseout = function() {
if(rating > 0) {
// reset to initial value
rating = _this._iGetRating(type, objectId);
var nodes = oBar.childNodes;
_this._vHighlight(oBar,nodes[rating-1]);
} else { 
_this._vHighlight(oBar,0);
}
};
li.onclick = function() {
var nodes = oBar.getElementsByTagName('li');
var rating = 0;
for(var i=0;i<nodes.length;i++) {
if(nodes[i] == this) {
rating = i+1; break;
}
}
oRating.vDoRate(oBar, type, objectId, rating, function() {
var nodes = oBar.childNodes;
for(var i=0;i<nodes.length;i++) {
nodes[i].onmouseover = null;
nodes[i].onclick = null;
nodes[i].onmouseout = null;
}
});
};
} 
else
{
li.style.cursor = 'default';
a.style.cursor = 'default';
oBar.title = 'Du hast Deine Bewertung bereits abgegeben.';
if (user_voted < -1) 
{
oBar.title = 'Bewertungen sind nur nach Login möglich.';
/*var _this = this;
li.onclick = function() { _this._vShowHint(); };*/
}
else if (user_voted < 0) 
{
oBar.title = 'Eigene Inhalte können nicht bewertet werden.';
}
}
li.appendChild(a);
oBar.appendChild(li);
}
return oBar;
},
_vShowHint: function()
{
var oM = new Modal(2,400);
oM.Show('Bitte anmelden',
'Um Bewertungen abgeben zu können musst Du angemeldet sein. Falls Du noch kein Mitglied bist, kannst Du Dich <a href="/community/registrierung">hier registrieren</a>.'
);
oM.SetCancelButtonTitle('Schliessen');
},
_vSetRating: function(type, objectId, rating) {
this.aRatingResults[type+'|'+objectId] = rating;
},
_iGetRating: function(type, objectId) {
return this.aRatingResults[type+'|'+objectId];
},
_vHighlight: function(oBar, oStar) {
var nodes = oBar.getElementsByTagName('li');
var sClass = 'rating_on';
if(!oStar) sClass = 'rating_off';
for(var i=0;i<nodes.length;i++) {
nodes[i].className = sClass;
if(nodes[i] == oStar) {
sClass = 'rating_off';
}
}
},
vDoRate: function(domObj, type, object_id, rating, onFinish) {
var nodes = domObj.getElementsByTagName('li');
for(var i=0;i>=rating;i++) {
nodes[i].className = 'rating_off';
}
var _this = this;
if(typeof sWebtrekkCode != 'undefined' && typeof wt_sendinfo != 'undefined') 
{ 
// alert(sWebtrekkCode+'text.confirmChangePassword.klick','click'); 
wt_sendinfo(sWebtrekkCode+'.Bild.Rating.klick','click');
}
sIVWCode = typeof sIVWCode != 'undefined' ? sIVWCode : null;
oIVW = typeof oIVW != 'undefined' ? oIVW : null;
if(sIVWCode && oIVW)
{
oIVW.Change(sIVWCode);
}
else if(typeof IVWCODE != 'undefined' && IVWCODE && oIVW)
{
oIVW.Change(IVWCODE); 
}
StdAjax(
'/__modules__/rating/rate/'+type+'/'+object_id,
{
parameters: "rating="+rating,
onSuccess: function(result) {
_this._vShowSuccess();
},
onError: function(result, errors) {
if(errors['not_logged_in']) {
_this._vShowError('Du bist nicht eingeloggt' );
}else if(errors['already_rated']) {
_this._vShowError('Du hast bereits abgestimmt' );
} else {
_this._vShowError('Ein unbekannter Fehler ist aufgetreten' );
}
}
}
);
onFinish();
},
_vShowSuccess: function()
{
if (this.oCallback)
{
return this.oCallback('Vielen Dank! Die Bewertung wird in Kürze verzeichnet', true);
}
var oModal = new Modal(1,500);
oModal.ShowSuccess('Vielen Dank!', 'Die Bewertung wird in Kürze verzeichnet',null,2 );
},
_vShowError: function(psMessage)
{
if (this.oCallback)
{
return this.oCallback(psMessage, false);
}
var oModal = new Modal(1,500);
oModal.ShowSuccess('Fehler!', psMessage,null,2 );
}  
}
oRating = new Rating();
var Abuse = Class.create();
Abuse.prototype = {
abuse_modalbox: null,
abuse_extra_data: null,
initialize: function() {
return this;
},
show: function( psExtraData, pfAbortAction ) {
this.abuse_extra_data = psExtraData;
StdAjax(
'/__modules__/abuse',
{
onSuccess: function(result) {
abuse_modalbox = new Modal( 1, 500 );
abuse_modalbox.Show( 'Missbrauch melden', result.contents );
abuse_modalbox.AddButton('Senden', function() { abuse_send('abuse_form'); });
if(pfAbortAction){
abuse_modalbox.vAddAbortAction(pfAbortAction);
}
modalbox.DefineCloseFunction
(
function(oModal)
{
oModal.Destroy();
}
);
},
onError: function(result, errors) {
}
}
);
},
user_abuse: function( psExtraData, pnUserId ){
this.abuse_extra_data = psExtraData;
StdAjax(
'/__modules__/abuse/user_abuse',
{
parameters: 'nUserId=' + pnUserId,
onSuccess: function(result) {
abuse_modalbox = new Modal( 1, 500 );
abuse_modalbox.AddButton('Senden', function() { abuse_user_send('abuse_user_form'); });
abuse_modalbox.Show( 'User melden', result.contents );
modalbox.DefineCloseFunction
(
function(oModal)
{
oModal.Destroy();
}
);
},
onError: function(result, errors) {
}
}
);
},	
send: function(form) {
var aValue = [];
for (var i = 0; i < $(form).elements.length; i++)
{
var oField = $(form).elements[i];
if (oField.type == 'radio' && oField.checked)
{
aValue.push(oField.value);
}
}
if ($('abuse_email') && $('abuse_email').value.length == 0)
{
$('abuse_email').addClassName('error');
abuse_modalbox.ShowErrorHint( 'Bitte füllen Sie die rot markierten Felder aus.' );
return;
}
if( $('description') != null && $('sonstiges'))
{
$('description').removeClassName('error');
$('sonstiges').removeClassName('error');
if( $('description').value == '' && $('sonstiges').value == '' )
{
if( $('description').value == '' && $('sonstiges_radio').checked ){
$('sonstiges').addClassName('error');
}else $('description').addClassName('error');
abuse_modalbox.ShowErrorHint( 'Bitte füllen Sie die rot markierten Felder aus.' );
return;
}else{
abuse_modalbox.HideErrorHint();
}	  
}else{	  
if( ($('abuse_body').value == '') && (!aValue.length)){
$('abuse_body').addClassName('error');
$('category_label1').addClassName('error'); 
$('category_label2').addClassName('error');
$('category_label3').addClassName('error');
$('category_label4').addClassName('error');
abuse_modalbox.ShowErrorHint( 'Bitte füllen Sie die rot markierten Felder aus.' );
return;
}
else{
$('category_label1').removeClassName('error'); 
$('category_label2').removeClassName('error');
$('category_label3').removeClassName('error');
$('category_label4').removeClassName('error');
$('abuse_body').removeClassName('error');
abuse_modalbox.HideErrorHint();
}
if(!aValue.length)
{
$('category_label1').addClassName('error'); 
$('category_label2').addClassName('error');
$('category_label3').addClassName('error');
$('category_label4').addClassName('error');
abuse_modalbox.ShowErrorHint( 'Bitte wählen Sie eine Kategorie' );
return; 
}
else{
$('category_label1').removeClassName('error'); 
$('category_label2').removeClassName('error');
$('category_label3').removeClassName('error');
$('category_label4').removeClassName('error');
abuse_modalbox.HideErrorHint();
}
if( $('abuse_body').value == ''){
$('abuse_body').addClassName('error');
abuse_modalbox.ShowErrorHint( 'Bitte füllen Sie die rot markierten Felder aus.' );
return;
}
else{
$('abuse_body').removeClassName('error');
abuse_modalbox.HideErrorHint();
}
}
StdAjax(
'/__modules__/abuse/send',
{
parameters: AjaxFormCollect(form) + '&extra_data=' + encodeURIComponent( this.abuse_extra_data ),
onSuccess: function(result) {
abuse_modalbox.ShowSuccess('Missbrauch gemeldet', 'Meldung wurde erfolgreich verschickt.',null,2 );
},
onError: function(result, errors) {
abuse_modalbox.ShowError('Missbrauch nicht gemeldet', 'Ihre Meldung konnte nicht verschickt werden. Möglicherweise sind Sie nicht angemeldet.' );
}
}
);
}
}
var oAbuse = new Abuse();
function abuse_show( psExtraData ){
sIVWCodeFooter = typeof sIVWCodeFooter != 'undefined' ? sIVWCodeFooter : null;
oIVW = typeof oIVW != 'undefined' ? oIVW : null;
if(sIVWCodeFooter && oIVW)
{
oIVW.Change(sIVWCodeFooter,null,null,true);
}
if( $('PageUrl') ){
psExtraData += "\n\nURL: " + $('PageUrl').innerHTML;
}
var fAbortAction = function(){
if(!oIVW){
var oIVW = new IVW();
}
oIVW.Change('1mp_int');
}
oAbuse.show( psExtraData, fAbortAction );
}
function abuse_send( form ){
if(typeof sWebtrekkCodeFooter != 'undefined' && typeof sWebtrekkCodeFooter != 'undefined' && typeof wt_sendinfo != 'undefined') 
{ 
// alert(sWebtrekkCode+'.text.editMedia.klick'); 
wt_sendinfo(sWebtrekkCodeFooter+'.text.abuse_send.klick','click');
}
oAbuse.send( form );
}
function abuse_user_send( form ){
oAbuse.send( form );
}
function abuse_user_show( psExtraData, pnUserId ){
if( $('PageUrl') ){
psExtraData += "\n\nURL:" + $('PageUrl').innerHTML;
} 
oAbuse.user_abuse(psExtraData,pnUserId);
}
var Recommend = Class.create();
Recommend.prototype = {
recommend_modalbox: null,
recommend_extra_data: null,
sTemplateId: 'recommend',
// limitations and counter for adding multiple recipients
iRcpCount: 5,
iTotalRcp: 5,
iMaxRcp: 15,
initialize: function() {
return this;
},
vShowModalBox: function(poConfig){
var that = this;
var fSendFunc = poConfig.sendFunc || function(){
recommend_send('recommend_form');
};
recommend_modalbox = new Modal( 1, poConfig.width );
recommend_modalbox.AddButton('Senden', fSendFunc);
recommend_modalbox.Show( poConfig.title, poConfig.content );
recommend_modalbox.DefineCloseFunction
(
function(oModal)
{
oModal.Destroy();
}
);
},
show: function( psExtraData, psTemplateId ) {
var that = this;
this.recommend_extra_data = psExtraData;
this.sTemplateId = psTemplateId ? psTemplateId : 'recommend';
StdAjax(
'/__modules__/recommend',
{
parameters: {
sTemplateId: this.sTemplateId
},
onSuccess: function(result) {
that.vShowModalBox({title: 'Seite weiterempfehlen', content: result.contents, width: 500});
},
onError: function(result, errors) {
}
}
);
},
showCompetition: function(psExtraData, piCompetitionUser){
var that = this;
this.recommend_extra_data = psExtraData;
this.sTemplateId = 'recommend_game';
StdAjax('/__modules__/recommend/competition/' + piCompetitionUser , {
parameters: {
sTemplateId: this.sTemplateId
},
onSuccess: function(result){
that.vShowModalBox({title: 'Gewinnspiel weiterempfehlen', content: result.contents, width: 650, sendFunc: function(){
recommend_send('recommend_form', piCompetitionUser);
}});
// init event handlers for adding and removing recipient items
$('addRecipient').observe('click', function(e){
that.iTotalRcp++;
that.iRcpCount++;
/*hide the add button if we reached the limit of rcps*/
if(that.iTotalRcp >= that.iMaxRcp){ Event.element(e).hide(); }
var oRcpItem = $('rcpItem0').cloneNode(true);
// we need to remove the input values..
$(oRcpItem).getElementsBySelector('input').each(function(n){
n.value = '';
});
$(oRcpItem).addClassName('added');
oRcpItem.setAttribute('id', oRcpItem.getAttribute('id') + that.iRcpCount);
$(oRcpItem).getElementsBySelector('a.RemoveButton')[0].observe('click', function(e){
that.iTotalRcp--;
$(oRcpItem).remove();
$('addRecipient').show();
Event.stop(e);
});
$('rcpContainer').appendChild(oRcpItem);
Event.stop(e);
});
}
});
},
sendRecommendation: function(form){
if( $('rcp_Name').value == '' ){
$('rcp_Name').addClassName('error');
}else{
$('rcp_Name').removeClassName('error');
}
if( $('rcp_email').value == '' ){
$('rcp_email').addClassName('error');
}
else{
$('rcp_email').removeClassName('error');
}  
if( $('sender_Name').value == '' ){
$('sender_Name').addClassName('error');
}else{
$('sender_Name').removeClassName('error');
} 
if( $('sender_email').value == '' ){
$('sender_email').addClassName('error');
}else{
$('sender_email').removeClassName('error');
}    
if($('recommend_privacy').checked == false){
$('recommend_privacy_label').addClassName('error');
}
else {
$('recommend_privacy_label').removeClassName('error');
}
if($('rcp_msg').value == '' || $('rcp_Name').value == '' || $('rcp_email').value == '' || $('sender_Name').value == '' || $('sender_email').value == '')
{
recommend_modalbox.ShowErrorHint( 'Bitte fülle die rot markierten Felder aus.' );
return;
}
// remove whitespaces
var rcp_email = $('rcp_email').value.replace(' ',''); 
// split email string
var aRcp_email = rcp_email.split(","); 
// trim name string an split it
var rcp_name = $('rcp_Name').value.replace(/^\s+/, '').replace(/\s+/, '');
var aName = rcp_name.split(",");
// check if recipient names = recipient email amount
if(aRcp_email.length != aName.length)
{
$('rcp_Name').addClassName('error'); 
$('rcp_email').addClassName('error');
recommend_modalbox.ShowErrorHint( 'Bitte geben Sie für jeden Empfänger eine E-mail Adresse sowie einen Namen an' );
return; 
}
for(var i = 0; i<aRcp_email.length; i++)
{
// trim string 
var rcp_emailvalue = aRcp_email[i].replace(/^\s+/, '').replace(/\s+$/, '');
var rcp_email_val = rcp_emailvalue.match(/^[a-z0-9_\-\.]+@[a-z0-9_\-\.]+\.[a-z\,]{2,6}$/gi) ? true : false;
if(rcp_email_val == false)
{
$('rcp_email').addClassName('error');
recommend_modalbox.ShowErrorHint( 'Bitte überprüfen Sie die Emailadresse' );
return;
}
}
var send_email = $('sender_email').value; 
var send_email_val = send_email.match(/^[a-z0-9_\-\.]+@[a-z0-9_\-\.]+\.[a-z]{2,6}$/gi) ? true : false;  
if(send_email_val == false)
{
$('sender_email').addClassName('error');
recommend_modalbox.ShowErrorHint( 'Bitte überprüfen Sie die Emailadresse' );
return;
}
if($('recommend_privacy').checked === false)
{
$('recommend_privacy').addClassName('error');
recommend_modalbox.ShowErrorHint( 'Bitte akzeptieren Sie die Datenschutzbestimmungen' );
return;
}
/* 
if($('rcp_msg').value.length > 250)
{
$('rcp_msg').addClassName('error');
recommend_modalbox.ShowErrorHint( 'Bitte geben Sie nicht mehr als 250 Zeichen ein.' );
return;
}
*/ 
StdAjax(
'/__modules__/recommend/send',
{
parameters: AjaxFormCollect(form) + '&sTemplateId=' + this.sTemplateId + '&extra_data=' + encodeURIComponent( this.recommend_extra_data ),
onSuccess: function(result) {
recommend_modalbox.ShowSuccess('Weiterempfehlung', 'Weiterempfehlung wurde erfolgreich verschickt.', null, 2 );
//recommend_modalbox.ShowNotification ('Weiterempfehlung wurde erfolgreich verschickt');
},
onError: function(result, errors) {
recommend_modalbox.ShowError('Weiterempfehlung', 'Ihre Weiterempfehlung konnte nicht verschickt werden. Überprüfen Sie die Sender und Empfänger Emailadressen.' );
//recommend_modalbox.ShowNotification ('Ihre Weiterempfehlung konnte nicht verschickt werden. Überprüfen Sie die Sender und Empfänger Emailadressen.');
}
}
);
},
send: function(form, piCompetitionUser) {
var bIsValid = true, aRcpNames = {}, sSenderEmail = $('sender_email').value.toLowerCase();
if( $('rcp_msg').value == '' ){
$('rcp_msg').addClassName('error');
}else{
$('rcp_msg').removeClassName('error');
}
if(!$('rcpContainer')){
return this.sendRecommendation(form);
}
$('rcpContainer').getElementsBySelector('div.rcp-row').each(function(n){
if(!bIsValid){return;}
var oInputs = {empty:[], set:[]};
$(n).getElementsBySelector('input').each(function(oInput){
if(oInput.value == ''){
oInputs['empty'].push(oInput);
}
else if(oInput.value != ''){
oInputs['set'].push(oInput);
}
if(oInputs['empty'].length == oInputs['set'].length){
oInputs['empty'][0].addClassName('error');
bIsValid = false;
recommend_modalbox.ShowErrorHint( 'Bitte überprüfen Sie die' + (oInputs['empty'][0].id == 'rcp_email' ? ' Emailadresse' : ' Eingaben'));
return;
}
else {
for(var sName in oInputs){
$(oInputs[sName]).each(function(i){
var oInput = $(i);
if(oInput.hasClassName('error')){
oInput.removeClassName('error');
}
});
}
}
//check the rcp email
if(oInput.getAttribute('id') == 'rcp_email' && oInput.value != ''){
var rcp_emailvalue = oInput.value.replace(/^\s+/, '').replace(/\s+$/, '');
var rcp_email_val = rcp_emailvalue.match(/^[a-z0-9_\-\.]+@[a-z0-9_\-\.]+\.[a-z\,]{2,6}$/gi) ? true : false;
if(rcp_email_val == false || aRcpNames[oInput.value.toLowerCase()] || rcp_emailvalue.toLowerCase() == sSenderEmail)
{
oInput.addClassName('error');
bIsValid = false;
recommend_modalbox.ShowErrorHint( 'Bitte überprüfen Sie die Emailadresse' );
return;
}
aRcpNames[oInput.value.toLowerCase()] = 1;
}
});
if(!bIsValid){return;}
});
// we need to check if the form is still valid, because we cant exit the send method through the traversing closure.
if(!bIsValid){ return; }
if( $('sender_Name').value == '' ){
$('sender_Name').addClassName('error');
}else{
$('sender_Name').removeClassName('error');
} 
if( $('sender_email').value == '' ){
$('sender_email').addClassName('error');
}else{
$('sender_email').removeClassName('error');
}    
if($('rcp_msg').value == '' || $('rcp_Name').value == '' || $('rcp_email').value == '' || $('sender_Name').value == '' || $('sender_email').value == '')
{
recommend_modalbox.ShowErrorHint( 'Bitte fülle die rot markierten Felder aus.' );
return;
}
var send_email = $('sender_email').value; 
var send_email_val = send_email.match(/^[a-z0-9_\-\.]+@[a-z0-9_\-\.]+\.[a-z]{2,6}$/gi) ? true : false;  
if(send_email_val == false)
{
$('sender_email').addClassName('error');
recommend_modalbox.ShowErrorHint( 'Bitte überprüfen Sie die Emailadresse' );
return;
}
if($('recommend_privacy').checked === false)
{
$('recommend_privacy').addClassName('error');
recommend_modalbox.ShowErrorHint( 'Bitte akzeptieren Sie die Datenschutzbestimmungen' );
return;
}
var sURL = piCompetitionUser ? '/__modules__/recommend/sendcompetition/' + piCompetitionUser : '/__modules__/recommend/send' ;
StdAjax(
sURL,
{
parameters: AjaxFormCollect(form) + '&sTemplateId=' + this.sTemplateId + '&extra_data=' + encodeURIComponent( this.recommend_extra_data ),
onSuccess: function(result) {
recommend_modalbox.ShowSuccess('Weiterempfehlung', 'Weiterempfehlung wurde erfolgreich verschickt.', null, 2 );
//recommend_modalbox.ShowNotification ('Weiterempfehlung wurde erfolgreich verschickt');
},
onError: function(result, errors) {
recommend_modalbox.ShowError('Weiterempfehlung', 'Ihre Weiterempfehlung konnte nicht verschickt werden. Überprüfen Sie die Sender und Empfänger Emailadressen.' );
//recommend_modalbox.ShowNotification ('Ihre Weiterempfehlung konnte nicht verschickt werden. Überprüfen Sie die Sender und Empfänger Emailadressen.');
}
}
);
}
}
var oRecommend = new Recommend();
function recommend_show( psExtraData, psTemplateId, piCompetitionUser )
{
var sExtraData = psExtraData || '';
sIVWCodeFooter = typeof sIVWCodeFooter != 'undefined' ? sIVWCodeFooter : null;
oIVW = typeof oIVW != 'undefined' ? oIVW : null;
if(sIVWCodeFooter && oIVW)
{
oIVW.Change(sIVWCodeFooter,null,null,true);
}
if ($('PageUrl'))
{
sExtraData += "link=" + $('PageUrl').innerHTML + "|";
}
switch(psTemplateId){
case 'recommend_game':
var iCompetitionUser = piCompetitionUser || 0;
oRecommend.showCompetition(sExtraData, iCompetitionUser);
break;
default: 
oRecommend.show(sExtraData, psTemplateId);
break;
}
}
function recommend_send( form, piCompetitionUser ){
if(typeof sWebtrekkCodeFooter != 'undefined' && typeof sWebtrekkCodeFooter != 'undefined' && typeof wt_sendinfo != 'undefined') 
{ 
// alert(sWebtrekkCode+'.text.editMedia.klick'); 
wt_sendinfo(sWebtrekkCodeFooter+'.text.recommend_send.klick','click');
}
if(piCompetitionUser){
oRecommend.send(form, piCompetitionUser);
}
else {
oRecommend.send( form );
}
}
var Visitors = Class.create();
Visitors.prototype = {
visitors_modalbox: null,
sTemplateId: 'all_visitors',
initialize: function() {
return this;
},
show: function(psTemplateId ) {
this.sTemplateId = psTemplateId ? psTemplateId : 'all_visitors';
StdAjax(
'/__modules__/visitors',
{
onSuccess: function(result) {
visitors_modalbox = new Modal( 1, 500 );
visitors_modalbox.RemoveCancelButton();
visitors_modalbox.AddButton('Schliessen', visitors_modalbox.Close, visitors_modalbox);
visitors_modalbox.Show( 'Alle Besucher meines Profils', result.contents );
modalbox.DefineCloseFunction
(
function(oModal)
{
oModal.Destroy();
}
);
},
onError: function(result, errors) {
}
}
);
}
}
var oVisitors = new Visitors();
function visitors_show(psTemplateId )
{  
sIVWCode = typeof sIVWCode != 'undefined' ? sIVWCode : null;
oIVW = typeof oIVW != 'undefined' ? oIVW : null;
if(sIVWCode && oIVW)
{
oIVW.Change(sIVWCode);
}
else if(typeof IVWCODE != 'undefined' && IVWCODE && oIVW)
{
oIVW.Change(IVWCODE); 
}
oVisitors.show(psTemplateId);
}
function search_doCheck( psSearchPhrase, psDefaultText, poSearchError ){
if( psSearchPhrase.length < 3 ){
poSearchError.innerHTML = '<b>Bitte mindestens 3 Zeichen eingeben</b>'
return false;
}
if( psSearchPhrase == psDefaultText ){
poSearchError.innerHTML = '<b>Bitte einen Suchbegriff eingeben</b>'
return false;
}
}
Event.observe(window, 'load', function(){
new Ajax.Autocompleter('query', 'autocompleteLayer', '/__modules__/search/ac/', {
paramName: 'searchTerm', 
parameters: 'command=autocomplete',
minChars: 3,
indicator: 'autocompleteSwirl'
});
});
var FriendsClass = Class.create();
FriendsClass.prototype = {
oModal: null,
oModal2: null,
User: null,
incr: 0,
FilterAssociations: null,
initialize: function() {
this.FilterAssociations = new Array();
return this;
},
Open: function(user) {
var _this = this;
StdAjax(
'/__modules__/friends/apply/'+user,
{
onSuccess: function(result) 
{
if(sIVWCode && oIVW)
{
oIVW.Change(sIVWCode);
}
else if(typeof IVWCODE != 'undefined' && IVWCODE)
{
oIVW.Change(IVWCODE); 
}
_this.oModal = new Modal(1, 500);
if (result.status == false) 
{
_this.oModal.AddButton
(
'Schließen',
function() { _this.oModal.Close(); }
);
_this.oModal.ShowError('Einladung fehlgeschlagen', 'Deine Einladung an <strong>'+result.displayname+'</strong> kann nicht verschickt werden. <br><br> Der Grund lautet: '+result.reason, function () {location.reload(true) } );
} 
else 
{
_this.oModal.AddButton(
'Senden',
function() { Friends.Send(user); }
);
_this.oModal.Show('Kontaktanfrage', result.contents);	
if ($('ff_description') && $('ff_num_chars'))
{
$('ff_description').counter = $('ff_num_chars');
$('ff_description').counter.maxChars = parseInt($('ff_description').counter.firstChild.nodeValue);
Event.observe($('ff_description'), 'keyup', 
function(e)
{
var t = Event.element(e);
var n = t.counter.maxChars - t.value.length;
if (n <= 0)
{
t.value = t.value.substr(0, t.counter.maxChars);
t.counter.firstChild.nodeValue = '0';
return;
}
t.counter.firstChild.nodeValue = n;
}
);
}
}
},
onError: function(result, errors) 
{
alert('error');
}
}
);
},
Revoke: function(user) {
var _this = this;
StdAjax(
'/__modules__/friends/revoke/'+user,
{
onSuccess: function(result) {
var oModal = new Modal(1,500);
oModal.ReloadOnExit();
oModal.ShowSuccess('Anfrage entfernt', 'Die Anfrage wurde gelöscht',null,2 );
},
onError: function(result, errors) {
alert('error');
}
}
);
},
Accept: function(user) {
var _this = this;
StdAjax(
'/__modules__/friends/accept/'+user,
{
onSuccess: function(result) {
var oModal = new Modal(1,500);
oModal.ReloadOnExit();
oModal.ShowSuccess('Anfrage angenommen', 'Die Anfrage wurde angenommen', null, 2 );	  			
//location.reload(true);                   // would reopen the friend request
//window.location.href = location.pathname;  // instead we only want to show the inbox
},
onError: function(result, errors) {
alert('error');
}
}
);
},
Remove: function(user, displayname) {
var _this = this;
var oModal = new Modal(1,500);
oModal.Show('Kontakt entfernen', 'Soll <strong>'+displayname+'</strong> wirklich von Deiner Kontaktliste entfernt werden?');
oModal.AddButton('OK', function(e)
{
if(typeof sWebtrekkCode != 'undefined' && typeof wt_sendinfo != 'undefined') 
{ 
// alert(sWebtrekkCode+'text.delete.klick','click'); 
wt_sendinfo(sWebtrekkCode+'text.delete.klick','click');
}
StdAjax(
'/__modules__/friends/remove/'+user,
{
onSuccess: function(result) {
oModal.ReloadOnExit();
oModal.ShowSuccess('Kontakt entfernt', 'Der Kontakt wurde erfolgreich entfernt.', null, 2);
},
onError: function(result, errors) {
alert('error');
}
}
);
});
},
Reject: function(user) {
var _this = this;
StdAjax(
'/__modules__/friends/reject/'+user,
{
onSuccess: function(result) {
var oModal = new Modal(1,500);
oModal.ReloadOnExit();
oModal.ShowSuccess('Anfrage abgelehnt', 'Die Anfrage wurde abgelehnt', null, 2 );
},
onError: function(result, errors) {
alert('error');
}
}
);
},
Renew: function(user) {
var _this = this;
StdAjax(
'/__modules__/friends/renew/'+user,
{
onSuccess: function(result) {
var oModal = new Modal(1,500);
oModal.ReloadOnExit();
oModal.ShowSuccess('Anfrage wiederhergestellt', 'Die Anfrage wurde wiederhergestellt und kann nun angenommen werden', null, 2 );
},
onError: function(result, errors) {
alert('error');
}
}
);
},
Decline: function(user) {
var _this = this;
StdAjax(
'/__modules__/friends/decline/'+user,
{
onSuccess: function(result) {
var oModal = new Modal(1,500);
oModal.ReloadOnExit();
oModal.ShowSuccess('Anfrage entfernt', 'Die Anfrage wurde erflogreich von der Liste entfernt', null, 2 );
},
onError: function(result, errors) {
alert('error');
}
}
);
},
Close: function() {
this.oModal.Close();
},
Send: function(user) {
var sParam = AjaxFormCollect('friends_form');
var _this = this;
if ($F('ff_description').length == 0)
{
_this.oModal.ShowErrorHint('Bitte gib einen Grund für Deine Kontaktanfrage an.');
}
else
{
StdAjax(
'/__modules__/friends/send/'+user,
{
parameters: sParam,
onSuccess: function(result) {
if (result.invited == false) {
_this.oModal.ShowError('Einladung fehlgeschlagen', 'Deine Einladung an <strong>'+result.displayname+'</strong> konnte nicht verschickt werden. <br><br> Der Grund lautet: '+result.reason, function () {location.reload(true) } );
}
else {
if(typeof sWebtrekkCode != 'undefined' && typeof wt_sendinfo != 'undefined') 
{ 
// alert(sWebtrekkCode+'text.invite.klick','click'); 
wt_sendinfo(sWebtrekkCode+'text.invite.klick','click');
}
_this.oModal.ShowSuccess('Einladung versendet!', 'Deine Einladung wurde erfolgreich an <strong>'+result.displayname+'</strong> verschickt.', function () {location.reload(true) }, 2);
}
},
onError: function(result, errors) {
}
}
);
}
},
Invite: function(paAssociations, noIvw)
{   
noIvw = typeof noIvw != 'undefined' ? noIvw : false;    
sIVWCode = typeof sIVWCode != 'undefined' ? sIVWCode : null;
oIVW = typeof oIVW != 'undefined' ? oIVW : null;
if(sIVWCode && oIVW && noIvw == false)
{
oIVW.Change(sIVWCode);
}
else if(typeof IVWCODE != 'undefined' && IVWCODE && noIvw == false)
{ 
oIVW.Change(IVWCODE); 
}
StdAjax('/__modules__/friends/invitemsg',
{
onSuccess: (function(result) 
{
var _this = this;
this.incr = 0;
this.oModal = new Modal(1,550);
this.oModal.Show('Freunde einladen', result.contents);
this.oModal.AddButton('senden', function() { _this._vSendInvitation(); });
}).bind(this),
onError: function(result, errors) 
{
}
});  
},
AddRecipient: function (iMax)
{
this.incr++;
//clone both p-tags within $Recipient
var rcpNameClone = $('Recipient').appendChild($('Recipient').select('.rcpName')[0].cloneNode(true));
var rcpEmailClone = $('Recipient').appendChild($('Recipient').select('.rcpEmail')[0].cloneNode(true));
//empty values
rcpNameClone.down().next().value = '';
rcpEmailClone.down().next().value = '';
//increment Ids and all
rcpNameClone.id = 'rcpName_'+this.incr;
rcpNameClone.down().htmlFor = 'rcp_name_'+this.incr;  //label name for-attr
rcpNameClone.down().next().id = 'rcp_name_'+this.incr; //input name id-attr
rcpNameClone.down().next().name = 'aRecipients['+this.incr+'][name]'; //input name name-attr
rcpEmailClone.id = 'rcpEmail_'+this.incr;
rcpEmailClone.down().htmlFor = 'rcp_email_'+this.incr; //label email for-attr
rcpEmailClone.down().next().id = 'rcp_email_'+this.incr; //input email id-attr
rcpEmailClone.down().next().name = 'aRecipients['+this.incr+'][email]'; //input email name-attr
if (this.incr >= iMax-1){
$('AddRecipientLink').style.display = 'none';
}
},
InviteAddressBook: function(paAssociationData, oCallback){
StdAjax(
'/__modules__/friends/addressbook',
{
onSuccess: (function(result) {    
aAddressBookAssociations = paAssociationData.clone();
this.oModal2 = new Modal(1,500);
this.oModal2.Show(
'Addressbuch', result.contents);
if ($('AssociationsTree') && Treepicker)
{
Object.extend($('AssociationsTree'), Treepicker);
$('AssociationsTree').initialize('/messages');
}
redrawTo( 'to_list', true );
var _this = this;
this.oModal2.AddButton('Empfänger übernehmen', function() { 
_this.oModal2.Destroy();
oCallback( aAddressBookAssociations.clone() );
});	
}).bind(this),
onError: function(result, errors) {
}
}
);  
},
_vSendInvitation: function()
{
var bError = false;
if ($('rcp_email_0').value.length == 0) {
bError = true;
$('rcp_email_0').addClassName('error');
} 
else if ($('rcp_email_0').hasClassName('error')) {
$('rcp_email_0').removeClassName('error');
}
if ($('rcp_name_0').value.length == 0) {
bError = true;
$('rcp_name_0').addClassName('error');
} 
else if ($('rcp_name_0').hasClassName('error')) {
$('rcp_name_0').removeClassName('error');
}
if ($('rcp_msg').value.length == 0) {
bError = true;
$('rcp_msg').addClassName('error');
}
else if ($('rcp_msg').hasClassName('error')) {
$('rcp_msg').removeClassName('error');
}
if (!$('privacy').checked) {
bError = true;
$('privacy_label').addClassName('error');
}
else if ($('privacy_label').hasClassName('error')) {
$('privacy_label').removeClassName('error');
}
if (bError) {
this.oModal.ShowErrorHint('Bitte fülle alle rot markierten Felder aus');
return;
}
var _this = this;
var params = AjaxFormCollect('InviteFriends');
if(typeof sWebtrekkCode != 'undefined' && typeof wt_sendinfo != 'undefined') 
{ 
// alert(sWebtrekkCode+'text.invitation.klick','click'); 
wt_sendinfo(sWebtrekkCode+'text.invitation.klick','click');
}
StdAjax('/__modules__/friends/invite',
{
parameters: params,
onSuccess: function() { _this.oModal.ShowSuccess('Einladung versendet', 'Deine Einladung wurde versendet.', null , 2); },
onError: function(oRequest, aErrors)
{ 
$A(aErrors).each(function(e)
{
alert(e);
switch (e)
{
case 'INVALID_EMAIL':
$A($('InviteFriends').select('.IFRecipient')).invoke('addClassName', 'error');
alert('yo2');
_this.oModal.ShowErrorHint('Bitte achte auf gültige E-Mail-Adressen in deiner Eingabe.');
break;
case 'REGISTERED_EMAIL':
$A($('InviteFriends').select('.IFRecipient')).invoke('addClassName', 'error');
_this.oModal.ShowErrorHint('Es wurde eine E-Mail-Adresse eingegeben welche schon für einen Benutzer registriert ist.');
break;
case 'TOO_MANY_RECIPIENTS':
_this.oModal.ShowErrorHint('Es wurden mehr als die maximal erlaubten E-Mail-Adressen angegeben.');
break;              
default:
_this.oModal.ShowErrorHint('Bitte fülle alle rot markierten Felder aus');
}
});
}
});
},
vOpenFilter: function() {
var _this = this;
oMessages.addressbook( new Array(), _this.FilterAssociations,
function(paUserData, paAssociationsData) {
_this.FilterAssociations = paAssociationsData;
var assocs = new Array();
$('AssociationFilter').innerHTML = '';
for(var i=0;i<_this.FilterAssociations.length;i++) {
var assoc = _this.FilterAssociations[i];
assocs.push(assoc.name);
$('AssociationFilter').innerHTML = assocs.join(', ');
}
_this.vSetFilter();
},false,true,1,this.User
);
return;
},
vSetFilter: function() {
var sPath = '/profile/'+this.User+'/__modules__/friends/setfilter';
var assocs = '';
for(i=0;i<this.FilterAssociations.length;i++) {
assocs += '&assoc[]='+this.FilterAssociations[i].id;
}
StdAjax(
sPath,
{
parameters: '1=1'+assocs,
onSuccess: function(res) {
location.reload(true);
},
onError: function(res,err) {
}
}
);
}
}
Friends = new FriendsClass();
/**
address book
**/
function invite_show_address_book() {
Friends.InviteAddressBook( aAddressBookAssociations, function( paAssociationsList ){ aAssociations = paAssociationsList; redrawTo( 'to_list_invite' ); });
}
function onlinegames_reload( psKey1, psKey2, psKey3, psKey4 ){
if (!psKey1 && !psKey2 && !psKey3 && !psKey4) // check if we have destination country and city
{
return;
}
var sKeys  = '+'+psKey1+'+'+psKey2+'+'+psKey3+'+'+psKey4+'+'; 
vUpdateAds(sKeys);
//ReloadBoxes(psKey1+','+psKey3);
return;
}

