// jFav, JQuery plugin
// v 1.0
// SAFARI & CHROME not Supported!
// Licensed under GPL licenses.
// Copyright (C) 2008 Nikos "DuMmWiaM" Kontis, info@dummwiam.com
// http://www.DuMmWiaM.com/EffectChain
// ----------------------------------------------------------------------------
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// ----------------------------------------------------------------------------

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}('(7($){$.8.9=7(d){g e=$.v({},$.8.9.k,d);g f=e.l;2.w(7(){5(!$(2).3(\'4\')||$(2).3(\'4\')=="#"){$(2).3(\'4\',j.x.4)}5(!$(2).3(\'6\')){$(2).3(\'6\',y.6)}5($.h.z){$(2).3(\'m\',$(2).3(\'4\')).3(\'4\',\'\').3(\'4\',\'A:B(0)\').3(\'C\',\'$.8.9.n(2,"\'+$(2).3(\'6\')+\'","\'+$(2).3(\'m\')+\'")\')}i{$(2).o(p)}});7 p(a){g b=$(2).3(\'4\');g c=$(2).3(\'6\');b=b.E("q:///","F://q/");5($.h.G){j.H.I(b,c)}i 5($.h.J){j.r.K(c,b,\'\')}i 5(L.M.N().O(\'P\')>-1){s(f)}i 5($.h.Q){s(f)}a.R()};t 2};$.8.9.k={l:\'S "T + D" U "V + D" W X, u Y 2 Z u 10 11.\'};$.8.9.n=7(e,a,b){e.12="r";e.6=a;e.4="";e.4=b;e.o();t 13}})(14);',62,67,'||this|attr|href|if|title|function|fn|jFav|||||||var|browser|else|window|defaults|msg|link|OperaBookmark|click|addToFavorites|file|sidebar|alert|return|to|extend|each|location|document|opera|javascript|void|onClick||replace|http|msie|external|AddFavorite|mozilla|addPanel|navigator|userAgent|toLowerCase|indexOf|chrome|safari|preventDefault|Press|Ctrl|or|CMD|for|MAC|add|page|your|bookmarks|rel|false|jQuery'.split('|'),0,{}))

// Fade Toggle
jQuery.fn.fadeToggle = function(speed, easing, callback) {
    return this.animate({opacity: 'toggle'}, speed, easing, callback);
};

