(function($) { var linkItems = [ 'default', 'curr-weather', 'forecast-48', 'forecast-week', 'warnings', 'all-world', 'auto-location', 'favorites', 'offline' ]; $(function() { var zindex = 10; var curr_index = 0; var prev_index=0; $(function() { //$('.iphone-container .iphone-bg').css ({'background':'url(images/iphone-bg.jpg) no-repeat 0 0'}); //$('.iphone-bg').html (''); for (var i=0; i<9; i++) { $('#screens'+i).html(''); $('#screens'+i).disableSelection(); } }) $(function() { $('#screens0').everyTime(4000, 'timer', function() {$(this).doForward();})}) $('#iphone_pict').disableSelection(); $('.screens').click(function() { $('#screens0').stopTime('timer'); $(this).doForward(); return false; }); $('.btn-home').click(function() { curr_index = 0; $('.loc-links a').each(function() { var linkName = $(this).attr('href').replace('#', ''); if (linkName == linkItems[curr_index]) { $(this).trigger('click'); } }); return false; }); $('.loc-links a').click(function() { $('#screens0').stopTime('timer'); $(this).linkClick(); return false; }); $.fn.doForward = function() { if (curr_index < linkItems.length-1) curr_index++; else curr_index = 1; isleft = false; $('.loc-links a').each(function() { var linkName = $(this).attr('href').replace('#', ''); if (linkName == linkItems[curr_index]) { $(this).linkClick(); } }); return false; } $.fn.linkClick = function() { var $link = $(this); // if ($link.is('.active')) return false; var $active = $('.loc-links a.active'); $active.removeClass('active'); $link.addClass('active'); $('.red-round-active').removeClass('red-round-active'); $link.closest('.red-round').addClass('red-round-active'); var linkName = $link.attr('href').replace('#', ''), activeName = $active.attr('href').replace('#', ''); var ind = $.inArray(linkName, linkItems); if (ind != -1) { curr_index = ind; } var pr=prev_index; if (prev_index!=ind) { $('body').addClass('f__k-ie').removeClass('f__k-ie'); $('body').addClass('f__k-ie').removeClass('f__k-ie'); $('#screens'+ind).css({'width': '320px'}); $('#screens'+ind).css({'height': '480px'}); $('#screens'+ind).css({'left': '48px'}); $('#screens'+ind).css({'top': '140px'}); $('#screens'+ind+' img').css({'left': '0px'}); $('#screens'+ind+' img').css({'top': '0px'}); $('.iphone_pict_background').css({'display': 'block'}); switch(ind) { case 0: $('#screens0').css({'display': 'block'}); if (prev_index>0) animate('#screens'+prev_index, '0px', '0px', '380px', '208px', null); break; case 1: case 2: case 3: case 4: case 8: $('#screens'+ind+' img').css({'left': '0px'}); if (((prev_index>0)&&(prev_index<5)) || (prev_index==8)) { fadeIn('#screens'+ind, function() {fadeOut('#screens'+pr);}); } else { $('#screens'+ind).css({'display': 'block'}); if ((prev_index==5) || (prev_index==7)) { $('#screens'+ind+' img').css({'left': '320px'}); animate('#screens'+prev_index+' img', null, null, null, '-320px', null); animate('#screens'+ind+' img', null, null, null, '0px', null); } if (prev_index==6) { $('#screens'+ind+' img').css({'left': '0px'}); animate('#screens6 img', null, null, '481px', null, null); } } break; case 6: if (prev_index!=0) { $('#screens6').css({'display': 'block'}); $('#screens6 img').css({'top': '481px'}); animate('#screens6 img', null, null, '0px', null, function() {$('#screens'+pr).css({'display': 'none'});}); } break; case 5: case 7: $('#screens'+ind).css({'display': 'block'}); if (prev_index==6) { $('#screens'+ind+' img').css({'left': '0px'}); animate('#screens6 img', null, null, '481px', null, null); } else if (prev_index!=0){ $('#screens'+ind+' img').css({'left': '-320px'}); animate('#screens'+ind+' img', null, null, null, '0px', null); animate('#screens'+prev_index+' img', null, null, null, '320px', null); } break; } if (prev_index==0) { $('#screens'+ind).css({'display': 'block'}); $('#screens'+ind).css({'width': '0px', 'height': '0px', 'top': '380px', 'left': '208px'}); //animate('#screens0', '0px', '0px', '380px', '208px', null); animate('#screens'+ind, '320px', '480px', '140px', '48px', function() {$('#screens0').css({'display': 'none'});}); } prev_index=ind; isLinkClick = true; } } $('#head .menu li').not('.disabled, .active').hover( function() { $(this).addClass('hover'); }, function() { $(this).removeClass('hover'); } ); }); })(jQuery); function fadeIn(identificator, callbackfunction) { if ($.browser.msie && $.browser.version < 7) { $(identificator).css({'display' : 'block'}); if (callbackfunction) callbackfunction(); } else { $(identificator).fadeIn(200, function() { if (callbackfunction) callbackfunction(); }); } } function fadeOut(identificator) { if ($.browser.msie && $.browser.version < 7) { $(identificator).css({'display' : 'none'}); } else { $(identificator).fadeOut(200); } } function animate(identificator, width, height, top, left, callbackfunction) { if (width == null) width = $(identificator).css('width'); if (height == null) height = $(identificator).css('height'); if (top == null) top = $(identificator).css('top'); if (left == null) left = $(identificator).css('left'); if ($.browser.msie && $.browser.version < 7) { $(identificator).css({'width' : width, 'height': height, 'top' : top, 'left' : left}); if (callbackfunction) callbackfunction(); } else { $(identificator).animate({'width' : width, 'height': height, 'top' : top, 'left' : left}, function() { if (callbackfunction) callbackfunction(); }); } }