// // MEDIA PLAYER SCRIPT // (function($){ $.fn.slideShow = function(options) { // multiple elements if (this.length > 1) { this.each(function() { $(this).slideShow(options)}); return this; } // private vars this.defaults = { start: 0, // start index, set to 'random' or 'rnd' to random start interval: 3, // interval, autoplay, set to false for no auto-play, in seconds repeat: true, // repeat at the end transition: { mode: 'fade', speed: 1 }, slideSize: 'auto', // size for slides (used for mouseover and stuff) hoverNavigation:false, // enable mouse to change images slideClick: false, // insert callback method for slide clicks gotoSlide: false // slide change callback }; this.options = $.extend({}, this.defaults, options); // internal vars this.numSlides = this.find('.slide').length; if (this.options.start == 'random' || this.options.start == 'rnd') { this.current = Math.floor(Math.random() * this.numSlides) + 1; } else { this.current = this.options.start; } if (this.current >= this.numSlides) { this.current = this.numSlides - 1; } this.last = false; this.elm = $(this); this.interval = false; this.mouse = { x: 0, // store mouse x relative position on element y: 0, // store mouse y relative position on element over: false // store mouse over boolena value }; // init slideshow this.init = function() { // set slide container to correct width and height if (this.find('.slides').length) { // auto-detect slide size if (this.options.slideSize == 'auto') { this.options.slideSize = { height: '480px', width: '640px' }; } // don't set size of slides and slide container if not needed if (this.options.slideSize != 'none' && this.options.slideSize != false) { this.find('.slides, .slide').css({ height: '480px', width: '640px', //For some reason IE7 only needs this. Whoever built IE should die. overflow: 'hidden' }); } } // set slides to be positioned absolute this.find('.slide').css('position','absolute'); // hide slides if not hidden allready this.find('.slide:not(:eq(' + this.current + '))').hide(); // navigation shortcuts this.find('.first, .next, .nextSwipe, .jump, .prev, .last, .navigation, .slide, .page, .slides, .controls,.jump1,.jump2,.jump3,.jump4,.jump5,.jump6,.jump7,.jump8,.jump9,.jump10,.jump11,.jump12,.jump13,.jump14,.jump15,.jump16,.jump17,.jump18,.jump19,.jump20,.jump21,.jump22,.jump23,.jump24,.jump25,.jump26,.jump27,.jump28,.jump29,.jump30,.jump31,.jump32,.jump33,.jump34,.jump35,.jump36,.jump37,.jump38,.jump39,.jump40,.jump41,.jump42,.jump43,.jump44,.jump45').data('slideShow', this); this.find('.first').click(this.first); this.find('.next').click(this.next); this.find('.nextSwipe').click(this.nextSwipe); this.find('.prev').click(this.previous); this.find('.last').click(this.last); this.find('.jump').click(this.jump); this.find('.jump1').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 0; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump2').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 1; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump3').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 2; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump4').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 3; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump5').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 4; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump6').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 5; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump7').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 6; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump8').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 7; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump9').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 8; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump10').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 9; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump11').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 10; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump12').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 11; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump13').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 12; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump14').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 13; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump15').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 14; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump16').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 15; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump17').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 16; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump18').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 17; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump19').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 18; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump20').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 19; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump21').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 20; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump22').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 21; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump23').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 22; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump24').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 23; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump25').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 24; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump26').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 25; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump27').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 26; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump28').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 27; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump29').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 28; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump30').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 29; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump31').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 30; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump32').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 31; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump33').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 32; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump34').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 33; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump35').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 34; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump36').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 35; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump37').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 36; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump38').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 37; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump39').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 38; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump40').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 39; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump41').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 40; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump42').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 41; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump43').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 42; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump44').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 43; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); this.find('.jump45').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } indexNum = 44; // alert(indexNum); handleVideo(indexNum,slideShow.numSlides); slideShow.gotoSlide(indexNum); }); // init pag��nation buttons if available this.find('.navigation .page:eq(' + this.current + ')').addClass('selected'); this.find('.page').click(function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } // determine position in navigation var index = $(this).html(); if (!(index = parseInt($(this).html()-1))) { var index = $(this).parents('.navigation').find('.page').index($(this)); handleVideo(index,slideShow.numSlides); } slideShow.gotoSlide(index); }); // init mouse move handler this.find('.slide').mousemove(function(event) { var slideShow = $(this).data('slideShow'); // calculate mouse relative position and store it slideShow.mouse.x = Math.abs(event.clientX - $(this).position().left); slideShow.mouse.y = Math.abs(event.clientY - $(this).position().top); if (slideShow.mouse.x > slideShow.options.slideSize.width) slideShow.mouse.x = slideShow.options.slideSize.width; if (slideShow.mouse.y > slideShow.options.slideSize.height) slideShow.mouse.y = slideShow.options.slideSize.height; // use mouse vor navigation, calculate new page from mouse position if (slideShow.options.hoverNavigation) { var index = Math.round((slideShow.numSlides - 1) * slideShow.mouse.x / slideShow.options.slideSize.width); slideShow.gotoSlide(index, true); } }); // mouse enter handler this.find('.slide').mouseenter(function() { var slideShow = $(this).data('slideShow'); slideShow.mouse.over = true; slideShow.stopAuto(); }); // mouse leave handler this.find('.slide').mouseleave(function() { var slideShow = $(this).data('slideShow'); slideShow.mouse.over = false; slideShow.auto(); }); // on click handler if (typeof(this.options.slideClick) == 'function') { this.find('.slide').click(function() { var slideShow = $(this).data('slideShow'); slideShow.options.slideClick(slideShow); }); } g = this.current; this.current = -1; this.gotoSlide(g); // start interval for auto animation if (this.options.interval > 0) { this.auto(); } return this; }; // public methods this.auto = function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } if (!slideShow.interval && slideShow.options.interval > 0.001) { slideShow.interval = window.setInterval(function() { slideShow.next(); }, slideShow.options.interval * 1000); } return this; } // check if slideshow is running this.isPlaying = function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } return slideShow.interval; } // stop/play slideshow automatic this.togglePlayback = function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } if (slideShow.isPlaying()) { slideShow.stopAuto(); } else { slideShow.auto(); } }, // stop automatic slideshow this.stopAuto = function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } if (slideShow.interval) { window.clearInterval(slideShow.interval); slideShow.interval = false; } return this; } // goto first slide this.first = function(elm) { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } return slideShow.gotoSlide(0); }; // goto last slide???? this.next = function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } nextSlide = slideShow.current + 1; if(nextSlide > (slideShow.numSlides-1)) { nextSlide = 0; } handleVideo(nextSlide,slideShow.numSlides); return slideShow.gotoSlide(nextSlide); }; this.nextSwipe = function() { alert("NEXT"); }; // jump to what slide this.jump = function() { // grab the id of the element in which is calling for the jump. the id should be a number of the slide inwhich you want to jump to. //this might be confusing but is neccesary for multiple applications of this function var jumpNum =$(".jump").attr('id') if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } slideIndex = jumpNum -1; handleVideo(slideIndex,slideShow.numSlides); return slideShow.gotoSlide(slideIndex) }; this.previous = function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } prevSlide = slideShow.current - 1; if(prevSlide < 0) { prevSlide = slideShow.numSlides - 1; } handleVideo(prevSlide,slideShow.numSlides); return slideShow.gotoSlide(prevSlide); }; function handleVideo(indexNum,numSlides){ // this closes the slideout story left if it is open and when someone wants to go to the next slide if(slideOut == false) { //alert("NOT OPEN") } else{ slideoutStoryLeft(); } // figure out what kind of slide we are on var adjustedIndex = indexNum+1 var CurrentDivID = $('#slide' + adjustedIndex); var idFind =$("#slide" + adjustedIndex + "> div").attr('id') // alert(idFind); var isVideo = false; var isHDVideo = false; var isGoogle = false; var isYouTube = false; var isSequence = false; var isMap = false; var isSlideOut = false; if(idFind == "video") { //alert("#video" + adjustedIndex); var isVideo = true; } else if(idFind == "google") { var isGoogle = true; //alert("#google" + adjustedIndex); } else if(idFind == "hdvideo") { var isHDVideo = true; } else if(idFind == "youtube") { //alert("#youtube" + adjustedIndex); var isYouTube = true; } else if(idFind == "sequence") { var isSequence = true; } else if(idFind == "GoogleMap") { //alert("#youtube" + adjustedIndex); var isMap = true; } else if(idFind == "story") { //alert("#youtube" + adjustedIndex); var isSlideOut = true; } if(isSlideOut == false) { if(hasIntroSlide == true) { closeSlideOut(); } } // if a user clicks on any navigation buttons pause the current video through the iframe window to the JW API Player for VIDEO // this is needed for IE and safari so the video doesnt keep playing in the background //handle videos - unload all if we are not on video slide if(isVideo == false){ for(i=1;i div").attr('id'); if(thisID == "video") { //$("#slide" + i + "> div").html(''); window["clearVideo" + i](); } } } else{ window["loadVideo" + adjustedIndex](); //clear any others for(i=1;i div").attr('id'); if(thisID == "video" && i != adjustedIndex) { window["clearVideo" + i](); } } } //handle HD videos - unload all if we are not on video slide if(isHDVideo == false){ for(i=1;i div").attr('id'); if(thisID == "hdvideo") { //$("#slide" + i + "> div").html(''); window["clearHDVideo" + i](); } } } else{ window["loadHDVideo" + adjustedIndex](); //clear any others for(i=1;i div").attr('id'); if(thisID == "hdvideo" && i != adjustedIndex) { window["clearHDVideo" + i](); } } } //handle maps - unload all if we are not on video slide if(isGoogle == false){ for(i=1;i div").attr('id'); if(thisID == "google") { //$("#slide" + i + "> div").html(''); window["clearGoogle" + i](); } } } else{ window["loadGoogle" + adjustedIndex](); //clear any others for(i=1;i div").attr('id'); if(thisID == "google" && i != adjustedIndex) { window["clearGoogle" + i](); } } } //handle sequences - unload all if we are not on video slide if(isSequence == false){ for(i=1;i div").attr('id'); if(thisID == "sequence") { window["clearSequence" + i](); } } } else{ window["loadSequence" + adjustedIndex](); //clear any others for(i=1;i div").attr('id'); if(thisID == "sequence" && i != adjustedIndex) { window["clearSequence" + i](); } } } //handle youTube videos - unload all if we are not on YouTube slide if(isYouTube == false){ for(i=1;i div").attr('id'); if(thisID == "youtube") { $("#slide" + i + "> div").html(''); } } } else{ var theFuncStr = "loadYouTube" + adjustedIndex; var theIFrame = eval(theFuncStr); $("#slide" + adjustedIndex + "> div").html(theIFrame); for(i=1;i div").attr('id'); if(thisID == "youtube" && i != adjustedIndex) { $("#slide" + i + "> div").html(''); } } } //handle maps - unload all if we are not on map slide if(isMap == false){ for(i=1;i div").attr('id'); if(thisID == "GoogleMap") { window["clearMap" + i](); } } } else{ window["loadMap" + adjustedIndex](); //clear any others for(i=1;i div").attr('id'); if(thisID == "GoogleMap" && i != adjustedIndex) { window["clearMap" + i](); } } } } this.last = function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } return slideShow.gotoSlide(slideShow.numSlides); }; this.gotoSlide = function(index, noanimation) { if (index < 0) { index = this.numSlides - 1; } if (index >= this.numSlides) { index = 0; } if (index === this.current) return this; // get slide elements var oldSlide = this.find('.slide:eq(' + this.current +')'); var newSlide = this.find('.slide:eq(' + index +')'); // callbacks for animation finished oldFinished = function () { $(this).removeClass('selected'); if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } slideShow.elm.find('.navigation .page:eq(' + slideShow.current + ')').addClass('selected'); if (!slideShow.mouse.over) { slideShow.auto(); } } newFinished = function() { if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } slideShow.elm.find('.navigation .page:not(:eq(' + slideShow.current + '))').removeClass('selected'); $(this).addClass('selected'); } // get slideshow if (!(slideShow = $(this).data('slideShow'))) { var slideShow = this; } slideShow.stopAuto(); // call callback if (typeof(this.options.gotoSlide) == 'function') { this.options.gotoSlide(slideShow, index); } // start transition if (noanimation) { oldSlide.hide(1, oldFinished); newSlide.show(1, newFinished); } else { if (typeof(this.options.transition.mode) == 'function') { this.call(this.options.transition.mode, newSlide, oldSlide); } else { switch(this.options.transition.mode) { default: case 'fade': oldSlide.fadeOut(this.options.transition.speed, oldFinished); newSlide.fadeIn(this.options.transition.speed, newFinished); break; } } } this.last = this.current; this.current = index; return this; }; return this.init(); } })(jQuery); jQuery.fn.highlight = function(selector, className, eventStart, eventEnd){ // variables var className = className || 'highlight'; if(eventStart == undefined && eventEnd == undefined){ var eventStart = 'mouseover'; var eventEnd = 'mouseout'; } else if(eventStart == eventEnd || eventStart != undefined && eventEnd == undefined){ var toggle = true; } // code this.each ( function(){ var tagName = this.tagName.toLowerCase(); if(tagName == 'form'){ selector = selector || 'li'; var elements = jQuery("textarea, select, multi-select, :text, :image, :password, :radio, :checkbox, :file", this); elements.bind ( 'focus', function(){ var parents = jQuery(this).parents(selector) var parent = jQuery(parents.get(0)) parent.addClass(className); } ); elements.bind ( 'blur', function(){ var parents = jQuery(this).parents(selector) var parent = jQuery(parents.get(0)) parent.removeClass(className); } ); } else{ if(tagName.match(/^(table|tbody)$/) != null){ selector = selector || 'tr'; } else if(tagName.match(/^(ul|ol)$/) != null){ selector = selector || 'li'; } else{ selector = '*'; } var elements = jQuery(selector, this); if(toggle){ elements.bind ( eventStart, function(){ if($(this).hasClass(className)){ $(this).removeClass(className); } else{ $(this).addClass(className); } } ); } else{ elements.bind ( eventStart, function(){ $(this).addClass(className); } ); elements.bind ( eventEnd, function(){ $(this).removeClass(className); } ); } } } ); }