/* jcarousellite_1.0.1.pack.js|customers */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(6($){$.1g.1w=6(o){o=$.1f({r:n,x:n,N:n,17:q,J:n,L:1a,16:n,y:q,u:12,H:3,B:0,k:1,K:n,I:n},o||{});8 G.R(6(){p b=q,A=o.y?"15":"w",P=o.y?"t":"s";p c=$(G),9=$("9",c),E=$("10",9),W=E.Y(),v=o.H;7(o.u){9.1h(E.D(W-v-1+1).V()).1d(E.D(0,v).V());o.B+=v}p f=$("10",9),l=f.Y(),4=o.B;c.5("1c","H");f.5({U:"T",1b:o.y?"S":"w"});9.5({19:"0",18:"0",Q:"13","1v-1s-1r":"S","z-14":"1"});c.5({U:"T",Q:"13","z-14":"2",w:"1q"});p g=o.y?t(f):s(f);p h=g*l;p j=g*v;f.5({s:f.s(),t:f.t()});9.5(P,h+"C").5(A,-(4*g));c.5(P,j+"C");7(o.r)$(o.r).O(6(){8 m(4-o.k)});7(o.x)$(o.x).O(6(){8 m(4+o.k)});7(o.N)$.R(o.N,6(i,a){$(a).O(6(){8 m(o.u?o.H+i:i)})});7(o.17&&c.11)c.11(6(e,d){8 d>0?m(4-o.k):m(4+o.k)});7(o.J)1p(6(){m(4+o.k)},o.J+o.L);6 M(){8 f.D(4).D(0,v)};6 m(a){7(!b){7(o.K)o.K.Z(G,M());7(o.u){7(a<=o.B-v-1){9.5(A,-((l-(v*2))*g)+"C");4=a==o.B-v-1?l-(v*2)-1:l-(v*2)-o.k}F 7(a>=l-v+1){9.5(A,-((v)*g)+"C");4=a==l-v+1?v+1:v+o.k}F 4=a}F{7(a<0||a>l-v)8;F 4=a}b=12;9.1o(A=="w"?{w:-(4*g)}:{15:-(4*g)},o.L,o.16,6(){7(o.I)o.I.Z(G,M());b=q});7(!o.u){$(o.r+","+o.x).1n("X");$((4-o.k<0&&o.r)||(4+o.k>l-v&&o.x)||[]).1m("X")}}8 q}})};6 5(a,b){8 1l($.5(a[0],b))||0};6 s(a){8 a[0].1k+5(a,\'1j\')+5(a,\'1i\')};6 t(a){8 a[0].1t+5(a,\'1u\')+5(a,\'1e\')}})(1x);',62,96,'||||curr|css|function|if|return|ul|||||||||||scroll|itemLength|go|null||var|false|btnPrev|width|height|circular||left|btnNext|vertical||animCss|start|px|slice|tLi|else|this|visible|afterEnd|auto|beforeStart|speed|vis|btnGo|click|sizeCss|position|each|none|hidden|overflow|clone|tl|disabled|size|call|li|mousewheel|true|relative|index|top|easing|mouseWheel|padding|margin|200|float|visibility|append|marginBottom|extend|fn|prepend|marginRight|marginLeft|offsetWidth|parseInt|addClass|removeClass|animate|setInterval|0px|type|style|offsetHeight|marginTop|list|jCarouselLite|jQuery'.split('|'),0,{}))
/* page.js|customers */
// inits script
function initPageJs() {
  // global vars get set
  accessibleInputs();
  // make accesible hr-elements
  $("hr[class!='mdAccess']").wrap("<div class='hr'></div>");
  // browserquirks
  browserQuirks();
  // convert list to select nav
  linksToSelectNav();
  // assign print functionality
  assignPrint();
  // initShadowBox
  initShadowBox();
  // init galleryslider & galleryroll
  initGallerySlider();
  initGalleryRoll();
  // assign tabbox
  tabBoxInit();
  // create iframe tab box
  initIframeTabs();
  // initPoll
  showPollResults();
  // insert numbers in themelist
  orderThemeList();
  // line on contest page
  $('div.mdCompetition fieldset fieldset:eq(0)').css({
    'border-bottom': '1px solid #b9c4cc',
    'margin': '0',
    'padding': '0 0 10px 0'
    });
  $('div.mdCompetition fieldset fieldset:eq(1)').css({
    'border-bottom': '1px solid #b9c4cc',
    'margin': '0',
    'padding': '0 0 10px 0'
    });
}

function browserQuirks(){
  if($.browser.msie){
    //if v6
    if($.browser.version == "6.0"){}
    // all ie
  }
}

function linksToSelectNav(){
  $(".mdSubFootOverviewInner dl,.mdCalculators dl").each(function(i){
    var selectHtml = '<div class="mdFormSelectWrap"><label for="selectNavProcessed'+i+'">'+$(this).find("dt:first").text()+'</label><select class="mdFormSelect" id="selectNavProcessed'+i+'"><option>'+Drupal.t('Choose')+'</option>';
    $(this).find("dd").each(function(){
      selectHtml += '<option value="'+$(this).find("a:first").attr("href")+'">'+$(this).find("a:first").text()+'</option>'
    })
    selectHtml += "</div>";
    $(this).replaceWith(selectHtml);
  })
  $(".mdSubFootOverviewInner select,.mdCalculators select").change(function(){
    if($(this).val() != Drupal.t('Choose')) window.location = $(this).val();
  })
};

function initShadowBox(){
  if($("a[rel*='shadowbox']").length > 0){
    $("head:first").append('<link rel="stylesheet" type="text/css" media="screen" href="'+Drupal.settings['mdPath']+'/skin.css" />');
    $.getScript(Drupal.settings['mdPath']+"/shadowbox.js",function(){
      $.getScript(Drupal.settings['mdPath']+"/skin.js",function(){
        var options = {
          animate:     false,
          fadeDuration:  0.25,
          ext: {
            img:        ['png', 'jpg', 'jpeg', 'gif', 'bmp'],
            swf:        ['swf'],
            flv:        ['flv'],
            qt:         ['dv', 'mov', 'moov', 'movie', 'mp4'],
            wmp:        ['asf', 'wm', 'wmv'],
            qtwmp:      ['avi', 'mpg', 'mpeg'],
            iframe:     ['']
          }
        };
        Shadowbox.init(options);
      });
    });
  }
}

function assignPrint(){
  $("ul.mdToolBar").append('<li></li>').find("li:last").append('<span class="mdIconPrint">'+Drupal.t('Print')+'</span>').click(function(){
    window.print();
  })
}


function tabBoxInit(){
  if($(".mdTabBox dt").length > 1){
    $(".mdTabBox").addClass("mdTabBoxJs");
    $(".mdTabBox dd:first").addClass("active");
    var tabWidth = ($(".mdTabBox dl").width() / $(".mdTabBox dt").length);
    $(".mdTabBox dt").each(function(i){
      if(i == 0){
        $(this).addClass("active");
      }
      // calculate tabwidth
      if(i == ($(".mdTabBox dt").length)-1){
        width = tabWidth-8;
      } else {
        width = tabWidth-11;
      }
      if (i == ($(".mdTabBox dt").length)-1) {
        width = width + 2;
      }
      $(this).css({left: (i*tabWidth)+"px",width: width+"px"})

      // assign click functionality
      $(this).click(function(){
        var width = parseInt($(".mdTabBox dt.active").width()) + 'px';
        $(".mdTabBox dt.active").removeClass("active").css('width',width);
        $(".mdTabBox dd.active").fadeOut(250);
        width = parseInt($(this).width()) + 'px';
        $(this).addClass("active").css('width',width).next("dd").fadeIn(150).addClass("active");
        
      })
    })
  }
}

function initIframeTabs(){
  // add js class
  $(".mdIframesBox").addClass("mdIframesBoxJs").find("dd:first").addClass("active").end().end().find("dt").each(function(i){
    dlHeight(this)
    $(this).wrapInner("<span><span></span></span>")
    if(i==0) $(this).addClass("active");
    $(this).click(function(){
      $(this).siblings("dt").removeClass("active").end().addClass("active").next("dd").siblings("dd").removeClass("active").end().addClass("active");
      dlHeight(this)
    });
  });
  
  function dlHeight(obj){
    var dlHeight = (parseInt($(obj).parents("dl").find("dd.active iframe").attr("height")) + 24) + "px";
    // ie7/8 bug
    try {
      $(obj).parent("dl").css("height", dlHeight);      
    }
    catch(e){ }
  }
}

function showPollResults(){
  $(".mdPollResults").each(function(){
    $(this).addClass("mdPollResultsJs");
    var baseWidth = $(this).find("dd:first").width() - 32;
    $(this).find("dd").each(function(){
      var percentage = parseInt($(this).html());
      $(this).wrapInner("<div><div><span></span></div></div>");
      if(percentage != 0){
        $(this).find("div:first").width(parseInt((baseWidth/100) * percentage)).find("div").width("3px");
      }
    })
  })
}

function orderThemeList(){
  $(".mdBox .mdThemeArticles").addClass("mdThemeArticlesJs").each(function(){
    $(this).find("dd").each(function(i){
      $(this).prepend("<span><span>"+(i+1)+"</span></span>");
    })
  })
}

/*
Drupal.behaviors.metadesign = function() {
  initPageJs();
};
*/

$(document).ready(function(){
  initPageJs();
});
/* accessibleInputs.js|global */
//Accessible Inputs (requires jQuery)

// moves labels value to inputs if class 'mdValueToInput' is present & then adds focus/blur to inputs
function accessibleInputs(){
  $("label.mdValueToInput[for]").each(function(i){
    // fill input fields with labeltext - html tags
    var regexp = /<("[^"]*"|'[^']*'|[^'">])*>/gi;
    var newVal = this.innerHTML.replace(regexp,"");
    //if el is type=input or textarea
    if($("#"+this.htmlFor).is("input") || $("#"+this.htmlFor).is("textarea")){
      if(($("#"+this.htmlFor).val() == "") || ($("#"+this.htmlFor).val() == newVal)){
        $("#"+this.htmlFor).attr("value",newVal);
      }
      // create onclick/blur functionality
      $("#"+this.htmlFor).focus(function(){if(this.value == newVal) this.value = "";});
      $("#"+this.htmlFor).blur(function(){if(this.value == "") this.value = newVal;});
    // if el is select  
    } else if($("#"+this.htmlFor).is("select")){
      var orgOptions = $("#"+this.htmlFor).html();
      var newOptions = '<option value="">'+newVal+'</option>'+orgOptions;
      // IE special Kung Fu
      if($.browser.msie && $.browser.version < 8){
        var go=0;
        $("#"+this.htmlFor).find("option").each(function(i){
          if($(this).get(0).defaultSelected){
            go=1;
          }
        })
        if(go==0){
          newOptions = newOptions.replace(/selected>/g,">");
        }
      }
      $("#"+this.htmlFor).html(newOptions);
      // IE8 force choose first option
      if($.browser.msie && $.browser.version <= 8){
        $("#"+this.htmlFor + " option:first").attr("selected","selected")
      }
    }
    // hide label
    $(this).hide();
  })
  cleanForms();
}

