Drupal.locale = { 'pluralFormula': function ($n) { return Number(($n!=1)); }, 'strings': {"An AJAX HTTP error occurred.":"Tapahtui AJAX HTTP virhe.","HTTP Result Code: !status":"HTTP koodi: !status","An AJAX HTTP request terminated abnormally.":"AJAX HTTP pyynt\u00f6 keskeytyi odottamatta.","Debugging information follows.":"Seuraavassa virhetiedot.","Path: !uri":"Polku: !url","StatusText: !statusText":"Tilanneteksti: !statusText","ResponseText: !responseText":"Vastausteksti: !responseText","ReadyState: !readyState":"ReadyState: !readyState","Loading":"Lataa","(active tab)":"(aktiivinen v\u00e4lilehti)","Hide":"Piilossa","Show":"N\u00e4yt\u00e4","Re-order rows by numerical weight instead of dragging.":"Uudelleenlajittele rivit numeerisen painon mukaan ved\u00e4-pudota toiminnon sijaan.","Show row weights":"N\u00e4yt\u00e4 rivien painokertoimet","Hide row weights":"Piilota rivien painokertoimet","Drag to re-order":"J\u00e4rjestele vet\u00e4m\u00e4ll\u00e4","Changes made in this table will not be saved until the form is submitted.":"Muutokset otetaan k\u00e4ytt\u00f6\u00f6n vasta kun valitset \u003cem\u003etallenna\u003c\/em\u003e.","Enabled":"K\u00e4yt\u00f6ss\u00e4","Configure":"M\u00e4\u00e4rittele","Hide shortcuts":"Piilota oikopolut","@title dialog":"@title dialogi","Show shortcuts":"N\u00e4yt\u00e4 oikopolut","Customize dashboard":"Kustomoi kojelautaa","Disabled":"Ei k\u00e4yt\u00f6ss\u00e4","Not restricted":"Ei rajoitettu","Restricted to certain pages":"Rajoitettu tiettyihin sivuihin","Not customizable":"Ei mukautettavissa","The changes to these blocks will not be saved until the \u003cem\u003eSave blocks\u003c\/em\u003e button is clicked.":"Lohkojen muutoksia ei tallenneta ennen kuin klikkaat \u003cem\u003eTallenna\u003c\/em\u003e-painiketta.","The block cannot be placed in this region.":"Lohkoa ei voi asettaa t\u00e4h\u00e4n alueeseen.","None":"Ei yht\u00e4\u00e4n","Edit":"Muokkaa","Select all rows in this table":"Valitse kaikki taulukon rivit","Deselect all rows in this table":"Poista kaikkien rivien valinnat","Please wait...":"Odota hetki...","Requires a title":"Vaatii otsikon","Not published":"Ei julkaistu","Don't display post information":"\u00c4l\u00e4 n\u00e4yt\u00e4 l\u00e4hetyksen tietoja","Hide summary":"Piilota yhteenveto","Edit summary":"Muokkaa yhteenvetoa","Not in menu":"Ei valikossa","New revision":"Uusi versio","No revision":"Ei versiota","By @name on @date":"@name p\u00e4iv\u00e4n\u00e4 @date","By @name":"@name","Alias: @alias":"Alias: @alias","No alias":"Ei aliasta","Autocomplete popup":"Automaattisen t\u00e4ydennyksen ponnahdusikkuna","Searching for matches...":"Haetaan tuloksia...","Done":"Tehty","Upload":"Siirr\u00e4","The selected file %filename cannot be uploaded. Only files with the following extensions are allowed: %extensions.":"Tiedostoa %filename ei voida ladata. Sallitu tiedostop\u00e4\u00e4tteet: %extensions.","This permission is inherited from the authenticated user role.":"Oikeus on periytetty k\u00e4ytt\u00e4j\u00e4roolista \"autentikoitu k\u00e4ytt\u00e4j\u00e4\".","Not in book":"Ei kirjasssa","New book":"Uusi kirja","Flag translations as outdated":"Merkitse k\u00e4\u00e4nn\u00f6kset vanhentuneiksi","Close":"Sulje","Only files with the following extensions are allowed: %files-allowed.":"Vain seuraavat tiedostop\u00e4\u00e4tteet ovat sallittuja: %files-allowed."} };;

