/**
* file default.js
*
* contains javascript for PFZW website
*
* @require MooTools version 1.2.4 core + selection of more
* @require efocuslib.js
* version 1.1.01
*/


window.addEvents({
    'domready': function() {
        defaultInputText();
        startPushbox();
        initAccordion();
        initSteps();
        initNewsTicker();
        toolTip();
        initDatePicker();
    },
    'load': function() {
        initQgo();
    }
});


/**
* toggles default text in text inputfields
*
* @author Klaas Dieleman <klaas{AT}efocus.nl>
* @return void
*/

function defaultInputText() {
    var inputfields = $$('.defaultText');

    inputfields.each(function(item) {
        item.defaultText = item.value;

        item.addEvents({
            'focus': function() {
                if (item.value == item.defaultText) item.value = '';
            },
            'blur': function() {
                if (item.value == '') {
                    item.value = item.defaultText;
                }
            }
        });
    });
}


/**
* replaces heads with sIFR
*
* @author Klaas Dieleman <klaas{AT}efocus.nl>
* @return void
*/
function replaceFonts() {
    var franklinGothicBook = { src: '/html/swf/franklingothicbook.swf' };
    var franklinGothicDemi = { src: '/html/swf/franklingothicdemi.swf' };
    sIFR.activate(franklinGothicBook, franklinGothicDemi);

    sIFR.replace(franklinGothicBook, {
        selector: 'h1',
        wmode: 'transparent',
        fitExactly: true,
        css: [
			'.sIFR-root { color: #21358b; font-size: 36px; }',
			'a { color: #21358b; text-decoration: underline; }',
			'a:hover { color: #00a94f; text-decoration: none; }'
		]
    });

    sIFR.replace(franklinGothicDemi, {
        selector: '.innerblock h2',
        wmode: 'transparent',
        fitExactly: true,
        css: [
			'.sIFR-root { color: #21358b; font-size: 24px; }'
		]
    });

    sIFR.replace(franklinGothicDemi, {
        selector: 'h2',
        wmode: 'transparent',
        fitExactly: true,
        css: [
			'.sIFR-root { color: #21358b; font-size: 16px; }',
			'a { color: #21358b; text-decoration: none; }',
			'a:hover { color: #00a94f; text-decoration: underline; }'
		]
    });

    sIFR.replace(franklinGothicDemi, {
        selector: 'div.col_left_home div.bottom_nav h3, div.overzichtspagina h3',
        wmode: 'transparent',
        css: [
			'.sIFR-root { color: #ffffff; font-size: 16px; }',
			'a { color: #ffffff; text-decoration: none;}',
			'a:hover { color: #ffffff; text-decoration: underline;}'
		]
    });

    sIFR.replace(franklinGothicDemi, {
        selector: '.bottom_nav h3',
        wmode: 'transparent',
        fitExactly: true,
        css: [
			'.sIFR-root { color: #21358b; font-size: 16px; }',
			'a { color: #21358b; text-decoration: none;}',
			'a:hover { color: #21358b; text-decoration: underline;}'
		]
    });

}


/**
* starts pushbox
*
* @author Rocco Janse <rocco@efocus.nl>
* @since 1.0, 14 aug, 2009
* @return void
*/

function startPushbox() {
    if (!$('pushbox')) return;
    var pbox = new Pushbox({
        'viewport': $('pushbox').getElement('div.viewport'),
        'slides': $('pushbox').getElement('ul.slides').getElements('li'),
        'navigation': $('pushbox').getElement('ul.pushbox_nav').getElements('li'),
        'delay': 8
    });
}


/**
* initialises Step By Step question tree
*
* @author Klaas Dieleman <klaas[AT]efocus.nl>
* @return void
*/

function initSteps() {
    if (!document.getElement('ul.keuzemaken')) return false;

    var steps = new Steps({
        'list': document.getElement('ul.keuzemaken'),
        'loadingImgUrl': '/html/images/2010/loading.gif',
        'loadingImgOffset': { x: 10, y: 30 }
    });
}


/**
* initAccordion
*
* puts Specifications list in an accordion
*
* @editor Phi Son Do <phison.do{AT}efocus.nl>
* @return void
*/

