/* JS functions */ /* Image Transitions Manager */ Element.addMethods({ bringToFront: function(p_eElement) { p_eElement.setStyle({ zIndex: '2' }); return p_eElement; }, sendToBack: function(p_eElement) { p_eElement.setStyle({ zIndex: '1' }); return p_eElement; }, getHeight: function(p_eElement) { return p_eElement.offsetHeight; }, getWidth: function(p_eElement) { return p_eElement.offsetWidth; }, getCenterHeight: function(p_eElement) { return (p_eElement.offsetHeight / 2); }, getCenterWidth: function(p_eElement) { return (p_eElement.offsetWidth / 2); }, isLoaded: function(p_eElement) { return (p_eElement.complete); } } ); //add a start method to complement the stop function on the PeriodicalExecuter PeriodicalExecuter.addMethods({ start: function() { if (!this.timer) this.registerCallback(); } }); var transitionConfig = { previousButtonId: 'previousbutton', nextButtonId: 'nextbutton', pauseButtonId: 'pausebutton', buttonParent: 'transarea', containerClass: '.tranpanel', customEvent: 'custom:click', pauseButtonClass: 'paused', playingButtonClass: 'playing', selectedAnchorClass: 'selected', selectedAnchorQuery: '.tranpanel a.selected' }; /* The Transition Class */ var Transition = Class.create(); Transition.prototype = { initialize: function(p_eTarget, p_sImage) { this.firstImageForIE = false; this.m_eTarget = $(p_eTarget); this.m_eTarget.setStyle({ position: 'relative' }); this.m_eLoading = null; /* Define the reference to this object globally so we can use it within the scope of the anchors */ g_eTransition = this; // clear all content of holder. while (this.m_eTarget.hasChildNodes()) this.m_eTarget.removeChild(this.m_eTarget.firstChild); /*/////////////////////////////////////////////////////////////////////////////////////////// * TEMPORARY WAY TO ADD FIRST IMAGE!! * Should be added by the loadImage function, but this expects an anchor as parameter. */ var eImage = document.createElement('img'); eImage.setAttribute('src', p_sImage); this.m_eTarget.appendChild(eImage); this.m_eCurrent = eImage; new Effect.Appear(this.m_eCurrent, { duration: 1.5, from: 0.0, to: 1.0 }); /*******************************************************************************************/ // loop through all anchors. REFACTORED: pretty nifty eh :) $$('a').each(function(eAnchor) { var sRel = String(eAnchor.getAttribute('rel')); if (eAnchor.getAttribute('href') && (sRel.toLowerCase().match('transition'))) { eAnchor.m_eRef = this; eAnchor.onclick = function() { g_eTransition.loadImage(this); return false; } //also add a custom event that does the same thing, for automatic firing eAnchor.observe(transitionConfig.customEvent, function(event) { g_eTransition.loadImage(this); return false; }); } }); //set the first anchor class to selected $$(transitionConfig.containerClass + ' a')[0].addClassName(transitionConfig.selectedAnchorClass); //call the onclick on the next anchor after 8 seconds executer = new PeriodicalExecuter(g_eTransition._timedImageLoader, 8); g_eTransition._addOnClickExecuter.delay(1, true); }, _addOnClickExecuter: function(play) { //create the pause button if (!$(transitionConfig.pauseButtonId)) { var pausebutton = new Element('a', { 'id': transitionConfig.pauseButtonId, href: '#', 'class': transitionConfig.playingButtonClass }).update("Pause"); Element.insert($(transitionConfig.buttonParent), pausebutton); } /* * if required, will need to calculate what these links should actually do //create the next button if(!$(transitionConfig.nextButtonId)){ var nextbutton = new Element('a',{ 'id': transitionConfig.nextButtonId, href: '#' }).update("Next"); Element.insert($(transitionConfig.buttonParent), nextbutton); } //create the previous button if(!$(transitionConfig.previousButtonId)){ var previousbutton = new Element('a',{ 'id': transitionConfig.previousButtonId, href: '#' }).update("Previous"); Element.insert($(transitionConfig.buttonParent), previousbutton); } */ if (play) { //pause button $(transitionConfig.pauseButtonId).observe('click', g_eTransition._pause); } else { //play button $(transitionConfig.pauseButtonId).observe('click', g_eTransition._play); } }, //call the next anchor's onclick _timedImageLoader: function() { var isClicked = false if ($$(transitionConfig.selectedAnchorQuery).size() != 0) { //get the next sibling. assumed structure is a list of anchors if (undefined != $$(transitionConfig.selectedAnchorQuery)[0].up(0).next('li')) { Event.fire($$(transitionConfig.selectedAnchorQuery)[0].up(0).next('li').down(0), transitionConfig.customEvent); isClicked = true; } } else { //make the first one selected, so that the first transition will be to the second pic Event.fire($$(transitionConfig.containerClass + ' a')[1], transitionConfig.customEvent); isClicked = true; } if (!isClicked) { //just click the first one then Event.fire($$(transitionConfig.containerClass + ' a:first-child')[0], transitionConfig.customEvent); } }, loadImage: function(p_eAnchor) { // Get transition type and image url. var sTransition = /^transition\[(.+)\]$/.exec(p_eAnchor.getAttribute('rel'))[1]; var sImage = p_eAnchor.getAttribute('href'); var eImage = document.createElement('img'); eImage.setAttribute('src', sImage); $(eImage).setStyle({ position: 'absolute', left: '0px', top: '0px', opacity: '0' }); this.m_eTarget.appendChild(eImage); if (!eImage.isLoaded()) { /* The image is not yet loaded, so fix the loading div */ this.m_eLoading = document.createElement('div'); $(this.m_eLoading).setStyle({ position: 'absolute', left: '5px', bottom: '5px', color: '#FFF' }); this.m_eLoading.appendChild(document.createTextNode('loading...')); this.m_eTarget.appendChild(this.m_eLoading); Event.observe(eImage, 'load', this._onLoad.bindAsEventListener(null, this, eImage, sTransition)); } else { /* The image is already loaded*/ this.m_eLoading = null; this._transImage(eImage, sTransition); } //remove selected class from the previously selected anchor $$(transitionConfig.selectedAnchorQuery).each(function(eAnchor) { eAnchor.removeClassName(transitionConfig.selectedAnchorClass); }); //add selected class to anchor p_eAnchor.addClassName(transitionConfig.selectedAnchorClass); //console.debug(p_eAnchor); }, _pause: function() { executer.stop(); $(transitionConfig.pauseButtonId).update('Play'); $(transitionConfig.pauseButtonId).removeClassName(transitionConfig.playingButtonClass); $(transitionConfig.pauseButtonId).addClassName(transitionConfig.pauseButtonClass); $(transitionConfig.pauseButtonId).stopObserving('click'); g_eTransition._addOnClickExecuter(false); }, _play: function() { executer.start(); $(transitionConfig.pauseButtonId).update('Pause'); $(transitionConfig.pauseButtonId).removeClassName(transitionConfig.pauseButtonClass); $(transitionConfig.pauseButtonId).addClassName(transitionConfig.playingButtonClass); $(transitionConfig.pauseButtonId).stopObserving('click'); g_eTransition._addOnClickExecuter(true); }, _onLoad: function(p_eEvent, p_oRef, p_eImage, p_sTransition) { p_oRef._transImage(p_eImage, p_sTransition); }, _transImage: function(eImage, sTransition) { if (this.m_eLoading != null) this.m_eLoading.remove(); /* ADDED: switch on different transitions, use the naming conventions of scriptaculous (appear, fade, etc).?) */ switch (sTransition) { case 'appear': new Effect.Appear(eImage, { duration: 1.5, from: 0.0, to: 1.0 }); new Effect.Appear(this.m_eCurrent, { duration: 1.5, from: 1.0, to: 0.0, afterFinish: this._removeImage }); break; } this.m_eCurrent = eImage; }, _removeImage: function(p_oObj) { //for some reason, removing the image in IE6 the first time stops any further images from appearing //so only remove the image the second time and onwards //does no harm for other IE browsers if (!Prototype.Browser.IE || (Prototype.Browser.IE && this.firstImageForIE)) { p_oObj.element.remove(); } this.firstImageForIE = true; } } function redefineOpacity() { //simply sets the minimum opacity minOpacity = 0.3; } function resize(size) { var frameObj = $('mediaplaybox'); if (!frameObj && parent && undefined == size) { //we must be in the iFrame, so resize the parent instead parent.resize($('contentarea').getHeight()); } else { if (undefined != size) { frameObj.style.height = size + "px"; } } } function crossfader() { //might be nice to rewrite this function so it uses prototype and scriptaculous //in line with the rest of the platform var useBSNns; if (useBSNns) { if (typeof (bsn) == "undefined") bsn = {} var _bsn = bsn; } else { var _bsn = this; } _bsn.Crossfader = function(divs, fadetime, delay) { this.nAct = -1; this.aDivs = divs; for (var i = 0; i < divs.length; i++) { document.getElementById(divs[i]).style.opacity = 0; document.getElementById(divs[i]).style.position = "absolute"; document.getElementById(divs[i]).style.filter = "alpha(opacity=0)"; document.getElementById(divs[i]).style.visibility = "hidden"; } this.nDur = fadetime; this.nDelay = delay; this._newfade(); } _bsn.Crossfader.prototype._newfade = function() { if (this.nID1) clearInterval(this.nID1); this.nOldAct = this.nAct; this.nAct++; if (!this.aDivs[this.nAct]) this.nAct = 0; if (this.nAct == this.nOldAct) return false; document.getElementById(this.aDivs[this.nAct]).style.visibility = "visible"; this.nInt = 50; this.nTime = 0; var p = this; this.nID2 = setInterval(function() { p._fade() }, this.nInt); } _bsn.Crossfader.prototype._fade = function() { this.nTime += this.nInt; var ieop = Math.round(this._easeInOut(this.nTime, 0, 1, this.nDur) * 100); var op = ieop / 100; document.getElementById(this.aDivs[this.nAct]).style.opacity = op; document.getElementById(this.aDivs[this.nAct]).style.filter = "alpha(opacity=" + ieop + ")"; if (this.nOldAct > -1) { document.getElementById(this.aDivs[this.nOldAct]).style.opacity = 1 - op; document.getElementById(this.aDivs[this.nOldAct]).style.filter = "alpha(opacity=" + (100 - ieop) + ")"; } if (this.nTime == this.nDur) { clearInterval(this.nID2); if (this.nOldAct > -1) document.getElementById(this.aDivs[this.nOldAct]).style.visibility = "hidden"; var p = this; this.nID1 = setInterval(function() { p._newfade() }, this.nDelay); } } _bsn.Crossfader.prototype._easeInOut = function(t, b, c, d) { return c / 2 * (1 - Math.cos(Math.PI * t / d)) + b; } } function imagefader() { //Homepage if ($('itemid5259823')) { var cf = new Crossfader(new Array('cf1', 'cf2', 'cf3', 'cf4', 'cf5', 'cf6', 'cf7', 'cf8', 'cf9'), 1000, 5000); } //Cardio Homepage if ($('itemid9023424')) { var cf = new Crossfader(new Array('cf1', 'cf2', 'cf3', 'cf4', 'cf5', 'cf6', 'cf7'), 1000, 5000); } //Neuro Homepage if ($('itemid9023538')) { var cf = new Crossfader(new Array('cf1', 'cf2'), 1000, 5000); } //Neuro Homepage if ($('itemid9023228')) { var cf = new Crossfader(new Array('cf1', 'cf2', 'cf3', 'cf4', 'cf5'), 1000, 5000); } } function imagedisplay() { $('cf1').toggleClassName("displayimage"); $('cf2').toggleClassName("displayimage"); $('cf3').toggleClassName("displayimage"); $('cf4').toggleClassName("displayimage"); $('cf5').toggleClassName("displayimage"); $('cf6').toggleClassName("displayimage"); $('cf7').toggleClassName("displayimage"); $('cf8').toggleClassName("displayimage"); $('cf9').toggleClassName("displayimage"); } function formValidation(){ if(!!$('frm_comment') && !!$('p_0050')){ var chk=$('c_0050'); var adv=$('c_0040'); var frm=$('frm_comment'); var idx=adv.selectedIndex; if(adv.options[idx].value!='adverse'){ chk.disabled=false; }else{ chk.checked=false; chk.disabled=true; } adv.onchange=function(){ var ix=adv.selectedIndex; if(adv.options[ix].value!='adverse'){ chk.disabled=false; }else{ chk.checked=false; chk.disabled=true; } }; if(document.getElementsByTagName("html")[0].getAttribute("lang")=='nl'){ var msg='If your question/remark does NOT regard a patient related adverse event, kindly tick the checkbox. If it does however, please select the option Patient Related Adverse Event in the Q subtype dropdown.'; }else{ var msg='If your question/remark does NOT regard a patient related adverse event, kindly tick the checkbox. If it does however, please select the option Patient Related Adverse Event in the Q subtype dropdown.'; } var inp=$$('input[name="_back"]')[0]; var sub=$$('input[name="_end"]')[0] var cancelBtn=false; inp.observe('click',function(e){cancelBtn=true;}); frm.observe('submit',function(e){ if(!cancelBtn){ if(!chk.disabled && !chk.checked){ if(!e.stopped){e.stop();} alert(msg); } } }); } } /* * SecondLevelNavigation */ function handleSecondLevelNavigation() { $$('ul.nav_menu li').each(function(s) { $(s).observe('mouseover', function(event){ var secondlevelul = $(s).down('ul'); if(secondlevelul != undefined) { secondlevelul.removeClassName('nav_submenu'); s.down('a').addClassName('nav_menu_hover'); } }); $(s).observe('mouseout', function(event){ var secondlevelul = $(s).down('ul'); if(secondlevelul != undefined) { secondlevelul.addClassName('nav_submenu'); s.down('a').removeClassName('nav_menu_hover'); } }); }); } function switchTabs(){ var items = $$('ul.tabs-nav a'); var panels = $$('div.tabs-panel'); items.each(function(el){ el.observe('click',function(e){ if(!e.stopped) e.stop(); items.each(function(e){$(e.parentNode).removeClassName('tabs-selected');}) $(el.parentNode).addClassName('tabs-selected'); var idx=el.href.split("#")[1].toString(); for(i=0;i= 2.13) { alert(dispnum(h)+" Metres seems to be too tall\n\nPlease try again."); } w_kgs = parseFloat(document.data.weight_kgs.value); w=w_kgs; if (w <= 25) { alert(dispnum(w)+" Kgs? Thats much too light\n\nPlease try again."); } if (w >= 227) { alert(dispnum(w)+" Kgs? Thats much too heavy\n\nPlease try again."); } bmi = w / (h*h); max_kgs = 25*h*h; weight_in_pounds = (max_kgs*2.2); document.data.bmi.value = dispnum(bmi); if (bmi < 18.5 ) document.data.expl.value = "Met een BMI waarde van minder dan 18,5 bent u te licht. Het is verstandig te proberen wat aan te komen door regelmatig te eten en geen maaltijd over te slaan. Eet of drink daarbij vier keer per dag iets tussendoor, om zo extra energie binnen te krijgen."; if (bmi >= 18.5 && bmi < 25 ) document.data.expl.value = "U hebt een gezond gewicht. Probeer uw gewicht te handhaven op dit peil. Check minstens een keer per half jaar opnieuw hoe het ervoor staat."; if (bmi > 25 && bmi <= 30 ) document.data.expl.value = "U bent iets te zwaar. Mensen met een BMI tussen 25 en 30 zonder bijkomende gezondheidsrisico's moeten voorkomen dat ze dikker worden. Het advies is om in ieder geval niet in gewicht aan te komen, uw eetpatroon te verbeteren en meer te bewegen."; if (bmi > 30 ) document.data.expl.value = "U bent veel te zwaar. Medisch gezien is het noodzakelijk af te vallen bij een Body Mass Index boven de 30. Dit levert een risico op voor uw gezondheid. Een gewichtsvermindering van 5-10% levert al een fikse gezondheidswinst op."; max_imperial = (weight_in_pounds/14)*10; max_imperial = Math.round(max_imperial); max_imperial = max_imperial/10; document.data.max_stones.value = Math.floor(max_imperial); temp1 = max_imperial - (Math.floor(max_imperial)); temp1 = Math.round(temp1*10); document.data.max_pounds.value = Math.round(temp1*1.4); document.data.max_kgs.value = dispnum(max_kgs); } function disableLink(){ if(!!$('signinemail_address') && !!$('home_page_4')){ var para=$$('.pinkbottom p'); para.each(function(el){ if(!!el.firstDescendant()){ var elm=el.firstDescendant(); el.insert({'bottom': elm.firstChild.nodeValue}); elm.remove(); } }); } } function big_num(){ if($('frm_big')){ var frmElt=$('frm_big'); var val=0; frmElt.observe("submit",function(ev){ if(!ev.stopped){ev.stop();} var errFlag=0; val=$('big_number').value; var len=val.length; var num=parseInt(val); if(len!=11 || isNaN(val) ){ errFlag=1; } if(errFlag==0){ $('errordetails').update(); frmElt.submit(); }else{ $('errordetails').update('Onjuist BIGnummer'); } }); } } function get_param(param) { var search = window.location.search.substring(1); if(search.indexOf('&') > -1) { var params = search.split('&'); for(var i = 0; i < params.length; i++) { var key_value = params[i].split('='); if(key_value[0] == param) return key_value[1]; } } else { var params = search.split('='); if(params[0] == param) return params[1]; } return null; } function bannerLink(){ if ($('banner')){ var bigVal=get_param('big_number'); var aLink=$('banner').href; aLink=aLink+bigVal; $('banner').href=aLink; } } var toCall=new Array(); toCall[0]=redefineOpacity; toCall[1]=resize; toCall[2]=imagedisplay; toCall[3]=crossfader; toCall[4]=imagefader; toCall[5]=formValidation; toCall[6]=handleSecondLevelNavigation; toCall[7]=switchTabs; toCall[8]=disableLink; toCall[9]=big_num; toCall[10]=bannerLink;