/**
 * Copyright (c) 2005 - 2010, James Auldridge
 * All rights reserved.
 *
 * Licensed under the BSD, MIT, and GPL (your choice!) Licenses:
 *  http://code.google.com/p/cookies/wiki/License
 *
 */
var jaaulde=window.jaaulde||{};jaaulde.utils=jaaulde.utils||{};jaaulde.utils.cookies=(function(){var resolveOptions,assembleOptionsString,parseCookies,constructor,defaultOptions={expiresAt:null,path:'/',domain:null,secure:false};resolveOptions=function(options){var returnValue,expireDate;if(typeof options!=='object'||options===null){returnValue=defaultOptions;}else
{returnValue={expiresAt:defaultOptions.expiresAt,path:defaultOptions.path,domain:defaultOptions.domain,secure:defaultOptions.secure};if(typeof options.expiresAt==='object'&&options.expiresAt instanceof Date){returnValue.expiresAt=options.expiresAt;}else if(typeof options.hoursToLive==='number'&&options.hoursToLive!==0){expireDate=new Date();expireDate.setTime(expireDate.getTime()+(options.hoursToLive*60*60*1000));returnValue.expiresAt=expireDate;}if(typeof options.path==='string'&&options.path!==''){returnValue.path=options.path;}if(typeof options.domain==='string'&&options.domain!==''){returnValue.domain=options.domain;}if(options.secure===true){returnValue.secure=options.secure;}}return returnValue;};assembleOptionsString=function(options){options=resolveOptions(options);return((typeof options.expiresAt==='object'&&options.expiresAt instanceof Date?'; expires='+options.expiresAt.toGMTString():'')+'; path='+options.path+(typeof options.domain==='string'?'; domain='+options.domain:'')+(options.secure===true?'; secure':''));};parseCookies=function(){var cookies={},i,pair,name,value,separated=document.cookie.split(';'),unparsedValue;for(i=0;i<separated.length;i=i+1){pair=separated[i].split('=');name=pair[0].replace(/^\s*/,'').replace(/\s*$/,'');try
{value=decodeURIComponent(pair[1]);}catch(e1){value=pair[1];}if(typeof JSON==='object'&&JSON!==null&&typeof JSON.parse==='function'){try
{unparsedValue=value;value=JSON.parse(value);}catch(e2){value=unparsedValue;}}cookies[name]=value;}return cookies;};constructor=function(){};constructor.prototype.get=function(cookieName){var returnValue,item,cookies=parseCookies();if(typeof cookieName==='string'){returnValue=(typeof cookies[cookieName]!=='undefined')?cookies[cookieName]:null;}else if(typeof cookieName==='object'&&cookieName!==null){returnValue={};for(item in cookieName){if(typeof cookies[cookieName[item]]!=='undefined'){returnValue[cookieName[item]]=cookies[cookieName[item]];}else
{returnValue[cookieName[item]]=null;}}}else
{returnValue=cookies;}return returnValue;};constructor.prototype.filter=function(cookieNameRegExp){var cookieName,returnValue={},cookies=parseCookies();if(typeof cookieNameRegExp==='string'){cookieNameRegExp=new RegExp(cookieNameRegExp);}for(cookieName in cookies){if(cookieName.match(cookieNameRegExp)){returnValue[cookieName]=cookies[cookieName];}}return returnValue;};constructor.prototype.set=function(cookieName,value,options){if(typeof options!=='object'||options===null){options={};}if(typeof value==='undefined'||value===null){value='';options.hoursToLive=-8760;}else if(typeof value!=='string'){if(typeof JSON==='object'&&JSON!==null&&typeof JSON.stringify==='function'){value=JSON.stringify(value);}else
{throw new Error('cookies.set() received non-string value and could not serialize.');}}var optionsString=assembleOptionsString(options);document.cookie=cookieName+'='+encodeURIComponent(value)+optionsString;};constructor.prototype.del=function(cookieName,options){var allCookies={},name;if(typeof options!=='object'||options===null){options={};}if(typeof cookieName==='boolean'&&cookieName===true){allCookies=this.get();}else if(typeof cookieName==='string'){allCookies[cookieName]=true;}for(name in allCookies){if(typeof name==='string'&&name!==''){this.set(name,null,options);}}};constructor.prototype.test=function(){var returnValue=false,testName='cT',testValue='data';this.set(testName,testValue);if(this.get(testName)===testValue){this.del(testName);returnValue=true;}return returnValue;};constructor.prototype.setOptions=function(options){if(typeof options!=='object'){options=null;}defaultOptions=resolveOptions(options);};return new constructor();})();(function(){if(window.jQuery){(function($){$.cookies=jaaulde.utils.cookies;var extensions={cookify:function(options){return this.each(function(){var i,nameAttrs=['name','id'],name,$this=$(this),value;for(i in nameAttrs){if(!isNaN(i)){name=$this.attr(nameAttrs[i]);if(typeof name==='string'&&name!==''){if($this.is(':checkbox, :radio')){if($this.attr('checked')){value=$this.val();}}else if($this.is(':input')){value=$this.val();}else
{value=$this.html();}if(typeof value!=='string'||value===''){value=null;}$.cookies.set(name,value,options);break;}}}});},cookieFill:function(){return this.each(function(){var n,getN,nameAttrs=['name','id'],name,$this=$(this),value;getN=function(){n=nameAttrs.pop();return!!n;};while(getN()){name=$this.attr(n);if(typeof name==='string'&&name!==''){value=$.cookies.get(name);if(value!==null){if($this.is(':checkbox, :radio')){if($this.val()===value){$this.attr('checked','checked');}else
{$this.removeAttr('checked');}}else if($this.is(':input')){$this.val(value);}else
{$this.html(value);}}break;}}});},cookieBind:function(options){return this.each(function(){var $this=$(this);$this.cookieFill().change(function(){$this.cookify(options);});});}};$.each(extensions,function(i){$.fn[i]=this;});})(window.jQuery);}})();;
/*
 * Swipe 1.0
 *
 * Brad Birdsall, Prime
 * Copyright 2011, Licensed GPL & MIT
 *
*/
window.Swipe=function(a,b){if(!a)return null;var c=this;this.options=b||{},this.index=this.options.startSlide||0,this.speed=this.options.speed||300,this.callback=this.options.callback||function(){},this.delay=this.options.auto||0,this.container=a,this.element=this.container.children[0],this.container.style.overflow="hidden",this.element.style.listStyle="none",this.setup(),this.begin(),this.element.addEventListener&&(this.element.addEventListener("touchstart",this,!1),this.element.addEventListener("touchmove",this,!1),this.element.addEventListener("touchend",this,!1),this.element.addEventListener("webkitTransitionEnd",this,!1),this.element.addEventListener("msTransitionEnd",this,!1),this.element.addEventListener("oTransitionEnd",this,!1),this.element.addEventListener("transitionend",this,!1),window.addEventListener("resize",this,!1))},Swipe.prototype={setup:function(){this.slides=this.element.children,this.length=this.slides.length;if(this.length<2)return null;this.width=this.container.getBoundingClientRect().width;if(!this.width)return null;this.container.style.visibility="hidden",this.element.style.width=this.slides.length*this.width+"px";var a=this.slides.length;while(a--){var b=this.slides[a];b.style.width=this.width+"px",b.style.display="table-cell",b.style.verticalAlign="top"}this.slide(this.index,0),this.container.style.visibility="visible"},slide:function(a,b){var c=this.element.style;c.webkitTransitionDuration=c.MozTransitionDuration=c.msTransitionDuration=c.OTransitionDuration=c.transitionDuration=b+"ms",c.webkitTransform="translate3d("+ -(a*this.width)+"px,0,0)",c.msTransform=c.MozTransform=c.OTransform="translateX("+ -(a*this.width)+"px)",this.index=a},getPos:function(){return this.index},prev:function(a){this.delay=a||0,clearTimeout(this.interval),this.index&&this.slide(this.index-1,this.speed)},next:function(a){this.delay=a||0,clearTimeout(this.interval),this.index<this.length-1?this.slide(this.index+1,this.speed):this.slide(0,this.speed)},begin:function(){var a=this;this.interval=this.delay?setTimeout(function(){a.next(a.delay)},this.delay):0},stop:function(){this.delay=0,clearTimeout(this.interval)},resume:function(){this.delay=this.options.auto||0,this.begin()},handleEvent:function(a){switch(a.type){case"touchstart":this.onTouchStart(a);break;case"touchmove":this.onTouchMove(a);break;case"touchend":this.onTouchEnd(a);break;case"webkitTransitionEnd":case"msTransitionEnd":case"oTransitionEnd":case"transitionend":this.transitionEnd(a);break;case"resize":this.setup()}},transitionEnd:function(a){this.delay&&this.begin(),this.callback(a,this.index,this.slides[this.index])},onTouchStart:function(a){this.start={pageX:a.touches[0].pageX,pageY:a.touches[0].pageY,time:Number(new Date)},this.isScrolling=undefined,this.deltaX=0,this.element.style.webkitTransitionDuration=0},onTouchMove:function(a){if(a.touches.length>1||a.scale&&a.scale!==1)return;this.deltaX=a.touches[0].pageX-this.start.pageX,typeof this.isScrolling=="undefined"&&(this.isScrolling=!!(this.isScrolling||Math.abs(this.deltaX)<Math.abs(a.touches[0].pageY-this.start.pageY))),this.isScrolling||(a.preventDefault(),clearTimeout(this.interval),this.deltaX=this.deltaX/(!this.index&&this.deltaX>0||this.index==this.length-1&&this.deltaX<0?Math.abs(this.deltaX)/this.width+1:1),this.element.style.webkitTransform="translate3d("+(this.deltaX-this.index*this.width)+"px,0,0)")},onTouchEnd:function(a){var b=Number(new Date)-this.start.time<250&&Math.abs(this.deltaX)>20||Math.abs(this.deltaX)>this.width/2,c=!this.index&&this.deltaX>0||this.index==this.length-1&&this.deltaX<0;this.isScrolling||this.slide(this.index+(b&&!c?this.deltaX<0?1:-1:0),this.speed)}};
Drupal.behaviors.skele = {
  attach: function(context, settings) {
    (function ($) {

      /* =============================================================================
         Display option JavaScript coding.
         ========================================================================== */      
      $('#show-hide-option').click(function() {
        $('#block-block-8').toggleClass('expand');
      });
      
      var currentFac = 0;
      var maxFontSize = 3;
      var minFontSize = 0;
      
      var ourText = $('.node-type-song .node-content');
      var ourText2 = $('.node-type-song .node-content span.part');
        
      // Get default value from cookie.
      if ($.cookies.get('fontFinalNum') != null) {
        ourText.css('fontSize', $.cookies.get('fontFinalNum') + 'px');
      }
      if ($.cookies.get('fontFinalNum2') != null) {
        ourText2.css('fontSize', $.cookies.get('fontFinalNum2') + 'px');
      }
      if ($.cookies.get('fontFinalNum2') != null) {
        currentFac = $.cookies.get('fontCurrFact');
      }
      
      $('#font-size-changer a').click(function() {
        var currFontSize = ourText.css('fontSize');
        var finalNum = parseFloat(currFontSize, 10);
        var stringEnding = currFontSize.slice(-2);
        
        if (ourText2.length > 0) {
          var currFontSize2 = ourText2.css('fontSize');
          var finalNum2 = parseFloat(currFontSize2, 10);
          var stringEnding2 = currFontSize2.slice(-2);
        }
        
        if(this.id == 'inc-font' && currentFac < maxFontSize) {
          finalNum *= 1.2;
          finalNum2 *= 1.2;
          currentFac++;
        }
        else if (this.id == 'dec-font' && currentFac > minFontSize){
          finalNum /=1.2;
          finalNum2 /=1.2;
          currentFac--;
        }
        
        $.cookies.set('fontFinalNum', finalNum);
        $.cookies.set('fontFinalNum2', finalNum);
        $.cookies.set('fontCurrFact', currentFac);
        
        ourText.css('fontSize', finalNum + stringEnding);
        ourText2.css('fontSize', finalNum2 + stringEnding2);
      });
      
      $('#reset-font').click(function() {
        ourText.css('font-size', '14px');
        ourText2.css('font-size', '16px');
        currentFac = 0;
        
        $.cookies.set('fontFinalNum', '14px');
        $.cookies.set('fontFinalNum2', '16px');
        $.cookies.set('fontCurrFact', currentFac);
      });
      
      /* =============================================================================
         Add 'x' close button and handler to status messages.
         ========================================================================== */
      $.fn.closeButtonMessages = function() {
        $('.messages').each(function() {
          if ($(this).find('a.close').length < 1) {
            $(this).prepend('<a class="close" href="#" title="' + Drupal.t('Close') + '">x</a>');
          }
        });
        $('.messages a.close').click(function(e) {
          e.preventDefault();
          $(this).parent().fadeOut('slow');
        });
      };
      $().closeButtonMessages();

      /* =============================================================================
         Wrap current page pager item with <a> element for styling.
         ========================================================================== */
      $('ul.pager li.pager-current, ul.pager li.pager-ellipsis').wrapInner('<a href="#" />');
      $('ul.pager li.pager-current a, ul.pager li.pager-ellipsis a').click(function(e) {
        e.preventDefault();
      });

      /* =============================================================================
         Search block usability enhancement.
         ========================================================================== */
      $.fn.searchBlockOverlabel = function() {
        var elem = $(this[0]);
        var searchBlockText = Drupal.t('Enter the title of the song of part of it...');

        $(elem).find('.form-text:first').val(searchBlockText);
        $(elem).find('.form-text:first').focus(function() {
          if ($(this).val() == searchBlockText) {
            $(this).val('');
          }
        });
        $(elem).find('.form-text:first').blur(function() {
          if ($(this).val() == '') {
            $(this).val(searchBlockText);
          }
        });
        $(elem).find('.form-submit').attr('title', searchBlockText);
        $(elem).find('form').submit(function(e) {
          if ($(elem).find('.form-text:first').val() == searchBlockText) {
            e.preventDefault();
            $(elem).find('.form-text:first').focus();
          }
        });
      };
      $('#block-search-form').searchBlockOverlabel();
      $('#block-multiblock-1').searchBlockOverlabel();
      
      if (window.location.pathname == Drupal.settings.basePath) {
        $('#block-multiblock-1 input.form-text').focus();
        $('#block-multiblock-1 input.form-text').val('');
      }
      
      if ($.cookies.get('closePreTopHeaderNews1') != null && $.cookies.get('closePreTopHeaderNews1')) {
        $('#pretop-header-wrapper').css('display', 'none');
      }
      $('#pretop-header-wrapper .close-btn a').click(function(e) {
        e.preventDefault();
        $('#pretop-header-wrapper').fadeOut('slow');
        $.cookies.set('closePreTopHeaderNews1', true, 5);
      });
    })(jQuery);
  }
}
;

