﻿// JScript File
   
    
   function hero(src,caption,top){
            this.src = src
            this.caption = caption
            this.top = (top || '30')
   }
    function doBackground(page){
        var heroarray = new Array()
        heroarray[0] = new hero('butt1_hero.jpg','Fall team practice \'08','40');
        heroarray[1] = new hero('chico08_hero.jpg','Chico Tournament \'08 Team','20');
        heroarray[2] = new hero('shasta_hero.jpg','Lake Shasta pit stop, Fall 08','60');
        heroarray[3] = new hero('team_hero.jpg','2008-2009 Team');
        heroarray[4] = new hero('work_hero.jpg','Work party at borderline, fall 08','60');
       // heroarray[0] = new hero('averi2.jpg','Summer Skiing on Lake Samish, Skier - Averi Creasia','90');
       // heroarray[1] = new hero('buttholes.jpg','Hosting the 2007 All Stars','50');
        heroarray[5] = new hero('morn10.jpg', 'Sunrise after morning Skiing on lake Samish');
       // heroarray[6] = new hero('speedo.jpg', 'Antics at the 2007 Night Jump Challenge','20');
        heroarray[6] = new hero('dane.jpg', 'Practice at Bow Lake, Skier - Dane Caldwell','95');
        //heroarray[5] = new hero('chops.jpg', 'Glove insertion (after stuck threw it at his face) on Lake Samish, Idiot - Ian Casey');
      //  heroarray[5] = new hero('skylake.jpg','Lakeside at Regionals 05','50');
        //heroarray[8] = new hero('speedo2.jpg', 'In the Boat'); 
        heroarray[7] = new hero('team.jpg','Team Shot at Davis\' After Chico Special 05', '20');
        heroarray[8] = new hero('chops2.jpg', 'Regionals 06 at Firebird Lake, AZ','65');
        heroarray[9] = new hero('teamjump.jpg','Team Shot in REd Square');
       // heroarray[10] = new hero('crane.jpg','Craig Batchelor - Wake Crossing Ejection Maneuver','70');
        heroarray[10] = new hero('averi.jpg','Regionals 05, Skier - Averi Creasia','75');
        heroarray[11] = new hero('morn1.jpg','Morning Skiing on Lake Samish','80');
        heroarray[12] = new hero('cali.jpg','On The Road to California for a Tournament');
        heroarray[13] = new hero('dane2.jpg','Regionals 05, Skier - Dane Caldwell','90');
       // heroarray[15] = new hero('josh.jpg','Not on purpose...','40');
        heroarray[14] = new hero('ikeski.jpg','Chico 07: Skier - Kyle Mortenson','85');
        heroarray[15] = new hero('speeder_aly.jpg','Official Business - Regionals 07','50');
       // heroarray[18] = new hero('clawbuttcg.jpg','Chillin - Regionals 07');
        heroarray[16] = new hero('dirtyjump.jpg','All-Stars 06 - Kelsie Blanchard');
        heroarray[17] = new hero('allstarsiowa.jpg','WWU Skiers Representing at All-Stars 06','50');
        
        var image = Math.round(Math.random()* (heroarray.length -1))

        var main = document.getElementById('main')
        main.style.backgroundImage = "url('http://www.wwuwaterski.com/images/"+heroarray[image].src+"')"

        if(page == 'home'){
            var caption = document.getElementById('caption');
            caption.innerHTML = heroarray[image].caption;
            window.onload = new Function('doAnalytics()');
            
            //docboxMO();
        }else{
            main.style.backgroundPosition =  'left ' + heroarray[image].top +'%';
            doAnalytics();
        }
        
    }

   function doAnalytics(){
        if(document.location.href.indexOf('ac.wwu.edu')!= -1){
            var urlparts = document.location.href.split('~wskiing');
            var newurl = 'http://www.wwuwaterski.com' + urlparts[1].replace('.shtml','.aspx').replace('.html','.aspx');
            document.location.href = newurl + '?' + Math.random();
        }
        
        var links = document.getElementsByTagName('A')

        for(var i = 0; i < links.length; i++){
            var a = links[i]
            if(!(a.href.indexOf('wwuski') != -1 || a.href.indexOf('garrettpatterson.com') != -1 || a.href.indexOf('.shtml') != -1 || a.href.indexOf('images/') != -1 || a.href.indexOf('ac.wwu.edu') != -1)){
            
                if (a.addEventListener){
                    a.addEventListener('click',doPageview, false)
                }else{
                    a.attachEvent('onclick',doPageview)
                }
            
            }
        
        }
   
   }
   
    function doPageview(e){
       
        if(!e){
             var e = window.event;
        }
        
        if(e.target){
            var obj = e.target;
        }else{
            var obj = e.srcElement;
        }
        
        var txt = ''
        
        if(obj.tagName == 'IMG'){
            txt = 'IMG|' + (obj.alt || obj.src)
        }else{
            if(obj.innerText){
                txt = obj.innerText;
            }else{
                txt = obj.textContent;
            }
        }

        if(txt != '') pageTracker._trackPageview('Link:' + txt);
    }
    

    
    