// makes sure that label values are not submitted to forms
function cleanForms(){
  $("form:has(label.mdValueToInput)").submit(function(){
    $("label.mdValueToInput[for]").each(function(){
      // check if value is same as label
      var regexp = /<("[^"]*"|'[^']*'|[^'">])*>/gi;
      var newVal = this.innerHTML.replace(regexp,"");
      if($("#"+this.htmlFor).attr("value") == newVal){
        $("#"+this.htmlFor).attr("value","");
      }
    })
  })
}

function initGallerySlider(){
  var amount = $(".mdGallerySliderInner li").length;
  var totalwidth = 0;
  $(".mdGallerySliderInner li").each(function(){totalwidth += $(this).width();})
  
  if($(".mdGallerySliderInner").width() < totalwidth){
    $(".mdGallerySlider div").not($(".mdGallerySliderInner")).css({display:"block"})
    $(".mdGallerySliderInner").jCarouselLite({
      btnNext: "div.mdNext",
      btnPrev: "div.mdPrev",
      visible: amount
    });  
  } else {
    $(".mdGallerySliderInner ul").css("margin",0)
  }
}

function initGalleryRoll(){
  var ulWidth = 0, afterSelected = 0, galleryRollWidth = $(".mdGalleryRoll").width();
  $(".mdGalleryRoll li").each(function(){
    ulWidth += $(this).width();
    $(this).css({"opacity":"0.5","-moz-opacity":"0.5","filter":"alpha(opacity=50)"});
    if($(this).attr("class") == "selected"){
      afterSelected = 0;
      $(this).css({"opacity":"1","-moz-opacity":"1","filter":"alpha(opacity=100)"});
    }  
    afterSelected += $(this).width();
    $(this).not(".selected").hover(function(){
      $(this).css({"opacity":"1","-moz-opacity":"1","filter":"alpha(opacity=100)"});
    },function(){
      $(this).css({"opacity":"0.5","-moz-opacity":"0.5","filter":"alpha(opacity=50)"});
    });
        
  })
  if(ulWidth < galleryRollWidth){
    $(".mdGalleryRoll").siblings().css({display:"none"});
  } else {
    var offset = ((ulWidth - afterSelected) - (galleryRollWidth / 2)) * -1;
    if(offset > 0) offset = 0
    if(afterSelected < (galleryRollWidth / 2)){
      offset += (galleryRollWidth / 2) - afterSelected;
    }
    $(".mdGalleryRoll ul").css({width:ulWidth+"px",margin:"0 0 0 "+offset+"px"});
  }
}
