//JQuery Setup

$(document).ready(function(){



  var flashModColor = '587D74'; //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) {

    $('#util li').hover(

      function() {

        $(this).addClass("sfhover");

      }, 

      function() {

        $(this).removeClass("sfhover");

      }

    );
	


    // Add other IE6 only code here

  }
  
    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');

  

  // Open external links in new windows

  $('a[@href^="http://"]').addClass('external').attr('target', '_blank');
  $('a[@href^="https://"]').addClass('external').attr('target', '_blank');

  

  // Open pdf links in new windows

  $('a[@href$=".pdf"]').addClass('pdf').attr('target', '_blank');

  

	//clear form fields

	$('.clearme').one("focus", function() {

  		$(this).val("");

	});



  



  //home page flash

  $('#flash-homepage').flash(

  { 

	  src: 'flash/homepage.swf',

	  width: 375,

	  height: 330,

	  wmode: 'transparent'

	},

	{ version: 8 }

	);


// Fancybox Video

$(document).ready(function() {
			$("a#video-commercial").fancybox();
			
		
		});
/*
$('#flash-video').flash(
	{ 
	  src: 'flv-player.swf',
	  width: 368,
	  height: 246,
	  wmode: 'transparent',
	  flashvars: { 
		flvToPlay: 'video/STONE-OAK-ORTHODONTICS.flv',
		autoStart: 'false',
		scaleMode: 'full',
		startImage: 'video/bg.jpg',
		showScaleModes: 'false'
	  }
	},
	{ 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 }

	);

	

  //Office in the News - Faster Braces

	$('#flash-faster-braces').flash(

		{ 

		  src: 'flash/faster-braces.swf',

		  width: 352,

		  height: 285,

		  wmode: 'opaque'

		},

		{ 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: 'flash/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: 'opaque'

		},

		{ 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',

			invisalign: 'true',

			lingual: 'true'

		  }

		},

		{ version: 8 }

	);

	

	$('#flash-ibraces-logo').flash(

		{ 

		  src: 'flash/ibraces-logo.swf',

		  width: 200,

		  height: 135,

		  wmode: 'opaque'

		},

		{ version: 8 }

	);

  

  

  // flash embeded video clips

  $(function() {

    // define which clips to activate

    var clips = Array('the-damon-system', 'in-ovation', 'ibraces-1', 'ibraces-2', 'ibraces-3', 'suresmile-1', 'suresmile-2', 'faster-braces');

  

    // set the click behavior for a game link

    var enableVideo = function(clip, div){

      $(div).flash(

        {

        src: 'video/flv-player.swf',

        width: 320,

        height: 285,

        wmode: 'transparent',

        menu: false,

        flashvars: {

          SkinPath: "video/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, 'div#content div#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