
    $(document).ready(function() {

    //rss feed from affwin blog - press releases
    var url = 'http://blog.affiliatewindow.com/?feed=rss2&cat=286';
    var api = 'http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&num=3&q=' + escape(url);
    $.getJSON(api, function(data){
        var feed = data.responseData.feed;
        var html = '<ul>';    
        var maxLen = 85;
            
        for (var i=0; i<feed.entries.length; i++) {
            var entry = feed.entries[i];                    
            var title;
            
            if (entry.title.length > maxLen) {
                title = entry.title.substring(0, maxLen) + '...';
            } else {
                title = entry.title;
            }

            html += '<li><h6><a href="' + entry.link + '" onclick="window.open(this.href); return false;">' + title + '</a></h6></li>';
        }
        
        html += '</ul>';
        $('#press').html(html);
    }); 

    //tabs
    $(".tab-nav").tabs(".panes > div", {
        effect: 'fade'
    });

	// company history timeline scrollable
	$(".timeline").scrollable({ 
        vertical: true,
        circular: false
    }).navigator(".timeline_navi");


    // ourclients pagination
    $(".merchant-pagination ul").tabs(".pages > ul", {
        effect: 'fade',
        rotate: true       
    }).slideshow({
        autoplay: true,
        interval:5000
    })


    // blog feed pagination
    $(".feed-pagination ul").tabs("#stories > ul", {
        effect: 'fade',
        rotate: false
    }).slideshow(); 
    

    // privacy / corporate policy overlay
   $("a[rel]").overlay({mask: '#382f2a'});
    

   // stop animated scroll if the user does something
   $('html,body').bind('scroll mousedown DOMMouseScroll mousewheel keyup', 
        function(e){
        if ( e.which > 0 || e.type == 'mousedown' || e.type == 'mousewheel' ){
        $('html,body').stop();
        }
    })

    // scroller
    $('.innernav a, .navhome, ul.vertical-nav li a').bind('click',
        function(event){var $anchor = $(this);
        $("a[href='#first']").click(); // show first tab
        $('html, body').stop().animate({
        scrollTop: $($anchor.attr('href')).offset().top}, 1500);
        event.preventDefault();
    })

    // adjust side menu pointer
    $(window).scroll(
    function() {

       var top = 0;
       top = $(window).scrollTop();

       if(top < 1250){
         $("a[href='#home']").parent().addClass("selected");
         $("a[href='#home']").parent().siblings().removeClass("selected");
       }

       if((top >= 1250) && (top < 2900)){
         $("a[href='#theboard']").parent().addClass("selected");
         $("a[href='#theboard']").parent().siblings().removeClass("selected");
       }    

       if((top >= 2900) && (top < 5200)){      
         $("a[href='#ourgroup']").parent().addClass("selected");
         $("a[href='#ourgroup']").parent().siblings().removeClass("selected");
        }

        if((top >= 5200) && (top < 6200)){      
         $("a[href='#ourclients']").parent().addClass("selected");
         $("a[href='#ourclients']").parent().siblings().removeClass("selected");
        }

        if((top >= 6200) && (top < 7200)){      
         $("a[href='#careers']").parent().addClass("selected");
         $("a[href='#careers']").parent().siblings().removeClass("selected");
        }

        if((top >= 7200)){      
         $("a[href='#contact']").parent().addClass("selected");
         $("a[href='#contact']").parent().siblings().removeClass("selected");
        }
     })


    // Timeline chart ////////////////////////////////

    var chart;
    
    chart = new Highcharts.Chart({
        chart: {
            borderWidth: 0,
            renderTo: 'chart_container',
            backgroundColor: '#382f2a',
            plotBackgroundColor: null,
            plotShadow: false,
            plotBorderWidth: 0,
            shadow: false,
            marginRight: 50,
            height: 200,
            marginLeft: 0,
            marginBottom:50,
            showAxes: false
        },

        title: {
            text: null
        },
                
        credits: {
            enabled: false
        },

        legend: {
            borderWidth: 0,
            lineHeight: 18,
            x: -40,
            align:'right',
            itemStyle: {
                color: '#7a745a',
                font: 'normal 10px/14px verdana,tahoma,helvetica,arial,sans-serif',
                margin: '0 0 10px',
                display:'block'
            },
            itemHoverStyle: {
			    color: '#adac8a'
		    },
		    itemHiddenStyle: {
			    color: '#595242'
		    }
        },

        xAxis: [{
            gridLineWidth: 0,
            lineColor: '#595242',
            tickColor: '#595242',
            labels: {
                style: {
                    color: '#7a745a',
                    fontWeight: 'normal'
                }
            },
            categories: ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11']
        }],

        yAxis: [{ // Primary yAxis / Turnover
            gridLineWidth: 0,
		    lineColor: '#595242',
		    tickColor: '#595242',
            labels: {
                enabled: false,
                formatter: function() {
                    return this.value +'GBP';
                }
            },
            title: {
                text: ' '
            },
            lineWidth: 0,
            opposite: true
            
        }, { // Secondary yAxis / Number of Staff
            gridLineWidth: 0,
            min: 20,
            max: 110,
            title: {
                text: ' '
            },
            labels: {
                enabled: false
            }
            
        }, { // Tertiary yAxis / Number of Advertisers
            gridLineWidth: 0,
            min: 0,
            max: 1500,
            title: {
                text: ' '
            },
            labels: {
                enabled: false
            },
            lineColor: '#25211f',
            lineWidth: 0,
            tickWidth: 0,
            tickColor: '#25211f',
            opposite: false
        }],

        tooltip: {
            backgroundColor: '#282320',
            borderWidth: 0,
            borderRadius: 0,
            style: {
                color: '#7a745a',
                font: 'normal 11px "trebuchet ms",tahoma,helvetica,arial,sans-serif',
                padding: '3px'
            },
            formatter: function() {
                var unit = {
                    'Turnover': 'GBP',
                    'Average staff numbers': 'employees',
                    'Number of advertisers': 'advertisers'
                }[this.series.name];
                return ' '+
                    Highcharts.numberFormat(this.y, 0) +' '+ unit;
            }
        },



        series: [{
            name: 'Average staff numbers',
            color: '#443d33',
            type: 'column',
            shadow: false,
            animation: true,
            borderWidth: 0,
            yAxis: 1,
            data: [4, 4, 7, 9, 14, 22, 26, 45, 67, 96, 160]
        
        }, {
            name: 'Number of advertisers',
            type: 'line',
            shadow: false,
            animation: true,
            color: '#25211f',
            yAxis: 2,
            marker: {
                enabled: false,
                lineColor: '#201e1c',
                fillColor: '#382f2a',
                lineWidth: 2,
                radius:2,
                states: {
                    hover: {
                        enabled: true
                    }
                }
            },
            data: [20, 50, 170, 458, 655, 732, 793, 931, 1135, 1289, 1615]
            
        }, {
            name: 'Turnover',
            color: '#adac8a',
            type: 'line',
            shadow: false,
            animation: true,
            marker: {
                enabled: false,
                lineColor: '#adac8a',
                fillColor: '#382f2a',
                lineWidth: 2,
                radius:2,
                states: {
                    hover: {
                        enabled: true
                    }
                }
            }, 
            data: [56343, 190429, 528361, 1569002, 3362865, 6534779, 15246813, 24115434, 34267428, 43249265, 111212824]
            
        }]
    });


});


