Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** jQuery **/
- var sitemap = isPage = 0;
- var currPage = "";
- //Determine what page it is on load
- //Must be in correct order
- var pages = new Array("about", "introduction", "benefits", "how-we-work", "become-a-member", "next-step", "hours", "testimonials", "contact", "partners");
- var sbItemId;
- var dashPos;
- var sbPage;
- var posNum;
- var hoverPos;
- var selPos;
- var selId;
- var pagePos
- function arraySearch(arr,val) {
- for (var i=0; i<arr.length; i++){
- if (arr[i] == val)
- return i;
- }
- return false;
- }
- $(document).ready(function(){
- //SIDEBAR CODE
- var url = window.location.hash;
- var linkPos = url.lastIndexOf("/");
- if(linkPos >= 0){
- currPage = url.substring(linkPos+1);
- $.each(pages, function(i, val){
- if(currPage == val){
- isPage=1;
- return;
- }
- });
- if(isPage==0){
- currPage = "about";
- }
- }
- else
- currPage = "about";
- sbPage = arraySearch(pages, currPage);
- //position to hover to:
- //position to hover to:
- switch(sbPage){
- case 0:
- case 1:
- case 2:
- pagePos = (sbPage * 40);
- break;
- case 3:
- case 4:
- case 5:
- case 6:
- pagePos = (sbPage * 40)+6;
- break;
- case 7:
- pagePos = (sbPage * 40)+12;
- break;
- case 8:
- pagePos = (sbPage * 40)+18;
- break;
- case 9:
- pagePos = (sbPage * 40)+24;
- break;
- }
- //pagePos = (sbPage * 40) + 6;
- $('#pos-'+sbPage).addClass('sel-sbitem');
- $('.sel-sbitem-bar').css({"top":+pagePos+"px"});
- //move color sidebar tab when hover
- hoverPos = 0;
- $('.sb-item').mouseover(function(){
- $(this).addClass('hov-sbitem');
- //get ID to get position #
- sbItemId = $(this).attr('id');
- dashPos = sbItemId.indexOf('-')+1;
- //get the position number of element as listed in id (1st, 2nd, etc)
- posNum = sbItemId.substring(dashPos);
- posNum = parseInt(posNum);
- //position to hover to:
- switch(posNum){
- case 0:
- case 1:
- case 2:
- hoverPos = (posNum * 40);
- break;
- case 3:
- case 4:
- case 5:
- case 6:
- hoverPos = (posNum * 40)+6;
- break;
- case 7:
- hoverPos = (posNum * 40)+12;
- break;
- case 8:
- hoverPos = (posNum * 40)+18;
- break;
- case 9:
- hoverPos = (posNum * 40)+24;
- break;
- }
- //move hover bar and change color
- $('.sel-sbitem-bar').stop().animate({"top":+hoverPos+"px"}, '400');
- }).mouseout(function(){
- //not hovering over anymore
- $(this).removeClass('hov-sbitem');
- //pos of selected sb item
- selId = $('.sel-sbitem').attr('id');
- dashPos = selId.indexOf('-');
- selNum = selId.substring(dashPos+1);
- /*/position to hover to:
- switch(selNum){
- case 0:
- case 1:
- case 2:
- selPos = (selNum * 40);
- break;
- case 3:
- case 4:
- case 5:
- case 6:
- selPos = (selNum * 40)+6;
- break;
- case 7:
- selPos = (selNum * 40)+12;
- break;
- case 8:
- selPos = (selNum * 40)+18;
- break;
- case 9:
- selPos = (selNum * 40)+24;
- break;
- }//*/
- if(selNum == 0 || selNum == 1 || selNum == 2)
- selPos = (selNum * 40);
- else if(selNum == 3 || selNum == 4 || selNum == 5 || selNum == 6)
- selPos = (selNum * 40)+6;
- else if(selNum == 7)
- selPos = (selNum * 40)+12;
- else if(selNum == 8)
- selPos = (selNum * 40)+18;
- else if(selNum == 9)
- selPos = (selNum * 40)+24;
- //selPos = parseInt(selNum*40)+6;
- //alert(selPos);
- $('.sel-sbitem-bar').stop().animate({"top":+selPos+"px"}, '400');
- });
- //set the correct current section to show
- setSec(currPage);
- //pops up buttons
- //twitter
- buttonPop('social-tweet', -28, -28, -193, -218);
- //facebook
- buttonPop('social-fb', -80, -80, -193, -218);
- }); //end doc.ready
- $('.sb-item').click(function(){
- $('.sb-item').each(function(){
- $(this).removeClass('sel-sbitem');
- });
- $(this).addClass('sel-sbitem');
- sel2Id = $(this).attr('id');
- dashPos = sel2Id.indexOf('-');
- sel2Num = sel2Id.substring(dashPos+1);
- //position to hover to:
- switch(sel2Num){
- case 0:
- case 1:
- case 2:
- sel2Pos = (sel2Num * 40);
- break;
- case 3:
- case 4:
- case 5:
- case 6:
- sel2Pos = (sel2Num * 40)+6;
- break;
- case 7:
- sel2Pos = (sel2Num * 40)+12;
- break;
- case 8:
- sel2Pos = (sel2Num * 40)+18;
- break;
- case 9:
- sel2Pos = (sel2Num * 40)+24;
- break;
- }
- //selPos = parseInt(selNum*40)+6;
- $('.sel-sbitem-bar').css({"top":+sel2Pos+"px"});
- });
- //END SIDEBAR CODE
- function setSec(currSec){
- $('#'+currSec).addClass('active');
- $('#'+currSec).removeClass('inactive');
- $('#'+currSec).css({'z-index':3, 'opacity':1});
- $('.section[id!="'+currSec+'"]').each(function(){
- $(this).removeClass('active');
- $(this).addClass('inactive');
- $(this).css({'z-index':1, 'opacity':0});
- });
- }
- function switchSec(currSec){
- //edit all sections but the one chosen
- $('.section[id!="'+currSec+'"]').each(function(){
- //put behind
- $(this).css({'z-index':1});
- //fade
- $(this).stop().animate({
- "opacity":0
- }, 400, function(){
- //must do this after or height will be sloppily changed
- $(this).removeClass('active');
- $(this).addClass('inactive');
- $('#'+currSec).removeClass('inactive');
- $('#'+currSec).stop().animate({
- "opacity":1
- }, 400, function(){
- $('#'+currSec).addClass('active');
- $('#'+currSec).css({'z-index':3});
- });
- });
- });
- }
- //pops up specified button
- function buttonPop(buttonId, bgStartX, bgEndX, bgStartY, bgEndY){
- $('#'+buttonId).hover(function(){
- $(this).css({backgroundPosition: bgStartX+'px '+bgStartY+'px'});
- $(this).stop().animate({backgroundPosition: bgEndX+'px '+bgEndY+'px'}, 250);
- },function(){
- $(this).stop().animate({backgroundPosition: bgStartX+'px '+bgStartY+'px'}, 250);
- });
- }
Add Comment
Please, Sign In to add comment