if (typeof(ZG) == 'undefined') var ZG = {};

ZG.Main = function() {
    var self = this,
        args = arguments;
    
    self.SECTIONS = new Array();
    
    self.init.apply(self, args);
};

ZG.Main.prototype = {
    init: function(options) {
        var self = this;
        
        self.section = $('body').attr('id').split('-')[0];
        
        if (self.section in self) {
            self[self.section].apply();
        }
        
        $('a#hello_zg').bind('click', function(event) {
            _gaq.push(['_trackPageview', '/contact/email_click.html']); 
        });
    },
    
    home: function() {
        var homescroller = new ZG.Scroller('#homeSlideshow', '.featuredProject', false, { delay: 7 });
    },
    
    work: function() {
        // If we're on the detail page init the screenshot scroller
        if ($('body').hasClass('detail')) {
            var screenshot_container = $('.screenshotItems'),
                screenshot_imgs = $('.screenshotItems').children('img'),
                screenshots = new Array(),
                delay = 5, // the delay before switching a photo
                current = 0; 

            screenshot_imgs.each(function(index) {
                if ($(this).is(":visible")) { current = index }
                screenshots.push($(this));
            });
            
            var interval = setInterval(function() {
                target = (current < (screenshots.length-1)) ? current+1 : 0;

                screenshots[current].fadeOut('slow');
                screenshots[target].fadeIn('slow');

                current = target;
            }, delay*1000);
        }
    },
    
    contact: function() {
        jQuery("#id_budget").slider({
            from: 10000, 
            to: 250000, 
            step: 5000, 
            smooth: true, 
            round: 0, 
            dimension: "$&nbsp;" 
        });
        
        var ZG_Point = new google.maps.LatLng(34.02602352389661, -118.3756685256958);
        
        var ZG_Map = new google.maps.Map(document.getElementById("contactMap"), {
            zoom: 11,
            center: ZG_Point,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            streetViewControl: true
        });
        
        var ZG_Office = new google.maps.Marker({
            position: ZG_Point,
            map: ZG_Map,
            title: 'ZG Office',
            icon: new google.maps.MarkerImage('/static/img/contact/mapZGPin.png')
        });
        
        if (CONTACT_SUCCESS) {
            _gaq.push(['_trackPageview', '/contact/quote_success.html']); 
        }
        
    }
};

$(document).ready(function() {
    var zg = new ZG.Main();
});
