function ClearText(Elem,DefaultText) { if(Elem) { if(typeof(Elem.value) != 'undefined') { if (Elem.value == DefaultText) { Elem.value = ''; } } else if(typeof(Elem.innerHTML) != 'undefined') { if (Elem.value == DefaultText) { Elem.innerHTML = ''; } } } } function DefaultText(Elem,DefaultText) { if(Elem) { if(typeof(Elem.value) != 'undefined') { if (Elem.value == '') { Elem.value = DefaultText; } } else if(typeof(Elem.innerHTML) != 'undefined') { if (Elem.innerHTML == '') { Elem.innerHTML = DefaultText; } } } } // Code for the jQuery slideshow initialization if(document.getElementById('main-photo-slider')) { var theInt = null; var $navthumb, $highlightthumb; var curclicked = 0; theInterval = function(cur){ clearInterval(theInt); if( typeof cur != 'undefined' ) curclicked = cur; $highlightthumb.removeClass("active-thumb"); $highlightthumb.eq(curclicked).addClass("active-thumb"); $(".stripNav ul li a").eq(curclicked).trigger('click'); theInt = setInterval(function(){ $highlightthumb.removeClass("active-thumb"); $highlightthumb.eq(curclicked).addClass("active-thumb"); $(".stripNav ul li a").eq(curclicked).trigger('click'); curclicked++; if( $highlightthumb.length == curclicked ) curclicked = 0; }, 5000); }; } $(function(){ if(document.getElementById('main-photo-slider')) { $("#main-photo-slider").codaSlider(); $navthumb = $(".nav-thumb"); $highlightthumb = $("#SlideShowNav li a"); $navthumb .click(function() { var $this = $(this); theInterval($this.parent().attr('href').slice(1) - 1); return false; }); var LastHeight = 0; $("#SlideShowNav li a span").each(function(index) { var ThisHeight = $(this).height(); if( ThisHeight > LastHeight) { LastHeight = ThisHeight; } var Height = LastHeight + 'px'; $(this).css("min-height", Height); }); jQuery("#SON #Slideshow .panel").addClass( 'Show' ); theInterval(); } }); // Rating Stars // Highlight stars function HighlightStars( StarElement, Score ) { var MaxStars = 5; var Container = StarElement.parentNode; var Stars = Container.getElementsByTagName('a'); for( var StarIndex = 0; StarIndex < MaxStars; StarIndex++ ) { Stars[StarIndex].className = 'Star' + ( StarIndex+1 <= Score ? 'On' : 'Off' ); } } // Submit Rating Form if(document.getElementById('RatingForm')) { $("#RatingForm a").click(function() { $('#RatingScore').val($(this).attr('rel')); $("#RatingForm").submit(); return false; }); } // Poll jQuery if(document.getElementById('PollDynamics')) { $("#PollDynamics .SubmitButton").click(function() { $("#SBPoll .BlueBorder").css("min-height",$("#SBPoll .BlueBorder").height()); $("#PollDynamics").fadeOut(500, function () { UpdatePoll($('#TrackingURL').val()) }); return false; }); } function UpdatePoll(trackingURL) { $("#PollDynamics").load( "http://www.thedailycat.com/includes/poll.php", $("#PollForm").serializeArray(), DisplayPollResults(trackingURL) ); } function DisplayPollResults(trackingURL) { $("#PollDynamics").fadeIn(500); $("#PollResults").load( "http://www.thedailycat.com/" + trackingURL, '' ); } function GetNextPoll(newURL) { $("#SBPoll .BlueBorder .Wrapper").fadeOut(500, RefreshPollContent(newURL)); } function RefreshPollContent(newURL) { $.ajax({ url:newURL, dataType:'html', timeout:5000, success:function (html) { $("#SBPoll .Wrapper").html(html); $("#SBPoll .Wrapper").fadeIn(500); $("#SBPoll .Wrapper #PollDynamics #PollForm fieldset input.SubmitButton").bind("click", function() { $("#SBPoll .BlueBorder").css("min-height",$("#SBPoll .BlueBorder").height()); $("#PollDynamics").fadeOut(500, function () { UpdatePoll($('#SBPoll #TrackingURL').val()) }); return false; }); } }); } // Quiz jQuery if(document.getElementById('QuizDynamics')) { $("#QuizDynamics .SubmitButton").click(function() { $("#QuizPromo .BlueBorder").css("min-height",$("#QuizPromo .BlueBorder").height()); $("#QuizDynamics").fadeOut(500,UpdateQuiz); return false; }); } function UpdateQuiz() { $("#QuizDynamics").load( "http://www.thedailycat.com/includes/quiz.php", $("#QuizForm").serializeArray(), DisplayQuizResults ); } function DisplayQuizResults() { $("#QuizDynamics").fadeIn(500,function(){$("#QuizDynamics p").fadeIn(500);}); $("#QuizResults").load( "http://www.thedailycat.com/quiz/full_skeletal_development/index.html", '' ); } function GetNextQuiz(newURL) { $("#Quiz .SideboxWrap").fadeOut(500, RefreshQuizContent(newURL)); } function RefreshQuizContent(newURL) { $.ajax({ url:newURL, dataType:'html', timeout:5000, success:function (html) { $("#Quiz .SideboxWrap").html(html); $("#Quiz .SideboxWrap").fadeIn(500); $("#Quiz #QuizForm .SubmitButton").bind("click", function() { $("#Quiz .SideboxWrap").css("min-height",$("#QuizPromo .SideboxWrap").height()); $("#QuizDynamics").fadeOut(500, function () { UpdateQuiz($('#TrackingURL').val()) }); return false; }); } }); } // Fix z-index issues in ie7 if($.browser.msie) { userAgent = $.browser.version; version = userAgent.substring(0,userAgent.indexOf('.')); if(version==7 || version==6) { $(function() { var zIndexNumber = 10000; $('*').each(function() { $(this).css('zIndex', zIndexNumber); zIndexNumber -= 1; }); }); } } // Breed Spotlight Slideshow if(document.getElementById('BreedSpotlight')) { $(document).ready(function() { //Speed of the slideshow var speed = 5000; var FadeTime = 200; //You have to specify width and height in #slider CSS properties //After that, the following script will set the width and height accordingly $('#mask-gallery, #gallery li').width($('#slider').width()); $('#gallery').width($('#slider').width() * $('#gallery li').length); $('#mask-gallery, #gallery li, #mask-excerpt, #excerpt li').height($('#slider').height()); //Assign a timer, so it will run periodically var run = setInterval('newsscoller(0)', speed); $('#gallery li:first, #excerpt li:first').addClass('selected'); /* //Pause the slidershow with clearInterval $('#btn-pause').click(function () { clearInterval(run); return false; }); //Continue the slideshow with setInterval $('#btn-play').click(function () { run = setInterval('newsscoller(0)', speed); return false; }); */ //Next Slide by calling the function $('#btn-next').click(function () { clearInterval(run); newsscoller(0); return false; }); //Next Slide by calling the function $('#Next').click(function () { clearInterval(run); newsscoller(0); return false; }); //Previous slide by passing prev=1 $('#btn-prev').click(function () { clearInterval(run); newsscoller(1); return false; }); $('#slider').hover( function() { clearInterval(run); $('#excerpt').animate({opacity: 0.85},FadeTime); }, function() { run = setInterval('newsscoller(0)', speed); $('#excerpt').animate({opacity: 0.0},FadeTime); } ); }); function newsscoller(prev) { //Get the current selected item (with selected class), if none was found, get the first item var current_image = $('#gallery li.selected').length ? $('#gallery li.selected') : $('#gallery li:first'); var current_excerpt = $('#excerpt li.selected').length ? $('#excerpt li.selected') : $('#excerpt li:first'); //if prev is set to 1 (previous item) if (prev) { //Get previous sibling var next_image = (current_image.prev().length) ? current_image.prev() : $('#gallery li:last'); var next_excerpt = (current_excerpt.prev().length) ? current_excerpt.prev() : $('#excerpt li:last'); //if prev is set to 0 (next item) } else { //Get next sibling var next_image = (current_image.next().length) ? current_image.next() : $('#gallery li:first'); var next_excerpt = (current_excerpt.next().length) ? current_excerpt.next() : $('#excerpt li:first'); } //clear the selected class $('#excerpt li, #gallery li').removeClass('selected'); $("#BreedSpotlightTitle").css("height",$("#BreedSpotlightTitle")[0].offsetHeight); $('#BreedSpotlightTitle span').fadeOut(200); //reassign the selected class to current items next_image.addClass('selected'); next_excerpt.addClass('selected'); //Scroll the items $('#mask-gallery').scrollTo(next_image, 800,function() { $('#BreedSpotlightTitle span').text($(next_image).find('img').attr('alt')); $('#BreedSpotlightTitle span').fadeIn(200); }); $('#mask-excerpt').scrollTo(next_excerpt, 800); } } var searchFocus = function (elem, val) { if (document.getElementById(elem).value == val || document.getElementById(elem).value.length == 0) document.getElementById(elem).value = ""; }; var searchBlur = function (elem, val) { if (document.getElementById(elem).value.length == 0) document.getElementById(elem).value = val; }; var searchSubmit = function(val, default_val, form) { if (val.length !== 0 && val !== default_val) { document.forms[form].submit(); return true; } else return false; }; /****************************************************************************************** * Add This Tracking ******************************************************************************************/ $(function(){ // Add This tracking addthis.addEventListener('addthis.menu.share', function(evt){ console.log('AddThis clicked: '+evt.data.service); $.get('http://www.thedailycat.com/programsend/socialmedia/' + evt.data.service + '/'); }); });