var _pm = (function() { 
    var B=0,P={},s={},_id=0;
    function inT(x,i){B=x;_id=i;bind();} function saT(x){P[x]=g();} function spT(x){var F=P[x]||B,D=g();s[x]=D-F;} function g(){return(new Date()).getTime();} 
    function m(){ 
        if( s.ready > 4000) globals.prbench = true;
        if(globals.prbench) {
            var i=0,m=15000,stt=g(),run=true;
            saT('bench'); var str = ''; for(;i<m&&run;i++){str=i+'tho'; run=(g()-stt<400); } spT('bench');
            if(!run) { s.bench = ( 400 / i ) *m; }
        }
        var d={id:_id,url:window.location.toString(),times:s,html:document.documentElement.innerHTML.length,dom:$('*').length,img:$('img').length,ngifs:$('img[src$=n.gif]').length,chrome_frame:(/x-clock|chromeframe/).test(navigator.userAgent)};
        if(!globals.workServer) $.post('xyz.html',d);
    }

    function bind(){$(document).ready(function(){spT('ready'); }); $(window).load(function(){spT('load'); m(); });}
    return {init:inT,start:saT,stop:spT};
})();

$(document).ready( function() {

    if( typeof globals !== 'undefined' && globals.bg_link ) {

        var $popup    = $('#oo-bgimage-window');

        var cbBGImage = function(e, that ) {

                var relativeX = e.pageX - that.offsetLeft;
                var relativeY = e.pageY - that.offsetTop;

                if( relativeX <= 313 && relativeY <= 900  ) {
                    $(that).css('cursor', 'pointer');
                    return true;
                }else{
                    $(that).css('cursor', 'auto');
                    return false;
                }
        };

        $('#oo-bgimage')
            .mousemove( function(e) {
                cbBGImage(e, this );      
            })
            .click( function(e) {
                
                var inside = cbBGImage( e, this );

                if( inside && !$popup.is(':visible') ) {

                    var _left = (e.pageX+7);
                    var _top  = (e.pageY+7);
                    var _winW = $(window).width();
                    var _winH = $(window).height();

                    if( _winW < _left + $popup.width() + 10 ) {
                        _left = e.pageX - $popup.width() - 10;
                    }

                    if( _winH  < _top + $popup.height() + 10 ) {
                         _top = e.pageY - $popup.height() - 10;
                    }

                    $popup
                        .css({ 'left': _left + 'px', 'top': _top +'px' })
                        .fadeIn( 400 );
                }else{
                    $popup.fadeOut( 300 ); 
                }

            })
            .bind('clickoutside', function() {
                $popup.fadeOut( 300 ); 
            });

    }

    var $fList = $('ul.flags');
    var $curFlag = null;

    $fList
        .mouseenter( function() {
            $curFlag = $('li a.flag-hl', $fList);
            $('li a', $fList).addClass('flag-hl');
        })
        .mouseleave( function() {
                $('li a', $fList).not( $curFlag ).removeClass('flag-hl');
        });
        
    $('#etcwgtab').change( function() {
        document.location = $(this).val();
    });

    var $topform = $('.topmarken form');
    
    $('button', $topform).mousedown( function() {

        var $btn = $(this);
        var key = $('input[type="hidden"][name="prod_group_key"]').val();

        $(this).text('.').everyTime( 600, 'dot', function() {
            if( $(this).text().length >= 3 ){
                $(this).text('.');
            }else{
                $(this).text( $(this).text() + '.' );
            }
        });

        $.get('cat_brandajax.html', { 'prod_group_key': key }, function( fields ) {

            $btn.stopTime('dot');

            var $select = $('<select name="topbrandselector"></select>');
            $select.append('<option value=""></option>');

            $.each( fields,  function( name, url ) { $select.append('<option value="' + url + '">' + name + '</option>'); });

            $btn.unbind('click').replaceWith( $select);

            $select.change( function() {
                if( $(this).val() != ''){
                    document.location.href = $(this).val();
                }
            });
            
        }, 'json');

    });

    if ($.browser.msie && $.browser.version.substr(0,1)<7) {
        $('.odd-height, .odd-width').each( function(){
            if( $(this).hasClass('odd-width') ){
                var w = $(this).width(); $(this).width( w-(w%2) );
            } 
            if( $(this).hasClass('odd-height') ){
                var h = $(this).height(); $(this).height( h-(h%2) );
            } 
        });
    }

    $('#sidebar_basket_moreentry').click( function() {
        $('.sidebar_basket_hiderow').show();
        $(this).hide();
    } );

});

String.prototype.trim = function () {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
};

if( !window.console ) {
    if( typeof globals == 'undefined'  || !globals.workServer ) {
        window.console={log:function(){}};
    } else {
        window.console={log:function(){
            if( arguments.length ) {
                for(var i=0;i<arguments.length;i++){   
                    ( !$('#thonsole-div').length ? $('<div/>').attr('id','thonsole-div').appendTo( $('body') ) : $('#thonsole-div') ).append( arguments[i].toString() + '<br>' );
                }
            }
        }};
    }
}
var var_dump=console.log;
String.prototype.log = function(){ console.log(this); return this; };
 
String.prototype.alert = function( b ) { //b == true ? surpress alert!
    if ( globals.workServer && !b ) alert( this );
    return this;
};

String.prototype.charRefToUnicode = function() {
    return this.replace(/&#(([0-9]{1,7})|(x[0-9a-f]{1,6}));?/gi,
        function(match, p1, p2, p3, offset, s) {
            return String.fromCharCode(p2 || ("0" + p3));
        });
}

function isChar( chr ) {
    return ( (chr >= 65 && chr <= 90) || chr == 0 || (chr >= 128 && chr <= 255 ));
}
function isNum( chr ) {
    return ( (chr >= 48 && chr <= 57) || (chr >= 97 && chr <= 105) ); // 97-105 for numpad
}


var style = [ ".jsAvail{display:block !important;}", '.noJS{display:none}' ];
if( style.length > 0 ){
    $('head').append('<style>'+ style.join(' ') + ' </style>');
}


$(function(){
    $.extend($.fn.disableTextSelect = function() {
        return this.each(function(){
            if($.browser.mozilla){//Firefox
                $(this).css('MozUserSelect','none');
            }else if($.browser.msie){//IE
                $(this).bind('selectstart',function(){return false;});
            }else{//Opera, etc.
                $(this).mousedown(function(){return false;});
            }
        });
    });
    $('.noSelect').disableTextSelect();//No text selection on elements with a class of 'noSelect'
});