function initAccordion() {
    if (!document.getElement('div.accordion')) return false;

    specsAccordion = new Accordion($$('div.accordion ul li h4'), $$('div.accordion div.answer_block'), {
        onActive: function(toggler) {
            toggler.getParent().addClass('open');
        },
        onBackground: function(toggler) {
            toggler.getParent().removeClass('open');
        },
        alwaysHide: true,
        show: 0
    });
}


/**
* initNewsTicker
*
* @author Phi Son Do <phison.do{AT}efocus.nl>
* @return void
*/

function initNewsTicker() {
    if (!$('news_ticker')) return false

    var newsTicker = new Ticker({
        elMainDiv: $('news_ticker'),
        speedIn: 500,
        speedOut: 500,
        delayOut: 3000,
        elNextBut: $("news_ticker").getElement('a.next'),
        elPrevBut: $("news_ticker").getElement('a.prev')
    });

};


/**
* initDatePicker
*
* @author Rocco Janse <rocco@efocus.nl>
* @since 1.0, 18 nov 2009
* @return void
*/

function initDatePicker() {
    if ($(document.body).getElement('input.date')) {
        new DatePicker('input.date', {
            pickerClass: 'datepicker_vista',
            'allowEmpty': true,
            'inputOutputFormat': 'd-m-Y'
        });
    };
}


/**
* Tooltip
*
* @author Phi Son Do <phison.do{AT}efocus.nl>
* @return void
*/

function toolTip() {
    if (!document.getElement('.tooltip')) return false

    var TipsFixed = new Class({ Extends: Tips,

        /*
        *      ---------------------------------------------------
        *      Fixed the element.getParent() is not a function bug
        *      by not only checking for element but for the
        *      getParent() as a function
        *
        *      Works for Moo-More 1.2.4.1+2
        *      ---------------------------------------------------
        */

        fireForParent: function(event, element) {
            if (element && typeof element.getParent() == 'function') {
                parentNode = element.getParent();
                if (parentNode == document.body) return;
                if (parentNode.retrieve('tip:enter'))
                    parentNode.fireEvent('mouseenter', event);
                else this.fireForParent(parentNode, event);
            } else return;
        }
    });

    $$('.tooltip').each(function(element, index) {
        var content = element.get('title').split('::');
        element.store('tip:title', content[0]);
        element.store('tip:text', content[1]);
    });

    var toolTip = new TipsFixed('.tooltip', {
        offset: { x: -184, y: -6 },
        fixed: true
    });

}


/**
* initialize q-go lightbox
*
* @author Ralph Meeuws <ralph.meeuws[AT]efocus.nl>
* @author Klaas Dieleman <klaas[AT]efocus.nl>
* @since 1.1, 7 dec 2009
* @return void
*/

