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('galmaxw','galmaxh'); var picgalContainerId=popupContainerId; var picgalContentId=popupContentId; var currentBody; var lastBody; var slideable = [true,true]; var passed = false; var naviMorph, contentMorph; var initLastBody=''; var initToggle=''; var pageHistory; var newLoad = true; var fading = true; window.addEvent('domready', function(){ if(document.id('trans_background')){ document.id('trans_background').addEvent('click',function(e){ closePopup(); }); } $$('.hide').fade('hide').removeClass('hide'); getConstants(preloadConstants); loadHtmlTemplates(); if(window.location.pathname != '/'){ newLoad = false; fading = false; } init_site(); // init_historyEngine(); assetImages(); setFormFunctions(); }); //Zeigt die Seite an wie sie am Anfang auszusehen hat //und fuegt ihr die Events hinzu. function init_site(){ if(newLoad){ $$('.navi')[0].setStyle('display','none'); $$('.navi')[0].getNext('div').setStyle('display','none'); $$('.navi','.contentarea','#wrapper').set('styles',{'opacity':0}); } else{ $$('.navi')[0].setStyle('display','block'); $$('.navi')[0].getNext('div').setStyle('display','block'); $$('.navi','.contentarea','#wrapper').set('styles',{'opacity':1}); } addEvents(); //lastBody = $('glasbody'); if(initLastBody!=''){ lastBody=document.id(initLastBody); toggleElements(document.id(initToggle)); }else{ lastBody = $('glasbody'); } } function init_historyEngine(){ pageHistory = new HistoryManager(); pageHistory.addEvent('page-added',function(pHistory){ toggleElements($(pHistory)); }); pageHistory.addEvent('page-changed',function(pHistory){ toggleElements($(pHistory)); }); pageHistory.start(); } function addEvents(){ $$('#glasbody','#guitarbody').addEvent('click',toggle); $$('#glasbody','#guitarbody').setStyle('cursor','pointer'); $$('.navi_gs_1').addEvents({ 'mouseenter':function(){ this.set('morph',{wait:false,duration:500}); this.morph({'background-color':['#ebebeb','#ffffff']}); }, 'mouseleave':function(){ this.set('morph',{wait:false,duration:500}); this.morph({'background-color':['#ffffff','#ebebeb']}); } }); $$('.navi_gr_1').addEvents({ 'mouseenter':function(){ this.set('morph',{wait:false,duration:500}); this.morph({'background-color':['#404B54','#999999']}); }, 'mouseleave':function(){ this.set('morph',{wait:false,duration:500}); this.morph({'background-color':['#999999','#404B54']}); } }); } function toggleElements(currentBody){ //alert('toggleElements' + currentBody.get('id')); if(currentBody.get('id')=='glasbody'){ document.id('guitarbody').setStyle('cursor','pointer'); }else{ document.id('glasbody').setStyle('cursor','pointer'); } if(!passed && currentBody.get('id')=='glasbody'){ //suche das erste Navigationselemnt im jeweiligen Body currentBodyNavi = currentBody.getFirst().getNext().getFirst('.navi'); new Fx.Morph(currentBodyNavi,{ wait: false, duration: 200, onStart: function(){ currentBodyNavi.setStyle('display','block'); } }).start({'opacity':[0,1]}); new Fx.Morph(currentBodyNavi.getNext(),{ wait: false, duration: 200, onStart: function(){ currentBodyNavi.getNext().setStyle('display','block'); } }).start({'opacity':[0,1]}); passed = true; } if(slideable[0] == true && slideable[1] == true){ if(lastBody!=currentBody){ //suche das erste Navigationselemnt im jeweiligen Body currentBodyNavi = currentBody.getFirst().getNext().getFirst('.navi'); lastBodyNavi = lastBody.getFirst().getNext().getFirst('.navi'); //Geklicktes Body if(newLoad){ new Fx.Morph(currentBody,{ wait: false, duration: 500, transition: Fx.Transitions.Cubic.easeOut, onStart: function(){ slideable[0] = false; }, onComplete: function(){ slideable[0] = true; new Fx.Morph(currentBodyNavi,{ wait: false, duration: 200, onStart: function(){ currentBodyNavi.setStyle('display','block'); } }).start({'opacity':[0,1]}); new Fx.Morph(currentBodyNavi.getNext(),{ wait: false, duration: 200, onStart: function(){ currentBodyNavi.getNext().setStyle('display','block'); } }).start({'opacity':[0,1]}); } }).start({'width': [197, 583]}); } else{ currentBody.setStyle('width',583); currentBodyNavi.setStyle('display','block'); currentBodyNavi.getNext().setStyle('display','block'); currentBodyNavi.setStyle('opacity',1); } //Zuletzt geklicktes Body if(newLoad){ new Fx.Morph(lastBody,{ wait: false, duration: 500, transition: Fx.Transitions.Cubic.easeOut, onStart: function(){ slideable[1] = false; lastBodyNavi.setStyle('display','none'); lastBodyNavi.getNext().setStyle('display','none'); lastBodyNavi.setStyle('opacity',0); lastBodyNavi.getNext().setStyle('opacity',0); }, onComplete: function(){ slideable[1] = true; } }).start({'width': [583, 197]}); } else{ lastBodyNavi.setStyle('display','none'); lastBodyNavi.getNext().setStyle('display','none'); lastBodyNavi.setStyle('opacity',0); lastBodyNavi.getNext().setStyle('opacity',0); lastBody.setStyle('width',197); } lastBody = currentBody; passed = true; newLoad = true; } } } function assetImages(){ var path = '/images/'; images = $(document.body).getElements('img').get('src'); images.push(path+'content_glas.jpg',path+'guitar.jpg',path+'contentbg_r.png',path+'contentbg_l.png'); var fxchange = new Fx.Morph('wrapper', { duration: 1500, link: 'cancel', transition: 'quad:in' }); new Asset.images(images, { onProgress: function(i) { $('progress').set('styles', {'visibility':'visible', 'position':'absolute', 'z-index':1000}); var percent = ((i + 1) * screen.width) / images.length; $('loadbar').set('styles', {'width':percent}).set('html', (i+1)+'/'+images.length); }, onComplete: function() { $('progress').set('styles', {'visibility':'hidden','display':'none'}); $('wrapper').set('styles',{'display':'block'}); $(document.body).set('styles',{'visibility':'visible'}); if(fading){ fxchange.start({opacity: [0, 1]}); } else{ $('wrapper').setStyle('opacity',1); } } }); } //Eventfunktion var toggle = function(){ // pageHistory.set('page',this.get('id')); this.setStyle('cursor','auto'); toggleElements(this); } 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('loadHtmlTemplates:' + jsonResponse.status); }else{ jsonResponse.data.each(function(item){ htmlTemplate[item.id]=item.value.substitute(langTexts); }); } }}); a.send('fn=getHtmlTemplate&htmlTemplate=*'); } function showMedia(media,opts){ if(document.id('trans_background').style.visibility=='hidden'){ document.id('trans_background').fade(0,0.6); } 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=='video'){ var vidObj='video'; var vidContentObj='video_content'; openPopupId=popupContainerId; document.id(popupContainerId).position({ position: 'centerTop', offset: {x:(getConstant('videomaxw').toInt()/2*-1),y: 80} }); document.id(popupContentId).innerHTML=htmlTemplate['video']; 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{ document.id('video').set('html',jsonResponse.video).delay(100); } }}); a.send('fn=getvideo&video_id='+opts); document.id(vidObj).style.display='block'; if(document.id(popupContainerId).style.visibility=='hidden'){ document.id(popupContainerId).fade(0,1); } } } function loadBigPic(pic,w,h,alt_txt){ return '' + alt_txt + ''; } function closePopup(){ 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 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 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; } }); } } 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; } }