Salve a tutti,
mi sono appena iscritto...avrei un bel problema da risolvere e spero possiate aiutarmi.
Sto facendo un sito interamente in JS, gestito da
-script.js
-jcarousellite.js
-content_switch.js

Il mo problema è il seguente...il sito che sto cercando di realizzare presenta 5 voci di menu con relative finestre, all'interno delle quali vanno inserite 5 slide differenti. Il numero di elementi in ogni slide cambia da pagina a pagina. Per intenderci nella Pagina 1 ho 9 elementi e nella pagina 2 ho 13 elementi...se io vado nella pagina 2 e clicco sull elemento numero 10, esco e vado ad aprire la pagina 1, mi uscirà una pagina vuota.
La mia idea sarebbe quella di impostare la slide in modo tale che all'uscita dalla pagina la slide stessa si resetti e riparta dalla prima immagine. Ho fatto vari tentativi ma non essendo esperto di js non so come poter impostare questa cosa. Vi posto i codici sperando che qualcuno possa aiutarmi

SCRIPT.JS

codice:
$(document).ready(function() { // hover $('footer > a').hover(function(){ $(this).stop().animate({color:'#4d4d4d'}) }, function(){ $(this).stop().animate({color:'#ad2f00'}) }) $('.link1').each(function(){ $(this).prepend('<span></span>') var col=$(this).css('color') $(this).find('span').css({background:col}) }) $('.list1 a').each(function(){ $(this).prepend('<span></span>') }) $('.link1, .list1 a').hover(function(){ $(this).find('span').css({opacity:1, width:0}).stop().animate({width:'100%'}) }, function(){ $(this).find('span').stop().animate({opacity:0}) }) $('.close span').css({opacity:0}) $('.close').hover(function(){ $(this).find('span').stop().animate({opacity:1}) }, function(){ $(this).find('span').stop().animate({opacity:0}) }) $('#icons .img_act').css({opacity:0}) $('#icons a').hover(function(){ $(this).find('.img_act').stop().animate({opacity:1}) }, function(){ $(this).find('.img_act').stop().animate({opacity:0}) }) // gallery $("#gallery1").jCarouselLite({ btnNext: ".next", btnPrev: ".prev", mouseWheel: true, visible: 3, speed: 600, easing: 'easeOutCirc' }); $("#gallery2").jCarouselLite({ btnNext: ".next", btnPrev: ".prev", mouseWheel: true, visible: 3, speed: 600, easing: 'easeOutCirc' }); $('.prev span, .next span').css({opacity:0}) $('.prev, .next').hover(function(){ $(this).find('span').stop().animate({opacity:1}) }, function(){ $(this).find('span').stop().animate({opacity:0}) }) var Img='.'+$(".gallery_big_img img#active").attr('class') $(".gallery_big_img img#active1").attr('class') $(".gallery_big_img img").css({opacity:0}); $("#caption li").css({opacity:0, display:'none'}); $("#caption1 li").css({opacity:0, display:'none'}); $(".gallery_big_img img#active").css({opacity:1}); $(".gallery_big_img img#active1").css({opacity:1}); $("#caption li"+Img).css({opacity:1, display:'block'}); $("#caption li"+Img).css({opacity:'none'}); $("#caption1 li"+Img).css({opacity:1, display:'block'}); $("#caption1 li"+Img).css({opacity:'none'}); $("#gallery1 a").click(function(){ var ImgId = '.'+$(this).attr("href").slice(1); if (ImgId!=Img) { $(Img).stop().animate({opacity:0}, 600, function(){$(this).css({display:'none'})}) $(Img).attr({id:''}); $(ImgId).css({display:'block'}).stop().animate({opacity:1}, 600, function(){$(this).css({opacity:'none'})}); $(ImgId).attr({id:'active'}) } Img=ImgId; return false; }) $("#gallery2 a").click(function(){ var ImgId = '.'+$(this).attr("href").slice(1); if (ImgId!=Img) { $(Img).stop().animate({opacity:0}, 600, function(){$(this).css({display:'none'})}) $(Img).attr({id:''}); $(ImgId).css({display:'block'}).stop().animate({opacity:1}, 600, function(){$(this).css({opacity:'none'})}); $(ImgId).attr({id:'active1'}) } Img=ImgId; return false; }) $('.submenu_1 span').css({opacity:0}) $('.submenu_1 li').hover(function(){ $(this).find('span').stop().animate({opacity:1}) }, function(){ $(this).find('span').stop().animate({opacity:0}) }) $('ul#menu').superfish({ delay: 600, animation: {height:'show'}, speed: 600, autoArrows: false, dropShadows: false }); $('#content > ul > li').each(function(){ $(this).data({height:$(this).height()}) $(this).css({top:$(this).data('height')/2}) }) }); $(window).load(function() { var m_top=30; h_cont=340; // scroll $('.scroll').cScroll({ duration:700, step:75, trackCl:'track', shuttleCl:'shuttle' }) $('#bgStretch').bgStretch({ align:'leftBottom', navs:$('#bg_pagination').navs({ hoverIn:function(li){ $('span',li).stop().animate({opacity:1}) $('a',li).stop().animate({color:'#fff'}) }, hoverOut:function(li){ $('span',li).stop().animate({opacity:0}) $('a',li).stop().animate({color:'#ad2f00'}) } }) }).sImg({ spinner:$('.spinner').css({opacity:.7}).hide() }) $('#bg_pagination').navs(0) //content switch var content=$('#content'), nav=$('.menu'); nav.navs({ useHash:true, hoverIn:function(li){ $('> a',li).stop().animate({color:'#e0ccbf'}) }, hoverOut:function(li){ if (!li.hasClass('with_ul') || !li.hasClass('sfHover')) { $('> a',li).stop().animate({color:'#fff'}) } } }) content.tabs({ actFu:function(_){ if (_.prev && _.curr) { h_last=_.prev.data('height'); h_new=_.curr.data('height'); _.prev.stop().animate({height:0, top:h_last/2}, function(){ _.prev.css({display:'none'}) _.curr.css({display:'block'}).stop().animate({height:h_new, top:0}) content.css({height:h_new}).stop().animate({height:h_new, top:80}); h_cont=h_new+340; centre() }) } else { if (_.curr) { h_new=_.curr.data('height'); _.curr.css({display:'block'}).stop().animate({height:h_new, top:90}) content.css({height:h_new}).stop().animate({height:h_new, top:0}) h_cont=h_new+340; centre() } if (_.prev) { h_last=_.prev.data('height'); _.prev.stop().animate({height:0, top:h_last/2}, function(){ _.prev.css({display:'none'}); content.css({height:0}) h_cont=340; centre() }) } } }, preFu:function(_){ $('#content > ul > li').css({display:'none', position:'absolute', height:0}) } }) nav.navs(function(n, _){ if (n=='close' || n=='#!/') { content.tabs(n); } else { content.tabs(n); } }) function centre() { var h=$(window).height(); if (h>h_cont) { m_top=(h-h_cont)/2+30; } else { m_top=30 } $('#content').css({marginTop:m_top}) } centre() $(window).resize(centre); })

CONTENT_SWITCH.JS


codice:
//0.4.5 ;(function($){ $.fn.navs=function(o){ this.each(function(){ var th=$(this), data=th.data('navs'), _={ enable:true, actCl:'active', changeEv:'change', indx:[], hshx:[], useHash:false, defHash:'#!/', emptyHash:'#', outerHash:false, autoPlay:false, blockSame:true, hover:true, contRetFalse:true, preFu:function(){ _.li.each(function(n){ var th=$(this) _.indx[n]=th _.useHash &&(_.hshx[n]=$('a',th).attr('href')) &&location.hash==_.hshx[n] &&th.addClass(_.actCl) }) }, rfrshFu:function(){ _.prev=_.curr _.pren=_.n _.curr=false _.n=-1 _.param='close' _.li.each(function(n){ var th=$(this) if(th.hasClass(_.actCl)) _.curr=th, _.n=n, _.href=$('a',th).attr('href'), _.param=_.useHash?_.href:_.n }) }, markFu:function(){ _.li.each(function(n){ var th=$(this) _.n==n?_.hvrin(th):_.hvrout(th) }) }, hashFu:function(){ $(window) .bind('hashchange',function(){ if(location.hash==_.emptyHash||location.hash.length==0){ location.hash=_.hash return false } _.prevHash=_.hash _.checkHashFu(_.outerHash=_.hash=location.hash) }) $('a',_.li) .click(function(){ if(!_.enable) return false }) }, checkHashFu:function(hash){ if(hash==_.emptyHash||hash.length==0) location.hash=_.defHash if(hash=='#back') return _.backFu() if(hash=='#close') return _.closeFu() _.li.each(function(n){ if(_.hshx[n]==_.hash) _.chngFu(n), _.outerHash=false }) if(_.outerHash) _.li.removeClass(_.actCl), _.rfrshFu(), _.markFu(), _.param=_.outerHash, _.me.trigger(_.changeEv) }, cntrFu:function(){ _.li.each(function(n){ var th=$(this) $('a',th) .click(function(){ _.chngFu(n) if(_.contRetFalse) return false }) }) }, autoPlayFu:function(){ if(!_.autoPlay) return false if(_.int) clearInterval(_.int) _.int=setInterval(_.nextFu,_.autoPlay) }, chngFu:function(n){ if(!_.enable) return false if(n==_.n&&_.blockSame) return false _.indx[n] &&_.li.removeClass(_.actCl) &&_.indx[n].addClass(_.actCl) _.rfrshFu() _.markFu() _.autoPlayFu() if(_.useHash&&location.hash!=_.hshx[_.n]) location.hash=_.hshx[_.n] _.me.trigger(_.changeEv) }, closeFu:function(){ _.li.removeClass(_.actCl) _.rfrshFu() _.markFu() _.me.trigger(_.changeEv) location.hash=_.defHash }, backFu:function(){ _.chngFu(_.pren) }, nextFu:function(){ var n=_.n _.chngFu(++n<_.li.length?n:0) }, prevFu:function(){ var n=_.n _.chngFu(--n>=0?n:_.li.length-1) }, customStr:function(str){ //console.log(str) }, init:function(){ _.li=$('>ul>li',_.me) _.preFu() _.rfrshFu() _.markFu() _.useHash ?_.hashFu() :_.cntrFu() _.hoverFu() _.autoPlayFu() _.useHash &&_.checkHashFu(_.outerHash=_.hash=location.hash) _.li.hasClass(_.actCl) &&_.me.trigger(_.changeEv) }, hoverFu:function(){ _.li.each(function(n){ var th=$(this) $('a',th) .bind('mouseenter',function(){ if(_.enable) if(_.hover&&n!=_.n) _.hvrin(th) }) .bind('mouseleave',function(){ if(_.enable) if(_.hover&&n!=_.n) _.hvrout(th) }) }) }, hvrin:function(el){ _.hoverIn(el,_) _.hover=='sprites' &&$('a',el).sprites('hoverin') }, hvrout:function(el){ _.hoverOut(el,_) _.hover=='sprites' &&$('a',el).sprites('hoverout') }, hoverIn:function(){}, hoverOut:function(){}, defFunc:function(){} } data?_=data:th.data({navs:_}) typeof o=='object'&&$.extend(_,o) if(typeof o=='function') return th.bind(_.changeEv,function(){o(_.param,_);return false}).trigger(_.changeEv) _.me||_.init(_.me=th) typeof o=='number'&&_.chngFu(o) typeof o=='boolean'&&(_.enable=o) typeof o=='string'&&(o=='prev'||o=='next'||o=='close'||o=='back'?_[o+'Fu']():_.useHash?o.slice(0,3)=='#!/'&&(location.hash=o)||_.customStr(o):_.customStr(o)) }) return this } $.fn.tabs=function(o){ return this.each(function(){ var th=$(this) ,_=th.data('tabs')||{ enable:true, show:0, blockSame:true, changeEv:'change', empty:'#!/splash', preFu:function(){ _.li.hide() }, actFu:function(){ _.prev &&_.prev.hide() _.curr &&_.curr.show() }, navFu:function(s){ if(_.pres==s||s.slice(0,3)!='#!/') return false _.pres=s s==_.empty &&$.when(_.li).then(_.closeFu) _.li.each(function(n){ $(this).attr('id')==s.slice(3) &&_.chngFu(n) }) }, chngFu:function(a){ if(!_.enable||(a==_.n&&_.blockSame)||a>=_.li.length) return false $.when(_.li) .then(function(){ _.pren=_.n _.prev=_.curr _.curr=_.li.eq(_.n=a) _.actFu(_) _.me.trigger(_.changeEv) }) }, nextFu:function(){ var n=_.n _.way=1 _.chngFu(++n<_.li.length-_.show?n:0) }, prevFu:function(){ var n=_.n _.way=-1 _.chngFu(--n>=0?n:_.li.length-1-_.show) }, closeFu:function(){ if(_.pres=='close') return false _.pren=_.n _.prev=_.curr _.n=-1 _.curr=false _.pres='close' _.actFu(_) }, backFu:function(){ _.chngFu(_.pren) }, init:function(){ _.ul=$('>ul',_.me) _.li=$('>li',_.ul) _.preFu(_) _.navs&&_.navs.navs(function(n){th.tabs(n)}) } } if(typeof o=='object') _=$.extend(true,_,o) _.me||_.init(_.me=th.data({tabs:_})) typeof o=='function'&&_.me.bind(_.changeEv,function(){o(_.n,_);return false}) typeof o=='boolean'&&(_.enable=o) typeof o=='number'&&_.chngFu(o) typeof o=='string'&&(o=='prev'||o=='next'||o=='close'||o=='back'?_[o+'Fu']():_.navFu(o)) }) } })(jQuery)

Grazie