Fix V3 counters
[ssproject1617.git] / testcms-final-anon / themes / default / js / main.js
1 $(function() {
2
3 var viewport = $(window),
4 body = $('body'),
5
6 header = $('#top div.wrap'),
7 search = $('#search');
8
9 // Give a CSS hook
10 body.addClass('js');
11
12 // A neat little
13 if(window.location.pathname === '/') {
14 body.css({position: 'relative', top: -50, opacity: 0})
15 .animate({ top: 0, opacity: 1 });
16 }
17
18 /**
19 Search box
20 */
21
22 // Hide the search
23 search.css('margin-top', -(search.outerHeight() - 4));
24
25 // Append some way of making it come back
26 var clicked = 1,
27 marginTop = search.css('margin-top');
28
29 header.append('<img src="' + base + 'img/search.gif" id="search">').children('#search').click(function() {
30
31 // Move the
32 search.animate({marginTop: clicked % 2 === 0 ? marginTop : 0});
33
34 if(clicked % 2 === 0) {
35 $(this).animate({opacity: 0}, 200, function() {
36 $(this).attr('src', base + 'img/search.gif').animate({opacity: 1}, 200);
37 });
38
39 search.animate({marginTop: marginTop});
40 } else {
41
42 $(this).animate({opacity: 0}, 200, function() {
43 $(this).attr('src', base + 'img/close.gif').animate({opacity: 1}, 200);
44 });
45
46 search.animate({marginTop: 0});
47 }
48
49 // Increment counter
50 clicked++;
51 });
52 });