(function ($) {
  Drupal.Panels = {};

  Drupal.Panels.autoAttach = function() {
    if ($.browser.msie) {
      // If IE, attach a hover event so we can see our admin links.
      $("div.panel-pane").hover(
        function() {
          $('div.panel-hide', this).addClass("panel-hide-hover"); return true;
        },
        function() {
          $('div.panel-hide', this).removeClass("panel-hide-hover"); return true;
        }
      );
      $("div.admin-links").hover(
        function() {
          $(this).addClass("admin-links-hover"); return true;
        },
        function(){
          $(this).removeClass("admin-links-hover"); return true;
        }
      );
    }
  };

  $(Drupal.Panels.autoAttach);
})(jQuery);
;
(function ($) {

  Drupal.behaviors.reseptihaku = {
    attach: function (context, settings) {

      $("#reseptihakukentta").keyup(function() {
        $("#filter_nimi").attr("value", $(this).val()).change();
        
      });

      /*$(".reseptihakucontainer #clear_hakukentat").click(function() {
            $('.block-reseptihaku input:checked').attr("checked", false);
            $("#filter_nimi").attr("value", "");
            $("#reseptihakukentta").attr("value", "");
            $("#filter_nimi").change();
            
      });
*/

	  $(".reseptihakupalkki").click(function() { 
			var the_parent = $(this).parent();
			var container_id = the_parent.attr("id");
			var the_area = $("#" + container_id + " .block-reseptihaku");
				  	
			if(the_area.is(':hidden') ) {
				 $(this).addClass("open");
		         the_parent.find("#clear_hakukentat").show();
		
		          
		          the_area.animate({
		            height: h,
		          }, "slow", function() {
		            ;
		
		          });  	
	       
		
		          the_area.show();

			}
			else {
				 $(this).removeClass("open");

				the_area.hide();
				


	

			}
	  	     return false;

	  	
	  });



/*
      $(".reseptihakucontainer #piilota_hakukentta").click(function() {
          $(".block-reseptihaku").hide("slow");
          $("#piilota_hakukentta").fadeOut("slow", function () {
              $("#nayta_hakukentta").fadeIn("slow");  
          });
          
          
          $("#clear_hakukentat").hide();

          $('.reseptihakucontainer').animate({
            height: "68px",
          }, "slow", function() {
            ;

          });  
          
                            
          return false;
      });

/*      $(".reseptihakucontainer #nayta_hakukentta").click(function() {
          $("#clear_hakukentat").show();
          $("#nayta_hakukentta").fadeOut("slow", function () {
              $("#piilota_hakukentta").fadeIn("slow", function() {
                
              });
              
              
              
          });

          $('.reseptihakucontainer').animate({
            height: "523px",
          }, "slow", function() {
;
          });          

                  $(".block-reseptihaku").show("slow");


          return false;
      });
*/

      $('.block-reseptihaku input.tuoteryhma_childof_0').change(function() {
              var tid = $(this).attr("name").split("_")[1];
              if($(this).attr('checked')) {
                  $(".tuoteryhma_childof_" + tid).attr("checked", true);
              } else {
                  $(".tuoteryhma_childof_" + tid).attr("checked", false);
              }
              
          
      });

      $('.block-reseptihaku input').change(function() {
              var tid = $(this).attr("name").split("_")[1];
              
              
      var tuotetyyppi_filtterit = $('.block-reseptihaku input.tuoteryhma_childof_121:checked, .block-reseptihaku input.tuoteryhma_childof_128:checked');
              
      var ruokatyyppi_filtterit = $('.block-reseptihaku input.vocabulary_14:checked');

      var vaikeustaso_filtterit = $('.block-reseptihaku input.vocabulary_12:checked');
      var valmistustapa_filtterit = $('.block-reseptihaku input.vocabulary_13:checked');
      var sesonki_filtterit = $('.block-reseptihaku input.vocabulary_22:checked');
      var valmistusaika_filtterit = $('.block-reseptihaku .valmistusaika_checkboxes input:checked');
     // var nimi_filter = $("#filter_nimi").val().toLowerCase();


              $(".reseptihakutulokset .views-row").each(function() {
                var t = $(this);
                var showThis = true;
                
                if (showThis) {                
                    var prodnamn = t.find(".proddesc a").html().toLowerCase();
                    // console.log(prodnamn + " -- " + nimi_filter);
                    /*if (nimi_filter && nimi_filter != "") {                
                        showThis = true;

                        if (prodnamn.indexOf(nimi_filter) == -1) {
                            showThis = false;
                        }
                        
                        
                    }*/
                }                
                
                
                if (showThis) {                
                    var tuoteryhma = t.find(".field_raaka_aineet").html();
                    if (tuotetyyppi_filtterit.length > 0) {                
                        showThis = false;
                        tuotetyyppi_filtterit.each(function() {
                            var filtername = $(this).next().text();
                            if (filtername == tuoteryhma) {
                                showThis = true;
                            }
                        });
                    }
                }


                if (showThis) {
                    var ruokatyyppi = t.find(".field_ruokatyyppi").html();
                    if (ruokatyyppi_filtterit.length > 0) {                
                         showThis = false;
                        ruokatyyppi_filtterit.each(function() {
                            var filtername2 = $(this).next().text();
                            // console.log(ruokatyyppi + " | " + filtername2);
                            if (ruokatyyppi.indexOf(filtername2) >= 0) {
                                showThis = true;
                                // console.log("NÄYTÄ");
                            }
                        });
                    }
                }


                if (showThis) {
                    var vaikeustaso = t.find(".field_vaikeustaso").html();
                    if (vaikeustaso_filtterit.length > 0) {                
                        showThis = false;
                        vaikeustaso_filtterit.each(function() {
                            var filtername3 = $(this).next().text();
                            if (vaikeustaso.indexOf(filtername3) == -1) {
                                showThis = true;
                            }
                        });
                    }
                }


                if (showThis) {
                    var valmistustapa = t.find(".field_valmistustapa").html();
                    if (valmistustapa_filtterit.length > 0) {                
                                showThis = false;

                        valmistustapa_filtterit.each(function() {
                            var filtername4 = $(this).next().text();
                            if (valmistustapa.indexOf(filtername4) >= 0) {
                                                                showThis = true;

                            }
                   
                            


                        });
                    }
                }



                if (showThis) {
                    var sesonki = t.find(".field_sesonki").html();
                    if (sesonki_filtterit.length > 0) {                
                                showThis = false;

                        sesonki_filtterit.each(function() {
                            var filtername5 = $(this).next().text();
                            if (sesonki.indexOf(filtername5) >= 0) {
                                showThis = true;

                            }
                            


                        });
                    }
                }

                if (showThis) {
                    
                    var preptime = t.find(".preptime").html();
                    var cooktime = t.find(".cooktime").html();
                    
                    if (valmistusaika_filtterit.length > 0) {                
                                showThis = false;

                        valmistusaika_filtterit.each(function() {
                            
                            var filtername5 = $(this).attr("name").replace("below_", "");
                            // console.log(filtername5);                            
                            if (parseInt(preptime) <= parseInt(filtername5)) {
                                showThis = true;

                            }
                            


                        });
                    }
                }



              
              if (showThis) {
                t.show();

              } else {
                t.hide();

                
                  
              }


                
              });
              


      });

      
      
      $('.block-reseptihaku input', context).click(function () {

        
        //$(this).next('ul').toggle('show');
      });
      
      
    }
  };

}(jQuery));;
;
(function ($) {

  Drupal.behaviors.tuotehaku = {
    attach: function (context, settings) {

		$(".tuotehakutulokset").ready( function() {
       $(".tuotehakutulokset .views-row").each(function() {

            var t = $(this);
            var uutuustext = $("input[name=tuote_29]").next().text();
            
				// console.log("finding uutuus: " + uutuustext);
            
            var egenskaper = t.find(".field_ominaisuudet").html().toLowerCase();
            if (egenskaper.indexOf(uutuustext.toLowerCase()) >= 0) {
				t.find(".product").append('<div class="uutuus_lapyska">' + uutuustext+ '</div>' );
            }


       });
		});

  /*    $("#tuotehakukentta").keyup(function() {
        $("#filter_nimi").attr("value", $(this).val()).change();
        
      });
*/
      $("#clear_hakukentat").click(function() {
            $('.tuotehakuarea input:checked').attr("checked", false);
            $("#filter_nimi").attr("value", "");
            $("#tuotehakukentta").attr("value", "");
            $("#filter_nimi").change();
            
      });

	  $(".tuotehakupalkki").click(function() { 
			var the_parent = $(this).parent();
			var container_id = the_parent.attr("id");
			var the_area = $("#" + container_id + " .tuotehakuarea");
				  	
			if(the_area.is(':hidden') ) {
				 $(this).addClass("open");
		         the_parent.find("#clear_hakukentat").show();
		
	
	       		  if (container_id=="haku_container_101") {
	       		  	the_area.css("height", "111px");	
	       		  } else if (container_id=="haku_container_102") {
	       		  	the_area.css("height", "230px");	
	       		  	
	       		  }
		
		          the_area.show();

			}
			else {
				 $(this).removeClass("open");

				the_area.hide();
				

	          
	          
	
	          the_area.animate({
	            height: "auto",
	          }, "slow", function() {
	            ;
	
	          });  
	

			}
	  	     return false;

	  	
	  });


 
      $('.tuotehakuarea input.tuoteryhma_childof_0').change(function() {
              var tid = $(this).attr("name").split("_")[1];
              if($(this).attr('checked')) {
                  $(".tuoteryhma_childof_" + tid).attr("checked", true);
              } else {
                  $(".tuoteryhma_childof_" + tid).attr("checked", false);
              }
              
          
      });

      $('.tuotehakuarea input, ').change(function() {
              var tid = $(this).attr("name").split("_")[1];
              
    //  var nimi_filter = $("#filter_nimi").val().toLowerCase();
      
              
      var tuotetyyppi_filtterit = $('.tuotehakuarea input.tuoteryhma_childof_121:checked, .tuotehakuarea input.tuoteryhma_childof_128:checked');
              
      var erikoisruokavalio_filtterit = $('.tuotehakuarea input.vocabulary_4:checked');
      var ominaisuudet_filtterit = $('.tuotehakuarea input.vocabulary_5:checked');
      var allergeeniset_filtterit = $('.tuotehakuarea input.vocabulary_20:checked');
      var mausteet_filtterit = $('.tuotehakuarea input.vocabulary_18:checked');
          // console.log(mausteet_filtterit);   

              $(".tuotehakutulokset .views-row").each(function() {
                var t = $(this);
                var showThis = true;

               /* if (showThis) {                
                    var prodnamn = t.find(".proddesc a").html().toLowerCase();
                    // console.log(prodnamn + " -- " + nimi_filter);
                    if (nimi_filter && nimi_filter != "") {                
                        showThis = true;

                        if (prodnamn.indexOf(nimi_filter) == -1) {
                            showThis = false;
                        }
                        
                        
                    }
                }
*/

                
                if (showThis) {                
                    var tuoteryhma = t.find(".field_tuoteryhma").html();
                    if (tuotetyyppi_filtterit.length > 0) {                
                        showThis = false;
                        tuotetyyppi_filtterit.each(function() {
                            var filtername = $(this).next().text();
                            if (filtername == tuoteryhma) {
                                showThis = true;
                            }
                        });
                    }
                }


                if (showThis) {
                    var erikoisruokavaliot = t.find(".field_erikoisruokavalio").html();
                    if (erikoisruokavalio_filtterit.length > 0) {                

                        erikoisruokavalio_filtterit.each(function() {
                            var filtername2 = $(this).next().text();
                            if (erikoisruokavaliot.indexOf(filtername2) == -1) {
                                showThis = false;
                            }
                        });
                    }
                }


                if (showThis) {
                    var ominaisuudet = t.find(".field_ominaisuudet").html();
                    if (ominaisuudet_filtterit.length > 0) {                
                        ominaisuudet_filtterit.each(function() {
                            var filtername3 = $(this).next().text();
                            if (ominaisuudet.indexOf(filtername3) == -1) {
                                showThis = false;
                            }
                        });
                    }
                }



                if (showThis) {
                    var ainekset =t.find(".field_ainekset").html().toLowerCase();
                    if (allergeeniset_filtterit.length > 0) {                

                        allergeeniset_filtterit.each(function() {
                            var filtername4 = $(this).next().text().toLowerCase();
                            if (ainekset.indexOf(filtername4) >= 0) {
                                showThis = false;
                            }
                            

                            if (filtername4.indexOf("porsa") >= 0) {
                                if (
                                	ainekset.indexOf("kinkku") >= 0 ||
                                	ainekset.indexOf("porsa") >= 0 ||
                                	ainekset.indexOf("sian") >= 0 ||
                                	ainekset.indexOf("sika") >= 0
                                	
                                
                                ) {
                                    showThis = false;
                                }
                            }




                            if (filtername4.indexOf("nauta") >= 0) {
                                if (
                                	ainekset.indexOf("naudan") >= 0 ||
                                	ainekset.indexOf("härän") >= 0 ||
                                	ainekset.indexOf("härkä") >= 0
                                	
                                
                                ) {
                                    showThis = false;
                                }
                            }
                            
                            if (filtername4.indexOf("gris") >= 0) {
                                if (
                                	ainekset.indexOf("gris") >= 0 ||
                                	ainekset.indexOf("skink") >= 0 ||
                                	ainekset.indexOf("svin") >= 0
                                	
                                
                                ) {      
                                	showThis = false;
                                }
                            }
                            
                            if (filtername4.indexOf("pork") >= 0) {
                                if (ainekset.indexOf(" ham") >= 0) {
                                    showThis = false;
                                }
                            }
                            
                            if (filtername4.indexOf("broiler") >= 0) {
                                if (
                                	ainekset.indexOf("broiler") >= 0 ||
                                	ainekset.indexOf("kyckling") >= 0 ||
                                	ainekset.indexOf("höns") >= 0
                                	
                                
                                ) {              
                                	
                                	showThis = false;
                                }



                            }
                            


                        });
                    }
                }



                if (showThis) {
                    var ainekset = t.find(".field_ainekset").html();
                    if (mausteet_filtterit.length > 0) {                

                        mausteet_filtterit.each(function() {
                            var filtername5 = $(this).next().text();
                            if (ainekset.indexOf(filtername5) >= 0) {
                                showThis = false;
                            }
                            


                        });
                    }
                }



              
              if (showThis) {
                t.show();
                // console.log("showing ");
                // console.log($(this));
              } else {
                t.hide();
                // console.log("hiding ");
                // console.log($(this));
                
                  
              }


                
              });
              


      });

      
      
      $('.tuotehakuarea input', context).click(function () {

        
        //$(this).next('ul').toggle('show');
      });
      
      
    }
  };

}(jQuery));;
(function ($) {

/**
 * Toggle the visibility of a fieldset using smooth animations.
 */
Drupal.toggleFieldset = function (fieldset) {
  var $fieldset = $(fieldset);
  if ($fieldset.is('.collapsed')) {
    var $content = $('> .fieldset-wrapper', fieldset).hide();
    $fieldset
      .removeClass('collapsed')
      .trigger({ type: 'collapsed', value: false })
      .find('> legend span.fieldset-legend-prefix').html(Drupal.t('Hide'));
    $content.slideDown({
      duration: 'fast',
      easing: 'linear',
      complete: function () {
        Drupal.collapseScrollIntoView(fieldset);
        fieldset.animating = false;
      },
      step: function () {
        // Scroll the fieldset into view.
        Drupal.collapseScrollIntoView(fieldset);
      }
    });
  }
  else {
    $fieldset.trigger({ type: 'collapsed', value: true });
    $('> .fieldset-wrapper', fieldset).slideUp('fast', function () {
      $fieldset
        .addClass('collapsed')
        .find('> legend span.fieldset-legend-prefix').html(Drupal.t('Show'));
      fieldset.animating = false;
    });
  }
};

/**
 * Scroll a given fieldset into view as much as possible.
 */
Drupal.collapseScrollIntoView = function (node) {
  var h = document.documentElement.clientHeight || document.body.clientHeight || 0;
  var offset = document.documentElement.scrollTop || document.body.scrollTop || 0;
  var posY = $(node).offset().top;
  var fudge = 55;
  if (posY + node.offsetHeight + fudge > h + offset) {
    if (node.offsetHeight > h) {
      window.scrollTo(0, posY);
    }
    else {
      window.scrollTo(0, posY + node.offsetHeight - h + fudge);
    }
  }
};

Drupal.behaviors.collapse = {
  attach: function (context, settings) {
    $('fieldset.collapsible', context).once('collapse', function () {
      var $fieldset = $(this);
      // Expand fieldset if there are errors inside, or if it contains an
      // element that is targeted by the uri fragment identifier. 
      var anchor = location.hash && location.hash != '#' ? ', ' + location.hash : '';
      if ($('.error' + anchor, $fieldset).length) {
        $fieldset.removeClass('collapsed');
      }

      var summary = $('<span class="summary"></span>');
      $fieldset.
        bind('summaryUpdated', function () {
          var text = $.trim($fieldset.drupalGetSummary());
          summary.html(text ? ' (' + text + ')' : '');
        })
        .trigger('summaryUpdated');

      // Turn the legend into a clickable link, but retain span.fieldset-legend
      // for CSS positioning.
      var $legend = $('> legend .fieldset-legend', this);

      $('<span class="fieldset-legend-prefix element-invisible"></span>')
        .append($fieldset.hasClass('collapsed') ? Drupal.t('Show') : Drupal.t('Hide'))
        .prependTo($legend)
        .after(' ');

      // .wrapInner() does not retain bound events.
      var $link = $('<a class="fieldset-title" href="#"></a>')
        .prepend($legend.contents())
        .appendTo($legend)
        .click(function () {
          var fieldset = $fieldset.get(0);
          // Don't animate multiple times.
          if (!fieldset.animating) {
            fieldset.animating = true;
            Drupal.toggleFieldset(fieldset);
          }
          return false;
        });

      $legend.append(summary);
    });
  }
};

})(jQuery);
;
;
(function ($) {
  Drupal.viewsSlideshow = Drupal.viewsSlideshow || {};
  
  Drupal.behaviors.viewsSlideshowControlsText = {
    attach: function (context) {
  
      // Process previous link
      $('.views_slideshow_controls_text_previous:not(.views-slideshow-controls-text-previous-processed)', context).addClass('views-slideshow-controls-text-previous-processed').each(function() {
        var uniqueID = $(this).attr('id').replace('views_slideshow_controls_text_previous_', '');
        $(this).click(function() {
          Drupal.viewsSlideshow.action({ "action": 'previousSlide', "slideshowID": uniqueID });
          return false;
        });
      });
      
      // Process next link
      $('.views_slideshow_controls_text_next:not(.views-slideshow-controls-text-next-processed)', context).addClass('views-slideshow-controls-text-next-processed').each(function() {
        var uniqueID = $(this).attr('id').replace('views_slideshow_controls_text_next_', '');
        $(this).click(function() {
          Drupal.viewsSlideshow.action({ "action": 'nextSlide', "slideshowID": uniqueID });
          return false;
        });
      });
      
      // Process pause link
      $('.views_slideshow_controls_text_pause:not(.views-slideshow-controls-text-pause-processed)', context).addClass('views-slideshow-controls-text-pause-processed').each(function() {
        var uniqueID = $(this).attr('id').replace('views_slideshow_controls_text_pause_', '');
        $(this).click(function() {
          if (Drupal.settings.viewsSlideshow[uniqueID].paused) {
            Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": uniqueID });
          }
          else {
            Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": uniqueID });
          }
          return false;
        });
      });
    }
  };
  
  Drupal.viewsSlideshowControlsText = Drupal.viewsSlideshowControlsText || {};

  /**
   * Implement hook_viewsSlideshowPause for text controls.
   */
  Drupal.viewsSlideshowControlsText.pause = function (options) {
    var pauseText = Drupal.theme.prototype['viewsSlideshowControlsPause'] ? Drupal.theme('viewsSlideshowControlsPause') : '';
    $('#views_slideshow_controls_text_pause_' + options.slideshowID).text(pauseText);
  }
  
  /**
   * Implement hook_viewsSlideshowPlay for text controls.
   */
  Drupal.viewsSlideshowControlsText.play = function (options) {
    var playText = Drupal.theme.prototype['viewsSlideshowControlsPlay'] ? Drupal.theme('viewsSlideshowControlsPlay') : '';
    $('#views_slideshow_controls_text_pause_' + options.slideshowID).text(playText);
  }
  
  // Theme control pause.
  Drupal.theme.prototype.viewsSlideshowControlsPause = function () {
    return Drupal.t('Resume');
  }
  
  // Theme control pause.
  Drupal.theme.prototype.viewsSlideshowControlsPlay = function () {
    return Drupal.t('Pause');
  }
  
  Drupal.behaviors.viewsSlideshowPagerFields = {
    attach: function (context) {
      // Process pause on hover.
      $('.views_slideshow_pager_field:not(.views-slideshow-pager-field-processed)', context).addClass('views-slideshow-pager-field-processed').each(function() {
        // Parse out the location and unique id from the full id.
        var pagerInfo = $(this).attr('id').split('_');
        var location = pagerInfo[2];
        pagerInfo.splice(0, 3);
        var uniqueID = pagerInfo.join('_');
        
        // Add the activate and pause on pager hover event to each pager item.
        if (Drupal.settings.viewsSlideshowPagerFields[uniqueID][location].activatePauseOnHover) {
          $(this).children().each(function(index, pagerItem) {
            $(pagerItem).hover(function() {
              Drupal.viewsSlideshow.action({ "action": 'goToSlide', "slideshowID": uniqueID, "slideNum": index });
              Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": uniqueID });
            },
            function() {
              Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": uniqueID });
            });
          });
        }
        else {
          $(this).children().each(function(index, pagerItem) {
            $(pagerItem).click(function() {
              Drupal.viewsSlideshow.action({ "action": 'goToSlide', "slideshowID": uniqueID, "slideNum": index });
            });
          });
        }
      });
    }
  };
  
  Drupal.viewsSlideshowPagerFields = Drupal.viewsSlideshowPagerFields || {};
  
  /**
   * Implement hook_viewsSlidshowTransitionBegin for pager fields pager.
   */
  Drupal.viewsSlideshowPagerFields.transitionBegin = function (options) {
    // Remove active class from pagers
    $('[id^="views_slideshow_pager_field_item_' + options.slideshowID + '"]').removeClass('active');
    
    // Add active class to active pager.
    $('#views_slideshow_pager_field_item_' + options.slideshowID + '_' + options.slideNum).addClass('active');
  }
  
  Drupal.viewsSlideshowSlideCounter = Drupal.viewsSlideshowSlideCounter || {};
  
  /**
   * Implement hook_viewsSlidshowTransitionBegin for pager fields pager.
   */
  Drupal.viewsSlideshowSlideCounter.transitionBegin = function (options) {
    $('#views_slideshow_slide_counter_' + options.slideshowID + ' .num').text(options.slideNum + 1);
  }
  
  /**
   * This is used as a router to process actions for the slideshow.
   */
  Drupal.viewsSlideshow.action = function (options) {
    // Set default values for our return status.
    var status = {
      'value': true,
      'text': ''
    }

    // If an action isn't specified return false.
    if (typeof options.action == 'undefined' || options.action == '') {
      status.value = false;
      status.text =  Drupal.t('There was no action specified.');
      return error;
    }
    
    // If we are using pause or play switch paused state accordingly.
    if (options.action == 'pause') {
      Drupal.settings.viewsSlideshow[options.slideshowID].paused = 1;
    }
    else if (options.action == 'play') {
      Drupal.settings.viewsSlideshow[options.slideshowID].paused = 0;
    }
    
    // We use a switch statement here mainly just to limit the type of actions
    // that are available.
    switch (options.action) {
      case "goToSlide":
      case "transitionBegin":
      case "transitionEnd":
        // The three methods above require a slide number. Checking if it is
        // defined and it is a number that is an integer.
        if (typeof options.slideNum == 'undefined' || typeof options.slideNum !== 'number' || parseInt(options.slideNum) != (options.slideNum - 0)) {
          status.value = false;
          status.text = Drupal.t('An invalid integer was specified for slideNum.');
        }
      case "pause":
      case "play":
      case "nextSlide":
      case "previousSlide":
        // Grab our list of methods.
        var methods = Drupal.settings.viewsSlideshow[options.slideshowID]['methods'];
        
        // if the calling method specified methods that shouldn't be called then
        // exclude calling them.
        var excludeMethodsObj = {};
        if (typeof options.excludeMethods !== 'undefined') {
          // We need to turn the excludeMethods array into an object so we can use the in
          // function.
          for (var i=0; i < excludeMethods.length; i++) {
            excludeMethodsObj[excludeMethods[i]] = '';
          }
        }
        
        // Call every registered method and don't call excluded ones.
        for (i = 0; i < methods[options.action].length; i++) {
          if (Drupal[methods[options.action][i]] != undefined && typeof Drupal[methods[options.action][i]][options.action] == 'function' && !(methods[options.action][i] in excludeMethodsObj)) {
            Drupal[methods[options.action][i]][options.action](options);
          }
        }
        break;
      
      // If it gets here it's because it's an invalid action. 
      default:
        status.value = false;
        status.text = Drupal.t('An invalid action "!action" was specified.', { "!action": options.action });
    }
    return status;
  }
})(jQuery);
;

