var openPopupId='';
var transBgId='trans_background';
var popupContainerId='se_cal';
var popupContentId='se_content';
var jsonData=Array();
var htmlTemplate=Array();
var constVars=Array();
var preloadConstants=Array('thumbmaxw','thumbmaxh','galmaxw','galmaxh','transBgZindex','counterValue');
var movePicGal=false;
var picGalStep=5;
var picGalWidth=-1;
var picgalObjects=Array();
var picgalObjectCnt=0;
var picgalContainerId=popupContainerId;
var picgalContentId=popupContentId;
var picMemo=Array();
var counterStart=undefined;
var counterObj=undefined;
window.addEvent('domready', function(){
if(document.id('trans_background')){
document.id('trans_background').addEvent('click',function(e){
closePopup();
});
}
if(Hyphenator!=undefined){
Hyphenator.run();
}
$$('.hide').fade('hide').removeClass('hide');
getConstants(preloadConstants);
loadHtmlTemplates();
if(document.id('book_date')){
new Calendar({book_date: 'd.m.Y'},{blocked: blockedDates, direction: saisonStartOffset,offset: 1,days: dayNames, months: monthNames
,onHideComplete: function(){
if(document.id('book_date').value!=''){
loadBahnen(document.id('book_date').value);
}
}});
}
if(document.id('von')){
new Calendar({von: 'd.m.Y'},{ direction:0.5, offset: 1, days: dayNames, months: monthNames});
}
if(document.id('bis')){
new Calendar({bis: 'd.m.Y'},{ direction:0.5, offset: 1, days: dayNames, months: monthNames});
}
$$('.showAgb').each(function(item){
item.addEvent('click',function(){
showMedia('agb');
});
});
setFormFunctions();
displayCounter();
initToolTips();
initWkorbFunctions();
loadWebcams();
});
function loadWebcams(){
$$('.webcamThumb').each(function(item){
var a=new Request.JSON({url: '/se-bin/localperl.pl',onComplete:function(response){
if(response.status=='OK'){
if(item.src!=response.pic){
item.src=response.pic;
}
if(response.target=='blank'){
item.addEvent('click',function(){
window.open(response.link);
});
}else if(response.target=='inline'){
item.addEvent('click',function(){
showMedia('webcam',{link: response.link});
});
}
}else{
alert(response.status);
}
}}).send('script=cam.pl&camId='+item.title);
});
}
function initToolTips(){
$$('.tooltip').each(function(element,index) {
if(element.title){
var content = element.get('title').split('::');
element.store('tip:title', content[0]);
element.store('tip:text', content[1]);
}
});
//create the tooltips
var tipz = new Tips('.tooltip',{
hideDelay: 50,
showDelay: 50
});
}
function initWkorbFunctions(){
$$('.quantity').each(function(item){
item.addEvent('change',function(){
var doRequest=true;
if(!isNaN(item.value.toInt())){
var a=new Request.JSON({url:'/scripts/ajax.php',onComplete: function(response){
if(response.status=='OK'){
updateWkorbDisplay(response);
}else{
alert(response.status);
}
}});
if(item.id.contains('zp')){
a.send('fn=changeQuantity&id='+item.title+'&quantity='+item.value.toInt());
}else{
a.send('fn=wkorb&action=update&dsId='+item.title+'&anzahl='+item.value.toInt());
}
}else{
alert(langTexts.NaNText);
}
});
});
$$('.price').each(function(item){
item.addEvent('change',function(){
var doRequest=true;
if(!isNaN(item.value.toInt())){
var a=new Request.JSON({url:'/scripts/ajax.php',onComplete: function(response){
if(response.status=='OK'){
updateWkorbDisplay(response);
}else{
alert(response.status);
}
}});
var postype='b';
if(item.id.contains('price_zp_')){
postype='zp';
}else if(item.id.contains('price_p_')){
postype='p';
}
a.send('fn=changePrice&id='+item.title+'&price='+item.value.toFloat()+'&postype='+postype);
}else{
alert(langTexts.NaNText);
}
});
});
}
function setFormFunctions(){
if(document.id('form_contact')){
document.id('form_contact').addEvent('submit', function(e){
if(e){ e.stop(); }
if(checkFormular('form_contact','error_contact')){
this.submit();
}else{
return false;
}
});
}
if(document.id('form_register')){
document.id('form_register').addEvent('submit', function(e){
if(e){ e.stop(); }
if(checkFormular('form_register','error_register')){
if(document.id('password').value != document.id('password2').value){
document.id('error_register').set('html','' + langTexts.passwordWrong + '
');
document.id('password').focus();
return false;
}
this.set('send',{onComplete: function(response){
var formResponse=JSON.decode(response);
if(formResponse.status=='OK'){
if(formResponse.saveAction=='replaceForm'){
document.id('registerBlock').set('html',formResponse.codeForm);
setFormFunctions();
}else{
document.id('info_register').set('html',formResponse.codeForm);
}
}else if(formResponse.status=='EXISTS'){
alert(formResponse.codeForm);
top.location.href='/wkorb.html';
}else{
alert(formResponse.status);
}
}});
this.send();
}else{
return false;
}
});
}
if(document.id('form_registercode')){
document.id('form_registercode').addEvent('submit', function(e){
if(e){ e.stop(); }
if(checkFormular('form_registercode','error_registercode')){
this.set('send',{onComplete: function(response){
var formResponse=JSON.decode(response);
if(formResponse.status=='OK'){
location.href='/wkorb.html';
}else{
document.id('error_registercode').set('html',formResponse.status);
//alert(formResponse.status);
}
}});
this.send();
}else{
return false;
}
});
}
if(document.id('form_paymentselect')){
document.id('form_paymentselect').addEvent('submit', function(e){
if(e){ e.stop(); }
if(checkFormular('form_paymentselect','error_paymentselect')){
this.set('send',{onComplete: function(response){
var formResponse=JSON.decode(response);
if(formResponse.status=='OK'){
location.href='/wkorb.html';
}else{
alert(formResponse.status);
}
}});
this.send();
}else{
return false;
}
});
}
if(document.id('form_review')){
document.id('form_review').addEvent('submit', function(e){
if(e){ e.stop(); }
if(checkFormular('form_review','error_review')){
if(document.id('trans_background').style.visibility=='hidden'){
document.id('trans_background').fade(0,0.6);
}
openPopupId=popupContainerId;
document.id(popupContainerId).position({
position: 'centerTop',
offset: {x:-300,y: 150}
});
document.id(popupContentId).innerHTML=htmlTemplate['qenta'];
if(document.id(popupContainerId).style.visibility=='hidden'){
document.id(popupContainerId).fade(0,1);
}
this.submit();
}else{
return false;
}
});
}
}
function loadHtmlTemplates(){
var a=new Request({ method: 'post',url: '/scripts/ajax.php', onComplete: function(response){
var jsonResponse=JSON.decode(response);
if(jsonResponse.status!='OK'){
alert(jsonResponse.status);
}else{
jsonResponse.data.each(function(item){
htmlTemplate[item.id]=item.value.substitute(langTexts);
});
}
}});
a.send('fn=getHtmlTemplate&htmlTemplate=*');
}
function loadBahnen(vDatum){
var a=new Request.JSON({method: 'post',url: '/scripts/ajax.php', onComplete: function(response){
if(response.status=='OK'){
var html='
'
+ '
ZEITEN
';
response.times.each(function(item){
html+='
' + item + '
';
});
html+='
';
response.bahnen.each(function(item){
html+=''
+ '
'+item.titel+' ↓
';
response.times.each(function(zeit){
var textStatus='.';
var classStatus='free';
if(response.reservStatus['b'+item.id+'_'+zeit]!=undefined){
textStatus='X';
classStatus='reserved';
}else if(response.markedStatus['b'+item.id+'_'+zeit]!=undefined){
textStatus='→ Kassa';
classStatus='marked';
}
html+='
' + textStatus + '
';
});
html+='
';
});
document.id('bahn_view').set('html',html);
var regFind=/b(\d+)_(.+)$/;
var arrClick=$$('.free');
arrClick.combine($$('.marked'));
arrClick.each(function(item){
item.addEvent('click',function(){
var regErg=regFind.exec(item.id);
var a=new Request.JSON({method: 'post', url: '/scripts/ajax.php', onComplete: function(clickResponse){
if(clickResponse.status=='OK'){
if(item.hasClass('free')){
item.removeClass('free').addClass('marked');
document.id(item.id).set('html','→ ' + langTexts.markedText);
}else{
item.removeClass('marked').addClass('free');
document.id(item.id).set('html','.');
}
}else{
item.removeClass('free').addClass('reserved');
document.id(item.id).set('html','X');
/* wird in updateWkorbDisplay abgefragt alert(clickResponse.status); */
}
displayCounter();
updateWkorbDisplay(clickResponse);
}}).send('fn=bahnReserv&bahn_id='+regErg[1]+'&zeit='+regErg[2]+'&datum='+document.id('book_date').value+'&countertime='+($time()/1000).toInt());
});
});
}else{
document.id('bahn_view').set('html',response.status);
}
}}).send('fn=loadBahnen&vDatum='+vDatum);
}
function displayCounter(){
if(counterStart==undefined){
var a=new Request.JSON({url: '/scripts/ajax.php', onComplete: function(response){
if(response.status=='OK'){
if(response.counterStart > 0){
document.id('counterBox').setStyle('display','block');
counterStart=response.counterStart.toInt();
var setCounter=function(){
if(!document.id('qenta')){
var validTime=(counterStart.toInt() + (getConstant('counterValue').toInt()*60) - ($time()/1000).toInt());
if(validTime < 1){
timedoutCounter();
}else{
var validMin=(validTime/60).toInt();
var validSec=(validTime - validMin*60).toInt();
if(validSec < 10){ validSec='0' + validSec; }
var validStr=validMin + ':' + validSec;
//document.id('counter').set('html','Start: ' + counterStart + '
' +'Time: ' + ($time()/1000).toInt() + '
' + 'Valid: ' + validTime + '
' + validStr);
document.id('counter').set('html',validStr);
}
}
}
counterObj=setCounter.periodical(1000);
}
}else{
alert(response.status);
}
}}).send('fn=getCounterStart');
}else{
if($$('.marked').length < 1){ resetCounter(); }
}
}
function timedoutCounter(){
var a=new Request.JSON({url: '/scripts/ajax.php',onComplete: function(response){
if(response.status=='OK'){
if(location.href.contains('wkorb.html')){
location.href=location.href;
}else{
resetCounter();
updateWkorbDisplay(response);
}
}else{
alert(response.status);
}
}}).send('fn=clearBahnen');
}
function resetCounter(){
counterStart=undefined;
counterObj=$clear(counterObj);
document.id('counter').set('html','');
document.id('counterBox').setStyle('display','none');
$$('.marked').each(function(item){
item.removeClass('marked').addClass('free');
document.id(item.id).set('html','.');
});
}
function doLogin(){
if(document.id('login').value==''){
document.id('login_error').set('html','Bitte Benutzernamen eintragen.');
document.id('login').focus();
return;
}
if(document.id('password').value==''){
document.id('login_error').set('html','Bitte Passwort eintragen.');
document.id('password').focus();
return;
}
var a=new Request({ method: 'post',url: '/scripts/ajax.php', onComplete: function(response){
var jsonResponse=JSON.decode(response);
if(jsonResponse.status!='OK'){
document.id('login_error').innerHTML=jsonResponse.status;
}else{
location.href=self.location;
}
}});
a.send('fn=doLogin&login='+document.id('login').value+'&password='+document.id('password').value);
}
function wkorb(action,dsId,anzahl,wkorbId){
/*
wkorbId Notwendig fuer Adminbuchungen
*/
if(wkorbId==undefined){ wkorbId=0; }
var a=new Request({ method: 'post',url: '/scripts/ajax.php', onComplete: function(response){
if(action=='del' || action=='delBahn' || action=='delZusatz'){
location.href=location.href;
}else{
updateWkorbDisplay(JSON.decode(response));
}
}});
a.send('fn=wkorb&action='+action+'&dsId='+dsId+'&anzahl='+anzahl+'&wkorbId='+wkorbId);
}
function updateWkorbDisplay(jsonResponse){
if(jsonResponse.status!='OK'){
alert(jsonResponse.status);
}else{
document.id('warenkorb').set('html',jsonResponse.warenkorb);
document.id('marketbasket_div').set('html',jsonResponse.marketbasket);
if(document.id('contentPositions')){
if(jsonResponse.content){
document.id('contentPositions').set('html',jsonResponse.content);
initToolTips();
initWkorbFunctions();
}else{
if(jsonResponse.summe){
document.id('summe').set('html',jsonResponse.summe);
document.id('mwst').set('html',jsonResponse.mwst);
if(jsonResponse.elementId){
document.id(jsonResponse.elementId).set('html',jsonResponse.preis);
}
}
}
}
}
}
function showMedia(media,opts){
if(document.id('trans_background').style.visibility=='hidden'){
document.id('trans_background').fade(0,0.6);
}
if(media=='search'){
document.id(popupContentId).innerHTML=htmlTemplate['search'];
document.id(popupContainerId).position({
position: 'centerTop',
offset: {x:-200,y: 150}
});
document.id(popupContainerId).fade(0,1);
setTimeout("document.id('pattern').focus()",500);
}else if(media=='newsletter'){
document.id(popupContentId).set('html',htmlTemplate['newsletter']);
if(document.id('form_newsletter')){
document.id('form_newsletter').addEvent('submit', function(e){
if(e){ e.stop(); }
if(checkFormular('form_newsletter','info_newsletter')){
document.id('info_newsletter').set('html','');
this.set('send',{onComplete: function(response){
var formResponse=JSON.decode(response);
if(formResponse.status=='OK'){
document.id('newsletter_div').setStyle('display','none');
document.id('info_newsletter').set('html',langTexts.newsletterSubscribe);
}else{
document.id('newsletter_div').setStyle('display','none');
document.id('info_newsletter').set('html',formResponse.status);
}
}});
this.send();
}else{
document.id('newsletter_userinfo').set('html','');
return false;
}
});
}else{
alert('Container nicht gefunden');
}
document.id(popupContainerId).position({
position: 'centerTop',
offset: {x:-200,y: 150}
});
if(document.id(popupContainerId).style.visibility=='hidden'){
document.id(popupContainerId).fade(0,1);
}
//setTimeout("document.id('email').focus()",500);
}else if(media=='picgal'){
openPopupId=popupContainerId;
document.id(popupContainerId).position({
position: 'centerTop',
offset: {x:(getConstant('galmaxw').toInt()/2*-1),y: 80}
});
document.id(popupContentId).innerHTML=htmlTemplate['picgal'];
getPicgal(opts);
if(document.id(popupContainerId).style.visibility=='hidden'){
document.id(popupContainerId).fade(0,1);
}
}else if(media=='bigpic'){
var picObj='picgalBigPic'; /* +picgalId */
var picContentObj='picgalBigPic_content'; /* +picgalId */
openPopupId=popupContainerId;
document.id(popupContainerId).position({
position: 'centerTop',
offset: {x:(getConstant('galmaxw').toInt()/2*-1),y: 80}
});
document.id(popupContentId).innerHTML=htmlTemplate['bigpic'];
window.setTimeout('document.id(\'picgalBigPic\').set(\'html\',loadBigPic(\''+opts[0]+'\',\''+opts[1]+'\',\''+opts[2]+'\',\''+opts[3]+'\'))',100);
document.id(picObj).style.display='block';
if(document.id(popupContainerId).style.visibility=='hidden'){
document.id(popupContainerId).fade(0,1);
}
}else if(media=='lostpassword'){
document.id(popupContentId).innerHTML=htmlTemplate['lostpassword'];
document.id('form_password').addEvent('submit', function(e){
if(e){ e.stop(); }
if(checkFormular('form_password','info_password')){
document.id('info_password').set('html','');
this.set('send',{onComplete: function(response){
var formResponse=JSON.decode(response);
if(formResponse.status=='OK'){
document.id('password_div').setStyle('display','none');
document.id('info_password').set('html',langTexts.passwordLostSend);
}else{
document.id('password_div').setStyle('display','none');
document.id('info_password').set('html',formResponse.status);
}
}});
this.send();
}else{
return false;
}
});
document.id(popupContainerId).position({
position: 'centerTop',
offset: {x:-200,y: 150}
});
if(document.id(popupContainerId).style.visibility=='hidden'){
document.id(popupContainerId).fade(0,1);
}
setTimeout("document.id('email').focus()",500);
}else if(media=='lostactivatekey'){
document.id(popupContentId).innerHTML=htmlTemplate['lostactivatekey'];
document.id('form_password').addEvent('submit', function(e){
if(e){ e.stop(); }
if(checkFormular('form_password','info_password')){
document.id('info_password').set('html','');
this.set('send',{onComplete: function(response){
var formResponse=JSON.decode(response);
if(formResponse.status=='OK'){
document.id('password_div').setStyle('display','none');
document.id('info_password').set('html',langTexts.activateKeyLostSend);
}else{
document.id('password_div').setStyle('display','none');
document.id('info_password').set('html',formResponse.status);
}
}});
this.send();
}else{
return false;
}
});
document.id(popupContainerId).position({
position: 'centerTop',
offset: {x:-200,y: 150}
});
if(document.id(popupContainerId).style.visibility=='hidden'){
document.id(popupContainerId).fade(0,1);
}
setTimeout("document.id('email').focus()",500);
}else if(media=='agb'){
openPopupId=popupContainerId;
document.id(popupContainerId).position({
position: 'centerTop',
offset: {x:-300,y: 150}
});
document.id(popupContentId).innerHTML=htmlTemplate['agb'];
var a=new Request.HTML({ url: '/agb',update: document.id('agb')}).send();
if(document.id(popupContainerId).style.visibility=='hidden'){
document.id(popupContainerId).fade(0,1);
}
}else if(media=='webcam'){
openPopupId=popupContainerId;
document.id(popupContainerId).position({
position: 'centerTop',
offset: {x:-200,y: 150}
});
var webcamHtml=htmlTemplate['webcam'].substitute({link: opts.link},/\$([^\$]+)\$/g);
document.id(popupContentId).set('html',webcamHtml);
if(document.id(popupContainerId).style.visibility=='hidden'){
document.id(popupContainerId).fade(0,1);
}
}
}
function lostPassword(){
document.id('form_password').fireEvent('submit');
}
function loadBigPic(pic,w,h,alt_txt){
return '
';
}
function closePopup(){
if(document.id('search_content')){ document.id('search_content').morph({height: 0}); }
document.id('trans_background').fade('out');
document.id(popupContainerId).fade('out');
document.id(transBgId).setStyle('z-Index',getConstant('transBgZindex'));
document.id(popupContentId).set('html','');
}
function doSearch(page){
document.id('search_content').set('morph', {duration: 500 });
document.id('search_content').morph({height: 50});
document.id('search_content').set('html',langTexts.doSearch+'...');
var a = new Request({ url: '/scripts/ajax.php', method: 'post', data: 'fn=doSearch&pattern='+document.id('pattern').value + '&page='+page});
a.addEvent('success', function(response) {
var searchResponse=JSON.decode(response);
document.id('search_content').morph({height: 350});
document.id('search_browse').innerHTML=searchResponse.browse;
document.id('search_content').innerHTML='';
var searchObj=searchResponse.data;
var space='';
for(var i=0;i < searchObj.length; i++){
if(searchObj[i][6]!=''){
searchObj[i][6]='
»» ' + langTexts.Details + '';
}
/*
searchObj[i][0]=ID
searchObj[i][1]=Titel
searchObj[i][2]=Kurztext
searchObj[i][3]=Bild
searchObj[i][4]=KatID
searchObj[i][5]=Rank (derzeit in %, könnte aber auch als Zahl repräsentiert werden)
searchObj[i][6]=Link
*/
document.id('search_content').innerHTML+= '
' + searchObj[i][1] + '
'
+ '
' + searchObj[i][3] + ''
+ searchObj[i][2] + '
'
+ ''+searchObj[i][6] + ''
+ '
' + langTexts.Relevanz + ': '+searchObj[i][5] + '
'
+ '
';
}
if(searchObj.length==0){
document.id('search_content').innerHTML+=langTexts.SearchNotFound;
}
document.id('search_content').innerHTML+='
';
});
a.send();
}
function logSponsor(sponsorId){
var a=new Request({ method: 'post',url: '/scripts/ajax.php', onComplete: function(response){
var jsonResponse=JSON.decode(response);
if(jsonResponse.status!='OK'){
alert(jsonResponse.status);
}
}});
a.send('fn=logSponsor&logSponsor='+sponsorId);
}
function getPicgal(picgalId){
var a=new Request({ method: 'post',url: '/scripts/ajax.php', onComplete: function(response){
var jsonResponse=JSON.decode(response);
if(jsonResponse.status!='OK'){
alert(jsonResponse.status);
}else{
picgalObjects=jsonResponse.pics;
fillPicgal(jsonResponse);
}
}});
a.send('fn=getPicgal&picgal_id='+picgalId);
}
function showPicgal(picgalId,pic,alt_txt){
var picObj='picgalBigPic'; /* +picgalId */
var picContentObj='picgalBigPic_content'; /* +picgalId */
if(document.id(picObj)){
if(pic==false){ //Schlieszen
document.id(picObj).style.display='none';
}else{
//document.id(+picgalId).innerHTML=loadPicgalPic(pic,alt_txt);
//IE7 Bug, wenn man direkt zuweist, wird das Bild erst beim 2. mal angezeigt.
window.setTimeout('document.id(\''+picContentObj+'\').set(\'html\',loadPicgalPic(\''+pic+'\',\''+alt_txt+'\'))',100);
document.id(picObj).style.display='block';
}
}else{
alert(picObj + ' nicht gefunden');
}
return false;
}
function loadPicgalPic(pic,alt_txt){
var picgalImageIndex=-1;
for(var i=0;i < picgalObjects.length;i++){
if(picgalObjects[i][1]==pic){
picgalImageIndex=i;
}
}
return '
';
}
function fillPicgal(gal){
/* gal.picgal [0] = id
[1] = titel
[2] = memo
gal.pics [0] = id
[1] = src
[2] = alt
*/
document.id('picgalTitel').set('html',gal.picgal[1]);
document.id('picgalMemo').set('html',gal.picgal[2]);
var pics=gal.pics;
var pichtml='';
//picMemo.splice(0,picMemo.length);
for(var i=0;i < pics.length; i++){
pichtml += ''
+ '
'
+ '';
//picMemo['picmemo'+pics[i][0]]=pics[i][3];
}
document.id('picgalPreviewBoxContent').set('html',pichtml);
}
function getPicGalWidth(obj){
for(var i=0;i0){
picGalWidth+=obj.childNodes[i].offsetWidth;
}
}
}
function picgalPreviewBoxMove(id,direction){
if(movePicGal==true){
if(document.id('picgalPreviewBoxContent')){
var obj=document.id('picgalPreviewBoxContent');
if(picGalWidth==-1){
getPicGalWidth(obj);
}
//debug('vorher ' + obj.style.left,false);
var objLeft=0;
if(!isNaN(parseInt(obj.style.left))){
objLeft=parseInt(obj.style.left);
}
if(direction=='left'){
if(objLeft > ( getConstant('galmaxw').toInt() - 2 * getConstant('galmoveWidth').toInt())-picGalWidth){
objLeft-=picGalStep;
}else{
movePicGal=false;
}
}else{
if(objLeft<=(picGalStep*-1)){
objLeft+=picGalStep;
//debug('nachher ' + (objLeft+picGalStep) + 'px',true);
}else{
objLeft=0;
movePicGal=false;
}
}
obj.style.left=objLeft + 'px';
}
window.setTimeout('picgalPreviewBoxMove(' + id + ',\'' + direction + '\')',20);
}
}
function getConstants(arrConst){
var a=new Request.JSON({url: '/scripts/ajax.php',async:false,onSuccess: function(response){
if(response.status=='OK'){
arrConst.each(function(item){
constVars[item]=response.constNames[item];
});
}
}}).send('fn=getConstant&constNames='+JSON.encode(arrConst));
}
function getConstant(constName,asyncReq){
if(asyncReq==undefined){ asyncReq=false; }
if(constVars[constName]==undefined){
var a=new Request.JSON({url: '/scripts/ajax.php',async:asyncReq,onSuccess: function(response){
if(response.status=='OK'){
constVars[constName]=response.constName;
}else{
constVars[constName]='';
alert('Constante ' + constName + ' nicht gefunden!');
}
}}).send('fn=getConstant&constName='+constName);
}
return constVars[constName];
}
function chkValidate(){
var myValidator = new FormValidator(document.id('form_validate'),{useTitles: true
, onElementFail: function(element,errTests){
if(!document.id('errmsg_' + element.name)){
var fieldName='';
if(element.title){
fieldName=element.title;
}else if(element.name){
fieldName=element.name.capitalize();
}else if(element.id){
fieldName=element.id.capitalize();
}
var errStr='' + langTexts.errorAtField + ' ' + fieldName + ': ';
var errSpace='';
errTests.each(function(item){
if(item=='required'){
errStr+=errSpace + langTexts.Pflichtfeld;
}else if(item=='validate-email'){
errStr+=element.value + ' ' + langTexts.noValidEmail + '.';
}else{
errStr+=errSpace + item;
}
errSpace=', ';
});
var errHtml=document.id('error_validate').get('html');
if(errHtml==''){
errHtml='' + langTexts.formNotSent + '
';
}else{
errHtml+='
';
}
document.id('error_validate').set('html',errHtml+errStr);
}
}});
if (myValidator.validate()) {
return true;
}else{
return false;
}
}
function checkFormular(formId,errorId){
document.id(errorId).set('html','');
var myValidator = new FormValidator(document.id(formId),{useTitles: true
, onElementFail: function(element,errTests){
if(!document.id('errmsg_' + element.name)){
var fieldName='';
if(element.title){
fieldName=element.title;
}else if(element.name){
fieldName=element.name.capitalize();
}else if(element.id){
fieldName=element.id.capitalize();
}
var errStr='' + langTexts.errorAtField + ' ' + fieldName + ': ';
var errSpace='';
errTests.each(function(item){
if(item=='required'){
errStr+=errSpace + langTexts.Pflichtfeld;
}else if(item=='validate-email'){
errStr+=element.value + ' ' + langTexts.noValidEmail + '.';
}else if(item=='validate-reqchk-byname'){
errStr+=errSpace + ' ' + langTexts.noRadioChecked + '.';
}else{
errStr+=errSpace + item;
}
errSpace=', ';
});
var errHtml=document.id(errorId).get('html');
if(errHtml==''){
errHtml='' + langTexts.formNotSent + '
';
}else{
errHtml+='
';
}
document.id(errorId).set('html',errHtml+errStr);
}
}});
if (myValidator.validate()) {
return true;
}else{
return false;
}
}
function addZusatz(produktId,bahnreservId){
var a=new Request.JSON({url: '/scripts/ajax.php',onComplete: function(response){
if(response.status=='OK'){
location.reload();
}else{
alert(response.status);
}
}}).send('fn=addZusatz&produkt_id='+produktId+'&bahnreserv_id='+bahnreservId);
}
function paymentAction(state){
if(state=='CANCEL'){
parent.document.id('qenta').src='about:blank';
parent.closePopup();
}else if(state=='SUCCESS'){
parent.location.href='/danke.php?thanksType=wkorb';
}else{
alert('Für Status ' + state + ' ist keine Routine implementiert.');
}
}
function showActivate(){
var a=new Request({ method: 'post',url: '/scripts/ajax.php', onComplete: function(response){
var jsonResponse=JSON.decode(response);
if(jsonResponse.status!='OK'){
//alert(jsonResponse.status);
document.id('error_registercode').set('html',formResponse.status);
}else{
document.id('container_loginform').set('html',jsonResponse.codeForm);
setFormFunctions();
}
}});
a.send('fn=showActivate');
}
function wkorbStorno(wkorbId){
var ret=confirm('Sind Sie sicher, das Sie diese Rechnung stornieren möchten? Achtung dieser Vorgang kann nicht Rückgängig gemacht werden.');
if(ret){
var a=new Request({ method: 'post',url: '/scripts/ajax.php', onComplete: function(response){
var jsonResponse=JSON.decode(response);
if(jsonResponse.status!='OK'){
alert(jsonResponse.status);
}else{
alert('Rechnung wurde Storniert.');
location.href='/setemplates/adminbook.php?atwork=1';
}
}});
a.send('fn=wkorbStorno&wkorbId='+wkorbId+'&sendsms='+document.id('sendsms').checked + '&sendemail=' +document.id('sendemail').checked);
}
}
function wkorbStornoTag(){
var ret=confirm('Sind Sie sicher, das Sie die ausgewählten Kunden stornieren möchten? Achtung dieser Vorgang kann nicht Rückgängig gemacht werden.');
if(ret){
var ids='';
$$('.stornobox').each(function(item){
if(item.checked==true){
//alert(item.value+ item.checked);
if(ids!='') { ids+=','; }
ids+=item.value;
}
});
if(ids!=''){
//alert('fuer ids ' + ids + ' wird der wkorb storniert');
var a=new Request({ method: 'post',url: '/scripts/ajax.php', onComplete: function(response){
var jsonResponse=JSON.decode(response);
if(jsonResponse.status!='OK'){
alert(jsonResponse.status);
}else{
alert('Buchungen wurden Storniert.');
location.href='/setemplates/adminbook.php?vtype=storno';
}
}});a.send('fn=wkorbStornoMore&wkorbIds='+ids+'&sendsms='+document.id('sendsms').checked + '&sendemail=' +document.id('sendemail').checked);
}
}
}