//imidiately executing code //default execution jQuery(document).ready(function($) { var featurePos = 0; //default position of feature scroller var elem_in_box = $('#feature').width() / 265 //get the width of the mask against the number of elements var elem = $('#featu li').size() - elem_in_box //finding out how much to adjust margin by var maxslide = (elem*265) - (elem*265) - (elem*265) //getting a negative*3 of the margin value //hide footer outline if it's empty var foot_elem = $('#sidebar-footer > li').size() //store the focus state of the input so it isn't hidden if it has focus //but the mouse leaves the search form var search_focus = false; //hide right arrow if there are no elements to scroll if($('#featu li').size() <= elem_in_box){ $('#right-scroller').hide(); } hideFooter(); hideFeature(); hideSearch(); //sliding feature content to the left function slideleft(){ $('#f-scroller').animate({marginLeft: featurePos+"px"}, 300) } //sliding feature content to the right function slideright(){ $('#f-scroller').animate({marginLeft: featurePos+"px"}, 300) } //function to be extecuted when left button is clicked $('#left-scroller').click(function(){ if(featurePos<0){ featurePos += 265; slideright() } if(featurePos<=0){ $('#right-scroller').show() } if(featurePos == 0){ $('#left-scroller').hide(); } return false }) //function to be executed when right button is clicked $('#right-scroller').click(function(){ if(featurePos>maxslide){ featurePos -= 265; slideleft() } if(featurePos<0){ $('#left-scroller').show(); } if(featurePos == maxslide){ $('#right-scroller').hide(); } return false }) //mobile menu button toggles the visibility of the menu on the mobile site $('#mobile_menu_button a').click(function(){ $('#menu').slideToggle(200); return false }) //hides footer if no widgets are put into it function hideFooter(){ if(foot_elem == 0){ $('#footer').hide() } } //hides the feature scroller if there are no items in it. function hideFeature(){ if($('#featu li').size() < 1){ $('#feature').hide(); } } function hideSearch(){ $('#search-men input.s').hide() $('#search-men form').css('width', '34px') } $('#search-men').hover( function(){ $('#search-men input.s').stop(false,true) $('#search-men form').animate({width:215},200,function(){ $('#search-men input.s').slideDown(100) }) }, function(){ if(search_focus == false){ //$('#search-men input.s').stop(true,true) //$('#search-men input.s').slideUp(200, function(){ // $('#search-men form').animate({width:34},200) //}) $('#search-men input.s').stop(false,true) $('#search-men input.s').slideUp(100, function(){ $('#search-men form').animate({width:34},200) }) } } ) $('#search-men input.s').focus(function(){ search_focus = true }) $('#search-men input.s').blur(function(){ search_focus = false $('#search-men input.s').stop(false,true) $('#search-men input.s').slideUp(100, function(){ $('#search-men form').animate({width:34},200) }) }) //background changer for demo purposes if($('#content h1').text() == "BACKGROUNDS"){ $('body').css({'background-color': '#ddd', 'background-image': 'url(\http://www.visiv.ca/Themes/Avum/wp-content/themes/Avum/img/bg_water_1.jpg\)'}) } });