/*
 * jQuery outside events - v1.1 - 3/16/2010
 * http://benalman.com/projects/jquery-outside-events-plugin/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */
(function($,c,b){$.map("click dblclick mousemove mousedown mouseup mouseover mouseout change select submit keydown keypress keyup".split(" "),function(d){a(d)});a("focusin","focus"+b);a("focusout","blur"+b);$.addOutsideEvent=a;function a(g,e){e=e||g+b;var d=$(),h=g+"."+e+"-special-event";$.event.special[e]={setup:function(){d=d.add(this);if(d.length===1){$(c).bind(h,f)}},teardown:function(){d=d.not(this);if(d.length===0){$(c).unbind(h)}},add:function(i){var j=i.handler;i.handler=function(l,k){l.target=k;j.apply(this,arguments)}}};function f(i){$(d).each(function(){var j=$(this);if(this!==i.target&&!j.has(i.target).length){j.triggerHandler(e,[i.target])}})}}})(jQuery,document,"outside");

/**
 * jQuery.timers - Timer abstractions for jQuery
 * Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)
 * Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
 * Date: 2009/10/16
 *
 * @author Blair Mitchelmore
 * @version 1.2
 *
 **/

jQuery.fn.extend({everyTime:function(interval,label,fn,times){return this.each(function(){jQuery.timer.add(this,interval,label,fn,times);});},oneTime:function(interval,label,fn){return this.each(function(){jQuery.timer.add(this,interval,label,fn,1);});},stopTime:function(label,fn){return this.each(function(){jQuery.timer.remove(this,label,fn);});}});jQuery.extend({timer:{global:[],guid:1,dataKey:"jQuery.timer",regex:/^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/,powers:{'ms':1,'cs':10,'ds':100,'s':1000,'das':10000,'hs':100000,'ks':1000000},timeParse:function(value){if(value==undefined||value==null)
return null;var result=this.regex.exec(jQuery.trim(value.toString()));if(result[2]){var num=parseFloat(result[1]);var mult=this.powers[result[2]]||1;return num*mult;}else{return value;}},add:function(element,interval,label,fn,times){var counter=0;if(jQuery.isFunction(label)){if(!times)
times=fn;fn=label;label=interval;}
interval=jQuery.timer.timeParse(interval);if(typeof interval!='number'||isNaN(interval)||interval<0)
return;if(typeof times!='number'||isNaN(times)||times<0)
times=0;times=times||0;var timers=jQuery.data(element,this.dataKey)||jQuery.data(element,this.dataKey,{});if(!timers[label])
timers[label]={};fn.timerID=fn.timerID||this.guid++;var handler=function(){if((++counter>times&&times!==0)||fn.call(element,counter)===false)
jQuery.timer.remove(element,label,fn);};handler.timerID=fn.timerID;if(!timers[label][fn.timerID])
timers[label][fn.timerID]=window.setInterval(handler,interval);this.global.push(element);},remove:function(element,label,fn){var timers=jQuery.data(element,this.dataKey),ret;if(timers){if(!label){for(label in timers)
this.remove(element,label,fn);}else if(timers[label]){if(fn){if(fn.timerID){window.clearInterval(timers[label][fn.timerID]);delete timers[label][fn.timerID];}}else{for(var fn in timers[label]){window.clearInterval(timers[label][fn]);delete timers[label][fn];}}
for(ret in timers[label])break;if(!ret){ret=null;delete timers[label];}}
for(ret in timers)break;if(!ret)
jQuery.removeData(element,this.dataKey);}}}});jQuery(window).bind("unload",function(){jQuery.each(jQuery.timer.global,function(index,item){jQuery.timer.remove(item);});});

/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-07-21 18:45:56 -0500 (Sat, 21 Jul 2007) $
 * $Rev: 2447 $
 *
 * Version 2.1.1
 */

(function($){$.fn.bgIframe=$.fn.bgiframe=function(s){if($.browser.msie&&/6.0/.test(navigator.userAgent)){s=$.extend({top:'auto',left:'auto',width:'auto',height:'auto',opacity:true,src:'javascript:false;'},s||{});var prop=function(n){return n&&n.constructor==Number?n+'px':n;},html='<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+'style="display:block;position:absolute;z-index:-1;'+(s.opacity!==false?'filter:Alpha(Opacity=\'0\');':'')+'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+'"/>';return this.each(function(){if($('> iframe.bgiframe',this).length==0)this.insertBefore(document.createElement(html),this.firstChild);});}return this;};})(jQuery);

/*
 * Lazy Load - jQuery plugin for lazy loading images
 * Copyright (c) 2007-2009 Mika Tuupola
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 * Project home:
 *   http://www.appelsiini.net/projects/lazyload
 * Version:  1.5.0
 */

(function($){$.fn.lazyload=function(options){var settings={threshold:0,failurelimit:0,event:"scroll",effect:"show",container:window};if(options){$.extend(settings,options);}
var elements=this;if("scroll"==settings.event){$(settings.container).bind("scroll",function(event){var counter=0;elements.each(function(){if($.abovethetop(this,settings)||$.leftofbegin(this,settings)){}else if(!$.belowthefold(this,settings)&&!$.rightoffold(this,settings)){$(this).trigger("appear");}else{if(counter++>settings.failurelimit){return false;}}});var temp=$.grep(elements,function(element){return!element.loaded;});elements=$(temp);});}
this.each(function(){var self=this;if(undefined==$(self).attr("original")){$(self).attr("original",$(self).attr("src"));}
if("scroll"!=settings.event||undefined==$(self).attr("src")||settings.placeholder==$(self).attr("src")||($.abovethetop(self,settings)||$.leftofbegin(self,settings)||$.belowthefold(self,settings)||$.rightoffold(self,settings))){if(settings.placeholder){$(self).attr("src",settings.placeholder);}else{$(self).removeAttr("src");}
self.loaded=false;}else{self.loaded=true;}
$(self).one("appear",function(){if(!this.loaded){$("<img />").bind("load",function(){$(self).hide().attr("src",$(self).attr("original"))
[settings.effect](settings.effectspeed);self.loaded=true;}).attr("src",$(self).attr("original"));};});if("scroll"!=settings.event){$(self).bind(settings.event,function(event){if(!self.loaded){$(self).trigger("appear");}});}});$(settings.container).trigger(settings.event);return this;};$.belowthefold=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).height()+$(window).scrollTop();}else{var fold=$(settings.container).offset().top+$(settings.container).height();}
return fold<=$(element).offset().top-settings.threshold;};$.rightoffold=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).width()+$(window).scrollLeft();}else{var fold=$(settings.container).offset().left+$(settings.container).width();}
return fold<=$(element).offset().left-settings.threshold;};$.abovethetop=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).scrollTop();}else{var fold=$(settings.container).offset().top;}
return fold>=$(element).offset().top+settings.threshold+$(element).height();};$.leftofbegin=function(element,settings){if(settings.container===undefined||settings.container===window){var fold=$(window).scrollLeft();}else{var fold=$(settings.container).offset().left;}
return fold>=$(element).offset().left+settings.threshold+$(element).width();};$.extend($.expr[':'],{"below-the-fold":"$.belowthefold(a, {threshold : 0, container: window})","above-the-fold":"!$.belowthefold(a, {threshold : 0, container: window})","right-of-fold":"$.rightoffold(a, {threshold : 0, container: window})","left-of-fold":"!$.rightoffold(a, {threshold : 0, container: window})"});})(jQuery);