// Load on document.ready
$(document).ready(function(){
// Hide elements
$('#sitetools').removeClass('active');
$('#lang-drop').hide();
$('#tabs > div.tabcontent').hide();

// Fix <hr />s
$('.textteaser hr, .text hr').each(function(){
  if($(this).parent().hasClass(':not(.clearer)')) {
     $(this).wrap('<div class="hr"></div>').css('border','1px solid red');
  }
});

// Toggle Country Select
$('#country-select').click(function(){
  $('a',this).attr('href','javascript:;');
  $(this).toggleClass('active');
  if($(this).is('.active')) {
   $('h1').css('border-right','none');
   return '';
  } else {
   $('h1').css('border-right', '1px solid #666');
   return 'active';
  }
});

// Toggle Language Select
$('#language').click(function(){ $('#lang-drop').fadeToggle('fast'); });

// Site Tools
$('#sitetools').click(function(){
  $('#tooltext').html('').css('padding-right','0');
  $(this).toggleClass('active');
});
$('#sitetools ul li a').mouseover(function(){
  $('#tooltext').html($(this).html()).css('padding-right','16px');
});
$('#sitetools').mouseleave(function(){
  $('#tooltext').html('').css('padding-right','0');
});
$('#sitetools .bookmark').jFav(); // Add bookmarks
$('#sitetools .print').click(function() { // Print Page
  window.print();
});

// Tabs
$('#tabs div.tabcontent:first').show(); // Show the first div
$('#tabs ul li:first').addClass('active'); // Set the class for active state
$('#tabs ul:first li a').click(function(){ // When link is clicked
  $('#tabs ul li').removeClass('active'); // Remove active class from links
  $(this).parent().addClass('active'); //Set parent of clicked link class to active
  var currentTab = $(this).attr('href'); // Set currentTab to value of href attribute
  //$('#tabs div.tabcontent').hide(); // Hide all divs
  //$(currentTab).show(200); // Show div with id equal to variable currentTab
  $('#tabs div.tabcontent:visible').fadeOut(200, function(){
   $(currentTab).fadeIn(200);
  });
  return false;
});

$("#product-image a[rel='highslide']").each(function() {
  this.onclick = function() {
   return hs.expand(this, singleImageOptions); // Product images
  };
});
$(".thumbnails a[rel='highslide']").each(function() {
  this.onclick = function() {
   return hs.expand(this, galleryOptions); // Product gallery
  };
});
$(".two-col-text a[rel='highslide']").each(function() {
  this.onclick = function() {
   return hs.expand(this, singleImageOptions); // Subpage images
  };
});
$(".text a[rel='highslide']").each(function() {
  this.onclick = function() {
   return hs.expand(this, singleImageOptions); // Subpage images
  };
});

// Subnavigation
$('.hoverteaser:gt(0)').hide();
$('#teasermenu > li').mouseover(function() {
   var current = $(this).index();
   $('.hoverteaser').each(function() { $(this).hide(); });
   $('#cat'+current).show();
});
  
// Team Pages
$('.employee:gt(0)').hide(); // Hide all but the 'boss' ...
$('ul#team li:first').addClass('active');
$('ul#team li').each(function(){ // Check if detailed information exists, bind click events and switch content
var $target = $(this).find('a.empimg').attr('href');
if($($target).length > 0) {
$(this).click(function(){
  $(this).siblings().removeClass('active')
  .end().addClass('active');
  $('.employee:visible').fadeOut(200, function(){
   $($target).fadeIn(200);
  });
}).find('a.empimg').andSelf().css('cursor','pointer');
}
});
$('ul#team li:even').addClass('clear'); // clear every even <li> 

});

// Highslide Config
//hs.graphicsDir = 'images/graphics/';
hs.captionEval = 'this.thumb.alt';
hs.showCredits = false;
// Add the controlbar
if (hs.addSlideshow) hs.addSlideshow({
    slideshowGroup: 'gallery',
    interval: 5000,
    repeat: false,
fixedControls: 'fit',
    useControls: true,
    overlayOptions: {
  opacity: .75,
     className: 'icon-controls',
  position: 'bottom center',
  hideOnMouseOut: true
}
});

var singleImageOptions = {
align: 'center',
outlineType: 'rounded-white',
transitions: ['expand', 'crossfade'],
fadeInOut: true
}

var galleryOptions = {
slideshowGroup: 'gallery',
outlineType: 'rounded-white',
align: 'center',
transitions: ['expand', 'crossfade'],
fadeInOut: true
};

function downloadLogo(/*url*/ url, /*element*/ element)
{
  if (element.selectedIndex > 0)
  {
    var binaryId = element.options[element.selectedIndex].value;
    url = url.replace(/binaryAttachmentId/, binaryId);
    element.selectedIndex = 0;
    location.href = url;
  }
  return false;
}

function downloadPicture(/*url*/ url, /*element*/ element)
{
  if (element.selectedIndex > 0)
  {
    var dpi = element.options[element.selectedIndex].value;
    if (dpi == '72')
    {
      url = url.replace(/pictureMethod/, '72dpi');
    }
    else if (dpi == '150')
    {
      url = url.replace(/pictureMethod/, '150dpi');
    }
    else if (dpi == '300')
    {
      url = url.replace(/pictureMethod/, '300dpi');
    }
    else
    {
      url = url.replace(/pictureMethod/, 'original');
    }

    element.selectedIndex = 0;
    location.href = url;
  }
  return false;
}

