﻿document.write('<script type="text/javascript" src="scripts/portfolio/ScriptInclude1.js"></script>'); 
document.write('<script type="text/javascript" src="scripts/portfolio/ScriptInclude2.js"></script>'); 
document.write('<script type="text/javascript" src="scripts/portfolio/ScriptInclude3.js"></script>'); 
document.write('<script type="text/javascript" src="scripts/portfolio/ScriptInclude4.js"></script>'); 
document.write('<script type="text/javascript" src="scripts/portfolio/ScriptInclude5.js"></script>'); 
document.write('<script type="text/javascript" src="scripts/portfolio/ScriptInclude6.js"></script>'); 

var Webnoxious = new Object()

Webnoxious.Portfolio = {
   sequence: 1, // variable used to iterate over the groups
   maxSequences: 3, // max number of groups
   maxSites: 12,
   currentGroup: null, // current group displayed
   newGroup: null,  // new group to display
   container: null,
   intervalTime:30000,
   interval: null, 
   topboxContainer: null,
   defaultTopBox: 1,
   currentTobBox: this.defaultTopBox,  
   browserType: "",
   nextAvailable: false,
   animation: null,
   Initialize: function(){
        //prep the layers to be faded in and out by setting their opacity to 0
        var group1 = $get('botgroup1');
        var group2 = $get('botgroup2');
        var group3 = $get('botgroup3');

        //AjaxControlToolkit.Animation.OpacityAction.play(group1, .0, 20, 0);
        AjaxControlToolkit.Animation.OpacityAction.play(group2, .0, 20, 0);
        AjaxControlToolkit.Animation.OpacityAction.play(group3, .0, 20, 0);  
        
        //Set the default properties
        this.container = $get('PortfolioContainer');   
        this.topboxContainer = $get('dvTopBoxContainer');   

        this.Click(this.defaultTopBox);
        
        if (document.compatMode && document.all){
        
            if (typeof document.body.style.maxHeight != "undefined") {
                    this.browserType = "IE7";
                } else {
                    this.browserType = "IE6";                
                }
        }
        
   },
   OnLoad: function(){
        //Position the groups
        var group1 = $get('botgroup1');
        var group2 = $get('botgroup2');
        var group3 = $get('botgroup3');
        
        this.MoveGroup(group1);
        this.MoveGroup(group2);
        this.MoveGroup(group3);
        
        //show the first layer and start the animation
        var botgroup = $get('botgroup' + this.sequence);
        this.currentGroup = botgroup;
        
        this.ShowCurrentGroup();
                
        this.interval =  setInterval ( "Webnoxious.Portfolio.ShowSiteGroup();", this.intervalTime );
   },
   ShowSiteGroup: function (){
        this.IncrementSequence();
                
        // Set the new incoming group
        this.newGroup = document.getElementById("botgroup" + this.sequence);

        this.FadeInOut(this.currentGroup, this.newGroup);
        this.currentGroup = this.newGroup; // set the current group to the new group    
   },
   IncrementSequence: function(){
        //incrmemnt the sequence number 
        this.sequence++;
        // reset the sequence if it is greater than the maxsequence
        if (this.sequence > this.maxSequences){
            this.sequence = 1
        }
   },
   MoveGroup: function(group){
        var pos = findPos(this.container);
        group.style.left = pos[0] + 'px';
        group.style.top = pos[1] + 'px';
   },
   FadeInOut: function(groupOut, groupIn){
        if (this.animation){this.animation.clear();}
        this.animation = new AjaxControlToolkit.Animation.SequenceAnimation(this, 0, 20, null, 1);        
        var fadeout = new AjaxControlToolkit.Animation.FadeOutAnimation(groupOut, 1, 20, 0, 1, true);
        var hideout = new AjaxControlToolkit.Animation.StyleAction(groupOut, 0, 20, 'display', 'none');
        this.animation.add(fadeout);
        this.animation.add(hideout);
                        
        var hidein = new AjaxControlToolkit.Animation.StyleAction(groupIn, 0, 20, 'display', 'block');
        var fadein = new AjaxControlToolkit.Animation.FadeInAnimation(groupIn, 2, 20, 0, 1, true);        
        this.animation.add(hidein);
        this.animation.add(fadein);
        this.animation.play();
   },
   HideGroups: function(){
 
        if (this.animation){this.animation.stop();}
        
        this.currentGroup.style.display = 'none';
        if (this.newGroup)
            this.newGroup.style.display = 'none';
        this.currentGroup.style.opacity = 0;
	    this.currentGroup.style.filter = 'alpha(opacity=0)';
   },
   ShowCurrentGroup: function(){
        this.currentGroup.style.display='block';   
        this.currentGroup.style.opacity = 100;
	    this.currentGroup.style.filter = 'alpha(opacity=100)';
   },
   Click: function(num){
        this.currentTopBox = num;
        var dv = $get('topbox' + num);
        this.topboxContainer.innerHTML = dv.innerHTML;  
        
        //Fix for IE6 Bug  
        if (this.browserType == "IE6"){    
            $get('TwoColBoxSpecial').style.paddingBottom = "0";
            this.topboxContainer.style.paddingBottom = '20';          
        }   
   },
   Next: function(){
        var nextTopBox;
        if (this.currentTopBox >= this.maxSites){
            nextTopBox = 1;
        }else{
            nextTopBox = this.currentTopBox + 1;
        }
        this.Click(nextTopBox);
   },
   NextGroup: function(){  
  
        if (this.interval){
            clearInterval(this.interval);            
        }
        this.HideGroups();
  
        this.IncrementSequence();
        this.currentGroup = document.getElementById("botgroup" + this.sequence);
        this.ShowCurrentGroup();

        this.interval = setInterval ( "Webnoxious.Portfolio.ShowSiteGroup();", this.intervalTime );
   },
   EnableNext: function(){
        this.nextAvailable = true;
   },
   DisableNext: function(){
        this.nextAvailable = false;
   }
};

function findPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        curleft = obj.offsetLeft
        curtop = obj.offsetTop
        while (obj = obj.offsetParent) {
            curleft += obj.offsetLeft
            curtop += obj.offsetTop
        }
    }
    return [curleft,curtop];
}

function mouseover(elem){
    elem.style.cursor='pointer';  
}

function mouseout(elem){
       
}


