//JQuery Setup
$(document).ready(function(){
 
  //IE6 duct tape
  $.browser.msie6 = $.browser.msie && /MSIE 6\.0/i.test(window.navigator.userAgent) && !/MSIE 7\.0/i.test(window.navigator.userAgent);
  if ($.browser.msie6) {
    $('#nav li').hover(
      function() {
        $(this).addClass("sfhover");
      },
      function() {
        $(this).removeClass("sfhover");
      }
    );
    // Add other IE6 only code here
  }
	
  $.sifr({ 
  font: 'flash/AvantGarde.swf', 
  color: '#b10f1d',
  textAlign: 'left'});
  $('#content h1').sifr();
  
  // Some effects rely on an element to be initially hidden,
  // but we only hide them if the user has javascript
  $('.jshide').addClass('hide');
  
  
	//clear form fields
	$('.clearme').one("focus", function() {
  		$(this).val("");
	});
  
  // Open external links in new windows
  $('a[@href^="http://"]').addClass('external').attr('target', '_blank');
  
  // Open pdf links in new windows
  $('a[@href$=".pdf"]').addClass('pdf').attr('target', '_blank');

  // add 'back to top' link when the content is taller than the window
  // this has to be done after flash replacement because the content height changes
  if ($('#content').height() > $(window).height()) {
    $('#content').append('<p><a href="#hd">Back to top</a></p>');
  }

});//end document.ready

$(function(){

  var flashModules = {
  
    defaults: {
      // Define the configuation values applied to each module.
      // Each module in flashModules can override these values.
      
      width: 500,
      height: 300,
      wmode: 'transparent',
      flashvars: {
        autoPlay: 'false', // change value to true to play on start
        thisColor: '0x' + '639CCE' // change global hex color (default=639CCE)
      },
      pluginOptions: {version: 8}
    },
    
    modules: [
      // Define the configuration values for each flash module.
      // Change item values in any 'flashvars' section to false to omit,
      // Add any value to override the default value in flashModuleDefaults.
      
      {name: 'homepage', config: {width:530, height:300}},
      
      {name: 'brushing-and-flossing',
        config: {
          flashvars: {
            brushing: 'true',
            flossing: 'true'
          }
        }
      },
      
      { name: 'know-your-teeth', config: {width:500, height:400}},
      
      {name: 'office-tour-bossier',
        config: {
          width: 500,
          height: 375,
          flashvars: {
            //set captions for each slide or leave blank if none
            caption01: 'Bossier City Office',
            caption02: 'Bossier City Office',
            caption03: 'Bossier City Office',
            caption04: 'Bossier City Office',
            caption05: 'Bossier City Office',
            caption06: 'Bossier City Office',
            caption07: 'Bossier City Office',
            caption08: 'Bossier City Office'
          }
        }
      },
      
      {name: 'office-tour-shreveport',
        config: {
          width: 500,
          height: 375,
          flashvars: {
            //set captions for each slide or leave blank if none
            caption01: 'Shreveport Office',
            caption02: 'Shreveport Office',
            caption03: 'Shreveport Office',
            caption04: 'Shreveport Office',
            caption05: 'Shreveport Office',
            caption06: 'Shreveport Office',
            caption07: 'Shreveport Office',
            caption08: 'Shreveport Office',
            caption09: 'Shreveport Office',
            caption10: 'Shreveport Office',
            caption11: 'Shreveport Office',
            caption12: 'Shreveport Office'
          }
        }
      },      

      {name: 'palatal-expander', config: {width: 200, height: 150}},
      {name: 'patient-care-videos', config: {height: 375}}
    ]
  };

  for (var j=0; j < flashModules.modules.length; j++) {
    var module = flashModules.modules[j];
    // combine default config settings with module config settings
    var modConfig = $.extend({}, flashModules.defaults, module.config);
    // combine default flashvars with module flashvars
    modConfig.flashvars = $.extend({}, flashModules.defaults.flashvars, module.config.flashvars);
    modConfig.src = 'flash/' + module.name + '.swf';
    $('#flash-' + module.name).flash(modConfig, flashModules.defaults.pluginOptions);
  }
  
});

// game room
$(function() {
  // list the games that we want activated on click
  var games = Array('asteroids', 'frogger', 'pong', 'simon', 'snake', 'space-invaders', 'tetris', 'tic-tac-toe');

  // set the click behavior for a game link
  var setGameClick = function(game){
    $("a." + game).click(function(){
      $('#sesame-game').flash(  // #sesame-game is the empty div that will contain the active game
        {
        src: 'games/' + game + '.swf',
        width: 400,
        height: 300,
        wmode: 'transparent'
        },
        { version: 8 }
      );
    });
  };
  
  // loop through the games array and
  // set the click behavior for each game link
  for (var j=0; j<games.length; j++){
    setGameClick(games[j]);
  };
});