//JQuery Setup
$(document).ready(function(){

  var flashModColor = '4C7273'; //background color for all flash modules
  
  
  //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
  }
	
  
  // 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("");
	});


  //home page flash
  $('#flash_home').flash(
  { 
	  src: 'flash/homepage.swf',
	  width: 570,
	  height: 420,
	  wmode: 'transparent'
	},
	{ version: 8 }
	);
  

	//office tour
	$('#flash-office-tour').flash(
		{ 
		  src: 'flash/office-tour.swf',
		  width: 500,
		  height: 375,
		  wmode: 'transparent',
		  flashvars: { 
			//change value to false to pause on start
			autoPlay: 'false',
			//set captions for each slide or leave blank if none
      caption01: "Pensacola Office",
      caption02: "Reception",
      caption03: "Waiting Area",
      caption04: "Waiting Area",
      caption05: "Video Game Area",
      caption06: "Treatment Area",
      caption07: "Treatment Area",
      caption08: "Treatment Area",
      caption09: "Sterilization Area",
      caption10: "X-Ray",
      caption11: "Pace Office",
      caption12: "Front Desk",
      caption13: "Reception Area",
      caption14: "Reception Area",
      caption15: "Clinic Area",
      caption16: "Clinic Area",
      caption17: "Clinic Area"
		  }
		},
		{ version: 8 }
	);

  // flash modules
  
  //braces diagram
	$('#flash-braces-diagram').flash(
		{ 
		  src: 'flash/braces-diagram.swf',
		  width: 500,
		  height: 375,
		  wmode: 'transparent',
		  flashvars: { 
			thisColor: '0x' + flashModColor
		  }
		},
		{ version: 8 }
	);
	
	//brace painter
	$('#flash-brace-painter').flash(
	  { 
		src: 'flash/brace-painter.swf',
		width: 500,
		height: 430,
		wmode: 'transparent'
	  },
	  { version: 8 }
	);
  
  //brushing-flossing
	$('#flash-brushing-and-flossing').flash(
		{ 
		src: 'flash/brushing-and-flossing.swf',
		width: 500,
		height: 300,
		wmode: 'transparent',
		  flashvars: { 
			autoPlay: 'false',
			thisColor: '0x' + flashModColor,
			brushing: 'true',
			flossing: 'true'
		  }
		},
		{ version: 8 }
	);
    
  //color your retainer
	$('#flash-color-your-retainer').flash(
	  { 
		src: 'flash/color-your-retainer.swf',
		width: 300,
		height: 300,
		wmode: 'transparent',
    flashvars: { 
			thisColor: '0x' + flashModColor
		  }
	  },
	  { version: 8 }
	);

  //common treatments
	$('#flash-common-treatments').flash(
		{ 
		  src: 'flash/common-treatments.swf',
		  width: 500,
		  height: 300,
		  wmode: 'transparent',
		  flashvars: { 
			autoPlay: 'false',
			thisColor: '0x' + flashModColor,
			crowding: 'true',
			openbite: 'true',
			deepOverbite: 'true',
			missing: 'true',
			underbite: 'true',
			spacing: 'true',
			overbite: 'true',
			nonBraces: 'true',
			phaseI: 'true'
		  }
		},
		{ version: 8 }
	);

	//Emergency care 
	$('#flash-emergency-care').flash(
		{ 
		  src: 'flash/emergency-care.swf',
		  width: 500,
		  height: 300,
		  wmode: 'transparent',
		  flashvars: { 
        autoPlay: 'false',
        thisColor: '0x' + flashModColor,
        pokingWire: 'true',
        bracket: 'true',
        looseWire: 'true',
        appliance: 'true',
        headgear: 'true',
        soreness: 'true'
		  }
		},
		{ version: 8 }
  );    
  
  //patient care videos
	$('#flash-patient-care').flash(
	  { 
      src: 'video/patient-care.swf',
      width: 500,
      height: 375,
      wmode: 'transparent',
      flashvars: {
        thisColor: '0x' + flashModColor
      }
	  },
	  { version: 8 }
	);
  
  //damon-system-comparison
	$('#flash-damon-system-comparison').flash(
		{ 
		  src: 'damon-system/damon-system-comparison.swf',
		  width: 250,
		  height: 165,
		  wmode: 'transparent'
		},
		{ version: 8 }
	);
  
  //types of appliances
	$('#flash-types-of-appliances').flash(
		{ 
		  src: 'flash/types-of-appliances.swf',
		  width: 500,
		  height: 300,
		  wmode: 'transparent',
		  flashvars: { 
        autoPlay: 'false',
        thisColor: '0x' + flashModColor,
        elastics: 'true',
        headgear: 'true',
        herbst: 'true',
        palatal: 'true',
        positioners: 'true',
        separators: 'true'
		  }
		},
		{ version: 8 }
	);
  
  //types of braces
	$('#flash-types-of-braces').flash(
		{ 
		  src: 'flash/types-of-braces.swf',
		  width: 500,
		  height: 300,
		  wmode: 'transparent',
		  flashvars: { 
			autoPlay: 'false',
			thisColor: '0x' + flashModColor,
			metal: 'true',
			gold: 'false',
			ceramic: 'true',
			invisible: 'true',
			lingual: 'false'
		  }
		},
		{ version: 8 }
	);
	
	//palatal expander
	$('#flash-palatal-expander').flash(
		{ 
		  src: 'flash/palatal-expander.swf',
		  width: 200,
		  height: 150,
		  wmode: 'transparent'
		},
		{ version: 8 }
	);
  
  
  // flash embeded video clips
  $(function() {
    // define which clips to activate
    var clips = Array('the-damon-system');
  
    // set the click behavior for a game link
    var enableVideo = function(clip, div){
      $(div).flash(
        {
        src: 'damon-system/flv-player.swf',
        width: 320,
        height: 285,
        wmode: 'transparent',
        menu: false,
        flashvars: {
          SkinPath: "damon-system/SteelExternalAll.swf",
          FLVPath: clip + ".flv" //link is relative to SkinPath
        }
        },
        { version: 8 }
      );
    };
    
    // enable each video clip
    for (var j=0; j<clips.length; j++){
      var video = clips[j];
      enableVideo(video, '#video-'+ video);
    };
  
    
  });
  
  
  
  // game room
  $(function() {
    // define which games to activate
    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(
          {
          src: 'games/' + game + '.swf',
          width: 400,
          height: 300,
          wmode: 'transparent'
          },
          { version: 8 }
        );
      });
    };
    
    // set the click behavior for each game
    for (var j=0; j<games.length; j++){
      setGameClick(games[j]);
    };
  });

});//end document.ready