/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 3/9/2009
 * @author Ariel Flesler
 * @version 1.4.1
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function($){var m=$.scrollTo=function(b,h,f){$(window).scrollTo(b,h,f)};m.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1};m.window=function(b){return $(window).scrollable()};$.fn.scrollable=function(){return this.map(function(){var b=this,h=!b.nodeName||$.inArray(b.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!h)return b;var f=(b.contentWindow||b).document||b.ownerDocument||b;return $.browser.safari||f.compatMode=='BackCompat'?f.body:f.documentElement})};$.fn.scrollTo=function(l,j,a){if(typeof j=='object'){a=j;j=0}if(typeof a=='function')a={onAfter:a};if(l=='max')l=9e9;a=$.extend({},m.defaults,a);j=j||a.speed||a.duration;a.queue=a.queue&&a.axis.length>1;if(a.queue)j/=2;a.offset=n(a.offset);a.over=n(a.over);return this.scrollable().each(function(){var k=this,o=$(k),d=l,p,g={},q=o.is('html,body');switch(typeof d){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px)?$/.test(d)){d=n(d);break}d=$(d,this);case'object':if(d.is||d.style)p=(d=$(d)).offset()}$.each(a.axis.split(''),function(b,h){var f=h=='x'?'Left':'Top',i=f.toLowerCase(),c='scroll'+f,r=k[c],s=h=='x'?'Width':'Height';if(p){g[c]=p[i]+(q?0:r-o.offset()[i]);if(a.margin){g[c]-=parseInt(d.css('margin'+f))||0;g[c]-=parseInt(d.css('border'+f+'Width'))||0}g[c]+=a.offset[i]||0;if(a.over[i])g[c]+=d[s.toLowerCase()]()*a.over[i]}else g[c]=d[i];if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],u(s));if(!b&&a.queue){if(r!=g[c])t(a.onAfterFirst);delete g[c]}});t(a.onAfter);function t(b){o.animate(g,j,a.easing,b&&function(){b.call(this,l,a)})};function u(b){var h='scroll'+b;if(!q)return k[h];var f='client'+b,i=k.ownerDocument.documentElement,c=k.ownerDocument.body;return Math.max(i[h],c[h])-Math.min(i[f],c[f])}}).end()};function n(b){return typeof b=='object'?b:{top:b,left:b}}})(jQuery);

/* Copyright (c) 2009 Brandon Aaron (http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
 *
 * Version: 3.0.2
 * 
 * Requires: 1.2.2+
 */
(function(c){var a=["DOMMouseScroll","mousewheel"];c.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var d=a.length;d;){this.addEventListener(a[--d],b,false)}}else{this.onmousewheel=b}},teardown:function(){if(this.removeEventListener){for(var d=a.length;d;){this.removeEventListener(a[--d],b,false)}}else{this.onmousewheel=null}}};c.fn.extend({mousewheel:function(d){return d?this.bind("mousewheel",d):this.trigger("mousewheel")},unmousewheel:function(d){return this.unbind("mousewheel",d)}});function b(f){var d=[].slice.call(arguments,1),g=0,e=true;f=c.event.fix(f||window.event);f.type="mousewheel";if(f.wheelDelta){g=f.wheelDelta/120}if(f.detail){g=-f.detail/3}d.unshift(f,g);return c.event.handle.apply(this,d)}})(jQuery);