function initQgo() {
    if (!$(document).getElement('.qgo_search') || !$('qgo_container')) return false;

    var elSearchInput = $(document.body).getElement('.qgo_search').getElement('input');
    var elSearchButton = $(document.body).getElement('.qgo_search').getElement('a.button');
    if (!elSearchInput || !elSearchButton) return false;

    var sbContent = $('qgo_container').clone(false);
    sbContent.adopt($('qgo_container').getChildren());
    $('qgo_container').dispose();

    var qgoFrame = new Element('iframe', {
        'frameborder': '0',
        'height': '366',
        'width': '866',
        'scrolling': 'no'
    });

    var closeText = 'sluiten';
    if ($('sb-nav-close').get('title')) {
        closeText = $('sb-nav-close').get('title');
    }

    var closeBtn = new Element('a', {
        'class': 'qgo_lb_close',
        'href': 'javascript:void(0)',
        'html': closeText
    });
    closeBtn.addEvent('click', function(event) {
        event.stop;
        Shadowbox.close();
    });

    var orgHref = new Array;

    sbContent.getElements('ul.qgo_nav a').each(function(item, index) {
        orgHref[index] = item.getProperty('href');
        item.href = 'javascript:void(0);';
    });

    var switchTab = function(tab) {
        $('sb-body-inner').getElements('ul.qgo_nav li').removeClass('active');
        $('sb-body-inner').getElements('ul.qgo_nav li')[tab].addClass('active');

        var url = orgHref[tab];
        if (tab == 0) url += '&q=' + elSearchInput.value
        qgoFrame.setProperty('src', url);
    };

    var openLightbox = function(tab) {
        Shadowbox.options.onFinish = function() {
            closeBtn.inject($('sb-content'), 'top');
            qgoFrame.injectInside($('sb-content'));

            $('sb-body-inner').getElements('ul.qgo_nav li').each(function(item, index) {
                item.addEvent('click', function(ev) {
                    var ev = new Event(ev);
                    ev.stop();
                    switchTab(index);
                });
            });

            switchTab(tab);

        };

        objQgo = {
            player: 'html',
            content: sbContent.get('html'),
            height: 429,
            width: 914
        };

        Shadowbox.open(objQgo);

    };

    elSearchInput.addEvent('keydown', function(event) {
        event = new Event(event);
        if (event.key == 'enter') {
            openLightbox(0);
            elSearchInput.blur();
        }
    });

    elSearchButton.addEvents({
        'keydown': function(event) {
            event = new Event(event);
            if (event.key == 'enter') openLightbox(0)
        },
        'click': function(event) { openLightbox(0) }
    });

    if (!$(document).getElement('.qgo_search_content')) return false;
    var elSearchInput_content = $(document.body).getElement('.qgo_search_content').getElement('input');
    var elSearchButton_content = $(document.body).getElement('.qgo_search_content').getElement('a.button');
    if (!elSearchInput_content || !elSearchButton_content) return false;

    var switchTab_content = function(tab) {
        $('sb-body-inner').getElements('ul.qgo_nav li').removeClass('active');
        $('sb-body-inner').getElements('ul.qgo_nav li')[tab].addClass('active');

        var url = orgHref[tab];
        if (tab == 0) url += '&q=' + elSearchInput_content.value
        qgoFrame.setProperty('src', url);
    };

    var openLightbox_content = function(tab) {
        Shadowbox.options.onFinish = function() {
            closeBtn.inject($('sb-content'), 'top');
            qgoFrame.injectInside($('sb-content'));

            $('sb-body-inner').getElements('ul.qgo_nav li').each(function(item, index) {
                item.addEvent('click', function(ev) {
                    var ev = new Event(ev);
                    ev.stop();
                    switchTab_content(index);
                });
            });

            switchTab_content(tab);

        };

        objQgo = {
            player: 'html',
            content: sbContent.get('html'),
            height: 429,
            width: 914
        };

        Shadowbox.open(objQgo);

    };

    elSearchInput_content.addEvent('keydown', function(event) {
        event = new Event(event);
        if (event.key == 'enter') {
            openLightbox_content(0);
            elSearchInput_content.blur();
        }
    });

    elSearchButton_content.addEvents({
        'keydown': function(event) {
            event = new Event(event);
            if (event.key == 'enter') openLightbox_content(0)
        },
        'click': function(event) { openLightbox_content(0) }
    });

}/*	SWFObject v2.0 rc1 <http://code.google.com/p/swfobject/>
	Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis
	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/

var swfobject=function(){var _1=[];var _2=[];var _3=null;var _4=null;var _5=false;var _6=false;var ua=function(){var _8=typeof document.getElementById!="undefined"&&typeof document.getElementsByTagName!="undefined"&&typeof document.createElement!="undefined"&&typeof document.appendChild!="undefined"&&typeof document.replaceChild!="undefined"&&typeof document.removeChild!="undefined"&&typeof document.cloneNode!="undefined";var _9=[0,0,0];var d=null;if(typeof navigator.plugins!="undefined"&&typeof navigator.plugins["Shockwave Flash"]=="object"){d=navigator.plugins["Shockwave Flash"].description;if(d){d=d.replace(/^.*\s+(\S+\s+\S+$)/,"$1");_9[0]=parseInt(d.replace(/^(.*)\..*$/,"$1"),10);_9[1]=parseInt(d.replace(/^.*\.(.*)\s.*$/,"$1"),10);_9[2]=/r/.test(d)?parseInt(d.replace(/^.*r(.*)$/,"$1"),10):0;}}else{if(typeof window.ActiveXObject!="undefined"){var a=null;var _c=false;try{a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_9=[6,0,21];a.AllowScriptAccess="always";}catch(e){if(_9[0]==6){_c=true;}}if(!_c){try{a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}}if(!_c&&typeof a=="object"){try{d=a.GetVariable("$version");if(d){d=d.split(" ")[1].split(",");_9=[parseInt(d[0],10),parseInt(d[1],10),parseInt(d[2],10)];}}catch(e){}}}}var u=navigator.userAgent.toLowerCase();var p=navigator.platform.toLowerCase();var _f=/webkit/.test(u);var _10=_f?parseFloat(u.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):0;var ie=false;var win=p?/win/.test(p):/win/.test(u);var mac=p?/mac/.test(p):/mac/.test(u);/*@cc_on ie=true;@if(@_win32)win=true;@elif(@_mac)mac=true;@end@*/return {w3cdom:_8,playerVersion:_9,webkit:_f,webkitVersion:_10,ie:ie,win:win,mac:mac};}();var _14=function(){if(!ua.w3cdom){return;}addDomLoadEvent(main);if(ua.ie&&ua.win){try{document.write("<script id=__ie_ondomload defer=true src=//:></script>");var s=document.getElementById("__ie_ondomload");if(s){s.onreadystatechange=function(){if(this.readyState=="complete"){this.parentNode.removeChild(this);callDomLoadFunctions();}};}}catch(e){}}if(ua.webkit&&typeof document.readyState!="undefined"){_3=setInterval(function(){if(/loaded|complete/.test(document.readyState)){callDomLoadFunctions();}},10);}if(typeof document.addEventListener!="undefined"){document.addEventListener("DOMContentLoaded",callDomLoadFunctions,null);}addLoadEvent(callDomLoadFunctions);}();function callDomLoadFunctions(){if(_5){return;}if(ua.ie&&ua.win){var s=document.createElement("span");try{var t=document.getElementsByTagName("body")[0].appendChild(s);t.parentNode.removeChild(t);}catch(e){return;}}_5=true;if(_3){clearInterval(_3);_3=null;}var dl=_1.length;for(var i=0;i<dl;i++){_1[i]();}}function addDomLoadEvent(fn){if(_5){fn();}else{_1[_1.length]=fn;}}function addLoadEvent(fn){if(typeof window.addEventListener!="undefined"){window.addEventListener("load",fn,false);}else{if(typeof document.addEventListener!="undefined"){document.addEventListener("load",fn,false);}else{if(typeof window.attachEvent!="undefined"){window.attachEvent("onload",fn);}else{if(typeof window.onload=="function"){var _1c=window.onload;window.onload=function(){_1c();fn();};}else{window.onload=fn;}}}}}function main(){var rl=_2.length;for(var i=0;i<rl;i++){var id=_2[i].id;if(ua.playerVersion[0]>0){var obj=document.getElementById(id);if(obj){if(hasPlayerVersion(_2[i].swfVersion)){if(ua.webkit&&ua.webkitVersion<312){fixParams(obj);}}else{if(_2[i].expressInstall&&!_6&&hasPlayerVersion([6,0,65])&&(ua.win||ua.mac)){showExpressInstall(_2[i]);}else{displayAltContent(obj);}}}}createCSS("#"+id,"visibility:visible");}}function fixParams(obj){var _22=obj.getElementsByTagName("object")[0];if(_22){var e=document.createElement("embed");var a=_22.attributes;if(a){var al=a.length;for(var i=0;i<al;i++){if(a[i].nodeName.toLowerCase()=="data"){e.setAttribute("src",a[i].nodeValue);}else{e.setAttribute(a[i].nodeName,a[i].nodeValue);}}}var c=_22.childNodes;if(c){var cl=c.length;for(var j=0;j<cl;j++){if(c[j].nodeType==1&&c[j].nodeName.toLowerCase()=="param"){e.setAttribute(c[j].getAttribute("name"),c[j].getAttribute("value"));}}}obj.parentNode.replaceChild(e,obj);}}function fixObjectLeaks(){if(ua.ie&&ua.win&&hasPlayerVersion([8,0,0])){window.attachEvent("onunload",function(){var o=document.getElementsByTagName("object");if(o){var ol=o.length;for(var i=0;i<ol;i++){o[i].style.display="none";for(var x in o[i]){if(typeof o[i][x]=="function"){o[i][x]=function(){};}}}}});}}function showExpressInstall(_2e){_6=true;var obj=document.getElementById(_2e.id);if(obj){if(_2e.altContentId){var ac=document.getElementById(_2e.altContentId);if(ac){_4=ac;}}else{_4=abstractAltContent(obj);}var w=_2e.width?_2e.width:(obj.getAttribute("width")?obj.getAttribute("width"):0);if(parseInt(w,10)<310){w="310";}var h=_2e.height?_2e.height:(obj.getAttribute("height")?obj.getAttribute("height"):0);if(parseInt(h,10)<137){h="137";}var pt=ua.ie&&ua.win?"ActiveX":"PlugIn";document.title=document.title.slice(0,47)+" - Flash Player Installation";var dt=document.title;var fv="MMredirectURL="+window.location+"&MMplayerType="+pt+"&MMdoctitle="+dt;var el=obj;if(ua.ie&&ua.win&&obj.readyState!=4){el=document.createElement("div");obj.parentNode.insertBefore(el,obj);obj.style.display="none";window.attachEvent("onload",function(){obj.parentNode.removeChild(obj);});}createSWF({data:_2e.expressInstall,id:"SWFObjectExprInst",width:w,height:h},{flashvars:fv},el);}}function displayAltContent(obj){if(ua.ie&&ua.win&&obj.readyState!=4){var el=document.createElement("div");obj.parentNode.insertBefore(el,obj);el.parentNode.replaceChild(abstractAltContent(obj),el);obj.style.display="none";window.attachEvent("onload",function(){obj.parentNode.removeChild(obj);});}else{obj.parentNode.replaceChild(abstractAltContent(obj),obj);}}function abstractAltContent(obj){var ac=document.createElement("div");if(ua.win&&ua.ie){ac.innerHTML=obj.innerHTML;}else{var _3b=obj.getElementsByTagName("object")[0];if(_3b){var c=_3b.childNodes;if(c){var cl=c.length;for(var i=0;i<cl;i++){if(!(c[i].nodeType==1&&c[i].nodeName.toLowerCase()=="param")&&!(c[i].nodeType==8)){ac.appendChild(c[i].cloneNode(true));}}}}}return ac;}function createSWF(_3f,_40,el){if(ua.ie&&ua.win){var att="";for(var i in _3f){if(typeof _3f[i]=="string"){if(i=="data"){_40.movie=_3f[i];}else{if(i.toLowerCase()=="styleclass"){att+=" class=\""+_3f[i]+"\"";}else{if(i!="classid"){att+=" "+i+"=\""+_3f[i]+"\"";}}}}}var par="";for(var j in _40){if(typeof _40[j]=="string"){par+="<param name=\""+j+"\" value=\""+_40[j]+"\" />";}}el.outerHTML="<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\""+att+">"+par+"</object>";fixObjectLeaks();}else{if(ua.webkit&&ua.webkitVersion<312){var e=document.createElement("embed");e.setAttribute("type","application/x-shockwave-flash");for(var k in _3f){if(typeof _3f[k]=="string"){if(k=="data"){e.setAttribute("src",_3f[k]);}else{if(k.toLowerCase()=="styleclass"){e.setAttribute("class",_3f[k]);}else{if(k!="classid"){e.setAttribute(k,_3f[k]);}}}}}for(var l in _40){if(typeof _40[l]=="string"){if(l!="movie"){e.setAttribute(l,_40[l]);}}}el.parentNode.replaceChild(e,el);}else{var o=document.createElement("object");o.setAttribute("type","application/x-shockwave-flash");for(var m in _3f){if(typeof _3f[m]=="string"){if(m.toLowerCase()=="styleclass"){o.setAttribute("class",_3f[m]);}else{if(m!="classid"){o.setAttribute(m,_3f[m]);}}}}for(var n in _40){if(typeof _40[n]=="string"&&n!="movie"){createObjParam(o,n,_40[n]);}}el.parentNode.replaceChild(o,el);}}}function createObjParam(el,_4d,_4e){var p=document.createElement("param");p.setAttribute("name",_4d);p.setAttribute("value",_4e);el.appendChild(p);}function hasPlayerVersion(rv){return (ua.playerVersion[0]>rv[0]||(ua.playerVersion[0]==rv[0]&&ua.playerVersion[1]>rv[1])||(ua.playerVersion[0]==rv[0]&&ua.playerVersion[1]==rv[1]&&ua.playerVersion[2]>=rv[2]))?true:false;}function createCSS(sel,_52){if(ua.ie&&ua.mac){return;}var h=document.getElementsByTagName("head")[0];var s=document.createElement("style");s.setAttribute("type","text/css");s.setAttribute("media","screen");if(!(ua.ie&&ua.win)&&typeof document.createTextNode!="undefined"){s.appendChild(document.createTextNode(sel+" {"+_52+"}"));}h.appendChild(s);if(ua.ie&&ua.win&&typeof document.styleSheets!="undefined"&&document.styleSheets.length>0){var ls=document.styleSheets[document.styleSheets.length-1];if(typeof ls.addRule=="object"){ls.addRule(sel,_52);}}}return {registerObject:function(_56,_57,_58){if(!ua.w3cdom||!_56||!_57){return;}var _59={};_59.id=_56;var v=_57.split(".");_59.swfVersion=[parseInt(v[0],10),parseInt(v[1],10),parseInt(v[2],10)];_59.expressInstall=_58?_58:false;_2[_2.length]=_59;createCSS("#"+_56,"visibility:hidden");},getObjectById:function(_5b){var r=null;if(ua.w3cdom&&_5){var o=document.getElementById(_5b);if(o){var n=o.getElementsByTagName("object")[0];if(!n||(n&&typeof o.SetVariable!="undefined")){r=o;}else{if(typeof n.SetVariable!="undefined"){r=n;}}}}return r;},embedSWF:function(_5f,_60,_61,_62,_63,_64,_65,_66,_67){if(!ua.w3cdom||!_5f||!_60||!_61||!_62||!_63){return;}if(hasPlayerVersion(_63.split("."))){createCSS("#"+_60,"visibility:hidden");var att=(typeof _67=="object")?_67:{};att.data=_5f;att.width=_61;att.height=_62;var par=(typeof _66=="object")?_66:{};if(typeof _65=="object"){for(var i in _65){if(typeof _65[i]=="string"){if(typeof par.flashvars!="undefined"){par.flashvars+="&"+i+"="+_65[i];}else{par.flashvars=i+"="+_65[i];}}}}addDomLoadEvent(function(){createSWF(att,par,document.getElementById(_60));createCSS("#"+_60,"visibility:visible");});}else{if(_64&&!_6&&hasPlayerVersion([6,0,65])&&(ua.win||ua.mac)){createCSS("#"+_60,"visibility:hidden");addDomLoadEvent(function(){var _6b={};_6b.id=_6b.altContentId=_60;_6b.width=_61;_6b.height=_62;_6b.expressInstall=_64;showExpressInstall(_6b);createCSS("#"+_60,"visibility:visible");});}}},getFlashPlayerVersion:function(){return {major:ua.playerVersion[0],minor:ua.playerVersion[1],release:ua.playerVersion[2]};},hasFlashPlayerVersion:function(_6c){return hasPlayerVersion(_6c.split("."));},createSWF:function(_6d,_6e,el){if(ua.w3cdom&&_5){createSWF(_6d,_6e,el);}},createCSS:function(sel,_71){if(ua.w3cdom){createCSS(sel,_71);}},addDomLoadEvent:addDomLoadEvent,addLoadEvent:addLoadEvent,getQueryParamValue:function(_72){var q=document.location.search||document.location.hash;if(_72==null){return q;}if(q){var _74=q.substring(1).split("&");for(var i=0;i<_74.length;i++){if(_74[i].substring(0,_74[i].indexOf("="))==_72){return _74[i].substring((_74[i].indexOf("=")+1));}}}return "";},expressInstallCallback:function(){if(_6&&_4){var obj=document.getElementById("SWFObjectExprInst");if(obj){obj.parentNode.replaceChild(_4,obj);_4=null;_6=false;}}}};}();