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; }); } // 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; }); }); } } /***************************************************************** * Do's And Don'ts Sidebox ****************************************************************/ $(document).ready( function () { $("#SON .SideBox #DDContainer").css("min-height", $("#SON .SideBox #DDContainer").height()); bindDDLink(); } ); function bindDDLink () { $("#SON .SideBox #DoAndDont #DDLink").click( function () { GetRandomDD($("#SON .SideBox #DoAndDont fieldset #ID").val()); } ); } function GetRandomDD(id) { $("#SON .SideBox #DoAndDont").fadeOut(500, function () { $.get("../includes/dosanddonts.php", { ID: id }, function (html) { $("#SON .SideBox #DDContainer") .hide() .html(html) .fadeIn(500) .css("min-height", $("#SON .SideBox #DDContainer").height()); bindDDLink(); } ); } ); } /***************************************************************** * END Do's And Don'ts Sidebox ****************************************************************/ // Poll jQuery if(document.getElementById('PollDynamics')) { $("#PollDynamics .SubmitButton").click(function() { $("#SON #SBPoll").css("min-height",$("#SON #SBPoll").height()); $("#SON #PollDynamics").fadeOut(500, function () { UpdatePoll($('#SON #TrackingURL').val()) }); return false; }); } function UpdatePoll(trackingURL) { $("#SON #PollDynamics").load( "http://www.everydayconnected.com/includes/poll.php", $("#SON #PollForm").serializeArray(), DisplayPollResults(trackingURL) ); } function DisplayPollResults(trackingURL) { $("#SON #PollDynamics").fadeIn(500); $("#SON #PollResults").load( "http://www.everydayconnected.com/" + trackingURL, '' ); } function GetNextPoll(newURL) { $("#SON #SBPoll").fadeOut(500, RefreshPollContent(newURL)); } function RefreshPollContent(newURL) { $.ajax({ url:newURL, dataType:'html', timeout:5000, success:function (html) { $("#SON #SBPoll").html(html); $("#SON #SBPoll").fadeIn(500); $("#SON #SBPoll #PollDynamics #PollForm fieldset .SubmitButton").bind("click", function() { $("#SON #SBPoll").css("min-height",$("#SON #SBPoll").height()); $("#SON #PollDynamics").fadeOut(500, function () { UpdatePoll($('#SON #TrackingURL').val()) }); return false; } ); } }); } /** * Bind thumb clicking functionality for voting on Archive Pages */ $(function () { $('#SON .voting_receptacle .thumbDown').bind("click", function () { voteComment($('#SON #ArchivePageIdentifier').val(), 'down', $(this).parent().parent().attr('class')); } ); $('#SON .voting_receptacle .thumbUp').bind("click", function () { voteComment($('#SON #ArchivePageIdentifier').val(), 'up', $(this).parent().parent().attr('class')); } ); initTrackVote(); }); /** * Initialize closure to track vote clicks */ function initTrackVote () { arrayIdentifierTracker = new Array(); incrementVote = function (identifier) { arrayIdentifierTracker.push(identifier); } } /** * XHR to track vote click */ function voteComment (section, type, identifier) { // Only allowed to vote once if ($.inArray(identifier, arrayIdentifierTracker) === -1) { vars = { 'section':section, 'type':type, 'identifier':identifier, 'spamCheck':1 }; $.ajax({ url:'http://www.everydayconnected.com/includes/voting.php', type:'get', dataType:'json', data:vars, success: function (response) { $('#SON tr.' + identifier + ' td.VoteMessage').html(response.text); $('#SON tr.' + identifier + ' td.' + ((type === 'up') ? 'UpVotes' : 'DownVotes')).html(response.newvotecount); }, error: function (response) { $('#SON tr.' + identifier + ' td.VoteMessage').html('An internal error has occured. Please try back later.'); } }); } // Increment vote count incrementVote(identifier); }