/**
* jQuery MD5 hash algorithm function
* 
* @alias Muhammad Hussein Fattahizadeh < muhammad [AT] semnanweb [DOT] com >
* @link http://www.semnanweb.com/jquery-plugin/md5.html
* @see http://www.webtoolkit.info/
* @license http://www.gnu.org/licenses/gpl.html [GNU General Public License]
* @param {jQuery} {md5:function(string))
* @return
*/
(function($){var rotateLeft=function(lValue,iShiftBits){return(lValue<<iShiftBits)|(lValue>>>(32-iShiftBits));}
var addUnsigned=function(lX,lY){var lX4,lY4,lX8,lY8,lResult;lX8=(lX&0x80000000);lY8=(lY&0x80000000);lX4=(lX&0x40000000);lY4=(lY&0x40000000);lResult=(lX&0x3FFFFFFF)+(lY&0x3FFFFFFF);if(lX4&lY4)return(lResult^0x80000000^lX8^lY8);if(lX4|lY4){if(lResult&0x40000000)return(lResult^0xC0000000^lX8^lY8);else return(lResult^0x40000000^lX8^lY8);}else{return(lResult^lX8^lY8);}}
var F=function(x,y,z){return(x&y)|((~x)&z);}
var G=function(x,y,z){return(x&z)|(y&(~z));}
var H=function(x,y,z){return(x^y^z);}
var I=function(x,y,z){return(y^(x|(~z)));}
var FF=function(a,b,c,d,x,s,ac){a=addUnsigned(a,addUnsigned(addUnsigned(F(b,c,d),x),ac));return addUnsigned(rotateLeft(a,s),b);};var GG=function(a,b,c,d,x,s,ac){a=addUnsigned(a,addUnsigned(addUnsigned(G(b,c,d),x),ac));return addUnsigned(rotateLeft(a,s),b);};var HH=function(a,b,c,d,x,s,ac){a=addUnsigned(a,addUnsigned(addUnsigned(H(b,c,d),x),ac));return addUnsigned(rotateLeft(a,s),b);};var II=function(a,b,c,d,x,s,ac){a=addUnsigned(a,addUnsigned(addUnsigned(I(b,c,d),x),ac));return addUnsigned(rotateLeft(a,s),b);};var convertToWordArray=function(string){var lWordCount;var lMessageLength=string.length;var lNumberOfWordsTempOne=lMessageLength+8;var lNumberOfWordsTempTwo=(lNumberOfWordsTempOne-(lNumberOfWordsTempOne%64))/64;var lNumberOfWords=(lNumberOfWordsTempTwo+1)*16;var lWordArray=Array(lNumberOfWords-1);var lBytePosition=0;var lByteCount=0;while(lByteCount<lMessageLength){lWordCount=(lByteCount-(lByteCount%4))/4;lBytePosition=(lByteCount%4)*8;lWordArray[lWordCount]=(lWordArray[lWordCount]|(string.charCodeAt(lByteCount)<<lBytePosition));lByteCount++;}
lWordCount=(lByteCount-(lByteCount%4))/4;lBytePosition=(lByteCount%4)*8;lWordArray[lWordCount]=lWordArray[lWordCount]|(0x80<<lBytePosition);lWordArray[lNumberOfWords-2]=lMessageLength<<3;lWordArray[lNumberOfWords-1]=lMessageLength>>>29;return lWordArray;};var wordToHex=function(lValue){var WordToHexValue="",WordToHexValueTemp="",lByte,lCount;for(lCount=0;lCount<=3;lCount++){lByte=(lValue>>>(lCount*8))&255;WordToHexValueTemp="0"+lByte.toString(16);WordToHexValue=WordToHexValue+WordToHexValueTemp.substr(WordToHexValueTemp.length-2,2);}
return WordToHexValue;};var uTF8Encode=function(string){string=string.replace(/\x0d\x0a/g,"\x0a");var output="";for(var n=0;n<string.length;n++){var c=string.charCodeAt(n);if(c<128){output+=String.fromCharCode(c);}else if((c>127)&&(c<2048)){output+=String.fromCharCode((c>>6)|192);output+=String.fromCharCode((c&63)|128);}else{output+=String.fromCharCode((c>>12)|224);output+=String.fromCharCode(((c>>6)&63)|128);output+=String.fromCharCode((c&63)|128);}}
return output;};$.extend({md5:function(string){var x=Array();var k,AA,BB,CC,DD,a,b,c,d;var S11=7,S12=12,S13=17,S14=22;var S21=5,S22=9,S23=14,S24=20;var S31=4,S32=11,S33=16,S34=23;var S41=6,S42=10,S43=15,S44=21;string=uTF8Encode(string);x=convertToWordArray(string);a=0x67452301;b=0xEFCDAB89;c=0x98BADCFE;d=0x10325476;for(k=0;k<x.length;k+=16){AA=a;BB=b;CC=c;DD=d;a=FF(a,b,c,d,x[k+0],S11,0xD76AA478);d=FF(d,a,b,c,x[k+1],S12,0xE8C7B756);c=FF(c,d,a,b,x[k+2],S13,0x242070DB);b=FF(b,c,d,a,x[k+3],S14,0xC1BDCEEE);a=FF(a,b,c,d,x[k+4],S11,0xF57C0FAF);d=FF(d,a,b,c,x[k+5],S12,0x4787C62A);c=FF(c,d,a,b,x[k+6],S13,0xA8304613);b=FF(b,c,d,a,x[k+7],S14,0xFD469501);a=FF(a,b,c,d,x[k+8],S11,0x698098D8);d=FF(d,a,b,c,x[k+9],S12,0x8B44F7AF);c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);a=FF(a,b,c,d,x[k+12],S11,0x6B901122);d=FF(d,a,b,c,x[k+13],S12,0xFD987193);c=FF(c,d,a,b,x[k+14],S13,0xA679438E);b=FF(b,c,d,a,x[k+15],S14,0x49B40821);a=GG(a,b,c,d,x[k+1],S21,0xF61E2562);d=GG(d,a,b,c,x[k+6],S22,0xC040B340);c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);b=GG(b,c,d,a,x[k+0],S24,0xE9B6C7AA);a=GG(a,b,c,d,x[k+5],S21,0xD62F105D);d=GG(d,a,b,c,x[k+10],S22,0x2441453);c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);b=GG(b,c,d,a,x[k+4],S24,0xE7D3FBC8);a=GG(a,b,c,d,x[k+9],S21,0x21E1CDE6);d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);c=GG(c,d,a,b,x[k+3],S23,0xF4D50D87);b=GG(b,c,d,a,x[k+8],S24,0x455A14ED);a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);d=GG(d,a,b,c,x[k+2],S22,0xFCEFA3F8);c=GG(c,d,a,b,x[k+7],S23,0x676F02D9);b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);a=HH(a,b,c,d,x[k+5],S31,0xFFFA3942);d=HH(d,a,b,c,x[k+8],S32,0x8771F681);c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);a=HH(a,b,c,d,x[k+1],S31,0xA4BEEA44);d=HH(d,a,b,c,x[k+4],S32,0x4BDECFA9);c=HH(c,d,a,b,x[k+7],S33,0xF6BB4B60);b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);d=HH(d,a,b,c,x[k+0],S32,0xEAA127FA);c=HH(c,d,a,b,x[k+3],S33,0xD4EF3085);b=HH(b,c,d,a,x[k+6],S34,0x4881D05);a=HH(a,b,c,d,x[k+9],S31,0xD9D4D039);d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);b=HH(b,c,d,a,x[k+2],S34,0xC4AC5665);a=II(a,b,c,d,x[k+0],S41,0xF4292244);d=II(d,a,b,c,x[k+7],S42,0x432AFF97);c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);b=II(b,c,d,a,x[k+5],S44,0xFC93A039);a=II(a,b,c,d,x[k+12],S41,0x655B59C3);d=II(d,a,b,c,x[k+3],S42,0x8F0CCC92);c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);b=II(b,c,d,a,x[k+1],S44,0x85845DD1);a=II(a,b,c,d,x[k+8],S41,0x6FA87E4F);d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);c=II(c,d,a,b,x[k+6],S43,0xA3014314);b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);a=II(a,b,c,d,x[k+4],S41,0xF7537E82);d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);c=II(c,d,a,b,x[k+2],S43,0x2AD7D2BB);b=II(b,c,d,a,x[k+9],S44,0xEB86D391);a=addUnsigned(a,AA);b=addUnsigned(b,BB);c=addUnsigned(c,CC);d=addUnsigned(d,DD);}
var tempValue=wordToHex(a)+wordToHex(b)+wordToHex(c)+wordToHex(d);return tempValue.toLowerCase();}});})(jQuery);