/**
 *  @file
 *  A simple jQuery Cycle Div Slideshow Rotator.
 */

/**
 * This will set our initial behavior, by starting up each individual slideshow.
 */
(function ($) {
  Drupal.behaviors.viewsSlideshowCycle = {
    attach: function (context) {
      $('.views_slideshow_cycle_main:not(.viewsSlideshowCycle-processed)', context).addClass('viewsSlideshowCycle-processed').each(function() {
        var fullId = '#' + $(this).attr('id');
        var settings = Drupal.settings.viewsSlideshowCycle[fullId];
        settings.targetId = '#' + $(fullId + " :first").attr('id');
        settings.slideshowId = settings.targetId.replace('#views_slideshow_cycle_teaser_section_', '');
        settings.paused = false;
    
        settings.opts = {
          speed:settings.speed,
          timeout:settings.timeout,
          delay:settings.delay,
          sync:settings.sync,
          random:settings.random,
          nowrap:settings.nowrap,
          after:function(curr, next, opts) {
            // Need to do some special handling on first load.
            var slideNum = opts.currSlide;
            if (typeof settings.processedAfter == 'undefined' || !settings.processedAfter) {
              settings.processedAfter = 1;
              slideNum = (typeof settings.opts.startingSlide == 'undefined') ? 0 : settings.opts.startingSlide;
            }
            Drupal.viewsSlideshow.action({ "action": 'transitionEnd', "slideshowID": settings.slideshowId, "slideNum": slideNum });
          },
          before:function(curr, next, opts) {
            // Remember last slide.
            if (settings.remember_slide) {
              createCookie(settings.vss_id, opts.currSlide + 1, settings.remember_slide_days);
            }
    
            // Make variable height.
            if (!settings.fixed_height) {
              //get the height of the current slide
              var $ht = $(this).height();
              //set the container's height to that of the current slide
              $(this).parent().animate({height: $ht});
            }
            
            // Need to do some special handling on first load.
            var slideNum = opts.nextSlide;
            if (typeof settings.processedBefore == 'undefined' || !settings.processedBefore) {
              settings.processedBefore = 1;
              slideNum = (typeof settings.opts.startingSlide == 'undefined') ? 0 : settings.opts.startingSlide;
            }
            
            Drupal.viewsSlideshow.action({ "action": 'transitionBegin', "slideshowID": settings.slideshowId, "slideNum": slideNum });
          },
          cleartype:(settings.cleartype)? true : false,
          cleartypeNoBg:(settings.cleartypenobg)? true : false
        }
        
        // Set the starting slide if we are supposed to remember the slide
        if (settings.remember_slide) {
          var startSlide = readCookie(settings.vss_id);
          if (startSlide == null) {
            startSlide = 0;
          }
          settings.opts.startingSlide =  startSlide;
        }
    
        if (settings.effect == 'none') {
          settings.opts.speed = 1;
        }
        else {
          settings.opts.fx = settings.effect;
        }
        
        // Take starting item from fragment.
        var hash = location.hash;
        if (hash) {
          var hash = hash.replace('#', '');
          var aHash = hash.split(';');
          var aHashLen = aHash.length;
          
          // Loop through all the possible starting points.
          for (var i = 0; i < aHashLen; i++) {
            // Split the hash into two parts. One part is the slideshow id the
            // other is the slide number.
            var initialInfo = aHash[i].split(':');
            // The id in the hash should match our slideshow.
            // The slide number chosen shouldn't be larger than the number of
            // slides we have.
            if (settings.slideshowId == initialInfo[0] && settings.num_divs > initialInfo[1]) {
              settings.opts.startingSlide = parseInt(initialInfo[1]);
            }
          }
        }

        // Pause on hover.
        if (settings.pause) {
          $('#views_slideshow_cycle_teaser_section_' + settings.vss_id).hover(function() {
            Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId });
          }, function() {
            if (!settings.paused) {
              Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": settings.slideshowId });
            }
          });
        }
    
        // Pause on clicking of the slide.
        if (settings.pause_on_click) {
          $('#views_slideshow_cycle_teaser_section_' + settings.vss_id).click(function() {
            Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId });
          });
        }
        
        if (typeof JSON != 'undefined') {
          var advancedOptions = JSON.parse(settings.advanced_options);
          for (var option in advancedOptions) {
            advancedOptions[option] = $.trim(advancedOptions[option]);
            advancedOptions[option] = advancedOptions[option].replace(/\n/g, '');
            if (!isNaN(parseInt(advancedOptions[option]))) {
              advancedOptions[option] = parseInt(advancedOptions[option]);
            }
            else if (advancedOptions[option].toLowerCase() == 'true') {
              advancedOptions[option] = true;
            }
            else if (advancedOptions[option].toLowerCase() == 'false') {
              advancedOptions[option] = false;
            }
            
            switch(option) {
              
              // Standard Options
              case "activePagerClass":
              case "allowPagerClickBubble":
              case "autostop":
              case "autostopCount":
              case "backwards":
              case "bounce":
              case "cleartype":
              case "cleartypeNoBg":
              case "containerResize":
              case "continuous":
              case "delay":
              case "easeIn":
              case "easeOut":
              case "easing":
              case "fastOnEvent":
              case "fit":
              case "fx":
              case "height":
              case "manualTrump":
              case "next":
              case "nowrap":
              case "pager":
              case "pagerEvent":
              case "pause":
              case "pauseOnPagerHover":
              case "prev":
              case "prevNextEvent":
              case "random":
              case "randomizeEffects":
              case "requeueOnImageNotLoaded":
              case "requeueTimeout":
              case "rev":
              case "slideExpr":
              case "slideResize":
              case "speed":
              case "speedIn":
              case "speedOut":
              case "startingSlide":
              case "sync":
              case "timeout":
                settings.opts[option] = advancedOptions[option];
                break;
              
              // These process options that look like {top:50, bottom:20}
              case "animIn":
              case "animOut":
              case "cssBefore":
              case "cssAfter":
              case "shuffle":
                settings.opts[option] = eval('(' + advancedOptions[option] + ')');
                break;
              
              // These options have their own functions.
              case "after":
                // transition callback (scope set to element that was shown): function(currSlideElement, nextSlideElement, options, forwardFlag) 
                settings.opts[option] = function(currSlideElement, nextSlideElement, options, forwardFlag) {
                  eval(advancedOptions[option]);
                }
                break;
              
              case "before":
                // transition callback (scope set to element to be shown):     function(currSlideElement, nextSlideElement, options, forwardFlag) 
                settings.opts[option] = function(currSlideElement, nextSlideElement, options, forwardFlag) {
                  eval(advancedOptions[option]);
                }
                break;
              
              case "end":
                // callback invoked when the slideshow terminates (use with autostop or nowrap options): function(options)
                settings.opts[option] = function(options) {
                  eval(advancedOptions[option]);
                }
                break;
              
              case "fxFn":
                // function used to control the transition: function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag)
                settings.opts[option] = function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag) {
                  eval(advancedOptions[option]);
                }
                break;
              
              case "onPagerEvent":
                settings.opts[option] = function(zeroBasedSlideIndex, slideElement) {
                  eval(advancedOptions[option]);
                }
                break;
              
              case "onPrevNextEvent":
                settings.opts[option] = function(isNext, zeroBasedSlideIndex, slideElement) {
                  eval(advancedOptions[option]);
                }
                break;
              
              case "pagerAnchorBuilder":
                // callback fn for building anchor links:  function(index, DOMelement)
                settings.opts[option] = function(index, DOMelement) {
                  eval(advancedOptions[option]);
                }
                break;
              
              case "pagerClick":
                // callback fn for pager clicks:    function(zeroBasedSlideIndex, slideElement)
                settings.opts[option] = function(zeroBasedSlideIndex, slideElement) {
                  eval(advancedOptions[option]);
                }
                break;
              
              case "timeoutFn":
                settings.opts[option] = function(currSlideElement, nextSlideElement, options, forwardFlag) {
                  eval(advancedOptions[option]);
                }
                break;
          
              case "updateActivePagerLink":
                // callback fn invoked to update the active pager link (adds/removes activePagerClass style)
                settings.opts[option] = function(pager, currSlideIndex) {
                  eval(advancedOptions[option]);
                }
                break;
            }
          }
        }
        
        // If selected wait for the images to be loaded.
        // otherwise just load the slideshow.
        if (settings.wait_for_image_load) {
          // For IE/Chrome/Opera we if there are images then we need to make
          // sure the images are loaded before starting the slideshow.
          settings.totalImages = $(settings.targetId + ' img').length;
          if (settings.totalImages) {
            settings.loadedImages = 0;
  
            // Add a load event for each image.
            $(settings.targetId + ' img').each(function() {
              var $imageElement = $(this);
              $imageElement.bind('load', function () {
                Drupal.viewsSlideshowCycle.imageWait(fullId);
              });
              
              // Removing the source and adding it again will fire the load event.
              var imgSrc = $imageElement.attr('src');
              $imageElement.attr('src', '');
              $imageElement.attr('src', imgSrc);
            });
          }
          else {
            Drupal.viewsSlideshowCycle.load(fullId);
          }
        }
        else {
          Drupal.viewsSlideshowCycle.load(fullId);
        }
      });
    }
  };
  
  Drupal.viewsSlideshowCycle = Drupal.viewsSlideshowCycle || {};
  
  // This checks to see if all the images have been loaded.
  // If they have then it starts the slideshow.
  Drupal.viewsSlideshowCycle.imageWait = function(fullId) {
    if (++Drupal.settings.viewsSlideshowCycle[fullId].loadedImages == Drupal.settings.viewsSlideshowCycle[fullId].totalImages) {
      Drupal.viewsSlideshowCycle.load(fullId);
    }
  }
  
  // Start the slideshow.
  Drupal.viewsSlideshowCycle.load = function (fullId) {
    var settings = Drupal.settings.viewsSlideshowCycle[fullId];
    $(settings.targetId).cycle(settings.opts);
    
    // Start Paused
    if (settings.start_paused) {
      Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId });
    }
    
    // Pause if hidden.
    if (settings.pause_when_hidden) {
      var checkPause = function(settings) {
        // If the slideshow is visible and it is paused then resume.
        // otherwise if the slideshow is not visible and it is not paused then
        // pause it.
        var visible = viewsSlideshowCycleIsVisible(settings.targetId, settings.pause_when_hidden_type, settings.amount_allowed_visible);
        if (visible && settings.paused) {
          Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": settings.slideshowId });
        }
        else if (!visible && !settings.paused) {
          Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": settings.slideshowId });
        }
      }
     
      // Check when scrolled.
      $(window).scroll(function() {
       checkPause(settings);
      });
      
      // Check when the window is resized.
      $(window).resize(function() {
        checkPause(settings);
      });
    }
  }
  
  Drupal.viewsSlideshowCycle.pause = function (options) {
    $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle('pause');
  }
  
  Drupal.viewsSlideshowCycle.play = function (options) {
    $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle('resume');
  }
  
  Drupal.viewsSlideshowCycle.previousSlide = function (options) {
    $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle('prev');
  }
  
  Drupal.viewsSlideshowCycle.nextSlide = function (options) {
    $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle('next');
  }
  
  Drupal.viewsSlideshowCycle.goToSlide = function (options) {
    $('#views_slideshow_cycle_teaser_section_' + options.slideshowID).cycle(options.slideNum);
  }
  
  // Verify that the value is a number.
  function IsNumeric(sText) {
    var ValidChars = "0123456789";
    var IsNumber=true;
    var Char;
  
    for (var i=0; i < sText.length && IsNumber == true; i++) { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) {
        IsNumber = false;
      }
    }
    return IsNumber;
  }
  
  /**
   * Cookie Handling Functions
   */
  function createCookie(name,value,days) {
    if (days) {
      var date = new Date();
      date.setTime(date.getTime()+(days*24*60*60*1000));
      var expires = "; expires="+date.toGMTString();
    }
    else {
      var expires = "";
    }
    document.cookie = name+"="+value+expires+"; path=/";
  }
  
  function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
      var c = ca[i];
      while (c.charAt(0)==' ') c = c.substring(1,c.length);
      if (c.indexOf(nameEQ) == 0) {
        return c.substring(nameEQ.length,c.length);
      }
    }
    return null;
  }
  
  function eraseCookie(name) {
    createCookie(name,"",-1);
  }
  
  /**
   * Checks to see if the slide is visible enough.
   * elem = element to check.
   * type = The way to calculate how much is visible.
   * amountVisible = amount that should be visible. Either in percent or px. If
   *                it's not defined then all of the slide must be visible.
   *
   * Returns true or false
   */
  function viewsSlideshowCycleIsVisible(elem, type, amountVisible) {
    // Get the top and bottom of the window;
    var docViewTop = $(window).scrollTop();
    var docViewBottom = docViewTop + $(window).height();
    var docViewLeft = $(window).scrollLeft();
    var docViewRight = docViewLeft + $(window).width();
  
    // Get the top, bottom, and height of the slide;
    var elemTop = $(elem).offset().top;
    var elemHeight = $(elem).height();
    var elemBottom = elemTop + elemHeight;
    var elemLeft = $(elem).offset().left;
    var elemWidth = $(elem).width();
    var elemRight = elemLeft + elemWidth;
    var elemArea = elemHeight * elemWidth;
    
    // Calculate what's hiding in the slide.
    var missingLeft = 0;
    var missingRight = 0;
    var missingTop = 0;
    var missingBottom = 0;
    
    // Find out how much of the slide is missing from the left.
    if (elemLeft < docViewLeft) {
      missingLeft = docViewLeft - elemLeft;
    }
  
    // Find out how much of the slide is missing from the right.
    if (elemRight > docViewRight) {
      missingRight = elemRight - docViewRight;
    }
    
    // Find out how much of the slide is missing from the top.
    if (elemTop < docViewTop) {
      missingTop = docViewTop - elemTop;
    }
  
    // Find out how much of the slide is missing from the bottom.
    if (elemBottom > docViewBottom) {
      missingBottom = elemBottom - docViewBottom;
    }
    
    // If there is no amountVisible defined then check to see if the whole slide
    // is visible.
    if (type == 'full') {
      return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom)
      && (elemBottom <= docViewBottom) &&  (elemTop >= docViewTop)
      && (elemLeft >= docViewLeft) && (elemRight <= docViewRight)
      && (elemLeft <= docViewRight) && (elemRight >= docViewLeft));
    }
    else if(type == 'vertical') {
      var verticalShowing = elemHeight - missingTop - missingBottom;
      
      // If user specified a percentage then find out if the current shown percent
      // is larger than the allowed percent.
      // Otherwise check to see if the amount of px shown is larger than the
      // allotted amount.
      if (amountVisible.indexOf('%')) {
        return (((verticalShowing/elemHeight)*100) >= parseInt(amountVisible));
      }
      else {
        return (verticalShowing >= parseInt(amountVisible));
      }
    }
    else if(type == 'horizontal') {
      var horizontalShowing = elemWidth - missingLeft - missingRight;
      
      // If user specified a percentage then find out if the current shown percent
      // is larger than the allowed percent.
      // Otherwise check to see if the amount of px shown is larger than the
      // allotted amount.
      if (amountVisible.indexOf('%')) {
        return (((horizontalShowing/elemWidth)*100) >= parseInt(amountVisible));
      }
      else {
        return (horizontalShowing >= parseInt(amountVisible));
      }
    }
    else if(type == 'area') {
      var areaShowing = (elemWidth - missingLeft - missingRight) * (elemHeight - missingTop - missingBottom);
      
      // If user specified a percentage then find out if the current shown percent
      // is larger than the allowed percent.
      // Otherwise check to see if the amount of px shown is larger than the
      // allotted amount.
      if (amountVisible.indexOf('%')) {
        return (((areaShowing/elemArea)*100) >= parseInt(amountVisible));
      }
      else {
        return (areaShowing >= parseInt(amountVisible));
      }
    }
  }
})(jQuery);
;

