var flashSite = {

  swf: undefined,
  
  initialize: function(movieID){

    // reference to swf embed object
    swf = document.getElementById(movieID);

    // initialize history and callback function
    dhtmlHistory.initialize();
    dhtmlHistory.addListener(flashSite.historyChange);
  },
  
  historyChange: function(newLocation, historyData) {

    // set new page title is there is one
    if(historyData && historyData.pageTitle){
      flashSite.changeTitle(historyData.pageTitle);
    }
    
    if(typeof(window.urchinTracker) == 'function'){
      urchinTracker(newLocation);
    }
    
    // tell flash that history state has changed
    if(swf.sendToActionScript){
      swf.sendToActionScript(newLocation);
    }else{
      return true;
    }
    
  },
  
  // callback function for flash to add history states
  historyAdd: function(newLocation, pageTitle){
    
    // save the pagetitle
    var historyData = {
      pageTitle: pageTitle
    };
    flashSite.changeTitle(pageTitle);

    // add a new history state
    dhtmlHistory.add(newLocation, historyData);
	
    // call google analytics for this location
    if(window.pageTracker){
      pageTracker._trackPageview('/' + newLocation);
    }
    
  },
  
  // helper function for changing the page title
  changeTitle: function(title){
    //if(Drupal.settings && Drupal.settings.siteName){
    //  document.title = title + ' | ' + Drupal.settings.siteName;
    //}else{
      document.title = title + " | Elevate Group";
    //}
  }

};

// expose a globally-scoped function for use with flash
var historyAdd = flashSite.historyAdd;

// add a flash class to html tag so we can hide replacement text before it gets swapped
var swf = new SWFObject();
if(swf.installedVer && swf.installedVer.major){
  document.documentElement.className += ' flash';  
}