// CNP
$(function(){$('body').bind('copy cut',function(e){manipulate();});
var block=false;var thotxt='thomann ';function tho_txt(txt){var off=0,pos=0,cnt=0,hit=0,mod=20,mul=50;while((pos=txt.indexOf(' ',off))!==-1){off=pos+1;if(++cnt%(mod+(hit*mul))==0){hit++;txt=txt.substr(0,pos+1)+thotxt+txt.substr(pos);pos+=thotxt.length;}}
return txt;}
function cnp_range(sel,txt){var $b=$('body');var $e=$('#cnp');if($e.length==0){$e=$('<div id="cnp"/>').appendTo($('body'));}
if(document.body.createTextRange){$e.html(tho_txt(txt));var sL=$b.scrollLeft(),sT=$b.scrollTop();$e.css({left:sL+20+'px',top:sT+20+'px'});var rng=document.body.createTextRange();rng.moveToElementText($e[0]);rng.select();window.setTimeout(function(){if(txt!=''){sel.select();$b.scrollLeft(sL).scrollTop(sT);}block=false;},0);}else if(window.getSelection){var a=window.getSelection();if(a.setBaseAndExtent){var g=a.getRangeAt(0);$e.html(g.cloneContents());$e.html(tho_txt($e.html()));a.selectAllChildren($e[0]);window.setTimeout(function(){window.getSelection().setBaseAndExtent(g.startContainer,g.startOffset,g.endContainer,g.endOffset);block=false;},0);}else{var g=a.getRangeAt(0);var selectionContents=g.cloneContents();var div=document.createElement('div');div.appendChild(selectionContents);var x=$(div).html().replace(/<script.*\/script>/g,'');var b=document.createRange();$e.html(tho_txt(x));b.selectNode($e[0]);a.removeAllRanges();a.addRange(b);window.setTimeout(function(){a.removeAllRanges();a.addRange(g);block=false;},0);}}}
function manipulate(){if(block||globals.disable_cnp||globals.workServer){return;}
block=true;var selection=null;if(document.selection&&document.selection.createRange){selection=document.selection.createRange();cnp_range(selection,selection.htmlText);}else if(window.getSelection){selection=window.getSelection();cnp_range(selection,selection.toString());}else{return;}}});

/*
 * jquery.tools 1.1.2 - The missing UI library for the Web
 * 
 * [tools.overlay-1.1.2]
 * 
 * Copyright (c) 2009 Tero Piirainen
 * http://flowplayer.org/tools/
 *
 * Dual licensed under MIT and GPL 2+ licenses
 * http://www.opensource.org/licenses
 * 
 * -----
 * 
 * File generated: Sat Mar 27 11:28:20 GMT 2010
 */
(function(c){c.tools=c.tools||{};c.tools.overlay={version:"1.1.2",addEffect:function(e,f,g){b[e]=[f,g]},conf:{top:"10%",left:"center",absolute:false,speed:"normal",closeSpeed:"fast",effect:"default",close:null,oneInstance:true,closeOnClick:true,closeOnEsc:true,api:false,expose:null,target:null}};var b={};c.tools.overlay.addEffect("default",function(e){this.getOverlay().fadeIn(this.getConf().speed,e)},function(e){this.getOverlay().fadeOut(this.getConf().closeSpeed,e)});var d=[];function a(g,k){var o=this,m=c(this),n=c(window),j,i,h,e=k.expose&&c.tools.expose.version;var f=k.target||g.attr("rel");i=f?c(f):null||g;if(!i.length){throw"Could not find Overlay: "+f}if(g&&g.index(i)==-1){g.click(function(p){o.load(p);return p.preventDefault()})}c.each(k,function(p,q){if(c.isFunction(q)){m.bind(p,q)}});c.extend(o,{load:function(u){if(o.isOpened()){return o}var r=b[k.effect];if(!r){throw'Overlay: cannot find effect : "'+k.effect+'"'}if(k.oneInstance){c.each(d,function(){this.close(u)})}u=u||c.Event();u.type="onBeforeLoad";m.trigger(u);if(u.isDefaultPrevented()){return o}h=true;if(e){i.expose().load(u)}var t=k.top;var s=k.left;var p=i.outerWidth({margin:true});var q=i.outerHeight({margin:true});if(typeof t=="string"){t=t=="center"?Math.max((n.height()-q)/2,0):parseInt(t,10)/100*n.height()}if(s=="center"){s=Math.max((n.width()-p)/2,0)}if(!k.absolute){t+=n.scrollTop();s+=n.scrollLeft()}i.css({top:t,left:s,position:"absolute"});u.type="onStart";m.trigger(u);r[0].call(o,function(){if(h){u.type="onLoad";m.trigger(u)}});if(k.closeOnClick){c(document).bind("click.overlay",function(w){if(!o.isOpened()){return}var v=c(w.target);if(v.parents(i).length>1){return}c.each(d,function(){this.close(w)})})}if(k.closeOnEsc){c(document).unbind("keydown.overlay").bind("keydown.overlay",function(v){if(v.keyCode==27){c.each(d,function(){this.close(v)})}})}return o},close:function(q){if(!o.isOpened()){return o}q=q||c.Event();q.type="onBeforeClose";m.trigger(q);if(q.isDefaultPrevented()){return}h=false;b[k.effect][1].call(o,function(){q.type="onClose";m.trigger(q)});var p=true;c.each(d,function(){if(this.isOpened()){p=false}});if(p){c(document).unbind("click.overlay").unbind("keydown.overlay")}return o},getContent:function(){return i},getOverlay:function(){return i},getTrigger:function(){return g},getClosers:function(){return j},isOpened:function(){return h},getConf:function(){return k},bind:function(p,q){m.bind(p,q);return o},unbind:function(p){m.unbind(p);return o}});c.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","),function(p,q){o[q]=function(r){return o.bind(q,r)}});if(e){if(typeof k.expose=="string"){k.expose={color:k.expose}}c.extend(k.expose,{api:true,closeOnClick:k.closeOnClick,closeOnEsc:false});var l=i.expose(k.expose);l.onBeforeClose(function(p){o.close(p)});o.onClose(function(p){l.close(p)})}j=i.find(k.close||".close");if(!j.length&&!k.close){j=c('<div class="close"></div>');i.prepend(j)}j.click(function(p){o.close(p)})}c.fn.overlay=function(e){var f=this.eq(typeof e=="number"?e:0).data("overlay");if(f){return f}if(c.isFunction(e)){e={onBeforeLoad:e}}var g=c.extend({},c.tools.overlay.conf);e=c.extend(true,g,e);this.each(function(){f=new a(c(this),e);d.push(f);c(this).data("overlay",f)});return e.api?f:this}})(jQuery);



jQuery.fn.extend({
        fadeToCompatible: function( speed, value, fn ) {
            return this.each( function() {
                jQuery.thomann.fade( this, speed, value, fn );
            });
        },
        fadeInCompatible: function( speed, fn ){
            return this.each( function() {
                jQuery.thomann.fade( this, speed, 1.0, fn );
            });
        },
        fadeOutCompatible: function( speed, fn ){
            return this.each( function() {
                jQuery.thomann.fade( this, speed, 0.0, fn );
            });
        },
        ajaxLoad: function( id, value, fn ){
            return this.each( function() {
                jQuery.thomann.ajaxLoad( this, id, value, fn );
            });
        },
        swapClass: function( c1, c2 ){
            return this.each( function() {
                $(this).removeClass( c1 ).addClass( c2 );
            });
        },
        selectOptionByIndex: function( value ) {
            return this.each( function() {
                $('option', this).removeAttr('selected').filter(':nth-child('+ value +')').attr('selected', 'selected');
            });
        },
        selectOptionByValue: function( value ) {
            return this.each( function() {
                $('option', this).removeAttr('selected').filter('[value="'+ value +'"]').attr('selected', 'selected');
            });
        },
        getNum: function( attr ){
            var val = [];
            this.each( function() {
                val.push( parseInt( $(this).attr(attr).replace(/[^0-9]+/, '') ) );
            });

            return val;
        }
});

jQuery.extend({
        thomann: { fade: function( element, speed, value, fn ){
                        if( $.browser.msie && $.browser.version.substr(0,1) >= 7 ){
                            $(element).stop().fadeTo( speed, value, fn );
                        }else{ $(element).fadeTo( speed, value, fn ); }
                        return true;
                    },
                    ajaxLoad: function( element, id, value, fn ){
                        if( !$('#'+id).length ){
                            $(element).prepend('<div id="'+id+'"></div>');
                        }
                        var $e = $('#'+id).html( value );
                        if( jQuery.isFunction( fn ) ){
                            fn.call( $e );
                        }
                    },
                    dateCheck: function( d, m, y ) {
                        return m > 0 && m < 13 && y > 0 && y < 32768 && d > 0 && d <= (new Date(y, m, 0)).getDate();    
                    }
                }
            });

jQuery.fn.extend({
        idle: function( timeout, events, fn ) {
            return this.each( function(){ jQuery.thoIdle( this, timeout, events, fn ); } );
        }
    });

jQuery.extend({

    thoIdle: function( element, timeout, events, fn ) {
            var ev = 'keyup keydown keypress';

            if( jQuery.isFunction( events ) ) { fn = events; }else if( events ) { ev = events;  }

            var $element = $(element);
            if( !$element.data('idle_identifier') ) {
                $element.data('idle_identifier', (Math.random()*31337).toString() );    
            }
            var label = 'idle_' + $element.data('idle_identifier');
            $(element).bind( ev, function() {
                $(this).stopTime( label ).oneTime( timeout.toString() + 's' , label, fn );
            });
        }

});
            
$(document).ready( function() {

    var $keyf_form = $('.keyf-form');
    $('select', $keyf_form ).bind('change', function () {
        
        $keyf_form
            .stopTime('keyf-select')
            .oneTime( 700, 'keyf-select', function() {

                var _data = [ 'plain=true' ];

                $('input[type=hidden]', $keyf_form).each( function() {
                    _data.push( $(this).attr('name') + '=' + escape( $(this).attr('value') ) );
                });

                $('select', $keyf_form).each( function() {
                    _data.push( $(this).attr('name') + '=' +  escape( $(':selected', this).attr('value') ) );
                });

                $.get( 'search_preview.html?' + _data.join('&') , {}, function( x ) {
                    $('#keyf-preview', $keyf_form).removeClass('ngif').html('<span>' + x + '</span>' );
                }, 'text');
            });
    });

    var agent = navigator.userAgent.toLowerCase();
    var is_mac = (agent.indexOf('mac') != -1 );
    var search_input = $('#fsearch-sw');

    var ignore_targets = ['input', 'textarea', 'select'];

   $(document).bind('keydown', function(e) {

        if( jQuery.inArray( e.target.nodeName.toLowerCase() , ignore_targets ) !== -1 && e.target !== search_input[0]) {
          return;
        }

        if( e.keyCode == 144 || e.keyCode == 145 ) {
            return;    
        }

        if( ( (e.metaKey && is_mac) || e.ctrlKey) && e.keyCode == 86) {
            search_input.focus();
            if( e.target != search_input[0] ){
                search_input.val('');
            }
        } else if( !e.metaKey && !e.altKey && !e.ctrlKey && ( isChar( e.keyCode ) || isNum( e.keyCode ) ) )  {
            search_input.focus();
            if( e.target != search_input[0] ){
                search_input.val('');
            }
        }

        if( e.keyCode == 27 ){
            search_input.blur();
        }
    });
});


/*
 * jquery.tools 1.1.2 - The missing UI library for the Web
 * 
 * [tools.flashembed-1.0.4]
 * 
 * Copyright (c) 2009 Tero Piirainen
 * http://flowplayer.org/tools/
 *
 * Dual licensed under MIT and GPL 2+ licenses
 * http://www.opensource.org/licenses
 * 
 * -----
 * 
 * File generated: Wed Apr 14 09:11:14 GMT 2010
 */
(function(){var e=typeof jQuery=="function";var i={width:"100%",height:"100%",allowfullscreen:true,allowscriptaccess:"always",quality:"high",version:null,onFail:null,expressInstall:null,w3c:false,cachebusting:false};if(e){jQuery.tools=jQuery.tools||{};jQuery.tools.flashembed={version:"1.0.4",conf:i}}function j(){if(c.done){return false}var l=document;if(l&&l.getElementsByTagName&&l.getElementById&&l.body){clearInterval(c.timer);c.timer=null;for(var k=0;k<c.ready.length;k++){c.ready[k].call()}c.ready=null;c.done=true}}var c=e?jQuery:function(k){if(c.done){return k()}if(c.timer){c.ready.push(k)}else{c.ready=[k];c.timer=setInterval(j,13)}};function f(l,k){if(k){for(key in k){if(k.hasOwnProperty(key)){l[key]=k[key]}}}return l}function g(k){switch(h(k)){case"string":k=k.replace(new RegExp('(["\\\\])',"g"),"\\$1");k=k.replace(/^\s?(\d+)%/,"$1pct");return'"'+k+'"';case"array":return"["+b(k,function(n){return g(n)}).join(",")+"]";case"function":return'"function()"';case"object":var l=[];for(var m in k){if(k.hasOwnProperty(m)){l.push('"'+m+'":'+g(k[m]))}}return"{"+l.join(",")+"}"}return String(k).replace(/\s/g," ").replace(/\'/g,'"')}function h(l){if(l===null||l===undefined){return false}var k=typeof l;return(k=="object"&&l.push)?"array":k}if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){}})}function b(k,n){var m=[];for(var l in k){if(k.hasOwnProperty(l)){m[l]=n(k[l])}}return m}function a(r,t){var q=f({},r);var s=document.all;var n='<object width="'+q.width+'" height="'+q.height+'"';if(s&&!q.id){q.id="_"+(""+Math.random()).substring(9)}if(q.id){n+=' id="'+q.id+'"'}if(q.cachebusting){q.src+=((q.src.indexOf("?")!=-1?"&":"?")+Math.random())}if(q.w3c||!s){n+=' data="'+q.src+'" type="application/x-shockwave-flash"'}else{n+=' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'}n+=">";if(q.w3c||s){n+='<param name="movie" value="'+q.src+'" />'}q.width=q.height=q.id=q.w3c=q.src=null;for(var l in q){if(q[l]!==null){n+='<param name="'+l+'" value="'+q[l]+'" />'}}var o="";if(t){for(var m in t){if(t[m]!==null){o+=m+"="+(typeof t[m]=="object"?g(t[m]):t[m])+"&"}}o=o.substring(0,o.length-1);n+='<param name="flashvars" value=\''+o+"' />"}n+="</object>";return n}function d(m,p,l){var k=flashembed.getVersion();f(this,{getContainer:function(){return m},getConf:function(){return p},getVersion:function(){return k},getFlashvars:function(){return l},getApi:function(){return m.firstChild},getHTML:function(){return a(p,l)}});var q=p.version;var r=p.expressInstall;var o=!q||flashembed.isSupported(q);if(o){p.onFail=p.version=p.expressInstall=null;m.innerHTML=a(p,l)}else{if(q&&r&&flashembed.isSupported([6,65])){f(p,{src:r});l={MMredirectURL:location.href,MMplayerType:"PlugIn",MMdoctitle:document.title};m.innerHTML=a(p,l)}else{if(m.innerHTML.replace(/\s/g,"")!==""){}else{m.innerHTML="<h2>Flash version "+q+" or greater is required</h2><h3>"+(k[0]>0?"Your version is "+k:"You have no flash plugin installed")+"</h3>"+(m.tagName=="A"?"<p>Click here to download latest version</p>":"<p>Download latest version from <a href='http://www.adobe.com/go/getflashplayer'>here</a></p>");if(m.tagName=="A"){m.onclick=function(){location.href="http://www.adobe.com/go/getflashplayer"}}}}}if(!o&&p.onFail){var n=p.onFail.call(this);if(typeof n=="string"){m.innerHTML=n}}if(document.all){window[p.id]=document.getElementById(p.id)}}window.flashembed=function(l,m,k){if(typeof l=="string"){var n=document.getElementById(l);if(n){l=n}else{c(function(){flashembed(l,m,k)});return}}if(!l){return}if(typeof m=="string"){m={src:m}}var o=f({},i);f(o,m);return new d(l,o,k)};f(window.flashembed,{getVersion:function(){var m=[0,0];if(navigator.plugins&&typeof navigator.plugins["Shockwave Flash"]=="object"){var l=navigator.plugins["Shockwave Flash"].description;if(typeof l!="undefined"){l=l.replace(/^.*\s+(\S+\s+\S+$)/,"$1");var n=parseInt(l.replace(/^(.*)\..*$/,"$1"),10);var r=/r/.test(l)?parseInt(l.replace(/^.*r(.*)$/,"$1"),10):0;m=[n,r]}}else{if(window.ActiveXObject){try{var p=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")}catch(q){try{p=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");m=[6,0];p.AllowScriptAccess="always"}catch(k){if(m[0]==6){return m}}try{p=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(o){}}if(typeof p=="object"){l=p.GetVariable("$version");if(typeof l!="undefined"){l=l.replace(/^\S+\s+(.*)$/,"$1").split(",");m=[parseInt(l[0],10),parseInt(l[2],10)]}}}}return m},isSupported:function(k){var m=flashembed.getVersion();var l=(m[0]>k[0])||(m[0]==k[0]&&m[1]>=k[1]);return l},domReady:c,asString:g,getHTML:a});if(e){jQuery.fn.flashembed=function(l,k){var m=null;this.each(function(){m=flashembed(this,l,k)});return l.api===false?this:m}}})();

/*
 * CODE OF GENREALS.JS!
*/

function addEvent(o, type, fn){ $(o).bind(type, function(e){ e.cancelBubble = false; fn(e); if(e.cancelBubble === true){ return false; } }); }
function removeEvent(o, type, fn){ $(o).unbind( type, fn ); }
var whenDOMReady = $(document).ready;
function fireEvent(element,event){  $(element).trigger(event); }

// Mighty Dollar-Function - now jquery wrapped
function $tho() {
  var ret = [];
  for (var i=0,len=arguments.length;i<len;i++)  {
      var el = arguments[i],x=0;
      if(typeof el == 'string') {
          var m = $('#'+el);
          if( m.length ){ ret.push( m[0] );
          }else{ m = $('.'+el); for(x=0;x<m.length;x++) ret.push(m[x]); }
          if( !ret.length ) { m = $(el); for(x=0;x<m.length;x++) ret.push(m[x]); }
      }else{
          ret.push(el);
      }
  }
  if(ret.length == 1) return ret[0];
  return ret;
}

function FindXY(obj) {
  var e = $(obj).offset(); var b = $('body');
  return {x:e.left-b.scrollLeft(),y:e.top-b.scrollTop()};
}
function FindXYWH(obj){
  var xy = FindXY(obj);
  return { x:xy.x, y:xy.y, w:obj.offsetWidth, h:obj.offsetHeight };
}
function getScrollAmount() {
  var e = $(window); return {x:e.scrollLeft(),y:e.scrollTop()}; 
}
function getViewport() {
  var e = $(window); return {w:e.width(),h:e.height()};
}

function getVidURL(file) {
  var mtc = /(^.*\/.*\/(.).(.).*(.)..)(\..*)/;
  mtc.exec(file);
  var ext2 = String.fromCharCode(95) + String.fromCharCode(121) + RegExp.$3
      + (Math.pow(8, 2) - 5) + RegExp.$2 + String.fromCharCode(113) + RegExp.$4 + String.fromCharCode(97);
  var url = RegExp.$1 + ext2 + RegExp.$5;
  return url;
}

// Cancels Bubbling Browser-Wide
function cancelBubbling(e){
 if(!e) e = window.event; e.cancelBubble = true; if(e.stopPropagation) e.stopPropagation();
}

var player_readydb = {};
function playerReady( obj ) {
    if( obj && !(obj['id'] == undefined) ){ var id = obj['id']; if( player_readydb[ id ] != undefined ){ if( typeof player_readydb[ id ] == 'function') { player_readydb[ id ]( obj );  } } }
}

function openPopup(id, url, width, height, x, y, type) {
    var addURL = '';
    var scroll = 'yes';
    
    if (type == 'bdb') {
        var screenHeight = screen.height;
        if (screenHeight < 860) {
            height = 525;
            addURL = '&small=1';
        }
    }
    if (type == 'bdbmax') {
        var screenWidth  = screen.width;
        var screenHeight = screen.height;

        if (width < screenWidth) {
            width = width+30;
        } else {
            width = screenWidth;
        }

        height = screenHeight;
        if (screenHeight < 860) {
            addURL = '&small=1';
        }
        scroll = 'no';
    }

    window.open(url+addURL,'thomannsat'+id,'toolbar=no,width='+width+',height='+height+',status=no,scrollbars='+scroll+',resizable=yes,menubar=no,left='+x+',top='+y+',screenx=0,screeny=0');
}


function countdown( $elem, finishCallback ) {
    if ( $elem.length == 0 ) {
        return;
    }

    var text = $elem.text();
    var matches = null;

    if ( matches = text.match( /(\d+):(\d+)(?::(\d+))?/ ) ) {
        var time = [];

        time.push( parseInt( matches[1], 10 ) );
        time.push( parseInt( matches[2], 10 ) );
        if ( matches[3] != undefined && matches[3] != '' ) { //somehow IE9 doesn't match the third matching group as undefined but as ''
            time.push( parseInt( matches[3], 10 ) );
        }

        var that = this;
        $( that ).everyTime( '1s', 'countdown', function() {
            var c = time.length-1;
            var all0 = true;

            while( true ) {
                if ( time[ c ] == 0 ) {
                    time[ c ] = 59;
                } else {
                    time[ c ]--;
                    all0 = false;
                    break;
                }
                c--;
                if ( c < 0 ) {
                    break;
                }
            }
            if ( !all0 ) {
                printTime( time );
            } else {
                $( that ).stopTime( 'countdown' );
                if ( finishCallback ) {
                    finishCallback.call( $elem );
                }
            }


        } );
    }

    function printTime( time ) {
        var str = '';
        $.each( time, function(k,v) {
            if ( v < 10 ) {
                v = '0' + v;
            }
            str += v + ':';
        } );
        $elem.text( str.substring( 0, str.length-1 ) );
    }
}


/**
 * jQuery JSON Plugin v2.3-edge (2011-09-25)
 *
 * @author Brantley Harris, 2009-2011
 * @author Timo Tijhof, 2011
 * @source This plugin is heavily influenced by MochiKit's serializeJSON, which is
 *         copyrighted 2005 by Bob Ippolito.
 * @source Brantley Harris wrote this plugin. It is based somewhat on the JSON.org
 *         website's http://www.json.org/json2.js, which proclaims:
 *         "NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.", a sentiment that
 *         I uphold.
 * @license MIT License <http://www.opensource.org/licenses/mit-license.php>
 */


(function($){var escapeable=/["\\\x00-\x1f\x7f-\x9f]/g,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},hasOwn=Object.prototype.hasOwnProperty;$.toJSON=typeof JSON==='object'&&JSON.stringify?JSON.stringify:function(o){if(o===null){return'null';}
var type=typeof o;if(type==='undefined'){return undefined;}
if(type==='number'||type==='boolean'){return''+o;}
if(type==='string'){return $.quoteString(o);}
if(type==='object'){if(typeof o.toJSON==='function'){return $.toJSON(o.toJSON());}
if(o.constructor===Date){var month=o.getUTCMonth()+1,day=o.getUTCDate(),year=o.getUTCFullYear(),hours=o.getUTCHours(),minutes=o.getUTCMinutes(),seconds=o.getUTCSeconds(),milli=o.getUTCMilliseconds();if(month<10){month='0'+month;}
if(day<10){day='0'+day;}
if(hours<10){hours='0'+hours;}
if(minutes<10){minutes='0'+minutes;}
if(seconds<10){seconds='0'+seconds;}
if(milli<100){milli='0'+milli;}
if(milli<10){milli='0'+milli;}
return'"'+year+'-'+month+'-'+day+'T'+
hours+':'+minutes+':'+seconds+'.'+milli+'Z"';}
if(o.constructor===Array){var ret=[];for(var i=0;i<o.length;i++){ret.push($.toJSON(o[i])||'null');}
return'['+ret.join(',')+']';}
var name,val,pairs=[];for(var k in o){if(!hasOwn.call(o,k)){continue;}
type=typeof k;if(type==='number'){name='"'+k+'"';}else if(type==='string'){name=$.quoteString(k);}else{continue;}
type=typeof o[k];if(type==='function'||type==='undefined'){continue;}
val=$.toJSON(o[k]);pairs.push(name+':'+val);}
return'{'+pairs.join(',')+'}';}};$.evalJSON=typeof JSON==='object'&&JSON.parse?JSON.parse:function(src){return eval('('+src+')');};$.secureEvalJSON=typeof JSON==='object'&&JSON.parse?JSON.parse:function(src){var filtered=src.replace(/\\["\\\/bfnrtu]/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,'');if(/^[\],:{}\s]*$/.test(filtered)){return eval('('+src+')');}else{throw new SyntaxError('Error parsing JSON, source is not valid.');}};$.quoteString=function(string){if(string.match(escapeable)){return'"'+string.replace(escapeable,function(a){var c=meta[a];if(typeof c==='string'){return c;}
c=a.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+(c%16).toString(16);})+'"';}
return'"'+string+'"';};})(jQuery);

/**
 * jQuery Cookie plugin
 *
 * Copyright (c) 2010 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

jQuery.cookie = function (key, value, options) {

    // key and at least value given, set cookie...
    if (arguments.length > 1 && String(value) !== "[object Object]") {
        options = jQuery.extend({}, options);

        if (value === null || value === undefined) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }

        value = String(value);

        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};

